import 'package:flutter/material.dart';
import 'package:flutter_wallet/base/YSBase.dart';
import 'package:flutter_wallet/generated/l10n.dart';
import 'package:flutter_wallet/login/view/YSHelpView.dart';
import 'package:flutter_wallet/tools/YSColors.dart';
import 'package:flutter_wallet/tools/YSNetWork.dart';
import 'package:flutter_wallet/tools/YSTools.dart';

class YSWalletCollection extends StatefulWidget {
  final Map wallet;
  const YSWalletCollection({Key? key, required this.wallet}) : super(key: key);

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

class YSWalletCollectionState extends State<YSWalletCollection> {
  bool _isTips = false;
  @override
  Widget build(BuildContext context) {
    return YSBase2(
      ysTitle: S.current.SHOUKUAN,
      ysChild: Container(
        margin: EdgeInsets.only(left: hsp(20),right: hsp(20)),
        decoration: BoxDecoration(
          color: YSColors.containColor(context),
          borderRadius: const BorderRadius.all(Radius.circular(10))
        ),
        padding: EdgeInsets.all(hsp(15)),
        child: Column(
          children: [
            if(_isTips==true)YSShowTipsView(tipStr: S.current.GAIDIZHIJINZHICHIBSC,callback: (){
              _isTips = false;
              setState(() {});
            },),
            Padding(
              padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
              child: YSCodeImage.codeImage(widget.wallet['public']),
            ),
            Container(
              width: ysWidth(context),
              margin: EdgeInsets.only(bottom: hsp(30)),
              decoration: BoxDecoration(
                color: YSColors.contain2Color(context),
                borderRadius: const BorderRadius.all(Radius.circular(10))
              ),
              padding: EdgeInsets.all(hsp(15)),
              child: Column(
                children: [
                  Text(S.current.JIESHOUDIZHI,style: YSColors.contentStyle(context),),
                  Text(widget.wallet['public'],style: YSColors.subStyle(context),textAlign: TextAlign.center,)
                ],
              ),
            ),
            SizedBox(
              height: hsp(50),
              child: Row(
                children: [
                  Expanded(child: GestureDetector(
                    onTap: (){},
                    behavior: HitTestBehavior.opaque,
                    child: Align(
                      alignment: Alignment.center,
                      child: Row(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Image.asset(YSColors.imageStyle(context, '导出 (2)'),height: hsp(15),width: hsp(15),),
                          Text(' ${S.current.FENXIANG}',style: YSColors.subStyle(context),)
                        ],
                      ),
                    ),
                  )),
                  Container(
                    height: hsp(15),
                    width: hsp(1),
                    color: YSColors.lineColor(context),
                  ),
                  Expanded(child: GestureDetector(
                    onTap: (){
                      YSCopyPaste.copy(widget.wallet['public']);
                    },
                    behavior: HitTestBehavior.opaque,
                    child: Align(
                      alignment: Alignment.center,
                      child: Row(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Image.asset(YSColors.imageStyle(context, '复制'),height: hsp(15),width: hsp(15),),
                          Text(' ${S.current.FUZHI}',style: YSColors.subStyle(context),)
                        ],
                      ),
                    ),
                  ))
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
