import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loopin/components/web_page.dart';
import 'package:loopin/styles/index.dart';

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

  @override
  Widget build(BuildContext context) {
    final List<Map<String, dynamic>> settings = [
      {
        'icon': Icons.person,
        'title': '账号设置',
        'onTap': () => Get.toNamed('/userInfo'),
      },
      {
        // 'icon': Icons.notifications,
        // 'title': '通知设置',
        // 'onTap': () => Get.toNamed('/notifications'),
        'icon': Icons.logout,
        'title': '注销账号',
        'onTap': () => Get.toNamed('/delete'),
      },
      {
        'icon': Icons.lock,
        'title': '隐私协议',
        'onTap': () => Get.to(() => SafeArea(child: WebPage(url: 'https://www.wuzhongjie.com.cn/download/yinsizhengce.html', title: '隐私协议'))),
      },
      {
        'icon': Icons.lock,
        'title': '用户协议',
        'onTap': () => Get.to(() => SafeArea(child: WebPage(url: 'https://www.wuzhongjie.com.cn/download/yonhuxieyi.html', title: '用户协议'))),
      },
      // {
      //   'icon': Icons.info,
      //   'title': '关于我们',
      //   'onTap': () => Get.toNamed('/about'),
      // },
    ];

    return Scaffold(
      appBar: AppBar(title: const Text('设置')),
      backgroundColor: Colors.grey[200],
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: [
            Card(
              elevation: 2,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(12),
              ),
              color: Colors.white,
              child: Column(
                children: settings.map((item) {
                  return Column(
                    children: [
                      ListTile(
                        leading: Icon(item['icon'] as IconData, color: FStyle.c999),
                        title: Text(item['title']),
                        trailing: const Icon(
                          Icons.chevron_right,
                          color: FStyle.c999,
                        ),
                        onTap: item['onTap'],
                      ),
                      if (item != settings.last) const Divider(height: 1, indent: 16, endIndent: 16),
                    ],
                  );
                }).toList(),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
