Changed main to be able to point to routes, and file restructuring
This commit is contained in:
3
android/.gitignore
vendored
3
android/.gitignore
vendored
@@ -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
0
lib/common/theme.dart
Normal file
@@ -1,64 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'placeholder_widget.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),
|
||||
];
|
||||
|
||||
final List<Widget> _children = [
|
||||
PlaceholderWidget(Colors.white),
|
||||
PlaceholderWidget(Colors.orange),
|
||||
PlaceholderWidget(Colors.blue),
|
||||
PlaceholderWidget(Colors.red),
|
||||
PlaceholderWidget(Colors.black38),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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: _children[2],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class Item {
|
||||
const Item(this.name, this.color);
|
||||
|
||||
final String name;
|
||||
final Color color;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'home_widget.dart';
|
||||
import 'screens/home_widget.dart';
|
||||
import 'screens/sport.dart';
|
||||
|
||||
void main() => runApp(App());
|
||||
|
||||
@@ -8,9 +9,11 @@ class App extends StatelessWidget{
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: Home(),
|
||||
initialRoute: '/',
|
||||
routes: {
|
||||
'/': (context) => Home(),
|
||||
'/Sport': (context) => Sport(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
51
lib/screens/home_widget.dart
Normal file
51
lib/screens/home_widget.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../placeholder_widget.dart';
|
||||
|
||||
class Home extends StatelessWidget {
|
||||
final List<Widget> _children = [
|
||||
PlaceholderWidget(Colors.white),
|
||||
PlaceholderWidget(Colors.orange),
|
||||
PlaceholderWidget(Colors.blue),
|
||||
PlaceholderWidget(Colors.red),
|
||||
PlaceholderWidget(Colors.black38),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, StateSetter setState) => Scaffold(
|
||||
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'),
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
DrawerHeader(
|
||||
child: Text(
|
||||
'Drawer Header',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.message),
|
||||
title: Text('Messages'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
57
lib/screens/sport.dart
Normal file
57
lib/screens/sport.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Sport 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),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Item selectedSport;
|
||||
|
||||
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(),
|
||||
),
|
||||
backgroundColor: _curSport[1],
|
||||
),
|
||||
body: Center(
|
||||
child: Text("Sports Page Body"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Item {
|
||||
const Item(this.name, this.color);
|
||||
|
||||
final String name;
|
||||
final Color color;
|
||||
}
|
||||
Reference in New Issue
Block a user