Skip to content

Commit

Permalink
feat: add example banner
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGong2013 committed Nov 27, 2020
1 parent b80cb85 commit 605766c
Showing 1 changed file with 80 additions and 41 deletions.
121 changes: 80 additions & 41 deletions example/lib/src/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,51 +52,90 @@ class _HomePageState extends State<HomePage> {
backgroundColor: CupertinoColors.secondarySystemBackground,
child: CustomScrollView(
physics: AlwaysScrollableScrollPhysics(),
slivers: [
CupertinoSliverNavigationBar(
backgroundColor: CupertinoColors.white,
border: null,
largeTitle: Text('Faraday功能演示'),
),
SliverToBoxAdapter(
child: Container(
height: 100,
color: CupertinoColors.white,
slivers: _buildSlivers(context),
),
),
),
);
}

List<Widget> _buildSlivers(BuildContext context) {
return [
CupertinoSliverNavigationBar(
backgroundColor: CupertinoColors.white,
border: null,
largeTitle: Text('Faraday功能演示'),
),
SliverPersistentHeader(
delegate: HomePageBannerDelegate(),
floating: false,
pinned: false,
),
SliverToBoxAdapter(child: Basic()),
SliverToBoxAdapter(child: Splash()),
SliverToBoxAdapter(child: GlobalNotification()),
SliverToBoxAdapter(child: Others()),
SliverToBoxAdapter(
child: Section(
title: '高级功能(Advance)',
subTitle: '以下是隐藏内容,请查看源码',
//
// 有什么你想要的功能没有看到,可以在 github 提 issue 我们会尽快加上哦
//
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Transform.scale(
scale: 0.6,
child: Image.asset('images/faraday.png'),
),
),
SliverToBoxAdapter(child: Basic()),
SliverToBoxAdapter(child: Splash()),
SliverToBoxAdapter(child: GlobalNotification()),
SliverToBoxAdapter(child: Others()),
SliverToBoxAdapter(
child: Section(
title: '高级功能(Advance)',
subTitle: '以下是隐藏内容,请查看源码',
//
// 有什么你想要的功能没有看到,可以在 github 提 issue 我们会尽快加上哦
//
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Transform.scale(
scale: 0.6,
child: Image.asset('images/faraday.png'),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Faraday',
style: TextStyle(color: CupertinoColors.secondaryLabel),
),
)
],
)),
)),
],
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Faraday',
style: TextStyle(color: CupertinoColors.secondaryLabel),
),
)
],
),
),
),
),
];
}
}

class HomePageBannerDelegate extends SliverPersistentHeaderDelegate {
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return AnimatedContainer(
padding: EdgeInsets.all(16),
duration: Duration(microseconds: 100),
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('* 右上角有绿色角标的均为 Flutter 页面'),
Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Text('* 所有功能在 iOS/Android 均可用'),
),
Text('* 钉钉群号:35138694 🚀'),
],
),
);
}

@override
double get maxExtent => 110;

@override
double get minExtent => 110;

@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
return false;
}
}

0 comments on commit 605766c

Please sign in to comment.