import 'dart:ui' as ui;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yumi/modules/room/rank/room_gift_rank_tab_page.dart';
import 'package:provider/provider.dart';
import 'package:yumi/app_localizations.dart';
import 'package:yumi/shared/business_logic/models/res/sc_room_reward_info_res.dart';
import 'package:yumi/services/audio/rtc_manager.dart';
import 'package:yumi/ui_kit/theme/socialchat_theme.dart';

import '../../../shared/data_sources/models/enum/sc_date_type.dart';

class RoomGiftRankPage extends StatefulWidget {
  @override
  _RoomGiftRankPageState createState() => _RoomGiftRankPageState();
}

class _RoomGiftRankPageState extends State<RoomGiftRankPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;
  final List<Widget> _pages = [];
  final List<Widget> _tabs = [];
  SCRoomRewardInfoRes? res;

  @override
  void initState() {
    super.initState();
    String roomId =
        Provider.of<RtcProvider>(
          context,
          listen: false,
        ).currenRoom?.roomProfile?.roomProfile?.id ??
        "";
    _pages.add(RoomGiftRankTabPage(roomId, SCDateType.DAY.name));
    _pages.add(RoomGiftRankTabPage(roomId, SCDateType.WEEK.name));
    _pages.add(RoomGiftRankTabPage(roomId, SCDateType.MONTH.name));
    _tabController = TabController(length: _pages.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    _tabs.clear();
    _tabs.add(Tab(text: SCAppLocalizations.of(context)!.daily));
    _tabs.add(Tab(text: SCAppLocalizations.of(context)!.weekly));
    _tabs.add(Tab(text: SCAppLocalizations.of(context)!.monthly));
    return SafeArea(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          ClipRRect(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(12.w),
              topRight: Radius.circular(12.w),
            ),
            child: BackdropFilter(
              filter: ui.ImageFilter.blur(sigmaX: 15, sigmaY: 15),
              child: Container(
                decoration: BoxDecoration(color: Colors.black54),
                height: 350.w,
                child: Column(
                  children: [
                    TabBar(
                      tabAlignment: TabAlignment.start,
                      labelPadding: EdgeInsets.symmetric(horizontal: 12.w),
                      labelColor: SocialChatTheme.primaryLight,
                      isScrollable: true,
                      indicator: BoxDecoration(),
                      unselectedLabelColor: Colors.white54,
                      labelStyle: TextStyle(
                        fontSize: 17.sp,
                        fontWeight: FontWeight.w600,
                      ),
                      unselectedLabelStyle: TextStyle(
                        fontSize: 15.sp,
                        fontWeight: FontWeight.w500,
                      ),
                      indicatorColor: Colors.transparent,
                      dividerColor: Colors.transparent,
                      controller: _tabController,
                      tabs: _tabs,
                    ),

                    Expanded(
                      child: TabBarView(
                        controller: _tabController,
                        children: _pages,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

}
