Add complete impl from codelabs github

master
Ibraheem Saleh 2 years ago
parent b094e8839f
commit 3ee73c301a

@ -43,7 +43,6 @@ class MyAppState extends ChangeNotifier {
} }
notifyListeners(); notifyListeners();
} }
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
@ -63,14 +62,16 @@ class _MyHomePageState extends State<MyHomePage> {
case 1: case 1:
page = FavoritesPage(); page = FavoritesPage();
default: default:
throw UnimplementedError('Unknown index: $selectedIndex'); throw UnimplementedError('no widget for $selectedIndex');
} }
return LayoutBuilder(builder: (context, constraints) {
return Scaffold( return Scaffold(
body: Row( body: Row(
children: [ children: [
SafeArea( SafeArea(
child: NavigationRail( child: NavigationRail(
extended: false, extended: constraints.maxWidth >= 600,
destinations: [ destinations: [
NavigationRailDestination( NavigationRailDestination(
icon: Icon(Icons.home), icon: Icon(Icons.home),
@ -98,6 +99,7 @@ class _MyHomePageState extends State<MyHomePage> {
], ],
), ),
); );
});
} }
} }
@ -145,7 +147,34 @@ class GeneratorPage extends StatelessWidget {
} }
} }
class BigCard extends StatelessWidget {
const BigCard({
super.key,
required this.pair,
});
final WordPair pair;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final style = theme.textTheme.displayMedium!.copyWith(
color: theme.colorScheme.onPrimary,
);
return Card(
color: theme.colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(20),
child: Text(
pair.asLowerCase,
style: style,
semanticsLabel: "${pair.first} ${pair.second}",
),
),
);
}
}
class FavoritesPage extends StatelessWidget { class FavoritesPage extends StatelessWidget {
@override @override
@ -174,34 +203,3 @@ class FavoritesPage extends StatelessWidget {
); );
} }
} }
class BigCard extends StatelessWidget {
const BigCard({
super.key,
required this.pair,
});
final WordPair pair;
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var style = theme.textTheme.displayMedium!.copyWith(
color: theme.colorScheme.onPrimary,
);
return Card(
color: theme.colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(20),
child: Text(
pair.asLowerCase,
style: style,
semanticsLabel: pair.asPascalCase,
),
),
);
}
}

Loading…
Cancel
Save