|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import 'package:flutter/material.dart';
- import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_bloc.dart';
- import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart';
- import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_sk.dart';
-
- class HotRankingContainer extends StatefulWidget {
- final Map<String, dynamic> data;
-
- const HotRankingContainer({Key key, this.data}) : super(key: key);
-
- @override
- _HotRankingState createState() => _HotRankingState();
- }
-
- class _HotRankingState extends State<HotRankingContainer>
- with TickerProviderStateMixin {
- HotRankingBloc _bloc;
- TabController _tabController;
-
- @override
- void initState() {
- _bloc = HotRankingBloc();
- super.initState();
- }
-
- _buildTabs() {
- List<Widget> listWidget = List();
- for (int index = 0; index < 4; index++) {
- listWidget.add(Tab(
- text: "hahah",
- ));
- }
- return listWidget;
- }
-
- @override
- void dispose() {
- _tabController.dispose();
- super.dispose();
- }
-
- ///构建
- void createTabController() {
- _tabController = TabController(length: 4, vsync: this);
- }
-
- ///构建TabView
- _buildTabView() {
- List<Widget> listWidget = List();
- for (var index = 0; index < 4; index++) {
- listWidget.add(ListView.builder(
- padding: EdgeInsets.all(0),
- itemCount: 10,
- itemBuilder: (context, index) {
- return Container(
- child: HotRankingGoods(),
- );
- }));
- }
- return listWidget;
- }
-
- @override
- Widget build(BuildContext context) {
-
- return StreamBuilder(
- stream: _bloc.outData,
- builder: (context, snapshot) {
- if (snapshot.data != null) {
- return HotRankingSkeleton();
- } else {
- createTabController();
- return Container(
- child: Column(
- children: <Widget>[
- TabBar(
- controller: _tabController,
- isScrollable: true,
- tabs: _buildTabs(),
- ),
- Expanded(
- child: TabBarView(
- controller: _tabController,
- children: _buildTabView()))
- ],
- ),
- );
- }
- });
- }
- }
|