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

69 lines
2.0 KiB

  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. MineProfileModel profile = MineProfileModel(
  43. '',
  44. '',
  45. '',
  46. '',
  47. '',
  48. '¥0',
  49. style.datas.map((item) {
  50. return MineProfileDataModel(item.name, '¥0');
  51. }).toList(),
  52. );
  53. return MineDataWidget(profile, widget.data);
  54. }
  55. return BlocProvider<MineHeaderBloc>(
  56. bloc: MineHeaderBloc(),
  57. child: MineDataContainer(widget.data),
  58. );
  59. }
  60. }