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

48 lines
1.4 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. Widget build(BuildContext context) {
  21. if (_isSketelon) {
  22. Provider.of<UserInfoNotifier>(context).getUserInfoModel().then((user) {
  23. setState(() {
  24. _user = user;
  25. _isSketelon = false;
  26. });
  27. });
  28. }
  29. if (_isSketelon) {
  30. return MineHeaderSkeleton();
  31. }
  32. if (_user == null) {
  33. // 未登录
  34. return MineStaticContainer(widget.data);
  35. }
  36. return BlocProvider<MineHeaderBloc>(
  37. bloc: MineHeaderBloc(),
  38. child: MineHeaderContainer(widget.data),
  39. );
  40. }
  41. }