123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_wallet/generated/l10n.dart';
- import 'package:flutter_wallet/login/YSChooseIntoType.dart';
- import 'package:flutter_wallet/tools/YSNetWork.dart';
- import 'package:flutter_wallet/tools/YSRefrehLoad.dart';
- import 'package:flutter_wallet/tools/YSSqflite.dart';
- import 'package:package_info_plus/package_info_plus.dart';
- import 'package:sqflite/sqflite.dart';
- import '../login/YSWalletCreate.dart';
- import '../login/YSWalletInto.dart';
- import '../wallet/view/YSWalletListItemView.dart';
- import 'YSColors.dart';
- import 'YSTools.dart';
- import 'YSVersionView.dart';
- class YSTipsAlertView2 extends StatefulWidget {
- final ValueSetter<bool> valueSetter;
- final String tipsStr;
- final String tipsStr2;
- final String? btnStr1;
- final String? btnStr2;
- const YSTipsAlertView2({Key? key, required this.valueSetter, this.tipsStr = '', this.tipsStr2 = '', this.btnStr1, this.btnStr2}) : super(key: key);
- @override
- YSTipsAlertView2State createState() => YSTipsAlertView2State();
- }
- class YSTipsAlertView2State extends State<YSTipsAlertView2> {
- @override
- Widget build(BuildContext context) {
- return Center(
- child: Container(
- width: ysWidth(context)-hsp(60),
- height: hsp(205),
- decoration: BoxDecoration(
- color: YSColors.backgroundColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(10))
- ),
- child: LayoutBuilder(
- builder: (context,conSize){
- return Column(
- children: [
- Padding(
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(top: hsp(30),bottom: hsp(15)),
- height: hsp(30),
- alignment: Alignment.center,
- child: Image.asset(YSColors.imageStyle(context, '警告'),height: hsp(30),width: hsp(30),)
- ),
- SizedBox(
- height: hsp(20),
- child: Text(widget.tipsStr,style: YSColors.contentStyle(context),maxLines: 3,overflow: TextOverflow.ellipsis,),
- ),
- Container(
- height: hsp(60),
- alignment: Alignment.center,
- child: Text(widget.tipsStr2,style: YSColors.subStyle(context),maxLines: 3,overflow: TextOverflow.ellipsis,),
- ),
- ],
- ),
- ),
- Container(
- height: hsp(50),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: 0.5))
- ),
- child: ListView.separated(
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- Navigator.pop(context);
- widget.valueSetter(index==1);
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- width: conSize.maxWidth/2-0.25,
- alignment: Alignment.center,
- child: Text(
- index==0?widget.btnStr1??S.current.FOU:widget.btnStr2??S.current.SHI,
- style: index==0?YSColors.contentStyle(context):TextStyle(fontSize: zsp(14),color: Colors.blue,
- fontWeight: FontWeight.normal,decoration: TextDecoration.none),
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Container(width: 0.5,color:YSColors.lineColor(context),);
- },
- itemCount: 2,
- scrollDirection: Axis.horizontal,
- ),
- )
- ],
- );
- },
- ),
- ),
- );
- }
- }
- class YSTipsAlertView extends StatefulWidget {
- final ValueSetter<bool> valueSetter;
- final String tipsStr;
- final String? btnStr1;
- final String? btnStr2;
- const YSTipsAlertView({Key? key, required this.valueSetter, this.tipsStr = '', this.btnStr1, this.btnStr2}) : super(key: key);
- @override
- YSTipsAlertViewState createState() => YSTipsAlertViewState();
- }
- class YSTipsAlertViewState extends State<YSTipsAlertView> {
- @override
- Widget build(BuildContext context) {
- return Center(
- child: Container(
- width: ysWidth(context)-hsp(60),
- height: hsp(150),
- decoration: BoxDecoration(
- color: YSColors.backgroundColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(10))
- ),
- child: LayoutBuilder(
- builder: (context,conSize){
- return Column(
- children: [
- Container(
- height: hsp(100),
- alignment: Alignment.center,
- padding: EdgeInsets.all(hsp(10)),
- child: Text(widget.tipsStr,style: YSColors.contentStyle(context),maxLines: 3,overflow: TextOverflow.ellipsis,),
- ),
- Container(
- height: hsp(50),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: 0.5))
- ),
- child: ListView.separated(
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- Navigator.pop(context);
- widget.valueSetter(index==1);
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- width: conSize.maxWidth/2-0.25,
- alignment: Alignment.center,
- child: Text(
- index==0?widget.btnStr1??S.current.FOU:widget.btnStr2??S.current.SHI,
- style: YSColors.contentStyle(context),
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Container(width: 0.5,color:YSColors.lineColor(context),);
- },
- itemCount: 2,
- scrollDirection: Axis.horizontal,
- ),
- )
- ],
- );
- },
- ),
- ),
- );
- }
- }
- class YSAlertMessage extends StatefulWidget {
- final Icon? icon;
- final String? message;
- final VoidCallback? callback;
- const YSAlertMessage({Key? key, this.icon, this.message, required this.callback}) : super(key: key);
- @override
- YSAlertMessageState createState() => YSAlertMessageState();
- }
- class YSAlertMessageState extends State<YSAlertMessage> {
- @override
- void initState() {
- Future.delayed(const Duration(seconds: 1)).then((value) {
- _clearAlert();
- });
- super.initState();
- }
- _clearAlert() {
- Navigator.pop(context);
- if(widget.callback!=null){
- widget.callback!();
- }
- }
- @override
- Widget build(BuildContext context) {
- return WillPopScope(
- onWillPop: () async{
- return false;
- },
- child: Center(
- child: GestureDetector(
- onTap: (){
- // _clearAlert();
- },
- child: Container(
- height: hsp(150),
- width: hsp(150),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- color: YSColors.alertColor(context)
- ),
- alignment: Alignment.center,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- widget.icon??Icon(Icons.check,size: hsp(50),color: YSColors.contain2Color(context),),
- Padding(
- padding: EdgeInsets.only(top: hsp(5)),
- child: Text(widget.message??'验证成功',style: YSColors.content2Style(context),),
- )
- ],
- ),
- ),
- ),
- ),
- );
- }
- }
- class YSChooseWalletType extends StatelessWidget {
- final bool isHome;
- const YSChooseWalletType({Key? key, this.isHome = false}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Container(
- width: ysWidth(context),
- height: hsp(300),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(35),topLeft: Radius.circular(35))
- ),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(top: hsp(15)),
- height: hsp(4),
- width: hsp(71),
- decoration: BoxDecoration(
- color: YSColors.lineColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(50))
- ),
- ),
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- child: Text(S.current.QIANBAOGUANLI2,style: YSColors.titleStyle(context),),
- ),
- Padding(
- padding: EdgeInsets.only(top: hsp(10)),
- child: SizedBox(
- width: ysWidth(context)-hsp(40),
- child: ListView.separated(
- itemBuilder: (context,index){
- return Container(
- padding: EdgeInsets.all(hsp(15)),
- decoration: BoxDecoration(
- color: index==0?Colors.white:Colors.black,
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- boxShadow: [
- BoxShadow(color: YSColors.shadowColor(context),blurRadius: 3)
- ]
- ),
- child: Row(
- children: [
- Image.asset(YSColors.imageStyle(context, index==0?'信用卡 2':'资管信托 2'),height: hsp(40),width: hsp(60),),
- Expanded(
- child: Padding(
- padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- index==0?S.current.MEIYOUQIANBAO:S.current.YIYOUQIANBAO,
- style: index==0?YSColors.contentStyle(context):YSColors.content2Style(context),
- ),
- Text(
- index==0?S.current.CHUANGJIANQUKUAILIANQIANBAO:S.current.DAORUQIANBAO,
- style: YSColors.subStyle(context),
- )
- ],
- ),
- )
- ),
- GestureDetector(
- onTap: (){
- if(isHome==false)Navigator.of(context).pop();
- if(index==0){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSWalletCreate();
- })
- );
- }else{
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSChooseIntoType();
- })
- );
- }
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- height: hsp(30),
- width: hsp(120),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- color: index==0?Colors.black:Colors.white
- ),
- alignment: Alignment.center,
- child: Text(
- index==0?S().CHUANGJIANQIANBAO:S().DAORUQIANBAO,
- style: index==0?YSColors.sub2Style(context):YSColors.sub4Style(context),
- ),
- ),
- )
- ],
- ),
- );
- },
- separatorBuilder: (context,index){
- return Container(height: hsp(25),);
- },
- itemCount: 2,
- shrinkWrap: true,
- padding: const EdgeInsets.all(0),
- physics: const NeverScrollableScrollPhysics(),
- ),
- ),
- )
- ],
- ),
- );
- }
- }
- ///TODO::网络选择
- class YSWalletNetView extends StatefulWidget {
- final ValueSetter? valueSetter;
- const YSWalletNetView({Key? key, this.valueSetter}) : super(key: key);
- @override
- YSWalletNetViewState createState() => YSWalletNetViewState();
- }
- class YSWalletNetViewState extends State<YSWalletNetView> {
- @override
- Widget build(BuildContext context) {
- return Container(
- height: hsp(400),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(49),
- alignment: Alignment.center,
- child: Text(S.current.XUANZEWANGLUO,style: YSColors.titleStyle(context),),
- ),
- Divider(height: hsp(1),color: YSColors.lineColor(context),),
- SizedBox(
- height: hsp(350),
- child: YSRefreshLoad(
- url: 'chains',
- request: const {},
- postData: (value) {
- YSData().typeArray = value;
- setState(() {});
- },
- child: ListView.separated(
- itemBuilder: (context,index){
- Map item = YSData().typeArray[index];
- bool isChoose = item['id'] == YSData().typeId;
- return GestureDetector(
- onTap: () async{
- if(widget.valueSetter!=null){
- widget.valueSetter!(item);
- }else{
- YSData().chooseIndex++;
- YSData().typeId = item['id'];
- setState(() {});
- YSData().exName = item['name'];
- List nodes = item['nodes']??[];
- if(nodes.isNotEmpty){
- YSData().rpc = nodes.first['rpc_url'];
- }
- YSSharedPreferences.setStringValue('typeId', item['id']);
- YSSharedPreferences.setStringValue('typeName', item['name']);
- YSSqflite sq = YSSqflite().init();
- List array = await sq.rawQuery();
- if(!mounted)return;
- if(array.isNotEmpty){
- LogUtil.d(array);
- Map wallet= array.firstWhere((element) => element['chooseType']==1,orElse: ()=>{});
- if(wallet.isEmpty)wallet = array.first;
- YSData().wallet = wallet;
- YSSqflite.notifier(context, array);
- addToken(context,kind: 1);
- checkAddress();
- }else{
- YSSqflite.notifier(context, array);
- }
- // getMindToken(context);
- }
- if(!mounted)return;
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- height: hsp(49),
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- child: Row(
- children: [
- SizedBox(
- height: hsp(40),
- width: hsp(40),
- child: YSImage.network(item['icon'],),
- ),
- Expanded(
- child: Text(' ${item['name']}',style: YSColors.contentStyle(context),)
- ),
- if(isChoose)Image.asset(YSColors.imageStyle(context, '矩形2'),height: hsp(15),width: hsp(15),),
- ],
- ),
- ),
- );
- },
- separatorBuilder: (context,index){
- return Divider(height: hsp(1),color: YSColors.lineColor(context),);
- },
- itemCount: YSData().typeArray.length
- ),
- ),
- )
- ],
- ),
- );
- }
- }
- class YSLoadView extends StatefulWidget {
- final Function() funAction;
- final Map wallet;
- final String? successStr;
- final String? failStr;
- final ValueSetter? valueSetter;
- const YSLoadView({Key? key, required this.funAction, required this.wallet, this.successStr, this.failStr, this.valueSetter}) : super(key: key);
- @override
- YSLoadViewState createState() => YSLoadViewState();
- }
- class YSLoadViewState extends State<YSLoadView> {
- int _type = 3;
- final TextEditingController _editingController = TextEditingController();
- @override
- void dispose() {
- _editingController.dispose();
- super.dispose();
- }
- _postFunction() async{
- bool result = await widget.funAction();
- if(result){
- _type = 1;
- }else{
- _type = 2;
- }
- setState(() {});
- Future.delayed(const Duration(seconds: 1)).then((value) {
- Navigator.pop(context);
- if(widget.valueSetter!=null){
- widget.valueSetter!(_type);
- }
- });
- }
- @override
- Widget build(BuildContext context) {
- return WillPopScope(
- onWillPop: () async{
- return true;
- },
- child: Padding(
- padding:EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom,),
- child: Center(
- child: _type==3?Container(
- height: hsp(200),
- width: ysWidth(context)-hsp(100),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(49),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- alignment: Alignment.center,
- child: Text(S.current.MIMAYANZHENG,style: YSColors.contentStyle(context),),
- ),
- Container(
- height: hsp(100),
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15),top: hsp(25),bottom: hsp(25)),
- child: CupertinoTextField(
- placeholder: S.current.QINGSHURMIMA,
- style: YSColors.contentStyle(context),
- padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
- controller: _editingController,
- obscureText: true
- ),
- ),
- Container(
- height: hsp(49),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- child: Row(
- children: [
- Expanded(child: GestureDetector(
- onTap: (){
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.opaque,
- child: Align(
- alignment: Alignment.center,
- child: Text(S.current.QUXIAO,style: YSColors.contentStyle(context),),
- ),
- )),
- Container(width: hsp(1),color: YSColors.lineColor(context),),
- Expanded(child: GestureDetector(
- onTap: (){
- FocusScope.of(context).unfocus();
- if(_editingController.text.isEmpty){
- ysFlutterToast(S.current.MIMABUNENGWEIKONG);
- return;
- }
- if(_editingController.text!=widget.wallet['password']){
- ysFlutterToast(S.current.MIMACUOWU);
- return;
- }
- _type = 0;
- setState(() {});
- _postFunction();
- },
- behavior: HitTestBehavior.opaque,
- child: Align(
- alignment: Alignment.center,
- child: Text(S.current.QUEDING,style: YSColors.contentStyle(context),),
- ),
- ))
- ],
- ),
- ),
- ],
- ),
- ):Container(
- height: hsp(150),
- width: hsp(150),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- color: YSColors.alertColor(context)
- ),
- alignment: Alignment.center,
- child: _type==0?CircularProgressIndicator(
- color: YSColors.containColor(context),
- ):Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(_type==1?Icons.check:Icons.error,size: hsp(50),color: YSColors.contain2Color(context),),
- Padding(
- padding: EdgeInsets.only(top: hsp(5)),
- child: Text(_type==1?(widget.successStr??S.current.ZHUANZHANGTIJIAOCHENGGONG):(widget.failStr??S.current.ZHUANZHANGTIJIAOSHIBAI),style: YSColors.content2Style(context),),
- )
- ],
- ),
- ),
- ),
- ),
- );
- }
- }
- class YSLoadView2 extends StatefulWidget {
- final Function() funAction;
- final ValueSetter? valueSetter;
- final String? successStr;
- final String? failStr;
- const YSLoadView2({Key? key, required this.funAction, this.valueSetter, this.successStr, this.failStr}) : super(key: key);
- @override
- YSLoadView2State createState() => YSLoadView2State();
- }
- class YSLoadView2State extends State<YSLoadView2> {
- int _type = 0;
- _postFunction() async{
- bool result = await widget.funAction();
- if(result){
- _type = 1;
- }else{
- _type = 2;
- }
- setState(() {});
- Future.delayed(const Duration(seconds: 0)).then((value) {
- widget.valueSetter!(result);
- Navigator.pop(context);
- });
- }
- @override
- void initState() {
- _postFunction();
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Center(
- child: Container(
- height: hsp(150),
- width: hsp(150),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- color: YSColors.alertColor(context)
- ),
- alignment: Alignment.center,
- child: _type==0?CircularProgressIndicator(
- color: YSColors.containColor(context),
- ):Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(_type==1?Icons.check:Icons.error,size: hsp(50),color: YSColors.contain2Color(context),),
- Padding(
- padding: EdgeInsets.only(top: hsp(5)),
- child: Text(_type==1?(widget.successStr??S.current.ZHUANZHANGTIJIAOCHENGGONG):(widget.failStr??S.current.ZHUANZHANGTIJIAOSHIBAI),style: YSColors.content2Style(context),),
- )
- ],
- ),
- ),
- );
- }
- }
- class YSChooseCheckView extends StatelessWidget {
- final ValueSetter<bool> valueSetter;
- const YSChooseCheckView({Key? key, required this.valueSetter}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Container(
- height: hsp(150),
- width: ysWidth(context),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- child: Text('类 型 选 择',style: TextStyle(fontSize: zsp(18),color: Colors.black),),
- ),
- SizedBox(
- height: hsp(100),
- child: ListView.builder(
- itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- if(index==0){
- }else{
- }
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- height: hsp(50),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- child: Text('指纹验证',style: YSColors.contentStyle(context),),
- ),
- );
- },
- itemCount: 2,
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- ),
- )
- ],
- ),
- );
- }
- }
- class YSInputPasswordView extends StatefulWidget {
- final Map wallet;
- final VoidCallback callback;
- const YSInputPasswordView({Key? key, required this.wallet, required this.callback}) : super(key: key);
- @override
- YSInputPasswordViewState createState() => YSInputPasswordViewState();
- }
- class YSInputPasswordViewState extends State<YSInputPasswordView> {
- final TextEditingController _editingController = TextEditingController();
- @override
- void dispose() {
- _editingController.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Center(
- child: Padding(
- padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom,),
- child: Container(
- height: hsp(200),
- width: ysWidth(context)-hsp(100),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(49),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- alignment: Alignment.center,
- child: Text(S.current.MIMAYANZHENG,style: YSColors.contentStyle(context),),
- ),
- Container(
- height: hsp(100),
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15),top: hsp(25),bottom: hsp(25)),
- child: CupertinoTextField(
- placeholder: S.current.QINGSHURMIMA,
- style: YSColors.contentStyle(context),
- padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
- controller: _editingController,
- obscureText: true
- ),
- ),
- Container(
- height: hsp(49),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- child: Row(
- children: [
- Expanded(child: GestureDetector(
- onTap: (){
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.opaque,
- child: Align(
- alignment: Alignment.center,
- child: Text(S.current.QUXIAO,style: YSColors.contentStyle(context),),
- ),
- )),
- Container(width: hsp(1),color: YSColors.lineColor(context),),
- Expanded(child: GestureDetector(
- onTap: (){
- if(_editingController.text.isEmpty){
- ysFlutterToast(S.current.MIMABUNENGWEIKONG);
- return;
- }
- if(_editingController.text!=widget.wallet['password']){
- ysFlutterToast(S.current.MIMACUOWU);
- return;
- }
- Navigator.pop(context);
- widget.callback();
- },
- behavior: HitTestBehavior.opaque,
- child: Align(
- alignment: Alignment.center,
- child: Text(S.current.QUEDING,style: YSColors.contentStyle(context),),
- ),
- ))
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
- }
- class YSInputNetView extends StatefulWidget {
- final ValueSetter valueSetter;
- const YSInputNetView({Key? key, required this.valueSetter}) : super(key: key);
- @override
- YSInputNetViewState createState() => YSInputNetViewState();
- }
- class YSInputNetViewState extends State<YSInputNetView> {
- final TextEditingController _editingController = TextEditingController();
- @override
- void dispose() {
- _editingController.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Center(
- child: Padding(
- padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom,),
- child: Container(
- height: hsp(200),
- width: ysWidth(context)-hsp(100),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(49),
- alignment: Alignment.center,
- child: Text('添加自定义节点',style: YSColors.contentStyle(context),),
- ),
- Container(
- height: hsp(100),
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15),top: hsp(10),bottom: hsp(10)),
- child: CupertinoTextField(
- placeholder: '请输入节点地址',
- style: YSColors.subStyle(context),
- padding: EdgeInsets.all(hsp(10)),
- controller: _editingController,
- decoration: BoxDecoration(
- color: YSColors.backgroundColor(context),
- borderRadius: const BorderRadius.all(Radius.circular(5))
- ),
- maxLines: 10,
- ),
- ),
- Container(
- height: hsp(49),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: hsp(1)))
- ),
- child: Row(
- children: [
- Expanded(child: GestureDetector(
- onTap: (){
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.opaque,
- child: Align(
- alignment: Alignment.center,
- child: Text(S.current.QUXIAO,style: YSColors.contentStyle(context),),
- ),
- )),
- Container(width: hsp(1),color: YSColors.lineColor(context),),
- Expanded(child: GestureDetector(
- onTap: (){
- if(_editingController.text.isEmpty){
- ysFlutterToast('节点不能为空');
- return;
- }
- widget.valueSetter(_editingController.text);
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.opaque,
- child: Align(
- alignment: Alignment.center,
- child: Text(S.current.QUEDING,style: YSColors.contentStyle(context),),
- ),
- ))
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
- }
- ///TODO::兑换选择
- class YSExchangeTypeChooseView1 extends StatefulWidget {
- final Map? item;
- final ValueSetter valueSetter;
- const YSExchangeTypeChooseView1({Key? key, required this.valueSetter, this.item}) : super(key: key);
- @override
- YSExchangeTypeChooseView1State createState() => YSExchangeTypeChooseView1State();
- }
- class YSExchangeTypeChooseView1State extends State<YSExchangeTypeChooseView1> with SingleTickerProviderStateMixin{
- List _titles = [];
- TabController? _tabController;
- @override
- void initState() {
- _getTitleArray();
- super.initState();
- }
- _getTitleArray() {
- _titles = YSData().typeArray;
- LogUtil.d(_titles);
- _tabController = TabController(length: _titles.length, vsync: this);
- }
- @override
- Widget build(BuildContext context) {
- return Container(
- height: hsp(500),
- width: ysWidth(context),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: _tabController!=null?DefaultTabController(
- length: _titles.length,
- child: Column(
- children: [
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- child: Text('钱 包 选 择',style: TextStyle(fontSize: zsp(18),color: Colors.black),),
- ),
- widget.item==null?Column(
- children: [
- Container(
- height: hsp(50),
- width: ysWidth(context),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: hsp(0)),bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(0)))
- ),
- child: TabBar(
- controller: _tabController,
- indicatorColor: Colors.transparent,
- indicatorWeight: hsp(1),
- isScrollable: true,
- labelPadding: EdgeInsets.only(left: hsp(15)),
- labelColor: YSColors.selectedColor(context),
- unselectedLabelColor: YSColors.unSelectedColor(context),
- tabs: _titles.map((f) {
- return Tab(
- child: Container(
- padding: EdgeInsets.only(left: hsp(10),right: hsp(10),top: hsp(5),bottom: hsp(5)),
- child: Text(f['token_sort_name']),
- ),
- );
- }).toList(),
- ),
- ),
- SizedBox(
- height: hsp(400),
- child: TabBarView(
- controller: _tabController,
- children: _titles.map((f) {
- return YSAlertChooseWalletListView(item: f, valueSetter: (value) {
- value['parentName'] = f['name'];
- value['parentIcon'] = f['icon'];
- List nodes = f['nodes']??[];
- if(nodes.isNotEmpty){
- value['parentRpc'] = nodes.first['rpc_url'];
- }
- widget.valueSetter(value);
- Navigator.pop(context);
- },);
- }).toList(),
- ),
- )
- ],
- ):YSAlertChooseWalletListView(item: {'icon':widget.item?['parentIcon'],'name':widget.item?['parentName']}, valueSetter: (value) {
- widget.valueSetter(value);
- Navigator.pop(context);
- },)
- ],
- ),
- ):Container(),
- );
- }
- }
- class YSAlertChooseWalletListView extends StatefulWidget {
- final ValueSetter valueSetter;
- final Map item;
- const YSAlertChooseWalletListView({Key? key, required this.item, required this.valueSetter}) : super(key: key);
- @override
- YSAlertChooseWalletListViewState createState() => YSAlertChooseWalletListViewState();
- }
- class YSAlertChooseWalletListViewState extends State<YSAlertChooseWalletListView> {
- List _dataArray = [];
- @override
- void initState() {
- _getWalletData();
- super.initState();
- }
- _getWalletData() async{
- _dataArray = await YSSqflite().init().rawQuery(name: widget.item['name']);
- setState(() {});
- }
- @override
- Widget build(BuildContext context) {
- return ListView.builder(
- itemBuilder: (context, index) {
- Map item = _dataArray[index];
- return Container(
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15),top: hsp(10),bottom: hsp(10)),
- alignment: Alignment.centerLeft,
- child: Row(
- children: [
- ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(50)),
- child: YSImage.network(widget.item['icon'],height: hsp(40),width: hsp(40),),
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(top: hsp(5),bottom: hsp(5),left: hsp(5),right: hsp(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(item['name']??'',style: YSColors.contentStyle(context),maxLines: 1,),
- Padding(
- padding: EdgeInsets.only(top: hsp(5)),
- child: Text(ysTextCut(item['public']),style: YSColors.subStyle(context),)
- )
- ],
- ),
- )
- ),
- GestureDetector(
- onTap: () async{
- widget.valueSetter({'icon_url':widget.item['icon'],'bl_symbol':widget.item['name'],'address':item['public'],'private':item['private']});
- },
- child: Icon(Icons.add_circle_outline,size: hsp(20),color: Colors.blue,),
- )
- ],
- )
- );
- },
- itemCount: _dataArray.length,
- padding: const EdgeInsets.all(0),
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- );
- }
- }
- class YSExchangeTypeChooseView2 extends StatefulWidget {
- final ValueSetter valueSetter;
- const YSExchangeTypeChooseView2({Key? key, required this.valueSetter}) : super(key: key);
- @override
- YSExchangeTypeChooseView2State createState() => YSExchangeTypeChooseView2State();
- }
- class YSExchangeTypeChooseView2State extends State<YSExchangeTypeChooseView2> with SingleTickerProviderStateMixin{
- List _titles = [];
- TabController? _tabController;
- List _dataArray = [];
- Map _type = {};
- @override
- void initState() {
- _getTitleArray();
- super.initState();
- }
- _getTitleArray() {
- _titles = YSData().typeArray;
- _tabController = TabController(length: _titles.length, vsync: this);
- _type = _titles.firstWhere((element) => element['id']==YSData().typeId);
- }
- @override
- Widget build(BuildContext context) {
- return Container(
- height: hsp(500),
- width: ysWidth(context),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: _tabController!=null?DefaultTabController(
- length: _titles.length,
- child: false?Column(
- children: [
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- child: Text('类 型 选 择',style: TextStyle(fontSize: zsp(18),color: Colors.black),),
- ),
- Container(
- height: hsp(50),
- width: ysWidth(context),
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: YSColors.lineColor(context),width: hsp(0)),bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(0)))
- ),
- child: TabBar(
- controller: _tabController,
- indicatorColor: Colors.transparent,
- indicatorWeight: hsp(1),
- isScrollable: true,
- labelPadding: EdgeInsets.only(left: hsp(15)),
- labelColor: YSColors.selectedColor(context),
- unselectedLabelColor: YSColors.unSelectedColor(context),
- tabs: _titles.map((f) {
- return Tab(
- child: Container(
- padding: EdgeInsets.only(left: hsp(10),right: hsp(10),top: hsp(5),bottom: hsp(5)),
- child: Text(f['token_sort_name']),
- ),
- );
- }).toList(),
- ),
- ),
- SizedBox(
- height: hsp(400),
- child: TabBarView(
- controller: _tabController,
- children: _titles.map((f) {
- return YSRefreshLoad(
- url: 'tokens',
- request: {'chain_id':f['id']},
- postData: (value) {
- _dataArray = value;
- setState(() {});
- },
- isLoading: false,
- child: ListView.builder(
- itemBuilder: (context, index) {
- Map item = _dataArray[index];
- return YSWalletListChooseItemView(item: item,valueSetter: (value){
- value['parentName'] = f['name'];
- value['parentIcon'] = f['icon'];
- List nodes = f['nodes']??[];
- if(nodes.isNotEmpty){
- value['parentRpc'] = nodes.first['rpc_url'];
- }
- widget.valueSetter(value);
- Navigator.pop(context);
- },);
- },
- itemCount: _dataArray.length,
- padding: const EdgeInsets.all(0),
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- ),
- );
- }).toList(),
- ),
- )
- ],
- ):Column(
- children: [
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- child: Text('类 型 选 择',style: TextStyle(fontSize: zsp(18),color: Colors.black),),
- ),
- SizedBox(
- height: hsp(450),
- child: YSRefreshLoad(
- url: 'tokens',
- request: {'chain_id':YSData().typeId},
- postData: (value) {
- _dataArray = value;
- setState(() {});
- },
- isLoading: false,
- child: ListView.builder(
- itemBuilder: (context, index) {
- Map item = _dataArray[index];
- return YSWalletListChooseItemView(item: item,valueSetter: (value){
- value['parentName'] = _type['name'];
- value['parentIcon'] = _type['icon'];
- List nodes = _type['nodes']??[];
- if(nodes.isNotEmpty){
- value['parentRpc'] = nodes.first['rpc_url'];
- }
- widget.valueSetter(value);
- Navigator.pop(context);
- },);
- },
- itemCount: _dataArray.length,
- padding: const EdgeInsets.all(0),
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- ),
- ),
- )
- ],
- ),
- ):Container(),
- );
- }
- }
- ///TODO::跨链选择
- class YSCrossCoinChooseView extends StatefulWidget {
- final ValueSetter valueSetter;
- const YSCrossCoinChooseView({Key? key, required this.valueSetter}) : super(key: key);
- @override
- YSCrossCoinChooseViewState createState() => YSCrossCoinChooseViewState();
- }
- class YSCrossCoinChooseViewState extends State<YSCrossCoinChooseView> {
- List _dataArray = [];
- @override
- Widget build(BuildContext context) {
- return Container(
- height: hsp(400),
- width: ysWidth(context),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- child: Text('资 产 选 择',style: TextStyle(fontSize: zsp(18),color: Colors.black),),
- ),
- SizedBox(
- height: hsp(350),
- child: YSRefreshLoad(
- url: 'tokens',
- request: {'chain_id':YSData().typeId},
- postData: (value) {
- _dataArray = value;
- setState(() {});
- },
- isLoading: false,
- child: ListView.builder(
- itemBuilder: (context, index) {
- Map item = _dataArray[index];
- return GestureDetector(
- onTap: (){
- widget.valueSetter(item);
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.opaque,
- child: YSCrossListItemView(item: item,),
- );
- },
- itemCount: _dataArray.length,
- padding: const EdgeInsets.all(0),
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- ),
- ),
- )
- ],
- ),
- );
- }
- }
- class YSCrossAddressView extends StatefulWidget {
- final ValueSetter valueSetter;
- final Map item;
- const YSCrossAddressView({Key? key, required this.valueSetter, required this.item}) : super(key: key);
- @override
- YSCrossAddressViewState createState() => YSCrossAddressViewState();
- }
- class YSCrossAddressViewState extends State<YSCrossAddressView> {
- @override
- Widget build(BuildContext context) {
- return Container(
- height: hsp(400),
- width: ysWidth(context),
- decoration: BoxDecoration(
- color: YSColors.containColor(context),
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
- ),
- child: Column(
- children: [
- Container(
- height: hsp(50),
- alignment: Alignment.center,
- child: Text('类 型 选 择',style: TextStyle(fontSize: zsp(18),color: Colors.black),),
- ),
- SizedBox(
- height: hsp(350),
- child: YSAlertChooseWalletListView(item: widget.item, valueSetter: (value) {
- widget.valueSetter(value);
- Navigator.pop(context);
- },),
- )
- ],
- ),
- );
- ;
- }
- }
- class YSCrossListItemView extends StatefulWidget {
- final Map item;
- const YSCrossListItemView({Key? key, required this.item}) : super(key: key);
- @override
- YSCrossListItemViewState createState() => YSCrossListItemViewState();
- }
- class YSCrossListItemViewState extends State<YSCrossListItemView> {
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15),top: hsp(10),bottom: hsp(10)),
- alignment: Alignment.centerLeft,
- child: Row(
- children: [
- ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(50)),
- child: YSImage.network(widget.item['icon_url'],height: hsp(40),width: hsp(40),),
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(top: hsp(5),bottom: hsp(5),left: hsp(5),right: hsp(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(widget.item['name']??'',style: YSColors.contentStyle(context),maxLines: 1,),
- Padding(
- padding: EdgeInsets.only(top: hsp(5)),
- child: Text(ysTextCut(widget.item['address']),style: YSColors.subStyle(context),)
- )
- ],
- ),
- )
- ),
- ],
- )
- );
- }
- }
- ///版本更新
- getVersionData(BuildContext context,Map data) async{
- if(data.isNotEmpty){
- PackageInfo packageInfo = await PackageInfo.fromPlatform();
- if(int.parse(packageInfo.buildNumber)<data['build']){
- // ignore: use_build_context_synchronously
- ysShowCenterAlertView(context, YSVersionView(
- title: 'v${data['version']}更新',
- content: data['txt'],
- url: data['url'],
- isBack: data['isForce']==0,
- ),isTrans: false,isBarr: data['isForce']==1);
- }
- }
- }
|