import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yumi/app/constants/sc_global_config.dart';
import 'package:provider/provider.dart';

import 'package:yumi/ui_kit/components/sc_compontent.dart';
import 'package:yumi/services/audio/rtm_manager.dart';

class LuckGiftNomorAnimWidget extends StatefulWidget {
  @override
  _LuckGiftNomorAnimWidgetState createState() =>
      _LuckGiftNomorAnimWidgetState();
}

class _LuckGiftNomorAnimWidgetState extends State<LuckGiftNomorAnimWidget> {
  @override
  void initState() {
    super.initState();
    Provider.of<RtmProvider>(context, listen: false).showLuckGiftBigHead = true;
  }

  dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return IgnorePointer(
      child: Consumer<RtmProvider>(
        builder: (context, provider, child) {
          return provider.currentPlayingLuckGift != null
              ? Container(
                height: 380.w,
                margin: EdgeInsets.only(top: 10.w),
                child: Stack(
                  children: [
                    Image.asset(
                      "sc_images/room/sc_icon_luck_gift_nomore.webp",
                      fit: BoxFit.fitWidth,
                    ),
                    provider.showLuckGiftBigHead?Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        SizedBox(height: 125.w),
                        netImage(
                          url:
                          provider
                              .currentPlayingLuckGift
                              ?.data
                              ?.userAvatar ??
                              "",
                          shape: BoxShape.circle,
                          height: 105.w,
                          width: 105.w,
                        ),
                        SizedBox(height: 16.w),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Image.asset(
                              "sc_images/general/sc_icon_jb.png",
                              height: 35.w,
                            ),
                            SizedBox(width: 3.w),
                            Image.asset(
                              "sc_images/general/sc_icon_game_numxx.png",
                              height: 20.w,
                            ),
                            Transform.translate(
                              offset: Offset(-5, 0),
                              child: buildNumForGame(
                                (provider
                                    .currentPlayingLuckGift
                                    ?.data
                                    ?.awardAmount ??
                                    0) >
                                    9999
                                    ? "${((provider.currentPlayingLuckGift?.data?.awardAmount ?? 0) / 1000).toStringAsFixed(0)}k"
                                    : "${(provider.currentPlayingLuckGift?.data?.awardAmount ?? 0)}",
                                size: 22.w,
                              ),
                            ),
                          ],
                        ),
                        SizedBox(height: 12.w),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            SizedBox(width: 15.w),
                            buildNumForGame(
                              "${provider.currentPlayingLuckGift?.data?.multiple ?? 0}",
                              size: 22.w,
                            ),
                            Transform.translate(
                              offset: Offset(-3, 3),
                              child: Image.asset(
                                SCGlobalConfig.lang=="ar"? "sc_images/room/sc_icon_times_text_ar.png":"sc_images/room/sc_icon_times_text_en.png",
                                height: 12.w,
                              ),
                            ),
                          ],
                        ),
                      ],
                    ):Container(),
                  ],
                ),
              )
              : Container();
        },
      ),
    );
  }
}
