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

270 lines
8.1 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. ///
  4. /// 我的团队 - 我的推荐人
  5. ///
  6. class TeamRecommendWidget extends StatefulWidget {
  7. // final Map<String, dynamic> data;
  8. //
  9. // const TeamRecommendWidget(this.data);
  10. @override
  11. _TeamRecommendWidgetState createState() => _TeamRecommendWidgetState();
  12. }
  13. class _TeamRecommendWidgetState extends State<TeamRecommendWidget> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return Container(
  17. margin: const EdgeInsets.only(left: 12.5, right: 12.5, top: 10.5),
  18. child: _getMainWidget(),
  19. );
  20. }
  21. /// 按钮点击事件
  22. void _onClickListener() {}
  23. /// 主体Widget
  24. Widget _getMainWidget() {
  25. return Container(
  26. padding: const EdgeInsets.only(left: 10, bottom: 12, right: 10),
  27. decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.white),
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: <Widget>[
  31. /// 左上角的Icon
  32. _getLeftTopWidget(),
  33. const SizedBox(height: 6),
  34. /// 数据视图
  35. Visibility(
  36. visible: true,
  37. replacement: _getInputCombWidget(),
  38. child: Padding(padding: const EdgeInsets.only(left: 10), child: _getDataWidget())),
  39. ],
  40. ),
  41. );
  42. }
  43. /// 我的推荐人IconWidget(左上角的ICON)
  44. Widget _getLeftTopWidget() {
  45. return Transform.translate(offset: Offset(0, -4.5), child: Container(width: 80, height: 28, color: Colors.red));
  46. }
  47. /// 没邀请人的Widget
  48. Widget _getInputCombWidget() {
  49. return Container(
  50. margin: const EdgeInsets.only(left: 2.5, right: 2.5),
  51. width: double.infinity,
  52. child: Column(
  53. mainAxisAlignment: MainAxisAlignment.center,
  54. // crossAxisAlignment: CrossAxisAlignment.center,
  55. children: <Widget>[
  56. /// 输入框
  57. Container(
  58. height: 30,
  59. width: double.infinity,
  60. decoration: BoxDecoration(
  61. borderRadius: BorderRadius.circular(30),
  62. color: HexColor.fromHex('#F7F7F7'),
  63. ),
  64. padding: const EdgeInsets.only(top: 3.5, bottom: 3.5, right: 3, left: 13),
  65. child: Row(
  66. children: <Widget>[
  67. Expanded(
  68. child: _getInputWidget(),
  69. ),
  70. /// 添加的按钮
  71. _getAddButtomWidget(),
  72. ],
  73. ),
  74. ),
  75. const SizedBox(height: 10.5),
  76. /// 文字提示
  77. Text('还没有填写邀请人ID,填写后双方都可以获得奖励', style: TextStyle(color: HexColor.fromHex('#909090'), fontSize: 11)),
  78. ],
  79. ),
  80. );
  81. }
  82. /// 输入框的
  83. Widget _getInputWidget(){
  84. return TextField(
  85. style:TextStyle(color: HexColor.fromHex('#000000'), fontSize: 12, textBaseline: TextBaseline.alphabetic),
  86. decoration: InputDecoration(
  87. border: InputBorder.none,
  88. enabledBorder: InputBorder.none,
  89. disabledBorder: InputBorder.none,
  90. errorBorder: InputBorder.none,
  91. focusedErrorBorder: InputBorder.none,
  92. focusedBorder: InputBorder.none,
  93. hintText: '输入邀请人ID',
  94. isDense: true,
  95. filled: true,
  96. fillColor: Colors.transparent,
  97. contentPadding: EdgeInsets.zero,
  98. hintStyle: TextStyle(color: HexColor.fromHex('#909090'), fontSize: 12, textBaseline: TextBaseline.alphabetic),
  99. ),
  100. );
  101. }
  102. /// 添加的按钮
  103. Widget _getAddButtomWidget() {
  104. // return Material(
  105. // child: Container(
  106. // height: 24,
  107. // color: Colors.white,
  108. // child: RaisedButton(
  109. // padding: EdgeInsets.zero,
  110. // child: Text('添加', style: TextStyle(fontSize: 13)),
  111. // textColor: HexColor.fromHex('#FFFFFF'),
  112. // color: HexColor.fromHex('#F94B47'),
  113. // disabledColor: HexColor.fromHex('#F94B47'),
  114. // disabledTextColor: HexColor.fromHex('#FFFFFF'),
  115. // elevation: 5,
  116. // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24 / 2)),
  117. // onPressed: () => _onClickListener(),
  118. // ),
  119. // ),
  120. // );
  121. return Material(
  122. child: InkWell(
  123. onTap: (){},
  124. child: Container(
  125. padding: const EdgeInsets.only(left: 21, right: 21, top: 2.5, bottom: 2.5),
  126. decoration: BoxDecoration(
  127. borderRadius: BorderRadius.circular(30),
  128. color: HexColor.fromHex('#F94B47')
  129. ),
  130. child: Text('添加', style: TextStyle(fontSize: 13, color: HexColor.fromHex('#FFFFFF'))),
  131. ),
  132. ),
  133. );
  134. }
  135. /// 数据视图
  136. Widget _getDataWidget() {
  137. return Row(
  138. mainAxisAlignment: MainAxisAlignment.start,
  139. children: <Widget>[
  140. /// 头像widget
  141. _getAvatarWidget(),
  142. const SizedBox(width: 12),
  143. /// 数据
  144. _getDataRightWidget(),
  145. ],
  146. );
  147. }
  148. /// 头像widget
  149. Widget _getAvatarWidget() {
  150. return Container(
  151. width: 55,
  152. height: 55,
  153. color: Colors.red,
  154. );
  155. }
  156. /// 数据右边视图,头像右边的widget
  157. Widget _getDataRightWidget() {
  158. return SizedBox(
  159. height: 55,
  160. child: Column(
  161. crossAxisAlignment: CrossAxisAlignment.start,
  162. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  163. children: <Widget>[
  164. /// 昵称
  165. _getNickNameWidget(),
  166. /// 手机号
  167. _getPhoneNumberWidget(),
  168. /// 微信号
  169. _getWXWidget()
  170. ],
  171. ),
  172. );
  173. }
  174. /// 昵称
  175. Widget _getNickNameWidget() {
  176. // return RichText(
  177. // text: TextSpan(text: '毛毛虫', style: TextStyle(fontSize: 14, color: HexColor.fromHex('#000000'), fontWeight: FontWeight.bold),
  178. // children: [
  179. // TextSpan(text: '邀请码:', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#909090'), fontWeight: FontWeight.w400)),
  180. // TextSpan(text: '123456', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#909090'), fontWeight: FontWeight.w400)),
  181. // ]
  182. // ),
  183. // );
  184. return Row(
  185. mainAxisAlignment: MainAxisAlignment.start,
  186. crossAxisAlignment: CrossAxisAlignment.center,
  187. children: <Widget>[
  188. /// 昵称
  189. Text('毛毛虫', style: TextStyle(fontSize: 14, color: HexColor.fromHex('#000000'), fontWeight: FontWeight.bold)),
  190. const SizedBox(width: 6),
  191. Text('邀请码:', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#909090'))),
  192. Text('123456', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#909090'), fontFamily: 'Din', package: 'zhiying_base_widget')),
  193. ],
  194. );
  195. }
  196. /// 手机号
  197. Widget _getPhoneNumberWidget() {
  198. return Row(
  199. children: <Widget>[
  200. Text('手机号:', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#AFAFAF'))),
  201. Text('12354678910', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#AFAFAF'), fontFamily: 'Din', package: 'zhiying_base_widget')),
  202. const SizedBox(width: 6),
  203. /// 拷贝按钮
  204. _getCustomCopyWidget(),
  205. ],
  206. );
  207. }
  208. /// 微信号
  209. Widget _getWXWidget() {
  210. return Row(
  211. children: <Widget>[
  212. Text('微信号:', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#AFAFAF'))),
  213. Text('12354678910', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#AFAFAF'), fontFamily: 'Din', package: 'zhiying_base_widget')),
  214. const SizedBox(width: 6),
  215. /// 拷贝按钮
  216. _getCustomCopyWidget(),
  217. ],
  218. );
  219. }
  220. /// 自定义复制按钮的Widget
  221. Widget _getCustomCopyWidget() {
  222. return Container(
  223. padding: const EdgeInsets.only(left: 4, bottom: 2, top: 2, right: 6),
  224. decoration: BoxDecoration(
  225. color: HexColor.fromHex('#FFF2F2'),
  226. borderRadius: BorderRadius.circular(30),
  227. ),
  228. child: Row(
  229. crossAxisAlignment: CrossAxisAlignment.center,
  230. children: <Widget>[
  231. Container(width: 11, height: 11, color: Colors.red),
  232. const SizedBox(width: 4.5),
  233. Text('复制', style: TextStyle(fontSize: 8, color: HexColor.fromHex('#F94B47')))
  234. ],
  235. ),
  236. );
  237. }
  238. }