Merge pull request #7 from allemangD/Navigation

Navigation
This commit is contained in:
2020-02-27 21:57:59 -05:00
committed by GitHub
7 changed files with 165 additions and 98 deletions

3
android/.gitignore vendored
View File

@@ -5,3 +5,6 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
/android/app/src/debug/gen
/android/app/src/main/gen
/android/app/src/profile/gen

0
lib/common/theme.dart Normal file
View File

View File

@@ -1,91 +0,0 @@
import 'package:flutter/material.dart';
import 'news/feed.dart';
class Home extends StatelessWidget {
final List<Object> _curSport = ['FootBall', Colors.green];
final List<Item> colorList = <Item>[
const Item("FootBall", Colors.red),
const Item("Soccer", Colors.pinkAccent),
const Item('Baseball', Colors.yellow),
];
var feed = Feed();
@override
Widget build(BuildContext context) {
int _currentBodyIndex = 0;
Item selectedSport;
return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar(
centerTitle: true,
title: DropdownButton<Item>(
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<DropdownMenuItem<Item>>((Item item) {
return DropdownMenuItem<Item>(
value: item,
child: SizedBox(
width: 100,
child: Text(item.name),
),
);
}).toList(),
),
backgroundColor: _curSport[1],
),
body: ListView(
children: <Widget>[
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;
}

View File

@@ -1,17 +1,19 @@
import 'package:flutter/material.dart';
import 'home_widget.dart';
import 'screens/home_widget.dart';
import 'screens/sport.dart';
void main() => runApp(App());
class App extends StatelessWidget{
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'UNCC Athletics',
home: Home(),
initialRoute: '/',
routes: {
'/': (context) => Home(),
'/Sport': (context) => Sport(),
},
);
}
}

View File

@@ -43,7 +43,7 @@ class HorizontalNewsFeed extends StatelessWidget {
title: title,
trailing: IconButton(
icon: Icon(Icons.navigate_next),
onPressed: () {},
onPressed: () => Navigator.pushNamed(context, '/Sport'),
),
),
Expanded(

View File

@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import '../news/feed.dart';
class Home extends StatelessWidget {
final feed = Feed(); //was var not final
@override
Widget build(BuildContext context) {
return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar(
centerTitle: false,
title: Text("49ers"),
backgroundColor: Colors.green,
),
body: ListView(
children: <Widget>[
HorizontalNewsFeed(newsFeed: feed, title: Text("Basketball")),
HorizontalNewsFeed(newsFeed: feed, title: Text("Soccer")),
HorizontalNewsFeed(newsFeed: feed, title: Text("Football")),
HorizontalNewsFeed(newsFeed: feed, title: Text("Volleyball")),
],
),
drawer: Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
child: Text(
'Drawer Header',
style: TextStyle(
color: Colors.white,
fontSize: 28,
),
),
decoration: BoxDecoration(
color: Colors.green,
),
),
ListTile(
leading: Icon(Icons.message),
title: Text('Messages'),
),
],
),
),
));
}
}

103
lib/screens/sport.dart Normal file
View File

@@ -0,0 +1,103 @@
import 'package:flutter/material.dart';
import '../news/feed.dart';
class Sport extends StatelessWidget {
static final List<Item> colorList = <Item>[
const Item('FootBall', Colors.green),
const Item("BasketBall", Colors.red),
const Item("Soccer", Colors.pinkAccent),
const Item('Baseball', Colors.orange),
];
Item _curSport = colorList[0];
final feed = Feed(); // was var not final
@override
Widget build(BuildContext context) {
Item selectedSport;
return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar(
centerTitle: false,
title: buildDropdownButton(selectedSport, setState),
backgroundColor: _curSport.color,
),
body: ListView(
children: <Widget>[
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
],
),
drawer: Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
child: Text(
'Drawer Header',
style: TextStyle(
color: Colors.white,
fontSize: 24,
),
),
decoration: BoxDecoration(
color: Colors.green,
),
),
ListTile(
title: IconButton(
icon: Icon(Icons.home),
onPressed: () => Navigator.pushNamed(context, '/'),
),
),
],
),
),
),
);
}
DropdownButtonHideUnderline buildDropdownButton(
Item selectedSport, StateSetter setState) {
return DropdownButtonHideUnderline(
child: DropdownButton<Item>(
value: selectedSport,
icon: Icon(Icons.arrow_drop_down),
iconSize: 28,
style: TextStyle(color: Colors.black, fontSize: 28),
iconEnabledColor: Colors.white,
hint: Text(
_curSport.name,
style: TextStyle(
color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold),
),
onChanged: (Item value) {
setState(() {
_curSport = value;
});
},
items: colorList.map<DropdownMenuItem<Item>>((Item item) {
return DropdownMenuItem<Item>(
value: item,
child: SizedBox(
child: Text(item.name),
width: 150,
),
);
}).toList(),
),
);
}
}
class Item {
const Item(this.name, this.color);
final String name;
final Color color;
}