YSWalletDetail.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_wallet/tools/YSAlertView.dart';
  4. import 'package:flutter_wallet/tools/YSBip.dart';
  5. import 'package:flutter_wallet/tools/YSSqflite.dart';
  6. import 'package:flutter_wallet/wallet/YSWalletExport.dart';
  7. import 'package:flutter_wallet/wallet/view/YSWalletManagerListItemView.dart';
  8. import '../base/YSBase.dart';
  9. import '../generated/l10n.dart';
  10. import '../login/view/YSHelpView.dart';
  11. import '../tools/YSColors.dart';
  12. import '../tools/YSTools.dart';
  13. import 'YSWalletExportPrivate.dart';
  14. import 'package:web3dart/web3dart.dart';
  15. import 'package:wallet/wallet.dart' as ysWallet;
  16. class YSWalletDetail extends StatefulWidget {
  17. final Map wallet;
  18. const YSWalletDetail({Key? key, required this.wallet}) : super(key: key);
  19. @override
  20. YSWalletDetailState createState() => YSWalletDetailState();
  21. }
  22. class YSWalletDetailState extends State<YSWalletDetail> {
  23. final List _menuArray = [
  24. {'image':'导入','title':S.current.DAOCHUSIYAO,'key':1},
  25. {'image':'导出 (2)','title':S.current.DAOCHUKEYSTORE,'key':2},
  26. // {'image':'同步','title':S.current.QIANBAOTONGBU,'key':3},
  27. // {'image':'白名单','title':S.current.BAIMINGDAN,'key':4},
  28. ];
  29. @override
  30. Widget build(BuildContext context) {
  31. return YSBase2(
  32. titleType: 2,
  33. ysRightWidget: const YSCapsule(),
  34. ysChild: Padding(
  35. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  36. child: Column(
  37. children: [
  38. Container(
  39. height: hsp(50),
  40. alignment: Alignment.centerLeft,
  41. child: Text('${S.current.QIANBAOXIANGQING2} ',style: YSColors.title2Style(context),),
  42. ),
  43. Padding(
  44. padding: EdgeInsets.only(top: hsp(5)),
  45. child: YSWalletManagerListItemView(item: widget.wallet,isDetail: true,)
  46. ),
  47. '${widget.wallet['private']}'.isEmpty?Container(
  48. height: hsp(100),
  49. ):Container(
  50. margin: EdgeInsets.only(top: hsp(15)),
  51. decoration: BoxDecoration(
  52. color: Colors.white,
  53. borderRadius: const BorderRadius.all(Radius.circular(10)),
  54. boxShadow: [
  55. BoxShadow(color: YSColors.shadowColor(context),blurRadius: 5)
  56. ]
  57. ),
  58. child: ListView.separated(
  59. itemBuilder: (context,index){
  60. Map item = _menuArray[index];
  61. return GestureDetector(
  62. onTap: (){
  63. if(item['key']==1||item['key']==2){
  64. ysShowCenterAlertView(context, YSInputPasswordView(wallet: widget.wallet, callback: () {
  65. Navigator.of(context).push(
  66. CupertinoPageRoute(builder: (context){
  67. return item['key']==1?YSWalletExportPrivate(wallet: widget.wallet,):YSWalletExport(wallet: widget.wallet,);
  68. })
  69. );
  70. },));
  71. }
  72. },
  73. behavior: HitTestBehavior.opaque,
  74. child: SizedBox(
  75. height: hsp(45),
  76. child: Row(
  77. children: [
  78. Image.asset(YSColors.imageStyle(context, item['image']),height: hsp(10),width: hsp(10),),
  79. Expanded(
  80. child: Padding(
  81. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  82. child: Text(item['title'],style: YSColors.contentStyle(context),)
  83. )
  84. ),
  85. ],
  86. ),
  87. ),
  88. );
  89. },
  90. separatorBuilder: (context,index){
  91. return Divider(height: hsp(1),color: YSColors.lineColor(context),);
  92. },
  93. itemCount: _menuArray.length,
  94. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  95. shrinkWrap: true,
  96. physics: const NeverScrollableScrollPhysics(),
  97. ),
  98. ),
  99. GestureDetector(
  100. onTap: (){
  101. ysShowBottomAlertView(context, YSTipsAlertView2(valueSetter: (value){
  102. if(value){
  103. ysShowCenterAlertView(context, YSInputPasswordView(wallet: widget.wallet, callback: () async{
  104. YSSqflite().rawDelete('${widget.wallet['id']}');
  105. List array = await YSSqflite().rawQuery();
  106. if(!mounted)return;
  107. YSSqflite.notifier(context, array);
  108. Navigator.of(context).pop('');
  109. }));
  110. }
  111. },
  112. tipsStr: S.current.QUEDINGYAOSHANCHUQIANBAO,
  113. tipsStr2: S.current.SHANCHUQIANQINGBEIFEN,
  114. btnStr1: S.current.QUXIAO,
  115. btnStr2: S.current.YIZHIXIAOJIXU,
  116. ),isBarr: true);
  117. },
  118. child: Container(
  119. margin: EdgeInsets.only(top: hsp(25)),
  120. height: hsp(50),
  121. decoration: BoxDecoration(
  122. color: YSColors.buttonColor(context),
  123. borderRadius: const BorderRadius.all(Radius.circular(10))
  124. ),
  125. alignment: Alignment.center,
  126. child: Text(S.current.SHANCHUQIANBAO,style: YSColors.buttonStyle(context),),
  127. ),
  128. )
  129. ],
  130. ),
  131. ),
  132. );
  133. }
  134. }