基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

250 lines
8.9 KiB

  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:tab_indicator_styler/tab_indicator_styler.dart';
  4. import 'package:zhiying_base_widget/widgets/team/data/team_data_widet.dart';
  5. import 'package:zhiying_base_widget/widgets/team/recommend/team_recommend_widget.dart';
  6. import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart';
  7. import 'package:zhiying_comm/zhiying_comm.dart';
  8. import 'dart:ui';
  9. ///
  10. /// 我的团队
  11. ///
  12. class TeamPage extends StatefulWidget {
  13. @override
  14. _TeamPageState createState() => _TeamPageState();
  15. }
  16. class _TeamPageState extends State<TeamPage> {
  17. @override
  18. Widget build(BuildContext context) {
  19. return _getMainWidget();
  20. }
  21. var tabTitle = [
  22. '全部会员',
  23. '青铜会员',
  24. '白银会员',
  25. '黄金会员',
  26. ];
  27. TabController _controller;
  28. @override
  29. void initState() {
  30. _controller = TabController(length: tabTitle.length, vsync: ScrollableState());
  31. super.initState();
  32. }
  33. @override
  34. void dispose() {
  35. _controller?.dispose();
  36. super.dispose();
  37. }
  38. /// 主体视图
  39. Widget _getMainWidget() {
  40. return Scaffold(
  41. backgroundColor: HexColor.fromHex('#F9F9F9'),
  42. body: NestedScrollView(
  43. headerSliverBuilder: (context, bool) {
  44. return [
  45. /// 头部Bar
  46. SliverAppBar(
  47. // expandedHeight: 200.0,
  48. leading: IconButton(
  49. icon: Icon(
  50. Icons.arrow_back_ios,
  51. size: 22,
  52. color: HexColor.fromHex('#333333'),
  53. ),
  54. onPressed: () => Navigator.maybePop(context),
  55. ),
  56. backgroundColor: Colors.white,
  57. floating: true,
  58. pinned: true,
  59. title: Text(
  60. '我的团队',
  61. style: TextStyle(color: HexColor.fromHex('#333333'), fontWeight: FontWeight.bold, fontSize: 18),
  62. ),
  63. centerTitle: true,
  64. elevation: 0,
  65. ),
  66. /// 我的推荐人
  67. SliverToBoxAdapter(
  68. child: TeamRecommendWidget(),
  69. ),
  70. /// 数据
  71. SliverToBoxAdapter(
  72. child: TeamDataWidget(),
  73. ),
  74. SliverToBoxAdapter(child: SizedBox(height: 8)),
  75. /// 输入框
  76. SliverPersistentHeader(
  77. delegate: CustomSliverPersistentHeaderDelegate(
  78. min: 34,
  79. max: 34,
  80. child: Container(
  81. width: double.infinity,
  82. height: double.infinity,
  83. padding: const EdgeInsets.only(top: 10, left: 12.5, right: 12.5),
  84. color: Colors.white,
  85. child: Row(
  86. children: <Widget>[
  87. /// 输入框
  88. Expanded(
  89. child: Container(
  90. height: 24,
  91. decoration: BoxDecoration(
  92. borderRadius: BorderRadius.circular(30),
  93. color: HexColor.fromHex('#F7F7F7'),
  94. ),
  95. padding: const EdgeInsets.only(top: 5, bottom: 4.5, left: 7.5, right: 7.5),
  96. width: double.infinity,
  97. child: Row(
  98. children: <Widget>[
  99. Container(width: 11.5, height: 11.5, color: Colors.red,),
  100. Expanded(child: Container(
  101. color: Colors.transparent,
  102. child: TextField(
  103. style: TextStyle(fontSize: 11 , color: HexColor.fromHex('#000000'), textBaseline: TextBaseline.alphabetic),
  104. decoration: InputDecoration(
  105. focusedBorder: InputBorder.none,
  106. border: InputBorder.none,
  107. focusedErrorBorder: InputBorder.none,
  108. errorBorder: InputBorder.none,
  109. disabledBorder: InputBorder.none,
  110. enabledBorder: InputBorder.none,
  111. filled: true,
  112. isDense: true,
  113. contentPadding: const EdgeInsets.only(left: 6, bottom: 0, top: 0, right: 0),
  114. fillColor: Colors.transparent,
  115. hintStyle: TextStyle(fontSize: 11 , color: HexColor.fromHex('#999999'), textBaseline: TextBaseline.alphabetic),
  116. hintText: '输入需搜索的手机号/昵称',
  117. ),
  118. ),
  119. ),),
  120. Container(width: 15, height: 15, color: Colors.red,)
  121. ],
  122. ),
  123. ),
  124. ),
  125. const SizedBox(width: 8),
  126. /// 确定按钮
  127. Container(
  128. decoration: BoxDecoration(borderRadius: BorderRadius.circular(30), color: HexColor.fromHex('#FF4242')),
  129. padding: const EdgeInsets.only(left: 15, right: 15, bottom: 6.5, top: 6.5),
  130. child: Text('搜索', style: TextStyle(color: HexColor.fromHex('#FFFFFF'), fontSize: 11),),
  131. )
  132. ],
  133. ),
  134. ),
  135. ),
  136. pinned: true,
  137. ),
  138. /// 悬停TabBar
  139. SliverPersistentHeader(
  140. delegate: new _SliverTabBarDelegate(
  141. TabBar(
  142. isScrollable: false,
  143. labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
  144. unselectedLabelStyle: TextStyle(fontSize: 13),
  145. indicator: MaterialIndicator(
  146. height: 2,
  147. topLeftRadius: 8,
  148. topRightRadius: 8,
  149. bottomLeftRadius: 8,
  150. bottomRightRadius: 8,
  151. color: HexColor.fromHex('#F94B47'),
  152. horizontalPadding: 30,
  153. ),
  154. controller: _controller,
  155. tabs: tabTitle.map((f) => Tab(text: f)).toList(),
  156. indicatorColor: Colors.red,
  157. unselectedLabelColor: HexColor.fromHex('#999999'),
  158. labelColor: HexColor.fromHex('#000000'),
  159. ),
  160. ),
  161. pinned: true,
  162. ),
  163. /// 筛选条件
  164. SliverPersistentHeader(
  165. delegate: CustomSliverPersistentHeaderDelegate(
  166. max: 32.5,
  167. min: 32.5,
  168. child: Container(
  169. height: double.infinity,
  170. width: double.infinity,
  171. color: HexColor.fromHex('#FFFFFF'),
  172. child: Row(
  173. mainAxisAlignment: MainAxisAlignment.spaceAround,
  174. children: <Widget>[
  175. Text('邀请人数', style: TextStyle(fontSize: 12, color: HexColor.fromHex('#999999')),),
  176. Text('邀请人数', style: TextStyle(fontSize: 12, color: HexColor.fromHex('#999999')),),
  177. Text('邀请人数', style: TextStyle(fontSize: 12, color: HexColor.fromHex('#999999')),),
  178. Text('邀请人数', style: TextStyle(fontSize: 12, color: HexColor.fromHex('#999999')),),
  179. ],
  180. ),
  181. )),
  182. pinned: true,
  183. ),
  184. ];
  185. },
  186. body: MediaQuery.removePadding(
  187. removeTop: true,
  188. context: context,
  189. child: TabBarView(
  190. controller: _controller,
  191. children: tabTitle
  192. .map((s) => ListView.builder(
  193. itemBuilder: (context, int) => Text("123"),
  194. itemCount: 100,
  195. ))
  196. .toList(),
  197. ),
  198. ),
  199. ),
  200. );
  201. }
  202. }
  203. class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate {
  204. final TabBar widget;
  205. const _SliverTabBarDelegate(this.widget) : assert(widget != null);
  206. @override
  207. Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
  208. return Container(
  209. color: Colors.white,
  210. child: Row(
  211. children: <Widget>[
  212. const SizedBox(width: 30),
  213. Expanded(
  214. child: this.widget,
  215. ),
  216. const SizedBox(width: 30),
  217. ],
  218. ),
  219. );
  220. }
  221. @override
  222. bool shouldRebuild(_SliverTabBarDelegate oldDelegate) {
  223. return false;
  224. }
  225. @override
  226. double get maxExtent => widget.preferredSize.height;
  227. @override
  228. double get minExtent => widget.preferredSize.height;
  229. }