基础组件库
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.
 
 
 
 
 

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