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

62 lines
1.8 KiB

  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:provider/provider.dart';
  4. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart';
  5. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_container.dart';
  6. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_sk.dart';
  7. import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_static_container.dart';
  8. import 'package:zhiying_comm/util/base_bloc.dart';
  9. import 'package:zhiying_comm/zhiying_comm.dart';
  10. class MineHeader extends StatefulWidget {
  11. final Map<String, dynamic> data;
  12. const MineHeader(this.data, {Key key}) : super(key: key);
  13. @override
  14. _MineHeaderState createState() => _MineHeaderState();
  15. }
  16. class _MineHeaderState extends State<MineHeader> {
  17. UserInfoModel _user;
  18. bool _isSketelon = true;
  19. @override
  20. void initState() {
  21. super.initState();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. // return Consumer<UserInfoNotifier>(builder: (context, user, child) {
  26. // print('user ${user.toString()}');
  27. // if (user == null) {
  28. // return MineStaticContainer(widget.data);
  29. // }
  30. // return BlocProvider<MineHeaderBloc>(
  31. // bloc: MineHeaderBloc(),
  32. // child: MineHeaderContainer(widget.data),
  33. // );
  34. // });
  35. if (_isSketelon) {
  36. Provider.of<UserInfoNotifier>(context).getUserInfoModel().then((user) {
  37. setState(() {
  38. _user = user;
  39. _isSketelon = false;
  40. });
  41. });
  42. }
  43. if (_isSketelon) {
  44. return MineHeaderSkeleton();
  45. }
  46. if (_user == null) {
  47. return MineStaticContainer(widget.data);
  48. }
  49. return BlocProvider<MineHeaderBloc>(
  50. bloc: MineHeaderBloc(),
  51. child: MineHeaderContainer(widget.data),
  52. );
  53. }
  54. }