From 34df11b2bf57f76e78a3e5e01f85ea52a514def2 Mon Sep 17 00:00:00 2001 From: sandunsameera Date: Fri, 18 Oct 2019 19:28:38 +0530 Subject: [PATCH 1/5] initialize project --- ios/Flutter/flutter_export_environment.sh | 10 ++++++++++ lib/myapp.dart | 0 lib/screens/home_screen.dart | 0 pubspec.lock | 20 ++++++++++---------- test/widget_test.dart | 3 +-- 5 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 ios/Flutter/flutter_export_environment.sh create mode 100644 lib/myapp.dart create mode 100644 lib/screens/home_screen.dart diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 0000000..1b7af81 --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=D:\softwares\Flutter\flutter_windows_v1.5.4-hotfix.2-stable\flutter" +export "FLUTTER_APPLICATION_PATH=D:\projects\traintracker" +export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build\ios" +export "FLUTTER_FRAMEWORK_DIR=D:\softwares\Flutter\flutter_windows_v1.5.4-hotfix.2-stable\flutter\bin\cache\artifacts\engine\ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" diff --git a/lib/myapp.dart b/lib/myapp.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart new file mode 100644 index 0000000..e69de29 diff --git a/pubspec.lock b/pubspec.lock index f6b0bbd..fbdb266 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,5 +1,5 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: async: dependency: transitive @@ -7,14 +7,14 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.3.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" charcode: dependency: transitive description: @@ -59,28 +59,28 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.1.7" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "1.6.4" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.8.0+1" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.5" sky_engine: dependency: transitive description: flutter @@ -113,7 +113,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" term_glyph: dependency: transitive description: @@ -127,7 +127,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" + version: "0.2.5" typed_data: dependency: transitive description: @@ -143,4 +143,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.2.0 <3.0.0" + dart: ">=2.2.2 <3.0.0" diff --git a/test/widget_test.dart b/test/widget_test.dart index e62c675..d2bc196 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -7,8 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; - -import 'package:trainfinder/main.dart'; +import 'package:trainfinder/myapp.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { From 6bec54f98e6748e969b06b10f3e7f0b0c1e29828 Mon Sep 17 00:00:00 2001 From: sandunsameera Date: Fri, 18 Oct 2019 20:10:54 +0530 Subject: [PATCH 2/5] Add header widget --- lib/main.dart | 109 +-------------------------------- lib/myapp.dart | 18 ++++++ lib/screens/home_screen.dart | 20 ++++++ lib/widgets/common/appbar.dart | 28 +++++++++ pubspec.lock | 14 +++++ pubspec.yaml | 3 +- 6 files changed, 83 insertions(+), 109 deletions(-) create mode 100644 lib/widgets/common/appbar.dart diff --git a/lib/main.dart b/lib/main.dart index f4ebf1d..514f2ed 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,111 +1,4 @@ import 'package:flutter/material.dart'; +import 'package:trainfinder/myapp.dart'; void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, - ), - home: MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - _MyHomePageState createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.display1, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } -} diff --git a/lib/myapp.dart b/lib/myapp.dart index e69de29..3635ab5 100644 --- a/lib/myapp.dart +++ b/lib/myapp.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:trainfinder/screens/home_screen.dart'; + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + @override + Widget build(BuildContext context) { + return MaterialApp( + title: "Train tracker", + darkTheme: ThemeData.dark(), + home: Homepage(), + ); + } +} \ No newline at end of file diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index e69de29..aa98c40 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:trainfinder/widgets/common/appbar.dart'; + +class Homepage extends StatefulWidget { + @override + _HomepageState createState() => _HomepageState(); +} + +class _HomepageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body:CustomScrollView( + slivers: [ + Header("Train \n Tracker") + ], + ) + ); + } +} \ No newline at end of file diff --git a/lib/widgets/common/appbar.dart b/lib/widgets/common/appbar.dart new file mode 100644 index 0000000..9d173e2 --- /dev/null +++ b/lib/widgets/common/appbar.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +class Header extends StatelessWidget { + final String title; + + Header(this.title); + + @override + Widget build(BuildContext context) { + return SliverAppBar( + expandedHeight: 240.0, + floating: false, + pinned: false, + flexibleSpace: FlexibleSpaceBar( + title: Padding( + padding: const EdgeInsets.only(bottom: 24.0), + child: Text(title, + style: TextStyle( + color: Colors.white, + fontSize: 36.0, + )), + ), + background: Container( + color: Colors.blue, + )), + ); + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index fbdb266..24e50b8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -60,6 +60,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.7" + mobx: + dependency: transitive + description: + name: mobx + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.37" path: dependency: transitive description: @@ -86,6 +93,13 @@ packages: description: flutter source: sdk version: "0.0.99" + sliver_glue: + dependency: "direct main" + description: + name: sliver_glue + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" source_span: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 212657e..174e368 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,11 +19,12 @@ environment: dependencies: flutter: sdk: flutter + sliver_glue: ^1.2.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 - + dev_dependencies: flutter_test: sdk: flutter From da5ac2db20205345d926cf9d9c9bfa21ef208927 Mon Sep 17 00:00:00 2001 From: sandunsameera Date: Fri, 18 Oct 2019 22:24:43 +0530 Subject: [PATCH 3/5] Model for content --- lib/screens/home_screen.dart | 30 ++++++++++++++---- lib/screens/main_screen.dart | 61 ++++++++++++++++++++++++++++++++++++ pubspec.lock | 21 +++++++++++++ pubspec.yaml | 3 ++ 4 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 lib/screens/main_screen.dart diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index aa98c40..0b823b3 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:trainfinder/screens/main_screen.dart'; import 'package:trainfinder/widgets/common/appbar.dart'; class Homepage extends StatefulWidget { @@ -10,11 +11,28 @@ class _HomepageState extends State { @override Widget build(BuildContext context) { return Scaffold( - body:CustomScrollView( - slivers: [ - Header("Train \n Tracker") - ], - ) + resizeToAvoidBottomInset: false, + body: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + Header("Train Tracker"), + ]; + }, + body: Container( + child: Center( + child: FlatButton( + color: Colors.amber, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20) + ), + child: Text("Start"), + onPressed: ()=>Navigator.push(context, MaterialPageRoute( + builder: (context)=>Mainscreen() + )) + ), + ), + ), + ), ); } -} \ No newline at end of file +} diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart new file mode 100644 index 0000000..7394390 --- /dev/null +++ b/lib/screens/main_screen.dart @@ -0,0 +1,61 @@ +import 'package:circular_bottom_navigation/circular_bottom_navigation.dart'; +import 'package:circular_bottom_navigation/tab_item.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class Mainscreen extends StatefulWidget { + @override + _MainscreenState createState() => _MainscreenState(); +} + +class _MainscreenState extends State { + List tabItems = List.of([ + new TabItem(FontAwesomeIcons.accessibleIcon, "Contribute", Colors.blue, + labelStyle: TextStyle(fontWeight: FontWeight.normal)), + new TabItem(Icons.search, "Search", Colors.orange, + labelStyle: TextStyle(color: Colors.red, fontWeight: FontWeight.bold)), + new TabItem(Icons.layers, "Notices", Colors.red), + new TabItem(Icons.notifications, "Notifications", Colors.cyan), + ]); + + int _selectedIndex = 0; + static const TextStyle optionStyle = + TextStyle(fontSize: 30, fontWeight: FontWeight.bold); + static const List _widgetOptions = [ + Text( + 'Index 0: Contribution', + style: optionStyle, + ), + Text( + 'Index 1: Search', + style: optionStyle, + ), + Text( + 'Index 2: Notices', + style: optionStyle, + ), + Text( + 'Index 4: Notificarions', + style: optionStyle, + ), + ]; + + static int selectedPos = 0; + CircularBottomNavigationController _navigationController = + new CircularBottomNavigationController(selectedPos); + @override + Widget build(BuildContext context) { + return Scaffold( + bottomNavigationBar: CircularBottomNavigation( + tabItems, + controller: _navigationController, + selectedCallback: (int selectedPos) { + setState(() { + _selectedIndex = selectedPos; + }); + }, + ), + body: _widgetOptions.elementAt(_selectedIndex), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 24e50b8..78fe4bd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -15,6 +15,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + bubble_bottom_bar: + dependency: "direct main" + description: + name: bubble_bottom_bar + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" charcode: dependency: transitive description: @@ -22,6 +29,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.2" + circular_bottom_navigation: + dependency: "direct main" + description: + name: circular_bottom_navigation + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" collection: dependency: transitive description: @@ -46,6 +60,13 @@ packages: description: flutter source: sdk version: "0.0.0" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "8.5.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 174e368..f27f11a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,6 +20,9 @@ dependencies: flutter: sdk: flutter sliver_glue: ^1.2.0 + font_awesome_flutter: ^8.5.0 + bubble_bottom_bar: ^1.2.0 + circular_bottom_navigation: ^1.0.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. From 6726e328373ee1f8f6f4bf5038bfa958d1939b9e Mon Sep 17 00:00:00 2001 From: sandunsameera Date: Fri, 18 Oct 2019 23:06:31 +0530 Subject: [PATCH 4/5] Search feature ui --- lib/content_screen/search_screen.dart | 34 +++++++++++++++++++++++++++ lib/screens/main_screen.dart | 26 +++++++------------- 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 lib/content_screen/search_screen.dart diff --git a/lib/content_screen/search_screen.dart b/lib/content_screen/search_screen.dart new file mode 100644 index 0000000..dde8b62 --- /dev/null +++ b/lib/content_screen/search_screen.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:scaffold_tab_bar/scaffold_tab_bar.dart'; + +class SearchScreen extends StatefulWidget { + @override + _SearchScreenState createState() => _SearchScreenState(); +} + +class _SearchScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: ScaffoldTabBar( + children: [ + ScreenTab( + screen: Text("Time Table"), + tab: BottomNavigationBarItem( + icon: Icon(FontAwesomeIcons.times), + title: Text('Time table'), + ), + ), + ScreenTab( + screen: Text("Search"), + tab: BottomNavigationBarItem( + icon: Icon(FontAwesomeIcons.search), + title: Text('Search'), + ), + ), + ], + ) + ); + } +} \ No newline at end of file diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart index 7394390..e2b5f4f 100644 --- a/lib/screens/main_screen.dart +++ b/lib/screens/main_screen.dart @@ -2,6 +2,10 @@ import 'package:circular_bottom_navigation/circular_bottom_navigation.dart'; import 'package:circular_bottom_navigation/tab_item.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:trainfinder/content_screen/contribution_screen.dart'; +import 'package:trainfinder/content_screen/notices_screen.dart'; +import 'package:trainfinder/content_screen/notification_screen.dart'; +import 'package:trainfinder/content_screen/search_screen.dart'; class Mainscreen extends StatefulWidget { @override @@ -21,23 +25,11 @@ class _MainscreenState extends State { int _selectedIndex = 0; static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); - static const List _widgetOptions = [ - Text( - 'Index 0: Contribution', - style: optionStyle, - ), - Text( - 'Index 1: Search', - style: optionStyle, - ), - Text( - 'Index 2: Notices', - style: optionStyle, - ), - Text( - 'Index 4: Notificarions', - style: optionStyle, - ), + static List _widgetOptions = [ + Contribution(), + SearchScreen(), + NoticesScreen(), + NotificationScreen(), ]; static int selectedPos = 0; From 378c3402010713a7a3b164518ebff97e44b73556 Mon Sep 17 00:00:00 2001 From: sandunsameera Date: Sat, 19 Oct 2019 20:30:24 +0530 Subject: [PATCH 5/5] Search function UI --- lib/content_screen/search_screen.dart | 112 ++++++++++++++++++++++---- lib/screens/main_screen.dart | 2 +- 2 files changed, 98 insertions(+), 16 deletions(-) diff --git a/lib/content_screen/search_screen.dart b/lib/content_screen/search_screen.dart index dde8b62..eb5e518 100644 --- a/lib/content_screen/search_screen.dart +++ b/lib/content_screen/search_screen.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:scaffold_tab_bar/scaffold_tab_bar.dart'; +import 'package:trainfinder/widgets/text_form_field.dart'; class SearchScreen extends StatefulWidget { @override @@ -11,24 +12,105 @@ class _SearchScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - body: ScaffoldTabBar( - children: [ - ScreenTab( - screen: Text("Time Table"), - tab: BottomNavigationBarItem( - icon: Icon(FontAwesomeIcons.times), - title: Text('Time table'), - ), + body: ScaffoldTabBar( + children: [ + ScreenTab( + screen: Text("Search"), + tab: BottomNavigationBarItem( + icon: Icon(FontAwesomeIcons.times), + title: Text('Time table'), + ), + ), + ScreenTab( + screen: _timeTable(), + tab: BottomNavigationBarItem( + icon: Icon(FontAwesomeIcons.search), + title: Text('Search'), + ), + ), + ], + )); + } + + Widget _timeTable() { + return Container( + child: Column( + children: [ + SizedBox( + height: 60, ), - ScreenTab( - screen: Text("Search"), - tab: BottomNavigationBarItem( - icon: Icon(FontAwesomeIcons.search), - title: Text('Search'), + Center( + child: Text( + "Find Train Schedule", + style: TextStyle( + fontSize: 40, + color: Colors.teal, + fontWeight: FontWeight.bold), ), ), + SizedBox( + height: 50, + ), + LabelTextField( + labelText: "From where", + hintText: "From where", + ), + SizedBox( + height: 20, + ), + LabelTextField( + labelText: "To where", + hintText: "To where", + ), + Row( + children: [ + Align( + alignment: Alignment.centerLeft, + child: IconButton( + onPressed: () {}, + icon: Icon( + Icons.swap_vert, + color: Colors.teal, + ), + ), + ), + Text("swap"), + Padding( + padding: EdgeInsets.only(left: 220), + ), + Align( + alignment: Alignment.bottomRight, + child: IconButton( + icon: Icon(FontAwesomeIcons.dropbox), + onPressed: () {}, + ), + ), + Text("more") + ], + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Padding( + padding: EdgeInsets.only(left: 40), + ), + ButtonTheme( + minWidth: MediaQuery.of(context).size.width*0.8, + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10) + ), + onPressed: () {}, + child: Text("Submit"), + color: Colors.teal, + ), + ), + ], + ) ], - ) + ), ); } -} \ No newline at end of file +} diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart index e2b5f4f..253e95d 100644 --- a/lib/screens/main_screen.dart +++ b/lib/screens/main_screen.dart @@ -15,7 +15,7 @@ class Mainscreen extends StatefulWidget { class _MainscreenState extends State { List tabItems = List.of([ new TabItem(FontAwesomeIcons.accessibleIcon, "Contribute", Colors.blue, - labelStyle: TextStyle(fontWeight: FontWeight.normal)), + labelStyle: TextStyle(fontWeight: FontWeight.bold)), new TabItem(Icons.search, "Search", Colors.orange, labelStyle: TextStyle(color: Colors.red, fontWeight: FontWeight.bold)), new TabItem(Icons.layers, "Notices", Colors.red),