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

87 lines
2.8 KiB

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