import 'package:clean/base/base_view.dart';
import 'package:clean/module/more/more_controller.dart';
import 'package:clean/module/wallpaper/wallpaper_view.dart';
import 'package:clean/router/app_pages.dart';
import 'package:clean/utils/expand.dart';
import 'package:flutter/Material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

import '../../resource/assets.gen.dart';

class MorePage extends BaseView<MoreController> {
  const MorePage({super.key});


  @override
  Widget buildBody(BuildContext context) {
    return SafeArea(
      child: Container(
        width: double.infinity,
        color: "#05050D".color,
        padding: EdgeInsets.symmetric(horizontal: 16.w),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              "CleanPro",
              style: TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.w900,
                fontSize: 24.sp,
              ),
            ),
            Expanded(
              child: SingleChildScrollView(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    SizedBox(height: 21.h),
                    _buildStoreCard(),
                    SizedBox(height: 30.h),
                    Container(
                      margin: EdgeInsets.only(left: 2.w),
                      child: Text(
                        "More features",
                        style: TextStyle(
                          color: Colors.white,
                          fontWeight: FontWeight.w700,
                          fontSize: 18.sp,
                        ),
                      ),
                    ),
                    SizedBox(height: 18.h),
                    _buildCustomCard(
                        "Privacy Space",
                        Assets.images.iconMorePrivacyBg.image(),
                        Assets.images.iconMorePrivacy
                            .image(height: 72.w, width: 72.w), onTap: () {
                      Get.toNamed(RoutePath.privacy);
                    }),
                    SizedBox(height: 14.h),
                    _buildCustomCard(
                      "Contacts",
                      Assets.images.iconMoreContactsBg.image(),
                      Assets.images.iconMoreContacts
                          .image(height: 72.w, width: 72.w),
                      onTap: () {
                        Get.toNamed(RoutePath.contact);
                      },
                    ),
                    SizedBox(height: 14.h),
                    _buildCustomCard(
                      "Photo Analysis",
                      Assets.images.iconMoreAnalysisBg.image(),
                      Assets.images.iconMoreAnalysis
                          .image(height: 72.w, width: 72.w),
                      onTap: () {
                        Get.toNamed(RoutePath.analysis);
                      },
                    ),
                    SizedBox(height: 14.h),
                    _buildCustomCard(
                        "Wallpaper",
                        Assets.images.iconMoreWallpaperBg.image(),
                        Assets.images.iconMoreWallpaper
                            .image(height: 72.w, width: 72.w),
                        onTap: () {
                          WallPaperPage.start();
                        }),
                    SizedBox(height: 14.h),
                    _buildCustomCard(
                      "Settings",
                      Assets.images.iconMoreSettingsBg.image(),
                      Assets.images.iconMoreSettings
                          .image(height: 72.w, width: 72.w),
                      onTap: () {
                        Get.toNamed(RoutePath.setting);
                      },
                    ),

                    SizedBox(height: 25.h),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildStoreCard() {
    return GestureDetector(
      onTap: () {
        Get.toNamed(RoutePath.store);
      },
      child: Stack(
        children: [
          Assets.images.iconMoreStoreCard.image(),
          Positioned(
            left: 12.w,
            bottom: 15.h,
            child: Container(
              width: 107.w,
              height: 30.h,
              decoration: BoxDecoration(
                border: Border.all(
                  color: '#FFFFFF'.color.withOpacity(0.18),
                  width: 1,
                ),
                borderRadius: BorderRadius.all(
                  Radius.circular(15.h),
                ),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Text(
                    "Get more",
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.w500,
                      fontSize: 14.sp,
                    ),
                  ),
                  Icon(
                    Icons.arrow_forward_ios,
                    size: 10.w,
                    color: Colors.white,
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildCustomCard(String title, Image bg, Image icon,
      {required Function() onTap}) {
    return GestureDetector(
      onTap: onTap,
      child: Stack(
        children: [
          bg,
          Positioned(
            top: 12.h,
            left: 22.w,
            child: Text(
              title,
              style: TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.w500,
                fontSize: 20.sp,
              ),
            ),
          ),
          Positioned(
            bottom: 12.h,
            left: 22.w,
            child: Assets.images.iconMoreBack.image(height: 28.w, width: 28.w),
          ),
          Positioned(
            right: 23.w,
            top: 12.h,
            child: icon,
          ),
        ],
      ),
    );
  }
}
