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

mine_header.dart 2.7 KiB

4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import 'dart:convert' as convert;
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart';
  6. import 'package:zhiying_comm/zhiying_comm.dart';
  7. class MineHeader extends StatefulWidget {
  8. final Map<String, dynamic> data;
  9. const MineHeader(this.data, {Key key}) : super(key: key);
  10. @override
  11. _MineHeaderState createState() => _MineHeaderState();
  12. }
  13. class _MineHeaderState extends State<MineHeader> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return _MineContainer(widget.data);
  17. }
  18. }
  19. class _MineContainer extends StatefulWidget {
  20. final Map<String, dynamic> data;
  21. Map<String, dynamic> json;
  22. MineHeaderModel staticModel;
  23. _MineContainer(this.data, {Key key}) : super(key: key) {
  24. String d = data['data'];
  25. json = convert.jsonDecode(d);
  26. staticModel = MineHeaderModel.fromJson(json);
  27. }
  28. @override
  29. _MineContainerState createState() => _MineContainerState();
  30. }
  31. class _MineContainerState extends State<_MineContainer> {
  32. @override
  33. Widget build(BuildContext context) {
  34. return Container(
  35. child: Row(
  36. children: <Widget>[
  37. GestureDetector(
  38. child: Container(
  39. margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12),
  40. width: 56,
  41. height: 56,
  42. child: ClipRRect(
  43. borderRadius: BorderRadius.circular(28),
  44. child: CachedNetworkImage(
  45. imageUrl: widget.staticModel.defaultAvatar,
  46. fit: BoxFit.cover)),
  47. ),
  48. onTap: () {
  49. RouterUtil.route(widget.json, context);
  50. },
  51. ),
  52. Expanded(
  53. child: Column(
  54. mainAxisAlignment: MainAxisAlignment.start,
  55. crossAxisAlignment: CrossAxisAlignment.start,
  56. children: <Widget>[
  57. Container(
  58. width: 120,
  59. height: 20,
  60. child: Text(
  61. widget.staticModel.loginName,
  62. style: TextStyle(
  63. color: HexColor.fromHex(widget.staticModel.loginColor),
  64. fontSize: 17),
  65. ),
  66. ),
  67. Container(
  68. margin: EdgeInsets.only(top: 8),
  69. width: 80,
  70. child: Text(
  71. widget.staticModel.loginNameHelpText,
  72. style: TextStyle(
  73. color: HexColor.fromHex(widget.staticModel.loginColor),
  74. fontSize: 13),
  75. )),
  76. ],
  77. ))
  78. ],
  79. ),
  80. );
  81. }
  82. }