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

58 lines
1.7 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart';
  3. import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.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/model/mine_profile_model.dart';
  6. import 'package:zhiying_comm/util/base_bloc.dart';
  7. class MineData extends StatefulWidget {
  8. final Map<String, dynamic> data;
  9. const MineData(this.data, {Key key}) : super(key: key);
  10. @override
  11. _MineDataState createState() => _MineDataState();
  12. }
  13. class _MineDataState extends State<MineData> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return BlocProvider<MineHeaderBloc>(
  17. bloc: MineHeaderBloc(),
  18. child: _MineDataContainer(widget.data),
  19. );
  20. }
  21. }
  22. class _MineDataContainer extends StatefulWidget {
  23. final Map<String, dynamic> data;
  24. const _MineDataContainer(this.data, {Key key}) : super(key: key);
  25. @override
  26. _MineDataContainerState createState() => _MineDataContainerState();
  27. }
  28. class _MineDataContainerState extends State<_MineDataContainer> {
  29. MineHeaderBloc _bloc;
  30. @override
  31. void initState() {
  32. _bloc = BlocProvider.of<MineHeaderBloc>(context);
  33. _bloc.loadData();
  34. super.initState();
  35. }
  36. @override
  37. Widget build(BuildContext context) {
  38. return StreamBuilder<MineProfileModel>(
  39. stream: _bloc.outData,
  40. builder: (BuildContext context, AsyncSnapshot snapshot) {
  41. MineProfileModel profile = snapshot.data;
  42. return profile == null
  43. ? MineDataSkeleton()
  44. : MineDataWidget(profile, widget.data);
  45. });
  46. }
  47. }