import 'package:betting/commom/utils/color_utils.dart';
import 'package:betting/view/mobile/favourites_view/competitions_view/competitions_screen.dart';
import 'package:betting/view/mobile/favourites_view/favourite_controller.dart';
import 'package:betting/view/mobile/favourites_view/matches_view/matches_screen.dart';
import 'package:betting/view/mobile/favourites_view/teams/teams_screen.dart';
import 'package:betting/view/mobile/home_page/home_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class FavouritesScreen extends StatelessWidget {
  FavouritesScreen({Key? key}) : super(key: key);
  final favouriteController = Get.put(FavouriteController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: RefreshIndicator(
        onRefresh: () async{
          Get.find<HomeController>().onRefreshPressed();
        },
        child: NestedScrollView(
          headerSliverBuilder: (context, innerBoxIsScrolled) {
            return [
              SliverToBoxAdapter(
                child: TabBar(
                  splashFactory: NoSplash.splashFactory,
                  controller: favouriteController.tabController,
                  labelColor: ColorUtils.PRIMARY_COLOR,
                  isScrollable: true,
                  indicatorColor: Colors.transparent,
                  unselectedLabelColor: Colors.white54,
                  labelStyle: TextStyle(fontSize: 12.sp),
                  tabs: List<Widget>.generate(
                    favouriteController.tabTitles.length,
                        (index) => Tab(
                      text: favouriteController.tabTitles[index],
                    ),
                  ),
                ),
              ),
            ];
          },
          body: TabBarView(
            physics: const BouncingScrollPhysics(),
            controller: favouriteController.tabController,
            children: [
              MatchesScreen(),
              CompetitionsScreen(),
              TeamsScreen(),
            ],
          ),
        ),
      ),
    );
  }
}
