基础组件库
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_data.dart 2.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'dart:convert' as convert;
  2. import 'package:flutter/material.dart';
  3. import 'package:provider/provider.dart';
  4. import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_container.dart';
  5. import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart';
  6. import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.dart';
  7. import 'package:zhiying_base_widget/widgets/mine/mine_data/model/mine_data_model.dart';
  8. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart';
  9. import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';
  10. import 'package:zhiying_comm/util/base_bloc.dart';
  11. import 'package:zhiying_comm/zhiying_comm.dart';
  12. class MineData extends StatefulWidget {
  13. final Map<String, dynamic> data;
  14. const MineData(this.data, {Key key}) : super(key: key);
  15. @override
  16. _MineDataState createState() => _MineDataState();
  17. }
  18. class _MineDataState extends State<MineData> {
  19. UserInfoModel _user;
  20. bool _isSketelon = true;
  21. @override
  22. Widget build(BuildContext context) {
  23. if (_isSketelon) {
  24. Provider.of<UserInfoNotifier>(context).getUserInfoModel().then((user) {
  25. setState(() {
  26. _user = user;
  27. _isSketelon = false;
  28. });
  29. });
  30. }
  31. if (_isSketelon) {
  32. return MineDataSkeleton();
  33. }
  34. if (_user == null) {
  35. String value = '123';
  36. int result = int.tryParse(value);
  37. // 未登录
  38. String d = widget.data['data'];
  39. Map json = convert.jsonDecode(d);
  40. MineDataModel style =
  41. MineDataModel.fromJson(Map<String, dynamic>.from(json));
  42. List<MineProfileDataModel> list = style.gridView.map((item) {
  43. return MineProfileDataModel(name: item.name, value: '¥0');
  44. }).toList();
  45. MineProfileModel profile = MineProfileModel(
  46. username:'',
  47. avatar:'',
  48. inviteCode:'',
  49. userLvName:'',
  50. userLvIcon:'',
  51. total:'',
  52. gridViews:list,
  53. );
  54. return MineDataWidget(profile, widget.data);
  55. }
  56. return BlocProvider<MineHeaderBloc>(
  57. bloc: MineHeaderBloc(),
  58. child: MineDataContainer(widget.data),
  59. );
  60. }
  61. }