import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:hello_wallpaper/common/components/navigation_bar/base_appbar.dart';
import 'package:hello_wallpaper/generated/assets.dart';
import 'package:hello_wallpaper/modules/settings/settings_controller.dart';

class SettingsView extends StatelessWidget{
  SettingsView({super.key});

  final controller = Get.find<SettingsController>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const BaseAppBar('Setting'),
      body: SingleChildScrollView(
        physics: const BouncingScrollPhysics(),
        padding: const EdgeInsets.symmetric(horizontal: 20).w,
        child: Container(
          decoration: BoxDecoration(
            color: const Color(0XFF1C1C1D),
            borderRadius: BorderRadius.circular(8).r,
          ),
          clipBehavior: Clip.hardEdge,
          child: ListView.separated(
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            padding: EdgeInsets.zero,
            itemCount: controller.options.length,
            itemBuilder: (context, index) {
              return _buildOptionItem(index);
            },
            separatorBuilder: (context, index) {
              return Container(
                height: 0.44.h,
                color: const Color(0x1AFFFFFF),
                margin: const EdgeInsets.symmetric(horizontal: 16).w,
              );
            },
          ),
        ),
      ),
    );
  }

  Widget _buildOptionItem(index) {
    return Material(
      color: Colors.transparent,
      child: InkWell(
        onTap: () => controller.onTapItem(index),
        child: Container(
          height: 66.h,
          padding: const EdgeInsets.symmetric(horizontal: 16).w,
          child: Row(
            children: [
              Expanded(
                child: Text(
                  controller.options[index],
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16.sp,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
              Image.asset(
                Assets.imagesIcSettingArrow,
                width: 6.84.w,
                height: 10.9.w,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
