diff --git a/lib/home_widget.dart b/lib/home_widget.dart index 546016c..76b85b7 100644 --- a/lib/home_widget.dart +++ b/lib/home_widget.dart @@ -1,46 +1,98 @@ import 'package:flutter/material.dart'; import 'news/feed.dart'; -class Home extends StatefulWidget { - @override - State createState() => HomeState(); -} +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), + ]; -class HomeState extends State { @override Widget build(BuildContext context) { - var feed = Feed(); + int _currentBodyIndex = 0; + Item selectedSport; - return Scaffold( - appBar: AppBar( - title: Text('UNCC Athletics App'), - ), - body: ListView( - children: [ - HorizontalNewsFeed(newsFeed: feed, title: Text("Basketball")), - HorizontalNewsFeed(newsFeed: feed, title: Text("Soccer")), - HorizontalNewsFeed(newsFeed: feed, title: Text("Football")), - HorizontalNewsFeed(newsFeed: feed, title: Text("Volleyball")), - ], - ), - bottomNavigationBar: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - 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")) - ], - ), - ); + 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: ListView( + children: [ + HorizontalNewsFeed(newsFeed: feed, title: Text("Basketball")), + HorizontalNewsFeed(newsFeed: feed, title: Text("Soccer")), + HorizontalNewsFeed(newsFeed: feed, title: Text("Football")), + HorizontalNewsFeed(newsFeed: feed, title: Text("Volleyball")), + ], + ), + 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 4bde493..47d6b1c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,7 +9,6 @@ class App extends StatelessWidget{ return MaterialApp( debugShowCheckedModeBanner: false, title: 'UNCC Athletics', - home: Home(), ); }