基础组件库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

mine_page.dart 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:zhiying_base_widget/pages/main_page/main_page.dart';
  4. class MinePage extends StatefulWidget {
  5. @override
  6. _MinePageState createState() => _MinePageState();
  7. }
  8. class _MinePageState extends State<MinePage> with TickerProviderStateMixin {
  9. TabController _tabController;
  10. Map<String, dynamic> _datas = Map();
  11. @override
  12. void initState() {
  13. _tabController = TabController(length: 3, vsync: this);
  14. // 模拟数据
  15. List<Map<String, dynamic>> list = List();
  16. list.add(
  17. Map<String, dynamic>.from({'mod_name': 'index_search', 'mod_id': 5}));
  18. list.add(
  19. Map<String, dynamic>.from({'mod_name': 'index_carousel', 'mod_id': 6}));
  20. list.add(Map<String, dynamic>.from({'mod_name': 'multi_nav', 'mod_id': 7}));
  21. list.add(Map<String, dynamic>.from(
  22. {'mod_name': 'index_banner_one', 'mod_id': 8}));
  23. list.add(Map<String, dynamic>.from(
  24. {'mod_name': 'index_banner_two', 'mod_id': 9}));
  25. list.add(Map<String, dynamic>.from(
  26. {'mod_name': 'index_recommend_list', 'mod_id': 10}));
  27. _datas['components'] = list;
  28. super.initState();
  29. }
  30. @override
  31. void dispose() {
  32. _tabController.dispose();
  33. super.dispose();
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. List<Widget> _silverBuilder(BuildContext context, bool innerBoxIsScrolled) {
  38. return <Widget>[
  39. SliverAppBar(),
  40. SliverPersistentHeader(
  41. pinned: true,
  42. delegate: _SilverAppBarDelegate(
  43. Container(
  44. color: Colors.amber,
  45. child: TabBar(
  46. labelColor: Colors.blue,
  47. unselectedLabelColor: Colors.black,
  48. controller: _tabController,
  49. tabs: <Widget>[
  50. new Tab(
  51. text: "tab10",
  52. ),
  53. new Tab(
  54. text: "tab2",
  55. ),
  56. new Tab(
  57. text: "tab3",
  58. ),
  59. ],
  60. ),
  61. ),
  62. ),
  63. ),
  64. ];
  65. }
  66. return Scaffold(
  67. body: SafeArea(
  68. child: NestedScrollView(
  69. headerSliverBuilder: _silverBuilder,
  70. body: TabBarView(
  71. controller: _tabController,
  72. children: <Widget>[
  73. MainPage(_datas),
  74. ListView.builder(
  75. itemCount: 50,
  76. itemBuilder: (context, count) {
  77. return Container(
  78. height: 50,
  79. color: Colors.primaries[count % Colors.primaries.length],
  80. child: Text('aaaaa ${count.toString()}'),
  81. );
  82. }),
  83. MainPage(_datas),
  84. ],
  85. ),
  86. )),
  87. );
  88. }
  89. }
  90. class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate {
  91. _SilverAppBarDelegate(this.child);
  92. final Widget child;
  93. @override
  94. double get minExtent => 44;
  95. @override
  96. double get maxExtent => 44;
  97. @override
  98. Widget build(
  99. BuildContext context, double shrinkOffset, bool overlapsContent) {
  100. return new Container(
  101. child: child,
  102. );
  103. }
  104. @override
  105. bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
  106. return false;
  107. }
  108. }