Skip to content

Commit

Permalink
Add menu toggle to HeroPage
Browse files Browse the repository at this point in the history
  • Loading branch information
bizz84 committed Jun 4, 2018
1 parent 3c7481b commit e8d6ae6
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions lib/pages/hero_page.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:flutter/material.dart';
import 'package:layout_demo_flutter/layout_type.dart';
import 'package:layout_demo_flutter/pages/list_page.dart';
import 'package:layout_demo_flutter/pages/main_app_bar.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/foundation.dart';

class HeroHeader implements SliverPersistentHeaderDelegate {
HeroHeader({this.minExtent, this.maxExtent});
HeroHeader({this.layoutGroup, this.onLayoutToggle, this.minExtent, this.maxExtent});
final LayoutGroup layoutGroup;
final VoidCallback onLayoutToggle;
double maxExtent;
double minExtent;

Expand All @@ -25,12 +26,24 @@ class HeroHeader implements SliverPersistentHeaderDelegate {
Colors.lightGreen,
],
stops: [0.0, 0.5, 1.0],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
tileMode: TileMode.repeated,
),
),
),
Positioned(
left: 4.0,
top: 4.0,
child: SafeArea(
child: IconButton(
icon: Icon(layoutGroup == LayoutGroup.nonScrollable
? Icons.filter_1
: Icons.filter_2),
onPressed: onLayoutToggle,
),
),
),
Positioned(
left: 16.0,
right: 16.0,
Expand Down Expand Up @@ -70,11 +83,13 @@ class HeroPage extends StatelessWidget implements HasLayoutGroup {
SliverPersistentHeader(
pinned: true,
delegate: HeroHeader(
minExtent: 100.0,
layoutGroup: layoutGroup,
onLayoutToggle: onLayoutToggle,
minExtent: 150.0,
maxExtent: 200.0,
),
),
new SliverList(
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
Contact contact = allContacts[index];
Expand Down

0 comments on commit e8d6ae6

Please sign in to comment.