From 58421e0ffb0a4d09adb2b47abdae472fa429918e Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Wed, 5 Feb 2020 21:50:33 -0500 Subject: [PATCH 1/6] Creating a skeleton for app with a BottomNavBar --- lib/home_widget.dart | 61 +++++++++++++++++++++ lib/main.dart | 105 ++---------------------------------- lib/placeholder_widget.dart | 9 ++++ test/widget_test.dart | 2 +- 4 files changed, 76 insertions(+), 101 deletions(-) create mode 100644 lib/home_widget.dart create mode 100644 lib/placeholder_widget.dart diff --git a/lib/home_widget.dart b/lib/home_widget.dart new file mode 100644 index 0000000..22dabbb --- /dev/null +++ b/lib/home_widget.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'placeholder_widget.dart'; + +class Home extends StatefulWidget { + @override + _HomeState createState() => _HomeState(); +} + +class _HomeState extends State{ + int _currentIndex = 0; + final List _children = [ + PlaceholderWidget(Colors.white), + PlaceholderWidget(Colors.orange), + PlaceholderWidget(Colors.blue), + PlaceholderWidget(Colors.red), + PlaceholderWidget(Colors.black38), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('UNCC Athletics App'), + ), + body: _children[_currentIndex], + bottomNavigationBar: BottomNavigationBar( + type: BottomNavigationBarType.fixed, + onTap: onTabTapped, + currentIndex: _currentIndex, + items: [ + BottomNavigationBarItem( + icon: new Icon(Icons.home), + title: new Text("Home"), + ), + BottomNavigationBarItem( + icon: new Icon(Icons.calendar_today), + title: new Text("Schedule") + ), + BottomNavigationBarItem( + icon: new Icon(Icons.table_chart), + title: new Text("Scores") + ), + BottomNavigationBarItem( + icon: new Icon(Icons.assessment), + title: new Text("Standings") + ), + BottomNavigationBarItem( + icon: new Icon(Icons.more_horiz), + title: new Text("More") + ) + ], + ), + ); + } + + void onTabTapped(int index) { + setState(() { + _currentIndex = index; + }); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 5a7af45..48b4830 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,111 +1,16 @@ import 'package:flutter/material.dart'; +import 'home_widget.dart'; -void main() => runApp(MyApp()); +void main() => runApp(App()); -class MyApp extends StatelessWidget { - // This widget is the root of your application. +class App extends StatelessWidget{ @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'), + title: 'UNCC Athletics', + home: Home(), ); } } -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 a 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/placeholder_widget.dart b/lib/placeholder_widget.dart new file mode 100644 index 0000000..10b8eb6 --- /dev/null +++ b/lib/placeholder_widget.dart @@ -0,0 +1,9 @@ +import 'package:flutter/material.dart'; + +class PlaceholderWidget extends StatelessWidget{ + final Color color; + PlaceholderWidget(this.color); + + @override + Widget build(BuildContext context) => Container(color: color,); +} \ No newline at end of file diff --git a/test/widget_test.dart b/test/widget_test.dart index 185ff86..c2147bd 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:capstone_hungry_hippos/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(App()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); From 18945ad19b0c6bc4b3cd41dc279170f87857dd49 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 6 Feb 2020 18:36:26 -0500 Subject: [PATCH 2/6] Changed the app's name displayed, IOS target 8 => 12 --- android/app/src/main/AndroidManifest.xml | 2 +- ios/Runner.xcodeproj/project.pbxproj | 3 +++ ios/Runner/Info.plist | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0fc243a..b4d4b56 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -7,7 +7,7 @@ FlutterApplication and put your custom class here. --> CFBundleInfoDictionaryVersion 6.0 CFBundleName - capstone_hungry_hippos + UNCC Athletics CFBundlePackageType APPL CFBundleShortVersionString From dd6c1e1f40e8728c9073cdcff9dae3a6733f0726 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Fri, 7 Feb 2020 14:37:16 -0500 Subject: [PATCH 3/6] Removed the debug banner --- lib/main.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/main.dart b/lib/main.dart index 48b4830..47d6b1c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ class App extends StatelessWidget{ @override Widget build(BuildContext context) { return MaterialApp( + debugShowCheckedModeBanner: false, title: 'UNCC Athletics', home: Home(), ); From e86b95ab46ad984f62f5966a93d6f71d574c8175 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Sat, 8 Feb 2020 19:05:33 -0500 Subject: [PATCH 4/6] Creating the Dropdown sport selector, functionality yet to come --- lib/drop_down_widget.dart | 38 ++++++++++++++++++++++++++++++++++++++ lib/home_widget.dart | 10 +++++++++- lib/main.dart | 1 - 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 lib/drop_down_widget.dart diff --git a/lib/drop_down_widget.dart b/lib/drop_down_widget.dart new file mode 100644 index 0000000..78b293d --- /dev/null +++ b/lib/drop_down_widget.dart @@ -0,0 +1,38 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class DropDownWidget extends StatefulWidget { + @override + _DropDownWidget createState() => _DropDownWidget(); +} + +class _DropDownWidget extends State{ + String curSport = "Men's Basketball"; + + @override + Widget build(BuildContext context) { + return DropdownButton( + value: curSport, + icon: Icon(Icons.arrow_drop_down), + iconSize: 24, + style: TextStyle(color: Colors.black), + iconEnabledColor: Colors.white, + onChanged: (String newSport) { + setState(() { + curSport = newSport; + }); + }, + items: ["Men's Basketball", "Women's Basketball", "Baseball", "Softball", "FootBall"] + .map>((String value) { + return DropdownMenuItem( + value: value, + child: SizedBox( + width: 100, + child: Text(value), + ), + ); + }).toList(), + ); + } +} \ No newline at end of file diff --git a/lib/home_widget.dart b/lib/home_widget.dart index 22dabbb..cb41b75 100644 --- a/lib/home_widget.dart +++ b/lib/home_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'placeholder_widget.dart'; +import 'drop_down_widget.dart'; class Home extends StatefulWidget { @override @@ -8,6 +9,8 @@ class Home extends StatefulWidget { class _HomeState extends State{ int _currentIndex = 0; + var curSport = ''; + final List _children = [ PlaceholderWidget(Colors.white), PlaceholderWidget(Colors.orange), @@ -20,7 +23,12 @@ class _HomeState extends State{ Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('UNCC Athletics App'), + + //title: Text(appBarTitle), + actions: [ + DropDownWidget(), + ], + backgroundColor: Colors.green, ), body: _children[_currentIndex], bottomNavigationBar: BottomNavigationBar( diff --git a/lib/main.dart b/lib/main.dart index 47d6b1c..aad7acc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,6 @@ class App extends StatelessWidget{ Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - title: 'UNCC Athletics', home: Home(), ); } From a6beebb4ce448c6c223ef18ef2107ce7ccf54b62 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Mon, 10 Feb 2020 20:02:04 -0500 Subject: [PATCH 5/6] oof --- lib/drop_down_widget.dart | 35 ++++++++++++++++++++++++----------- lib/home_widget.dart | 17 +++++++++++------ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lib/drop_down_widget.dart b/lib/drop_down_widget.dart index 78b293d..e8dcce8 100644 --- a/lib/drop_down_widget.dart +++ b/lib/drop_down_widget.dart @@ -1,38 +1,51 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'home_widget.dart'; -class DropDownWidget extends StatefulWidget { +class DropDownWidget extends StatefulWidget{ @override _DropDownWidget createState() => _DropDownWidget(); + } class _DropDownWidget extends State{ - String curSport = "Men's Basketball"; + Item selectedSport; + String curSport; + Color _appBarColor; + List colorList = [ + const Item("Men's Basketball", Colors.red), + const Item("Women's Basketball", Colors.pinkAccent), + const Item('Baseball', Colors.yellow), + ]; @override Widget build(BuildContext context) { - return DropdownButton( - value: curSport, + return DropdownButton( + value: selectedSport, icon: Icon(Icons.arrow_drop_down), iconSize: 24, style: TextStyle(color: Colors.black), iconEnabledColor: Colors.white, - onChanged: (String newSport) { + onChanged: (Item value) { setState(() { - curSport = newSport; + selectedSport = value; + curSport = selectedSport.name; + _appBarColor = selectedSport.color; }); }, - items: ["Men's Basketball", "Women's Basketball", "Baseball", "Softball", "FootBall"] - .map>((String value) { - return DropdownMenuItem( - value: value, + items: colorList.map>((Item item) { + return DropdownMenuItem( + value: item, child: SizedBox( width: 100, - child: Text(value), + child: Text(item.name), ), ); }).toList(), ); } + String getString(){ + return curSport; + } } \ No newline at end of file diff --git a/lib/home_widget.dart b/lib/home_widget.dart index cb41b75..f0e8ce4 100644 --- a/lib/home_widget.dart +++ b/lib/home_widget.dart @@ -19,16 +19,14 @@ class _HomeState extends State{ PlaceholderWidget(Colors.black38), ]; + DropDownWidget ddw = DropDownWidget(); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - - //title: Text(appBarTitle), - actions: [ - DropDownWidget(), - ], - backgroundColor: Colors.green, + title: ddw, + //backgroundColor: , ), body: _children[_currentIndex], bottomNavigationBar: BottomNavigationBar( @@ -64,6 +62,13 @@ class _HomeState extends State{ void onTabTapped(int index) { setState(() { _currentIndex = index; + print(ddw); }); } +} + +class Item { + const Item(this.name, this.color); + final String name; + final Color color; } \ No newline at end of file From 5ba8bf327706377847710b2eea44fadcf71fd3fc Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Wed, 12 Feb 2020 20:16:12 -0500 Subject: [PATCH 6/6] Re-did home_widget.dart -> home_widget2.dart and Dropdown works --- lib/drop_down_widget.dart | 51 --------------------- lib/home_widget.dart | 74 ------------------------------ lib/home_widget2.dart | 91 +++++++++++++++++++++++++++++++++++++ lib/main.dart | 2 +- lib/placeholder_widget.dart | 10 ++-- 5 files changed, 99 insertions(+), 129 deletions(-) delete mode 100644 lib/drop_down_widget.dart delete mode 100644 lib/home_widget.dart create mode 100644 lib/home_widget2.dart diff --git a/lib/drop_down_widget.dart b/lib/drop_down_widget.dart deleted file mode 100644 index e8dcce8..0000000 --- a/lib/drop_down_widget.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'home_widget.dart'; - -class DropDownWidget extends StatefulWidget{ - @override - _DropDownWidget createState() => _DropDownWidget(); - -} - -class _DropDownWidget extends State{ - Item selectedSport; - String curSport; - Color _appBarColor; - List colorList = [ - const Item("Men's Basketball", Colors.red), - const Item("Women's Basketball", Colors.pinkAccent), - const Item('Baseball', Colors.yellow), - ]; - - @override - Widget build(BuildContext context) { - return DropdownButton( - value: selectedSport, - icon: Icon(Icons.arrow_drop_down), - iconSize: 24, - style: TextStyle(color: Colors.black), - iconEnabledColor: Colors.white, - onChanged: (Item value) { - setState(() { - selectedSport = value; - curSport = selectedSport.name; - _appBarColor = selectedSport.color; - }); - }, - items: colorList.map>((Item item) { - return DropdownMenuItem( - value: item, - child: SizedBox( - width: 100, - child: Text(item.name), - ), - ); - }).toList(), - ); - } - String getString(){ - return curSport; - } -} \ No newline at end of file diff --git a/lib/home_widget.dart b/lib/home_widget.dart deleted file mode 100644 index f0e8ce4..0000000 --- a/lib/home_widget.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'package:flutter/material.dart'; -import 'placeholder_widget.dart'; -import 'drop_down_widget.dart'; - -class Home extends StatefulWidget { - @override - _HomeState createState() => _HomeState(); -} - -class _HomeState extends State{ - int _currentIndex = 0; - var curSport = ''; - - final List _children = [ - PlaceholderWidget(Colors.white), - PlaceholderWidget(Colors.orange), - PlaceholderWidget(Colors.blue), - PlaceholderWidget(Colors.red), - PlaceholderWidget(Colors.black38), - ]; - - DropDownWidget ddw = DropDownWidget(); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: ddw, - //backgroundColor: , - ), - body: _children[_currentIndex], - bottomNavigationBar: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - onTap: onTabTapped, - currentIndex: _currentIndex, - items: [ - BottomNavigationBarItem( - icon: new Icon(Icons.home), - title: new Text("Home"), - ), - BottomNavigationBarItem( - icon: new Icon(Icons.calendar_today), - title: new Text("Schedule") - ), - BottomNavigationBarItem( - icon: new Icon(Icons.table_chart), - title: new Text("Scores") - ), - BottomNavigationBarItem( - icon: new Icon(Icons.assessment), - title: new Text("Standings") - ), - BottomNavigationBarItem( - icon: new Icon(Icons.more_horiz), - title: new Text("More") - ) - ], - ), - ); - } - - void onTabTapped(int index) { - setState(() { - _currentIndex = index; - print(ddw); - }); - } -} - -class Item { - const Item(this.name, this.color); - final String name; - final Color color; -} \ No newline at end of file diff --git a/lib/home_widget2.dart b/lib/home_widget2.dart new file mode 100644 index 0000000..174614d --- /dev/null +++ b/lib/home_widget2.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'placeholder_widget.dart'; + +class Home extends StatelessWidget { + final List _curSport = ['FootBall', Colors.green]; + + final List colorList = [ + const Item("FootBall", Colors.red), + const Item("Soccer", Colors.pinkAccent), + const Item('Baseball', Colors.yellow), + ]; + + final List _children = [ + PlaceholderWidget(Colors.white), + PlaceholderWidget(Colors.orange), + PlaceholderWidget(Colors.blue), + PlaceholderWidget(Colors.red), + PlaceholderWidget(Colors.black38), + ]; + + @override + Widget build(BuildContext context) { + int _currentBodyIndex = 0; + Item selectedSport; + + return StatefulBuilder( + builder: (context, StateSetter setState) => Scaffold( + appBar: AppBar( + centerTitle: true, + title: DropdownButton( + value: selectedSport, + icon: Icon(Icons.arrow_drop_down), + iconSize: 24, + style: TextStyle(color: Colors.black), + iconEnabledColor: Colors.white, + onChanged: (Item value) { + setState(() { + selectedSport = value; + _curSport[0] = selectedSport.name; + _curSport[1] = selectedSport.color; + }); + }, + items: colorList.map>((Item item) { + return DropdownMenuItem( + value: item, + child: SizedBox( + width: 100, + child: Text(item.name), + ), + ); + }).toList(), + ), + backgroundColor: _curSport[1], + ), + body: _children[_currentBodyIndex], + bottomNavigationBar: BottomNavigationBar( + type: BottomNavigationBarType.fixed, + onTap: (int index) { + setState(() { + _currentBodyIndex = index; + }); + }, + currentIndex: _currentBodyIndex, + items: [ + BottomNavigationBarItem( + icon: new Icon(Icons.home), + title: new Text("Home"), + ), + BottomNavigationBarItem( + icon: new Icon(Icons.calendar_today), + title: new Text("Schedule")), + BottomNavigationBarItem( + icon: new Icon(Icons.table_chart), + title: new Text("Scores")), + BottomNavigationBarItem( + icon: new Icon(Icons.assessment), + title: new Text("Standings")), + BottomNavigationBarItem( + icon: new Icon(Icons.more_horiz), title: new Text("More")) + ], + ), + )); + } +} + +class Item { + const Item(this.name, this.color); + + final String name; + final Color color; +} diff --git a/lib/main.dart b/lib/main.dart index aad7acc..2edca9a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'home_widget.dart'; +import 'home_widget2.dart'; void main() => runApp(App()); diff --git a/lib/placeholder_widget.dart b/lib/placeholder_widget.dart index 10b8eb6..64e35a2 100644 --- a/lib/placeholder_widget.dart +++ b/lib/placeholder_widget.dart @@ -2,8 +2,12 @@ import 'package:flutter/material.dart'; class PlaceholderWidget extends StatelessWidget{ final Color color; - PlaceholderWidget(this.color); + PlaceholderWidget(this.color,); @override - Widget build(BuildContext context) => Container(color: color,); -} \ No newline at end of file + Widget build(BuildContext context) { + return Container( + color: color, + ); + } +}