Commit 1d7268c6 authored by Timothe's avatar Timothe

mercredi 9h14 -6 ça fait pi

parent 555f9f42
......@@ -27,6 +27,7 @@ class MyApp extends StatelessWidget {
}
}
class MyAppState extends ChangeNotifier {
var current = WordPair.random();
......@@ -53,17 +54,31 @@ class MyHomePage extends StatefulWidget {
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePag State extends State<MyHomePage> {
class _MyHomePageState extends State<MyHomePage> {
var selectedIndex = 0;
@override
Widget build(BuildContext context) {
Widget page;
switch (selectedIndex) {
case 0:
page = GeneratorPage();
break;
case 1:
page = FavoritePage();
break;
default:
throw UnimplementedError('no widget for $selectedIndex');
}
return LayoutBuilder(
builder: (context,constraints) {
return Scaffold(
body: Row(
children: [
SafeArea(
child: NavigationRail(
extended: false,
extended: constraints.maxWidth>=600,
destinations: [
NavigationRailDestination(
icon: Icon(Icons.home),
......@@ -86,13 +101,15 @@ class _MyHomePag State extends State<MyHomePage> {
Expanded(
child: Container(
color: Theme.of(context).colorScheme.primaryContainer,
child: GeneratorPage(),
child: page,
),
),
],
),
);
}
);
}
}
......@@ -170,3 +187,26 @@ class BigCard extends StatelessWidget {
}
}
class FavoritePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var appState = context.watch<MyAppState>();
var favorites = appState.favorites;
return Scaffold(
body: Column(children: [
Text('Favorites'),
for (var fav in favorites)
Text(fav.asLowerCase),
],)
);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment