import 'package:betting/commom/utils/color_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'automatic_refresh_controller.dart';


class AutomaticRefreshPage extends GetView<AutomaticRefreshController> {
  @override
  final controller = Get.put(AutomaticRefreshController());

  AutomaticRefreshPage({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<AutomaticRefreshController>(builder: (controller) {
      return Stack(
        children: [
          Image.asset(
            "assets/images/background_app_betting.jpg",
            height: MediaQuery.of(context).size.height,
            width: MediaQuery.of(context).size.width,
            fit: BoxFit.cover,
          ),
          Scaffold(
            appBar: AppBar(
              backgroundColor: Colors.transparent,
              bottom: const PreferredSize(preferredSize: Size(double.infinity, 1), child: Divider(color: Colors.white,)),
              title: const Text("Automatic Refresh",style: TextStyle(color: Colors.white),),
              centerTitle: true,
            ),
            backgroundColor: Colors.transparent,
            resizeToAvoidBottomInset: true,
            body: Container(
              margin: EdgeInsets.only(bottom: 24.h,right: 16.w,left: 16.w),
              child: Column(
                children: [
                  Row(
                    children: [
                      const Text("Automatic Refresh",style: TextStyle(color: Colors.white),),
                      const Spacer(),
                      Transform.scale(
                        scale: 0.7,
                        child: CupertinoSwitch(
                          activeColor: ColorUtils.PRIMARY_COLOR,
                          value: controller.isAutomaticRefresh,
                          onChanged: (value) {
                            controller.isAutomaticRefresh = value;
                            controller.update();
                          },),
                      ),

                    ],
                  ),
                  Row(
                    children: [
                      const Text("Refresh Interval",style: TextStyle(color: Colors.white),),
                      const Spacer(),
                      Text("${controller.currentSliderValue} sec",style: const TextStyle(color: Colors.white),)
                    ],
                  ),
                  Slider(
                    value: controller.currentSliderValue,
                    min: 30,
                    max: 180,
                    divisions: 150,
                    activeColor: ColorUtils.PRIMARY_COLOR,
                    thumbColor: Colors.white,
                    label:  controller.currentSliderValue.round().toString(),
                    onChanged: (double value) {
                      controller.currentSliderValue = value;
                      controller.update();
                    },
                  )
                ],
              ),
            ),
          )
        ],
      );
    },);
  }
}
