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

import 'notifications_preferences_controller.dart';


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


  @override
  Widget build(BuildContext context) {
    return  GetBuilder<NotificationPreferencesController>(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("Notifications 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(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(height: 8.h,),
                  Row(
                    children: [
                      Icon(CupertinoIcons.gift, size: 24.sp,color: Colors.white24,),
                      SizedBox(width: 8.w,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('Promotions', style: TextStyle(color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.bold),),
                          Text('Receive ofer & promotios from Betting', style: TextStyle(color: Colors.white24, fontSize: 10.sp, fontWeight: FontWeight.w400),),

                        ],
                      ),
                      const Spacer(),
                      Obx(() =>
                          SizedBox(
                            child:
                            Transform.scale(scale: 0.6, child: CupertinoSwitch(
                                activeColor: ColorUtils.PRIMARY_COLOR,
                                value: controller.isNotificationsSwich.value,
                                onChanged:(value){
                                  controller.isNotificationsSwich.value =! controller.isNotificationsSwich.value;
                                }),),
                          )
                      )

                    ],
                  ),
                  SizedBox(height: 8.h,),
                  Row(
                    children: [
                      Icon(Icons.newspaper_outlined, size: 24.sp,color: Colors.white24,),
                      SizedBox(width: 8.w,),

                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('Featured New', style: TextStyle(color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.bold),),
                          Text('Get the lastest featured news updates', style: TextStyle(color: Colors.white24, fontSize: 10.sp, fontWeight: FontWeight.w400),),

                        ],
                      ),
                      const Spacer(),
                      Obx(() =>
                          SizedBox(
                            child:
                            Transform.scale(scale: 0.6, child: CupertinoSwitch(
                                activeColor: ColorUtils.PRIMARY_COLOR,
                                value: controller.isNotificationsSwich.value,
                                onChanged:(value){
                                  controller.isNotificationsSwich.value =! controller.isNotificationsSwich.value;
                                }),),
                          )
                      )

                    ],
                  ),
                  SizedBox(height: 8.h,),
                  Row(
                    children: [
                      Icon(Icons.video_camera_back_outlined, size: 24.sp,color: Colors.white24,),
                      SizedBox(width: 8.w,),

                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('Streaming ', style: TextStyle(color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.bold),),
                          Text('Get the lastest video & streaming content updates', style: TextStyle(color: Colors.white24, fontSize: 10.sp, fontWeight: FontWeight.w400),),

                        ],
                      ),
                      const Spacer(),
                      Obx(() =>
                          SizedBox(
                            child:
                            Transform.scale(scale: 0.6, child: CupertinoSwitch(
                                activeColor: ColorUtils.PRIMARY_COLOR,
                                value: controller.isNotificationsSwich.value,
                                onChanged:(value){
                                  controller.isNotificationsSwich.value =! controller.isNotificationsSwich.value;
                                }),),
                          )
                      )

                    ],
                  ),
                  SizedBox(height: 8.h,),
                  Row(
                    children: [
                      Icon(CupertinoIcons.arrow_down_circle, size: 24.sp,color: Colors.white24,),
                      SizedBox(width: 8.w,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('Product Updates', style: TextStyle(color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.bold),),
                          Text('Get the latest product info & feature updates', style: TextStyle(color: Colors.white24, fontSize: 10.sp, fontWeight: FontWeight.w400),),

                        ],
                      ),
                      const Spacer(),
                      Obx(() =>
                          SizedBox(
                            child:
                            Transform.scale(scale: 0.6, child: CupertinoSwitch(
                                activeColor: ColorUtils.PRIMARY_COLOR,
                                value: controller.isNotificationsSwich.value,
                                onChanged:(value){
                                  controller.isNotificationsSwich.value =! controller.isNotificationsSwich.value;
                                }),),
                          )
                      )

                    ],
                  ),
                  SizedBox(height: 8.h,),
                  Row(
                    children: [
                      Text('TEAMS',style: TextStyle(color: Colors.white24, fontSize: 14.sp, fontWeight: FontWeight.bold)),
                      const Spacer(),
                      Text('MATCHS',style: TextStyle(color: Colors.white24, fontSize: 14.sp, fontWeight: FontWeight.bold)),
                      SizedBox(width: 8.w,),
                      Text('NEWS',style: TextStyle(color: Colors.white24, fontSize: 14.sp, fontWeight: FontWeight.bold)),
                    ],
                  ),
                  ListView.builder(
                    shrinkWrap: true,
                    itemCount: controller.itemTeam.length,
                    itemBuilder: (context, index) {
                    return
                      controller.itemTeam[index].name== "EDIT" ? const SizedBox() :  Obx(() => Container(
                        margin: EdgeInsets.symmetric(vertical: 4.h),
                        padding: EdgeInsets.all(8.sp),
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(6),
                            color: Colors.white12
                        ),
                        child: Row(
                          children: [
                            Icon(CupertinoIcons.arrow_down_circle, size: 24.sp,color: Colors.white24,),
                            SizedBox(width: 8.w,),
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text('${controller.itemTeam[index].name}', style: TextStyle(color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.bold),),
                                Text('${controller.itemTeam[index].country?.name ?? ""}', style: TextStyle(color: Colors.white24, fontSize: 10.sp, fontWeight: FontWeight.w400),),

                              ],
                            ),
                            const Spacer(),
                            InkWell(
                              onTap: (){
                                Get.dialog(
                                    AlertDialog(

                                      contentPadding: EdgeInsets.symmetric(horizontal: 16.w),
                                      backgroundColor: const Color.fromRGBO(51, 51, 51, 1),
                                      titlePadding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
                                      title: Text('Match notifications are off', style: TextStyle(color: Colors.white38, fontWeight: FontWeight.w500, fontSize: 16.sp),),
                                      content:  Text('In order to receive instant notifications for match events you must turn on match alert', style: TextStyle(color: Colors.white38, fontWeight: FontWeight.w500, fontSize: 14.sp),),
                                      actions: [
                                        TextButton(onPressed: (){
                                          Get.back();
                                        }, child: Text('CANCEL', style: TextStyle(color:ColorUtils.PRIMARY_COLOR, fontSize: 14.sp, fontWeight: FontWeight.w500),)),
                                        SizedBox(width: 8.w,),
                                        TextButton(onPressed: (){
                                          controller.isNotificationsMatch.value =! controller.isNotificationsMatch.value;
                                          Get.back();

                                        }, child: Text('TURN ON', style: TextStyle(color:ColorUtils.PRIMARY_COLOR, fontSize: 14.sp, fontWeight: FontWeight.w500),)),

                                      ],
                                    )

                                );
                              },
                              child:controller.isNotificationsMatch.value ? const Icon(Icons.notifications_on_rounded,color: ColorUtils.PRIMARY_COLOR,) :  const Icon(Icons.notifications_off_outlined,color: ColorUtils.PRIMARY_COLOR,),
                            ),
                            SizedBox(width: 24.w,),
                            InkWell(
                              onTap: (){
                                controller.isNotificationsNews.value =! controller.isNotificationsNews.value;
                              },
                              child: controller.isNotificationsNews.value ? const Icon(Icons.notifications_on_rounded,color: ColorUtils.PRIMARY_COLOR,):const Icon(Icons.notifications_off_outlined,color: ColorUtils.PRIMARY_COLOR,),
                            )


                          ],
                        ),
                      ));
                  },)
                ],
              ),
            ),
          )
        ],
      );
    },);
  }
}
