Restructured files, and added the basic navigation

This commit is contained in:
clopezr1
2020-02-27 19:09:34 -05:00
8 changed files with 271 additions and 54 deletions

View File

@@ -1,14 +1,10 @@
import 'package:flutter/material.dart';
import '../placeholder_widget.dart';
import '../news/feed.dart';
class Home extends StatelessWidget {
final List<Widget> _children = [
PlaceholderWidget(Colors.white),
PlaceholderWidget(Colors.orange),
PlaceholderWidget(Colors.blue),
PlaceholderWidget(Colors.red),
PlaceholderWidget(Colors.black38),
];
final feed = Feed(); //was var not final
@override
Widget build(BuildContext context) {
@@ -17,12 +13,15 @@ class Home extends StatelessWidget {
appBar: AppBar(
centerTitle: false,
title: Text("49ers"),
),
body: _children[4],
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.green,
child: Icon(Icons.arrow_forward_ios),
onPressed: () => Navigator.pushNamed(context, '/Sport'),
),
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(
@@ -32,7 +31,7 @@ class Home extends StatelessWidget {
'Drawer Header',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontSize: 28,
),
),
decoration: BoxDecoration(

View File

@@ -1,14 +1,18 @@
import 'package:flutter/material.dart';
import '../news/feed.dart';
class Sport extends StatelessWidget {
final List<Object> _curSport = ['FootBall', Colors.green];
final List<Item> colorList = <Item>[
const Item("FootBall", Colors.red),
const Item('FootBall', Colors.green),
const Item("BasketBall", Colors.red),
const Item("Soccer", Colors.pinkAccent),
const Item('Baseball', Colors.yellow),
const Item('Baseball', Colors.orange),
];
final feed = Feed(); // was var not final
@override
Widget build(BuildContext context) {
Item selectedSport;
@@ -16,34 +20,76 @@ class Sport extends StatelessWidget {
return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar(
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(),
),
centerTitle: false,
title: buildDropdownButton(selectedSport, setState),
backgroundColor: _curSport[1],
),
body: Center(
child: Text("Sports Page Body"),
body: ListView(
children: <Widget>[
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport[0])),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport[0])),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport[0])),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport[0])),
],
),
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[0],
style: TextStyle(
color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold),
),
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(
child: Text(item.name),
width: 110,
),
);
}).toList(),
),
);
}