import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_header_bloc.dart';
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods.dart';
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_header.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class GoodsListCreater extends WidgetCreater {
  final EventBus _eventBus = EventBus();

  @override
  List<Widget> createWidgets(Map<String, dynamic> model) {
    print('创建商品列表');
    Widget _widget = BlocProvider<HomeGoodsHeaderBloc>(
      bloc: HomeGoodsHeaderBloc(),
      child: HomeGoodsHeader(model, _eventBus),
    );

    return [
      SliverPersistentHeader(
        pinned: true,
        floating: false,
        delegate: HomeGoodsHeaderDelegate(_widget),
      ),
      SliverToBoxAdapter(
        child: HomeGoods(model, eventBus: _eventBus),
      ),
    ];
  }

  @override
  bool isSliverChild() {
    return true;
  }
}

class HomeGoodsHeaderEvent {
  String provider;

  HomeGoodsHeaderEvent(this.provider);
}
