import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:velocity_x/velocity_x.dart';

import '../../base/base_style.dart';
import '../widget/plone_back_button.dart';
import '../widget/plone_bottom.dart';

class ExcludeSinglePage extends StatefulWidget {
  const ExcludeSinglePage({Key? key}) : super(key: key);

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

class _ExcludeSinglePageState extends State<ExcludeSinglePage> {

  String phone="";
  String name="";
  @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: 110.w,
          leading: const CloudBackButton(isSpecial: true),
          backgroundColor: kForeGroundColor),
      backgroundColor: Colors.white,
      body: Container(
        padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            addNumber("号码", "请输入号码"),
            40.hb,
            addNumber("名称", "请输入名称"),
            43.hb,
            Text(
              "使用说明:",
              style: TextStyle(color: BaseStyle.color999999, fontSize: 28.sp),
            ),
            12.hb,
            Text("如输入00852*，可匹配所有00852开头的号码",
                style: TextStyle(color: BaseStyle.color999999, fontSize: 28.sp))
            // RichText(
            //   text: const TextSpan(
            //     children: [
            //       TextSpan(text: "使用说明："),
            //       TextSpan(text: "如输入000*，可屏蔽所有000开头的号码")
            //     ],
            //   ),
            // ),
          ],
        ),
      ),
      bottomNavigationBar: PloneBottom(
        onTap: (){},
        border: name.isEmpty || phone.isEmpty,
        opacity:name.isEmpty || phone.isEmpty ? 0.4 : 1,
        text: "添加",
      ).paddingOnly(bottom: 30.w),
    );
  }

  addNumber(String title, content) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: TextStyle(
            fontSize: 28.sp,
            color: Colors.black38,
            fontWeight: FontWeight.w600,
          ),
        ),
        15.heightBox,
        CupertinoTextField(
          padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 20.w),
          decoration: BoxDecoration(
              border: Border.all(color: Colors.white),
              // borderRadius: BorderRadius.all(
              //   Radius.circular(4.w)
              // ),
              color: const Color(0xFFF9F9F9)),
          placeholderStyle:
              TextStyle(color: BaseStyle.color999999, fontSize: 28.sp),
          placeholder: content,
          onChanged: (value) {
            if(title=="号码"){
              phone=value;
              print("phone:$phone");
            }else{
              name=value;
              print("name:$name");
            }
            setState(() {});
          },
        ),
      ],
    );
  }
}
