|
| 1 | +import 'package:adaptive_navigation/scaffold.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | + |
| 4 | +class DefaultScaffoldDemo extends StatefulWidget { |
| 5 | + @override |
| 6 | + _DefaultScaffoldDemoState createState() => _DefaultScaffoldDemoState(); |
| 7 | +} |
| 8 | + |
| 9 | +class _DefaultScaffoldDemoState extends State<DefaultScaffoldDemo> { |
| 10 | + int _destinationCount = 5; |
| 11 | + bool _fabInRail = false; |
| 12 | + |
| 13 | + @override |
| 14 | + Widget build(BuildContext context) { |
| 15 | + return AdaptiveNavigationScaffold( |
| 16 | + selectedIndex: 0, |
| 17 | + destinations: _allDestinations.sublist(0, _destinationCount), |
| 18 | + appBar: AppBar(title: Text('Default Demo')), |
| 19 | + body: _body(), |
| 20 | + floatingActionButton: FloatingActionButton( |
| 21 | + child: Icon(Icons.add), |
| 22 | + onPressed: () {}, |
| 23 | + ), |
| 24 | + fabInRail: _fabInRail, |
| 25 | + ); |
| 26 | + } |
| 27 | + |
| 28 | + Widget _body() { |
| 29 | + return Center( |
| 30 | + child: Column( |
| 31 | + mainAxisAlignment: MainAxisAlignment.center, |
| 32 | + children: [ |
| 33 | + const Text(''' |
| 34 | + This is the default behavior of the AdaptiveNavigationScaffold. |
| 35 | + It switches between bottom navigation, navigation rail, and a permanent drawer. |
| 36 | + Resize the window to switch between the navigation types. |
| 37 | + '''), |
| 38 | + const SizedBox(height: 40), |
| 39 | + Slider( |
| 40 | + min: 2, |
| 41 | + max: _allDestinations.length.toDouble(), |
| 42 | + divisions: _allDestinations.length - 2, |
| 43 | + value: _destinationCount.toDouble(), |
| 44 | + label: _destinationCount.toString(), |
| 45 | + onChanged: (value) { |
| 46 | + setState(() { |
| 47 | + _destinationCount = value.round(); |
| 48 | + }); |
| 49 | + }, |
| 50 | + ), |
| 51 | + const Text('Destination Count'), |
| 52 | + const SizedBox(height: 40), |
| 53 | + Switch( |
| 54 | + value: _fabInRail, |
| 55 | + onChanged: (value) { |
| 56 | + setState(() { |
| 57 | + _fabInRail = value; |
| 58 | + }); |
| 59 | + }, |
| 60 | + ), |
| 61 | + const Text('fabInRail'), |
| 62 | + const SizedBox(height: 40), |
| 63 | + RaisedButton( |
| 64 | + child: const Text('BACK'), |
| 65 | + onPressed: () { |
| 66 | + Navigator.of(context).pushReplacementNamed('/'); |
| 67 | + }, |
| 68 | + ) |
| 69 | + ], |
| 70 | + ), |
| 71 | + ); |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +const _allDestinations = [ |
| 76 | + AdaptiveScaffoldDestination(title: 'Alarm', icon: Icons.alarm), |
| 77 | + AdaptiveScaffoldDestination(title: 'Book', icon: Icons.book), |
| 78 | + AdaptiveScaffoldDestination(title: 'Cake', icon: Icons.cake), |
| 79 | + AdaptiveScaffoldDestination(title: 'Directions', icon: Icons.directions), |
| 80 | + AdaptiveScaffoldDestination(title: 'Email', icon: Icons.email), |
| 81 | + AdaptiveScaffoldDestination(title: 'Favorite', icon: Icons.favorite), |
| 82 | + AdaptiveScaffoldDestination(title: 'Group', icon: Icons.group), |
| 83 | + AdaptiveScaffoldDestination(title: 'Headset', icon: Icons.headset), |
| 84 | + AdaptiveScaffoldDestination(title: 'Info', icon: Icons.info), |
| 85 | +]; |
0 commit comments