import 'package:betting/commom/utils/color_utils.dart';
import 'package:betting/view/mobile/home_page/preferences/preferences_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';


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

  PreferencesPage({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PreferencesController>(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("Preferences",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("Show Favourites in Scores",style: TextStyle(color: Colors.white),),
                      const Spacer(),
                      Container(
                        padding: EdgeInsets.zero,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(12.r),
                            border: Border.all(color:controller.isShowFavourites?Colors.transparent: Colors.white)
                        ),
                        child: SizedBox(
                          height: 18.h,
                          width: 32.w,
                          child: Transform.scale(
                            scale: 0.6,
                            child: CupertinoSwitch(
                              activeColor: ColorUtils.PRIMARY_COLOR,
                              value: controller.isShowFavourites,
                              onChanged: (value) {
                                controller.isShowFavourites = value;
                                controller.update();
                              },),
                          ),
                        ),
                      ),
                    ],
                  ),
                  SizedBox(height: 8.h,),
                  Row(
                    children: [
                      const Text("Show subsitutions in Match Summary",style: TextStyle(color: Colors.white),),
                      const Spacer(),
                      Container(
                        margin: EdgeInsets.only(right: controller.isShowSubstitutions?0.w:0.w),
                        padding: EdgeInsets.zero,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(16.r),
                            border: Border.all(color:controller.isShowSubstitutions?Colors.transparent: Colors.white)
                        ),
                        child: SizedBox(
                          height: 18.h,
                          width: 32.w,
                          child: Transform.scale(
                            scale: 0.6,
                            child: CupertinoSwitch(
                              activeColor: ColorUtils.PRIMARY_COLOR,
                              value: controller.isShowSubstitutions,
                              onChanged: (value) {
                                controller.isShowSubstitutions = value;
                                controller.update();
                              },),
                          ),
                        ),
                      ),
                    ],
                  )
                ],
              ),
            ),
          )
        ],
      );
    },);
  }
}
