import 'package:flutter/material.dart';
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
import 'package:project_telephony/utils/headers.dart';

import '../../../base/base_style.dart';

import '../../widget/plone_back_button.dart';

// class setItem{
//
// }

class PhoneSetPage extends StatefulWidget {

  const PhoneSetPage({Key? key}) : super(key: key);

  @override
  _PhoneSetPageState createState() => _PhoneSetPageState();
}

class _PhoneSetPageState extends State<PhoneSetPage> {
  int select = 0;
  List setList = [
    {
      "icon": Assets.icons.rylyphone.path,
      "title": "任意来源号码发送",
      "text": "所有的号码来电都会发送",
      // "select": true,
    },
    {
      "icon": Assets.icons.txlphone.path,
      "title": "在通讯录中的号码发送",
      "text": "只给在通讯录中的号码来电发送",
      // "select": false,
    },
    {
      "icon": Assets.icons.notxlphone.path,
      "title": "不在通讯录中的号码发送",
      "text": "只给不在通讯录中的号码来电发送",
      // "select": false,
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          elevation: 0,
          title: Text(
            '发送号码设置',
            style: TextStyle(
                fontSize: BaseStyle.fontSize34,
                color: BaseStyle.color333333,
                fontWeight: FontWeight.bold),
          ),
          titleSpacing: 162.w,
          leading: const CloudBackButton(isSpecial: true),
          backgroundColor: kForeGroundColor),
      backgroundColor: kForeGroundColor,
      body: Column(
        children: [
          _getList(),
          24.hb,
          GestureDetector(
            onTap: () {
              Get.to(()=>const SpecifyPhonePage());
            },
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),
              height: 144.w,
              child: ListTile(
                  leading: SizedBox(
                    width: 72.w,
                    height: 72.w,
                    child: Image.asset(
                      Assets.icons.zdphone.path,
                      fit: BoxFit.fill,
                    ),
                  ),
                  title: Text(
                    "指定号码不发送",
                    style:
                        TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
                  ),
                  subtitle: Text(
                    "通过添加指定号码来设置不发送",
                    style: TextStyle(
                        fontSize: 28.sp, color: const Color(0xFF999999)),
                  ),
                  trailing: SizedBox(
                    width: 48.w,
                    height: 48.w,
                    child: const Icon(Icons.arrow_forward_ios),
                  )),
            ),
          )
        ],
      ),
    );
  }

  _getList() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),
      height: 500.w,
      child: ListView.builder(
        itemBuilder: (context, index) {
          return _getListBox(setList, index);
        },
        itemCount: setList.length,
      ),
    );
  }

  _getListBox(List item, int index) {
    return GestureDetector(
      onTap: () {
        select = index;
        // print(_selectIndex);
        setState(() {});
      },
      child: ListTile(
        leading: SizedBox(
            width: 72.w,
            height: 72.w,
            child: Image.asset(
              item[index]["icon"],
              fit: BoxFit.fill,
            )),
        title: Text(
          item[index]["title"],
          style: TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
        ),
        subtitle: Text(
          item[index]["text"],
          style: TextStyle(fontSize: 28.sp, color: const Color(0xFF999999)),
        ),
        trailing: SizedBox(
          width: 40.w,
          height: 40.w,
          child: Radio(
            onChanged: (int? value) {
              select = index;
              // print(_selectIndex);
              setState(() {});
            },
            groupValue: select,
            value: index,
          ),
        ),

        // BeeCheckRadio(
        //   value: index,
        //   groupValue: [select],
        // ),
      ),
    );
  }
}