Skip to content

Commit 2f1eff3

Browse files
committed
example: reference for #73
1 parent 9e11511 commit 2f1eff3

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import 'package:backdrop/backdrop.dart';
2+
import 'package:flutter/material.dart';
3+
4+
void main() => runApp(MyApp());
5+
6+
class MyApp extends StatefulWidget {
7+
@override
8+
_MyAppState createState() => _MyAppState();
9+
}
10+
11+
class ShortOption extends StatelessWidget {
12+
final int index;
13+
14+
ShortOption(this.index);
15+
16+
@override
17+
Widget build(BuildContext context) => Center(
18+
child: Column(
19+
mainAxisSize: MainAxisSize.min,
20+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
21+
children: [
22+
Text("Page #$index is open with desired height."),
23+
const Flexible(child: FractionallySizedBox(heightFactor: 0.1)),
24+
Text("It looks better! 😄"),
25+
const Flexible(child: FractionallySizedBox(heightFactor: 0.1)),
26+
Text("But Page #0 still needs to be tall."),
27+
],
28+
));
29+
}
30+
31+
class TallOption extends StatelessWidget {
32+
@override
33+
Widget build(BuildContext context) => ListView(
34+
children: List.generate(
35+
20,
36+
(index) => Padding(
37+
padding: const EdgeInsets.all(16),
38+
child: Text("Tall page #0, lots of content 👍"))));
39+
}
40+
41+
class _MyAppState extends State<MyApp> {
42+
int _currentIndex = 0;
43+
44+
final List<Widget> _pages = [
45+
TallOption(),
46+
ShortOption(1),
47+
ShortOption(2),
48+
ShortOption(3),
49+
ShortOption(4),
50+
ShortOption(5),
51+
ShortOption(6),
52+
ShortOption(7),
53+
ShortOption(8),
54+
ShortOption(9),
55+
];
56+
57+
final _nav = List.generate(
58+
10,
59+
(i) => ListTile(
60+
title: Text('Menu: open page #$i',
61+
style: TextStyle(color: Colors.white))));
62+
63+
@override
64+
Widget build(BuildContext context) {
65+
return MaterialApp(
66+
title: 'Backdrop Demo',
67+
home: BackdropScaffold(
68+
appBar: BackdropAppBar(title: Text("AppBar is OK 👍")),
69+
frontLayer: _pages[_currentIndex],
70+
// headerHeight: 512,
71+
stickyFrontLayer: true,
72+
// subHeaderAlwaysActive: false,
73+
backLayerScrim: Colors.red.withOpacity(0.5),
74+
frontLayerScrim: Colors.green.withOpacity(0.5),
75+
frontLayerActiveFactor:
76+
_currentIndex == 0 ? 1 : (.1 * _currentIndex),
77+
subHeader: BackdropSubHeader(title: Text('Subheader')),
78+
backLayer: BackdropNavigationBackLayer(
79+
items: _nav,
80+
onTap: (int position) =>
81+
{setState(() => _currentIndex = position)},
82+
separatorBuilder: (_, __) =>
83+
Divider(indent: 16, endIndent: 16, color: Colors.white))));
84+
}
85+
}

0 commit comments

Comments
 (0)