YSWalletRocChoose.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_wallet/base/YSBase.dart';
  3. import 'package:flutter_wallet/generated/l10n.dart';
  4. import 'package:flutter_wallet/tools/YSColors.dart';
  5. import 'package:flutter_wallet/tools/YSPingView.dart';
  6. import '../tools/YSAlertView.dart';
  7. import '../tools/YSRefrehLoad.dart';
  8. import '../tools/YSTools.dart';
  9. class YSWalletRocChoose extends StatefulWidget {
  10. const YSWalletRocChoose({Key? key}) : super(key: key);
  11. @override
  12. YSWalletRocChooseState createState() => YSWalletRocChooseState();
  13. }
  14. class YSWalletRocChooseState extends State<YSWalletRocChoose> {
  15. List _dataArray = [];
  16. @override
  17. Widget build(BuildContext context) {
  18. return YSBase2(
  19. ysTitle: YSData().exName,
  20. ysChild: Column(
  21. children: [
  22. Container(
  23. margin: EdgeInsets.only(top: hsp(20)),
  24. width: ysWidth(context)-hsp(30),
  25. padding: EdgeInsets.all(hsp(10)),
  26. height: hsp(130),
  27. decoration: BoxDecoration(
  28. color: YSColors.containColor(context),
  29. borderRadius: const BorderRadius.all(Radius.circular(10))
  30. ),
  31. alignment: Alignment.center,
  32. child: Column(
  33. mainAxisSize: MainAxisSize.min,
  34. crossAxisAlignment: CrossAxisAlignment.start,
  35. children: [
  36. Row(
  37. children: [
  38. Text(S.current.JIEDIANSUDU,style: YSColors.contentStyle(context),),
  39. ],
  40. ),
  41. Padding(
  42. padding: EdgeInsets.only(top: hsp(5)),
  43. child: Text(S.current.QUKUAIGAODUGAODUZHIYUEDA,style: YSColors.subStyle(context),),
  44. )
  45. ],
  46. ),
  47. ),
  48. Container(
  49. height: hsp(40),
  50. width: ysWidth(context)-hsp(30),
  51. alignment: Alignment.centerLeft,
  52. child: Text(S.current.RUIJIANJIEDIAN,style: YSColors.content2Style(context),),
  53. ),
  54. Container(
  55. height: ysHeight(context)-ysTOP(context)-hsp(300),
  56. decoration: BoxDecoration(
  57. color: YSColors.containColor(context),
  58. borderRadius: const BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  59. ),
  60. width: ysWidth(context),
  61. child: YSRefreshLoad(
  62. url: 'rpcnodes',
  63. request: {'chain_id':YSData().typeId},
  64. postData: (value) {
  65. _dataArray = value;
  66. setState(() {});
  67. },
  68. child: ListView.builder(
  69. itemBuilder: (context, index) {
  70. Map item = _dataArray[index];
  71. bool isChoose = item['rpc_url']==YSData().rpc;
  72. return GestureDetector(
  73. onTap: (){
  74. if(!isChoose){
  75. YSData().rpc = item['rpc_url'];
  76. setState(() {});
  77. }
  78. },
  79. behavior: HitTestBehavior.opaque,
  80. child: Container(
  81. padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  82. decoration: BoxDecoration(
  83. border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
  84. ),
  85. child: Row(
  86. mainAxisSize: MainAxisSize.min,
  87. children: [
  88. Expanded(
  89. child: Column(
  90. mainAxisSize: MainAxisSize.min,
  91. crossAxisAlignment: CrossAxisAlignment.start,
  92. children: [
  93. Text(item['chain_name'],style: YSColors.contentStyle(context),),
  94. Padding(
  95. padding: EdgeInsets.only(top: hsp(5)),
  96. child: Text(item['rpc_url'],style: YSColors.subStyle(context),maxLines: 1,overflow: TextOverflow.ellipsis,),
  97. )
  98. ],
  99. )
  100. ),
  101. const YSPingView(),
  102. if(isChoose)Padding(
  103. padding: EdgeInsets.only(left: hsp(10)),
  104. child: Image.asset(YSColors.imageStyle(context, '矩形2'),height: hsp(15),width: hsp(15),color: YSColors.iconColor(context),),
  105. ),
  106. ],
  107. ),
  108. ),
  109. );
  110. },
  111. itemCount: _dataArray.length,
  112. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  113. shrinkWrap: true,
  114. physics: const NeverScrollableScrollPhysics(),
  115. ),
  116. ),
  117. ),
  118. GestureDetector(
  119. onTap: (){
  120. ysShowCenterAlertView(context, YSInputNetView(valueSetter: (value){
  121. YSData().rpc = value;
  122. }));
  123. },
  124. behavior: HitTestBehavior.opaque,
  125. child: Container(
  126. height: hsp(50),
  127. width: ysWidth(context)-hsp(40),
  128. decoration: BoxDecoration(
  129. color: YSColors.buttonColor(context),
  130. borderRadius: const BorderRadius.all(Radius.circular(10))
  131. ),
  132. alignment: Alignment.center,
  133. child: Text(S.current.RIANJIAZIDINGYIJIEDIAN,style: YSColors.buttonStyle(context),),
  134. ),
  135. )
  136. ],
  137. ),
  138. );
  139. }
  140. }