|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:zhiying_base_widget/pages/main_page/main_page.dart';
-
- class MinePage extends StatefulWidget {
- @override
- _MinePageState createState() => _MinePageState();
- }
-
- class _MinePageState extends State<MinePage> with TickerProviderStateMixin {
- TabController _tabController;
- Map<String, dynamic> _datas = Map();
-
- @override
- void initState() {
- _tabController = TabController(length: 3, vsync: this);
- // 模拟数据
- List<Map<String, dynamic>> list = List();
- list.add(
- Map<String, dynamic>.from({'mod_name': 'index_search', 'mod_id': 5}));
- list.add(
- Map<String, dynamic>.from({'mod_name': 'index_carousel', 'mod_id': 6}));
- list.add(Map<String, dynamic>.from({'mod_name': 'multi_nav', 'mod_id': 7}));
- list.add(Map<String, dynamic>.from(
- {'mod_name': 'index_banner_one', 'mod_id': 8}));
- list.add(Map<String, dynamic>.from(
- {'mod_name': 'index_banner_two', 'mod_id': 9}));
- list.add(Map<String, dynamic>.from(
- {'mod_name': 'index_recommend_list', 'mod_id': 10}));
- _datas['components'] = list;
- super.initState();
- }
-
- @override
- void dispose() {
- _tabController.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- List<Widget> _silverBuilder(BuildContext context, bool innerBoxIsScrolled) {
- return <Widget>[
- SliverAppBar(),
- SliverPersistentHeader(
- pinned: true,
- delegate: _SilverAppBarDelegate(
- Container(
- color: Colors.amber,
- child: TabBar(
- labelColor: Colors.blue,
- unselectedLabelColor: Colors.black,
- controller: _tabController,
- tabs: <Widget>[
- new Tab(
- text: "tab10",
- ),
- new Tab(
- text: "tab2",
- ),
- new Tab(
- text: "tab3",
- ),
- ],
- ),
- ),
- ),
- ),
- ];
- }
-
- return Scaffold(
- body: SafeArea(
- child: NestedScrollView(
- headerSliverBuilder: _silverBuilder,
- body: TabBarView(
- controller: _tabController,
- children: <Widget>[
- MainPage(_datas),
- ListView.builder(
- itemCount: 50,
- itemBuilder: (context, count) {
- return Container(
- height: 50,
- color: Colors.primaries[count % Colors.primaries.length],
- child: Text('aaaaa ${count.toString()}'),
- );
- }),
- MainPage(_datas),
- ],
- ),
- )),
- );
- }
- }
-
- class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate {
- _SilverAppBarDelegate(this.child);
-
- final Widget child;
-
- @override
- double get minExtent => 44;
-
- @override
- double get maxExtent => 44;
-
- @override
- Widget build(
- BuildContext context, double shrinkOffset, bool overlapsContent) {
- return new Container(
- child: child,
- );
- }
-
- @override
- bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
- return false;
- }
- }
|