// setting_screen.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import '../../widgets/custom_app_bar.dart';
import '../change_pass/change_pass_screen.dart';

class SettingScreen extends StatelessWidget {
  const SettingScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar.back(title: "Cài đặt"),
      backgroundColor: const Color(0xFFF5F6F7),
      body: Column(
        children: [
          Container(
            width: double.infinity,
            margin: const EdgeInsets.symmetric(horizontal: 0, vertical: 16),
            decoration: BoxDecoration(
              color: Colors.white,
              // borderRadius: BorderRadius.circular(12),
              // boxShadow: [
              //   BoxShadow(
              //     color: Colors.black12,
              //     blurRadius: 8,
              //     offset: const Offset(0, 4),
              //   ),
              // ],
            ),
            child: Column(
              children: [
                _buildSettingItem(
                  icon: Icons.apps,
                  title: 'Các lĩnh vực quan tâm',
                  onTap: () {},
                ),
                _buildDivider(),
                _buildSettingItem(
                  icon: Icons.lock_outline,
                  title: 'Đổi mật khẩu',
                  onTap: () => Get.to(ChangePassScreen()),
                ),
                _buildDivider(),
                _buildSettingItem(
                  icon: Icons.fingerprint,
                  title: 'Xác thực sinh trắc học',
                  showTrailing: false,
                  onTap: () {},
                ),
                _buildDivider(),
                _buildSettingItem(
                  icon: Icons.devices_other,
                  title: 'Quản lý thiết bị đăng nhập',
                  onTap: () {},
                ),
                _buildDivider(),
                _buildSettingItem(
                  icon: Icons.delete_outline,
                  title: 'Xóa tài khoản',
                  onTap: () {},
                  textColor: Colors.red,
                  iconColor: Colors.red,
                  showTrailing: false,
                ),
              ],
            ),
          ),
          const Expanded(child: SizedBox()),
        ],
      ),
    );
  }

  Widget _buildSettingItem({
    required IconData icon,
    required String title,
    required VoidCallback onTap,
    Color? textColor,
    Color? iconColor,
    bool showTrailing = true,
  }) {
    return ListTile(
      leading: Icon(icon, color: iconColor ?? Colors.black54),
      title: Text(
        title,
        style: TextStyle(
          fontSize: 16,
          color: textColor ?? Colors.black87,
          fontWeight: FontWeight.w500,
        ),
      ),
      trailing: showTrailing ? const Icon(Icons.chevron_right, color: Colors.black26) : null,
      onTap: onTap,
      contentPadding: const EdgeInsets.symmetric(horizontal: 16),
    );
  }

  Widget _buildDivider() {
    return const Divider(height: 1, indent: 16, endIndent: 16);
  }
}