import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/bloc/mine_quick_entry_bloc.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry_sk.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart';
import 'package:zhiying_comm/util/base_bloc.dart';

class MineQuickEntry extends StatefulWidget {
  @override
  _MineQuickEntryState createState() => _MineQuickEntryState();
}

class _MineQuickEntryState extends State<MineQuickEntry> {
  @override
  Widget build(BuildContext context) {
    return BlocProvider<MineQuickEntryBloc>(
      bloc: MineQuickEntryBloc(),
      child: _MineQuickEntryContainer(),
    );
  }
}

class _MineQuickEntryContainer extends StatefulWidget {
  @override
  _MineQuickEntryContainerState createState() =>
      _MineQuickEntryContainerState();
}

class _MineQuickEntryContainerState extends State<_MineQuickEntryContainer> {
  MineQuickEntryBloc _bloc;

  @override
  void initState() {
    _bloc = BlocProvider.of<MineQuickEntryBloc>(context);
    _bloc.loadData(4);

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<List<MineQuickEntryModel>>(
        stream: _bloc.outData,
        builder: (BuildContext context, AsyncSnapshot snapshot) {
          if (snapshot.data == null) {
            return MineQuickEntrySkeleton();
          }

          return MineQuickEntrySkeleton();
        });
  }
}
