Skip to content
Snippets Groups Projects
Commit e1d051c1 authored by Jingeun Lee's avatar Jingeun Lee
Browse files

7. 탐색 레일 추가

parent 4f221194
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,69 @@ class MyAppState extends ChangeNotifier { ...@@ -44,7 +44,69 @@ class MyAppState extends ChangeNotifier {
} }
} }
class MyHomePage extends StatelessWidget { class MyHomePage extends StatefulWidget {
@override
State<MyHomePage> createState() => _MyHomePageState();
}
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 = Placeholder();
break;
default:
throw UnimplementedError('no widget for $selectedIndex');
}
return LayoutBuilder(
builder: (context, constraints) {
return Scaffold(
body: Row(
children: [
SafeArea(
child: NavigationRail(
extended: constraints.maxWidth >= 600,
destinations: [
NavigationRailDestination(
icon: Icon(Icons.home),
label: Text('Home'),
),
NavigationRailDestination(
icon: Icon(Icons.favorite),
label: Text('Favorites'),
),
],
selectedIndex: selectedIndex,
onDestinationSelected: (value) {
setState(() {
selectedIndex = value;
});
},
),
),
Expanded(
child: Container(
color: Theme.of(context).colorScheme.primaryContainer,
child: page,
),
),
],
),
);
},
);
}
}
class GeneratorPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var appState = context.watch<MyAppState>(); var appState = context.watch<MyAppState>();
...@@ -57,8 +119,7 @@ class MyHomePage extends StatelessWidget { ...@@ -57,8 +119,7 @@ class MyHomePage extends StatelessWidget {
icon = Icons.favorite_border; icon = Icons.favorite_border;
} }
return Scaffold( return Center(
body: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
...@@ -85,7 +146,6 @@ class MyHomePage extends StatelessWidget { ...@@ -85,7 +146,6 @@ class MyHomePage extends StatelessWidget {
), ),
], ],
), ),
),
); );
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment