Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 14.75 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_map/flutter_map.dart';
  3. import 'package:latlong/latlong.dart';
  4. import 'package:cloud_firestore/cloud_firestore.dart';
  5.  
  6.  
  7. void main() {
  8.   runApp(TabBarDemo());
  9. }
  10.  
  11. class TabBarDemo extends StatelessWidget {
  12.   @override
  13.   Widget build(BuildContext context) {
  14.     return MaterialApp(
  15.      
  16.       home: DefaultTabController(
  17.         length: 4,
  18.         child: Scaffold(
  19.           appBar: AppBar(
  20.             bottom: TabBar(
  21.               tabs: [
  22.                 Tab(icon: Icon(Icons.calendar_today)),
  23.                 Tab(icon: Icon(Icons.directions)),
  24.                 Tab(icon: Icon(Icons.chat)),
  25.                 Tab(icon: Icon(Icons.list)),
  26.               ],
  27.             ),
  28.             title: Text('WSDC 2018'),
  29.           ),
  30.           body: TabBarView(
  31.             children: [
  32.               //ExpansionTileSample(),
  33.               Scaffold(
  34.                 body: ListView.builder(
  35.                   itemBuilder: (BuildContext context, int index) =>
  36.                       EntryItem(data[index]),
  37.                   itemCount: data.length,
  38.                 ),
  39.               ),
  40.              
  41.               /*
  42.               Scaffold(
  43.                 body: new ZoomableImage(
  44.                     new AssetImage('images/mreza.png'),
  45.                     placeholder: const Center(child: const CircularProgressIndicator()),
  46.                     backgroundColor: Colors.white
  47.                   ),
  48.               ),*/
  49.              
  50.               OfflineMapPage(),
  51.               MyHomePage(),
  52.               Pairing(),
  53.             ],
  54.             physics: NeverScrollableScrollPhysics(),
  55.           ),
  56.         ),
  57.       ),debugShowCheckedModeBanner: false,
  58.     );
  59.   }
  60. }
  61.  
  62. class ExpansionTileSample extends StatelessWidget {
  63.   @override
  64.   Widget build(BuildContext context) {
  65.     return MaterialApp(
  66.       home: Scaffold(
  67.         body: ListView.builder(
  68.           itemBuilder: (BuildContext context, int index) =>
  69.               EntryItem(data[index]),
  70.           itemCount: data.length,
  71.         ),
  72.       ),
  73.     );
  74.   }
  75. }
  76.  
  77. // One entry in the multilevel list displayed by this app.
  78. class Entry {
  79.   Entry(this.title, [this.children = const <Entry>[]]);
  80.  
  81.   final String title;
  82.   final List<Entry> children;
  83. }
  84.  
  85. // The entire multilevel list displayed by this app.
  86. final List<Entry> data = <Entry>[
  87.   Entry('Tuesday 17.07.',<Entry>[
  88. Entry('10:00 – … Registrations'),
  89. Entry('19:30 Dinner (Hotel)'),
  90. ],),
  91. Entry('Wednesday 18.07.',<Entry>[
  92. Entry('10:30 Adjudicator briefing (obligatory for all adjudicators)'),
  93. Entry('14:00 New nations meeting'),
  94. Entry('16:00 Team managers meeting'),
  95. Entry('17:50 Departures for Opening Ceremony'),
  96. Entry('19:30 Opening Ceremony and dinner (at the venue)'),
  97. Entry('21:30 Return to the Hotel'),
  98. ],),
  99. Entry('Thursday 19.07.',<Entry>[
  100. Entry('09:00 Departure from the Hotel'),
  101. Entry('10:00 Opening assembly'),
  102. Entry('10:30 Round 1'),
  103. Entry('12:30 Lunch break'),
  104. Entry('14:30 Round 2'),
  105. Entry('16:30 Departure for hotel'),
  106. Entry('20:30 First council meeting'),
  107. ],),
  108. Entry('Friday 20.07.',<Entry>[
  109. Entry('09:00 Departure from the Hotel'),
  110. Entry('10:00 Opening assembly'),
  111. Entry('10:30 Round 3 motion announcement'),
  112. Entry('11:30 Round 3'),
  113. Entry('13:30 Lunch break'),
  114. Entry('15:00 Round 4 pairing and motion announcement'),
  115. Entry('16:00 Round 4'),
  116. Entry('18:00 Departure for the hotel'),
  117. Entry('21:00 Country expo'),
  118. ],),
  119. Entry('Saturday 21.07',<Entry>[
  120. Entry('00:00 Free day'),
  121. ],),
  122. Entry('Sunday 22.07.',<Entry>[
  123. Entry('09:00 Departure from the Hotel'),
  124. Entry('10:00 Opening assembly'),
  125. Entry('10:30 Round 5'),
  126. Entry('12:30 Lunch break'),
  127. Entry('14:30 Round 6 pairing and motion announcement'),
  128. Entry('15:30 Round 6'),
  129. Entry('17:30 Departure for the hotel'),
  130. Entry('20:30 Second council meeting'),
  131. ],),
  132. Entry('Monday 23.07.',<Entry>[
  133. Entry('09:00 Departure from the Hotel'),
  134. Entry('10:00 Opening assembly'),
  135. Entry('10:30 Round 7'),
  136. Entry('12:30 Lunch break'),
  137. Entry('14:30 Round 8 pairing and motion announcement'),
  138. Entry('15:30 Round 8'),
  139. Entry('17:30 Departure for the hotel'),
  140. Entry('19:00 Dinner at the hotel'),
  141. Entry('21:00 Departures for Break night party'),
  142. Entry('22:30 Break announcements'),
  143. Entry('23:00 Departures for the Hotel (not obligatory - you can stay at the break night venue)'),
  144. ],),
  145. Entry('Tuesday 24.07.',<Entry>[
  146. Entry('09:00 Departure from the Hotel'),
  147. Entry('10:00 Opening assembly'),
  148. Entry('10:15 DO motion announcement'),
  149. Entry('11:15 Double octos'),
  150. Entry('13:00 Lunch break'),
  151. Entry('14:30 Octo motion announcement'),
  152. Entry('15:30 Octos'),
  153. Entry('17:30 Departure for the hotel'),
  154. Entry('20:30 Possible another council meeting'),
  155. ],),
  156. Entry('Wednesday 25.07.',<Entry>[
  157. Entry('09:30 Departure from the Hotel'),
  158. Entry('10:00 Opening assembly'),
  159. Entry('10:15 QF motion announcement'),
  160. Entry('11:15 QF'),
  161. Entry('13:00 Lunch break'),
  162. Entry('14:30 SF motion announcement'),
  163. Entry('15:30 SF'),
  164. Entry('17:30 Departure for the hotel'),
  165. ],),
  166. Entry('Thursday 26.07.',<Entry>[
  167. Entry('10:30 Third council meeting'),
  168. Entry('17:00 Finals'),
  169. Entry('19:00 Closing ceremony'),
  170. ],),
  171. ];
  172.  
  173. // Displays one Entry. If the entry has children then it's displayed
  174. // with an ExpansionTile.
  175. class EntryItem extends StatelessWidget {
  176.   const EntryItem(this.entry);
  177.  
  178.   final Entry entry;
  179.  
  180.   Widget _buildTiles(Entry root) {
  181.     if (root.children.isEmpty) return ListTile(title: Text(root.title));
  182.     return ExpansionTile(
  183.       key: PageStorageKey<Entry>(root),
  184.       title: Text(root.title),
  185.       children: root.children.map(_buildTiles).toList(),
  186.     );
  187.   }
  188.  
  189.   @override
  190.   Widget build(BuildContext context) {
  191.     return _buildTiles(entry);
  192.   }
  193. }
  194.  
  195. class OfflineMapPage extends StatelessWidget {
  196.   static const String route = '/offline_map';
  197.   Widget build(BuildContext context) {
  198.     return new Scaffold(
  199.       body: new Padding(
  200.         padding: new EdgeInsets.all(8.0),
  201.         child: new Column(
  202.           children: [
  203.             new Padding(
  204.               padding: new EdgeInsets.only(top: 8.0, bottom: 8.0),
  205.               child: new Text("Offline map"),
  206.             ),
  207.             new Flexible(
  208.               child: new FlutterMap(
  209.                 options: new MapOptions(
  210.                   center: new LatLng(45.8045, 15.9788),
  211.                   minZoom: 13.0,
  212.                   maxZoom: 16.0,
  213.                   zoom: 13.0,
  214.                   swPanBoundary: LatLng(45.767523, 15.95404),
  215.                   nePanBoundary: LatLng(45.843238, 16.039608),
  216.                 ),
  217.                 layers: [
  218.                   new TileLayerOptions(
  219.                     offlineMode: true,
  220.                     maxZoom: 14.0,
  221.                     urlTemplate: "Map/{z}/{x}/{y}.png",
  222.                   ),
  223.                   new MarkerLayerOptions(
  224.                     markers: [
  225.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80568, 15.95208),builder: (ctx) => new Container(child: new Text("Hotel Panorama"),),),
  226.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80568, 15.95208),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  227.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80391, 15.95441),builder: (ctx) => new Container(child: new Text("Hostel Moving"),),),
  228.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80391, 15.95441),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  229.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81968, 16.0069),builder: (ctx) => new Container(child: new Text("Venue: MIOC"),),),
  230.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81968, 16.0069),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  231.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80246, 15.94419),builder: (ctx) => new Container(child: new Text("Venue: Senoa"),),),
  232.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80246, 15.94419),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  233.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81957, 16.00555),builder: (ctx) => new Container(child: new Text("Venue: Nazor"),),),
  234.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81957, 16.00555),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  235.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80938, 15.97011),builder: (ctx) => new Container(child: new Text("Opening"),),),
  236.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80938, 15.97011),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  237.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81179, 15.97333),builder: (ctx) => new Container(child: new Text("Finals"),),),
  238.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81179, 15.97333),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  239.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81453, 15.97371),builder: (ctx) => new Container(child: new Text("Octos"),),),
  240.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81453, 15.97371),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  241.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81058, 15.96973),builder: (ctx) => new Container(child: new Text("Quarters/Semis"),),),
  242.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.81058, 15.96973),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  243.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80842, 15.96865),builder: (ctx) => new Container(child: new Text("Quarters/Semis"),),),
  244.                               new Marker(width: 80.0,height: 80.0,point: new LatLng(45.80842, 15.96865),builder: (ctx) => new Container(child: new IconButton(icon: Icon(Icons.location_on),color: Colors.red,iconSize: 20.0,onPressed: (){} ,),),),
  245.                     ],
  246.                   ),
  247.                 ],
  248.               ),
  249.             ),
  250.           ],
  251.         ),
  252.       ),
  253.     );
  254.   }
  255. }
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264. class OnlineApp extends StatelessWidget {
  265.   const OnlineApp();
  266.  
  267.   @override
  268.   Widget build(BuildContext context) {
  269.     return new MaterialApp(
  270.       title: 'WSDC Notifications',
  271.       home: const MyHomePage(title: 'WSDC Notifs'),
  272.     );
  273.   }
  274. }
  275.  
  276. class MyHomePage extends StatelessWidget {
  277.   const MyHomePage({Key key, this.title}) : super(key: key);
  278.  
  279.   final String title;
  280.  
  281.  
  282.   @override
  283.   Widget build(BuildContext context) {
  284.     return new Scaffold(
  285.       body: new StreamBuilder(
  286.           stream: Firestore.instance.collection('wsdc_announcements').orderBy('time', descending: true).snapshots(),
  287.           builder: (context, snapshot) {
  288.             if (!snapshot.hasData) return const Text('Loading...');
  289.             return new ListView.builder(
  290.               itemCount: snapshot.data.documents.length,
  291.               padding: const EdgeInsets.only(top: 10.0, left: 5.0, right: 5.0),
  292.               itemBuilder: (context, index) {
  293.                 DocumentSnapshot ds = snapshot.data.documents[index];
  294.  
  295.                 var text = new RichText(
  296.                   text: new TextSpan(
  297.                     // Note: Styles for TextSpans must be explicitly defined.
  298.                     // Child text spans will inherit styles from parent
  299.                     style: new TextStyle(
  300.                       fontSize: 14.0,
  301.                       color: Colors.black,
  302.                     ),
  303.                     children: <TextSpan>[
  304.                       new TextSpan(text: "${ds['title']} \n", style: new TextStyle(fontWeight: FontWeight.bold)),
  305.                       new TextSpan(text: "${ds['time']} \n", style: new TextStyle(fontStyle: FontStyle.italic)),
  306.                       new TextSpan(text: "${ds['announcement']}\n\n"),
  307.                     ],
  308.                   ),
  309.                   textAlign: TextAlign.justify,
  310.                 );
  311.                 //return new Text("${ds['title']} ${ds['time']} \n ${ds['announcement']} \n");
  312.                 return text;
  313.               }
  314.             );
  315.           }),
  316.     );
  317.   }
  318. }
  319.  
  320.  
  321.  
  322. class Pairing extends StatelessWidget {
  323.   const Pairing({Key key, this.title}) : super(key: key);
  324.  
  325.   final String title;
  326.  
  327.  
  328.   @override
  329.   Widget build(BuildContext context) {
  330.     return new Scaffold(
  331.       body: new StreamBuilder(
  332.           stream: Firestore.instance.collection('wsdc_pairing').orderBy('round_no', descending: true).snapshots(),
  333.           builder: (context, snapshot) {
  334.             if (!snapshot.hasData) return const Text('Loading...');
  335.             return new ListView.builder(
  336.               itemCount: snapshot.data.documents.length,
  337.               padding: const EdgeInsets.only(top: 10.0, left: 5.0, right: 5.0),
  338.               itemBuilder: (context, index) {
  339.                 DocumentSnapshot ds = snapshot.data.documents[index];
  340.  
  341.                 var text = new RichText(
  342.                   text: new TextSpan(
  343.                     // Note: Styles for TextSpans must be explicitly defined.
  344.                     // Child text spans will inherit styles from parent
  345.                     style: new TextStyle(
  346.                       fontSize: 14.0,
  347.                       color: Colors.black,
  348.                     ),
  349.                     children: <TextSpan>[
  350.                       new TextSpan(text: "Pairing for round ${ds['round_no']} \n", style: new TextStyle(fontWeight: FontWeight.bold)),
  351.                       new TextSpan(text: "${ds['pairing']}\n\n".replaceAll('_n_', '\n')),
  352.                     ],
  353.                   ),
  354.                   textAlign: TextAlign.justify,
  355.                 );
  356.                 //return new Text("${ds['title']} ${ds['time']} \n ${ds['announcement']} \n");
  357.                 return text;
  358.               }
  359.             );
  360.           }),
  361.     );
  362.   }
  363. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement