YSWalletExport.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import 'dart:convert';
  2. import 'dart:math';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_wallet/base/YSBase.dart';
  5. import 'package:flutter_wallet/generated/l10n.dart';
  6. import 'package:flutter_wallet/tools/YSColors.dart';
  7. import 'package:flutter_wallet/tools/YSTools.dart';
  8. import 'package:web3dart/credentials.dart';
  9. class YSWalletExport extends StatefulWidget {
  10. final Map wallet;
  11. const YSWalletExport({Key? key, required this.wallet}) : super(key: key);
  12. @override
  13. YSWalletExportState createState() => YSWalletExportState();
  14. }
  15. class YSWalletExportState extends State<YSWalletExport> with SingleTickerProviderStateMixin{
  16. final List _titleArray = [
  17. {'title':S.current.KEYSTOREWENJIAN,'type':1},
  18. {'title':S.current.ERWEIMA,'type':2}
  19. ];
  20. late TabController _tabController;
  21. String _store = '';
  22. @override
  23. void initState() {
  24. _getStore();
  25. _tabController = TabController(
  26. vsync: this,
  27. length: _titleArray.length,
  28. );
  29. super.initState();
  30. }
  31. _getStore() {
  32. Wallet wallet = Wallet.createNew(EthPrivateKey.fromHex(widget.wallet['private']), widget.wallet['password'], Random(100));
  33. _store = wallet.toJson();
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. LogUtil.d(widget.wallet);
  38. return YSBase(
  39. isBake: true,
  40. ysChild: Padding(
  41. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  42. child: DefaultTabController(
  43. length: _titleArray.length,
  44. child: Column(
  45. children: [
  46. SizedBox(
  47. height: hsp(45),
  48. child: TabBar(
  49. controller: _tabController,
  50. indicatorWeight: hsp(1),
  51. labelColor: Colors.blue,
  52. tabs: _titleArray.map((f) {
  53. return Tab(
  54. child: Text(f['title']),
  55. );
  56. }).toList(),
  57. ),
  58. ),
  59. Container(
  60. padding: EdgeInsets.only(top: hsp(20)),
  61. height: ysHeight(context)-ysTOP(context)-hsp(150),
  62. child: TabBarView(
  63. controller: _tabController,
  64. children: _titleArray.map((f) {
  65. return Align(
  66. alignment: Alignment.center,
  67. child: f['type']==1?Column(
  68. crossAxisAlignment: CrossAxisAlignment.start,
  69. children: [
  70. RichText(text: TextSpan(
  71. style: TextStyle(fontSize: zsp(20),color: Colors.blue),
  72. children: [
  73. TextSpan(
  74. text: '${S.current.LIXIANBAOCUN}\n'
  75. ),
  76. TextSpan(
  77. text: S.current.QINGFUZHIZHANTIE,
  78. style: TextStyle(fontSize: zsp(14),color: Colors.grey)
  79. ),
  80. TextSpan(
  81. text: '\n\n${S.current.QINGWUSHIYONGWANGLUO}\n'
  82. ),
  83. TextSpan(
  84. text: S.current.QINGWUTONGGYOWANGLUOGONGJU,
  85. style: TextStyle(fontSize: zsp(14),color: Colors.grey)
  86. ),
  87. TextSpan(
  88. text: '\n\n${S.current.MIMABAOXIANXIANGBAOCUN}\n'
  89. ),
  90. TextSpan(
  91. text: '${S.current.RUXUZAIXIANBAOCUN}\n',
  92. style: TextStyle(fontSize: zsp(14),color: Colors.grey)
  93. )
  94. ]
  95. )),
  96. Container(
  97. height: hsp(200),
  98. decoration: BoxDecoration(
  99. color: YSColors.lineColor(context),
  100. borderRadius: const BorderRadius.all(Radius.circular(10))
  101. ),
  102. padding: EdgeInsets.all(hsp(15)),
  103. child: Text(_store,style: TextStyle(fontSize: zsp(14),color: Colors.grey),),
  104. ),
  105. GestureDetector(
  106. onTap: (){
  107. YSCopyPaste.copy(_store);
  108. },
  109. behavior: HitTestBehavior.opaque,
  110. child: Container(
  111. margin: EdgeInsets.only(top: hsp(50)),
  112. height: hsp(50),
  113. alignment: Alignment.center,
  114. decoration: BoxDecoration(
  115. color: YSColors.buttonColor(context),
  116. borderRadius: const BorderRadius.all(Radius.circular(5))
  117. ),
  118. child: Text(S.current.FUZHI,style: YSColors.buttonStyle(context),),
  119. ),
  120. )
  121. ],
  122. ):Column(
  123. crossAxisAlignment: CrossAxisAlignment.start,
  124. children: [
  125. RichText(text: TextSpan(
  126. style: TextStyle(fontSize: zsp(20),color: Colors.blue),
  127. children: [
  128. TextSpan(
  129. text: '${S.current.JINGONGZHIJIESAOMIAO}\n'
  130. ),
  131. TextSpan(
  132. text: S.current.ERWEIMAJINZHIBAOCUN,
  133. style: TextStyle(fontSize: zsp(14),color: Colors.grey)
  134. ),
  135. TextSpan(
  136. text: '\n\n${S.current.ZAIANQUANHUANJING}\n'
  137. ),
  138. TextSpan(
  139. text: '${S.current.ZAIANQUANHUANJINGSHIYONGQINGZAIQUEBAO}\n',
  140. style: TextStyle(fontSize: zsp(14),color: Colors.grey)
  141. )
  142. ]
  143. )),
  144. Align(
  145. alignment: Alignment.center,
  146. child: SizedBox(
  147. height: hsp(200),
  148. width: hsp(200),
  149. child: YSCodeImage.codeImage(_store),
  150. ),
  151. )
  152. ],
  153. ),
  154. );
  155. }).toList(),
  156. ),
  157. ),
  158. ],
  159. ),
  160. ),
  161. ),
  162. );
  163. }
  164. }