import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_wallet/tools/YSNetWork.dart';
import '../base/YSBase.dart';
import '../generated/l10n.dart';
import '../tools/YSColors.dart';
import '../tools/YSTools.dart';
import 'YSWalletWord.dart';
class YSWalletWordKnow extends StatefulWidget {
  const YSWalletWordKnow({Key? key}) : super(key: key);

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

class YSWalletWordKnowState extends State<YSWalletWordKnow> {
  final List _tipsArray = [
    {'image':'已选禁用 2','imageS':'已选 2','tips':S.current.RUGUOWONONGDUILZHUJICI,'isChoose':false},
    {'image':'已选禁用 2','imageS':'已选 2','tips':S.current.RUGUOWOXIANGRENHERENTOULUHUOFENXIANG,'isChoose':false},
    {'image':'已选禁用 2','imageS':'已选 2','tips':S.current.BAOHUHAOZHUJICIDEANQUANZEREN,'isChoose':false},
  ];
  @override
  Widget build(BuildContext context) {
    return YSBase2(
      isScroll: false,
      ysTitle: S.current.BEIFENZHUJICI,
      ysChild: Padding(
        padding: EdgeInsets.only(top: hsp(5)),
        child: Column(
          children: [
            Image.asset(YSColors.imageStyle(context, 'maintenance'),height: hsp(50),width: hsp(40),),
            Container(
              padding: EdgeInsets.only(left: hsp(40),right: hsp(40),top: hsp(30),bottom: hsp(15)),
              child: Text(S.current.ZAIXIAYIBUNINJIANGKANDAOKEYIHUIFU,style: YSColors.content2Style(context),),
            ),
            Expanded(
                child: Padding(
                  padding: EdgeInsets.only(top: hsp(20),left: hsp(15),right: hsp(15)),
                  child: ListView.separated(
                    itemBuilder: (context,index){
                      Map item = _tipsArray[index];
                      bool isChoose = item['isChoose']??false;
                      return GestureDetector(
                        onTap: (){
                          item['isChoose'] = !isChoose;
                          setState(() {});
                        },
                        behavior: HitTestBehavior.opaque,
                        child: Container(
                          padding: EdgeInsets.all(hsp(15)),
                          decoration: BoxDecoration(
                            color: YSColors.containColor(context),
                            borderRadius: const BorderRadius.all(Radius.circular(10)),
                            border: Border.all(color: isChoose?Colors.black:Colors.transparent,width: hsp(1))
                          ),
                          child: Row(
                            children: [
                              Expanded(
                                  child: Padding(
                                    padding: EdgeInsets.only(right: hsp(20)),
                                    child: Text(item['tips'],style: YSColors.contentStyle(context),),
                                  )
                              ),
                              Image.asset(YSColors.imageStyle(context,isChoose?item['imageS']:item['image']),height: hsp(15),width: hsp(15),)
                            ],
                          ),
                        ),
                      );
                    },
                    separatorBuilder: (context,index){
                      return Container(height: hsp(10),);
                    },
                    itemCount: _tipsArray.length,
                    shrinkWrap: true,
                    physics: const NeverScrollableScrollPhysics(),
                    padding: EdgeInsets.only(top: hsp(20)),
                  ),
                )
            ),
            Container(
              padding: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(20),right: hsp(20)),
              color: YSColors.backgroundColor(context),
              child: GestureDetector(
                onTap: (){
                  for (var element in _tipsArray) {
                    if(element['isChoose']==false){
                      ysFlutterToast(S.current.QINGXUANZHONGSUOYOUTISHIYIBIAOSHILIAOJIE);
                      return;
                    }
                  }
                  Navigator.of(context).push(
                    CupertinoPageRoute(builder: (context){
                      return const YSWalletWord();
                    })
                  );
                },
                child: Container(
                  height: hsp(50),
                  decoration: BoxDecoration(
                    color: YSColors.buttonColor(context),
                    borderRadius: const BorderRadius.all(Radius.circular(10)),
                  ),
                  alignment: Alignment.center,
                  child: Text(S.current.XIAYIBU,style: YSColors.buttonStyle(context),),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

