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

home_auth.dart 3.2 KiB

pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import 'dart:convert' as convert;
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:provider/provider.dart';
  5. import 'package:zhiying_base_widget/widgets/home/home_auth/models/home_auth_model.dart';
  6. import 'package:zhiying_comm/zhiying_comm.dart';
  7. class HomeAuth extends StatelessWidget {
  8. final Map<String, dynamic> data;
  9. Map<String, dynamic> _json;
  10. HomeAuthModel _style;
  11. UserInfoModel _user;
  12. HomeAuth(this.data, {Key key}) : super(key: key) {
  13. String d = data['data'];
  14. _json = convert.jsonDecode(d);
  15. _style = HomeAuthModel.fromJson(Map<String, dynamic>.from(_json));
  16. }
  17. @override
  18. Widget build(BuildContext context) {
  19. _user = Provider.of<UserInfoNotifier>(context).userInfo;
  20. return Container(
  21. height: 34,
  22. width: double.infinity,
  23. margin: EdgeInsets.only(left: 12, right: 12, top: 4, bottom: 4),
  24. decoration: BoxDecoration(
  25. color: HexColor.fromHex(_style?.taoaboTipBgColor ?? 'ffffff'),
  26. borderRadius: BorderRadius.circular(17),
  27. boxShadow: [
  28. BoxShadow(
  29. offset: Offset(2, 1), //x,y轴
  30. color:
  31. HexColor.fromHex(_style?.taoaboTipShadowColor ?? '767676')
  32. .withAlpha(70), //投影颜色
  33. blurRadius: 5 //投影距离
  34. )
  35. ]),
  36. child: Row(
  37. children: <Widget>[
  38. Container(
  39. margin: EdgeInsets.only(left: 10, right: 8),
  40. width: 20,
  41. height: 20,
  42. child: CachedNetworkImage(
  43. imageUrl: _style.taobaoAuthIcon,
  44. fit: BoxFit.contain,
  45. ),
  46. ),
  47. Expanded(
  48. child: Text(
  49. _style?.taoaboTipText ?? '',
  50. maxLines: 1,
  51. style: TextStyle(
  52. fontSize: 12,
  53. fontWeight: FontWeight.bold,
  54. color: HexColor.fromHex(_style?.taoaboTipTextColor ?? '333333'),
  55. ),
  56. ),
  57. ),
  58. GestureDetector(
  59. child: Container(
  60. padding: EdgeInsets.only(left: 12, right: 12, top: 3, bottom: 3),
  61. margin: EdgeInsets.only(left: 8, right: 8),
  62. decoration: BoxDecoration(
  63. color:
  64. HexColor.fromHex(_style?.taoaboTipBtnBgColor ?? 'FF4242'),
  65. borderRadius: BorderRadius.circular(20)),
  66. child: Text(
  67. _style?.taoaboTipBtnText ?? '',
  68. style: TextStyle(
  69. fontSize: 12,
  70. color: HexColor.fromHex(
  71. _style?.taoaboTipBtnTextColor ?? 'ffffff'),
  72. ),
  73. ),
  74. ),
  75. onTap: () async {
  76. if (_user?.token == null || _user.token == '') {
  77. print('need login...');
  78. RouterUtil.goLogin(context);
  79. return;
  80. }
  81. bool isAuth = await TaobaoAuth.isAuth();
  82. if (!isAuth) {
  83. TaobaoAuth.auth(context);
  84. } else {
  85. Logger.debug('您已经授权过了');
  86. }
  87. },
  88. ),
  89. ],
  90. ),
  91. );
  92. }
  93. }