123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014 |
- import 'dart:async';
- import 'dart:ui';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_wallet/tools/YSAlertView.dart';
- import 'package:flutter_wallet/tools/YSColors.dart';
- import 'package:flutter_wallet/tools/YSSqflite.dart';
- import 'package:flutter_wallet/tools/YSTools.dart';
- import 'package:flutter_wallet/wallet/YSMessage.dart';
- import 'package:flutter_wallet/wallet/YSWalletCollection.dart';
- import 'package:flutter_wallet/wallet/YSWalletManager.dart';
- import 'package:flutter_wallet/wallet/YSWalletTokenChoose.dart';
- import 'package:flutter_wallet/wallet/YSWalletTransfer.dart';
- import 'package:flutter_wallet/wallet/view/YSWalletListItemView.dart';
- import 'package:provider/provider.dart';
- import 'package:skeletons/skeletons.dart';
- import '../base/YSTabBar.dart';
- import '../generated/l10n.dart';
- import '../login/YSWalletSetting.dart';
- import '../login/view/YSHelpView.dart';
- import '../tools/YSBip.dart';
- import '../tools/YSNetWork.dart';
- import 'YSWalletDetail.dart';
- class YSWallet extends StatefulWidget {
- const YSWallet({Key? key}) : super(key: key);
- @override
- YSWalletState createState() => YSWalletState();
- }
- class YSWalletState extends State<YSWallet> with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin{
- final List _titles = [
- {'title':'资产','type':0},
- {'title':'藏品','type':1},
- ];
- bool _isShow = true;
- late TabController _tabController;
- // int _refeshIndex = 0;
- Map _wallet = {};
- Timer? _timer;
- @override
- void initState() {
- _tabController = TabController(
- vsync: this,
- length: _titles.length,
- );
- _getWalletData();
- _startTime();
- checkAddress();
- super.initState();
- }
- _startTime() {
- // _timer = Timer.periodic(const Duration(seconds: 1), (timer) async{
- // _refreshData();
- // });
- }
- _getPriceData() {
- YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'tokens', parameter: {'chain_id':YSData().typeId,'page':1,'count':100}, successSetter: (dict) async{
- YSData().allTokenArray = dict['data']['list']??[];
- addToken(context);
- getMindToken(context);
- });
- }
- _getSymbolData() {
- List array = YSData().typeArray.where((element) => element['id']==YSData().typeId).toList();
- if(array.isNotEmpty){
- Map map = array.first;
- YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'prices', parameter: {'symbol':map['token_name'],'page':1,'count':5}, successSetter: (dict) async{
- YSData().priceArray = dict['data']['list']??[];
- });
- }
- }
- _refreshData() async{
- List array = YSData().typeArray.where((element) => element['id']==YSData().typeId).toList();
- if(array.isNotEmpty){
- Map map = array.first;
- YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'prices', parameter: {'symbol':map['token_name'],'page':1,'count':5}, successSetter: (dict) async{
- YSData().priceArray = dict['data']['list']??[];
- YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'tokens', parameter: {'chain_id':YSData().typeId,'page':1,'count':100}, successSetter: (dict) async{
- YSData().allTokenArray = dict['data']['list']??[];
- _getTokenArray();
- });
- });
- }
- }
- _getWalletData() async{
- YSSqflite sqflite = YSSqflite().init();
- List walletArray = await sqflite.rawQuery();
- if(!mounted)return;
- YSSqflite.notifier(context, walletArray);
- if(walletArray.isNotEmpty){
- YSData().wallet = walletArray.first;
- _getPriceData();
- }
- }
- @override
- void dispose() {
- if(_timer!=null){
- _timer?.cancel();
- }
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- super.build(context);
- List _menuArray = [
- {'title':S.current.ZHUANZHANG,'type':1},
- {'title':S.current.SHOUKUAN,'type':2},
- {'title':S.current.SHANDUI,'type':3}
- ];
- YSData().context = context;
- return Scaffold(
- body: SingleChildScrollView(
- child: Consumer2(
- builder: (context,YSWalletNotifier value,YSTokenNotifier value2,child) {
- _getSymbolData();
- if(value.walletArray.isNotEmpty){
- _wallet = value.walletArray.firstWhere((element) => element['chooseType']==1,orElse: ()=>{});
- if(_wallet.isEmpty)_wallet = value.walletArray.first;
- }else{
- _wallet.clear();
- }
- YSData().wallet = _wallet;
- YSData().tokenArray = value2.value;
- // _getTokenArray();
- return Skeleton(
- isLoading: YSData().isLoad==false,
- skeleton: Stack(
- children: [
- Column(
- children: [
- SkeletonAvatar(
- style: SkeletonAvatarStyle(
- width: double.infinity,
- height: hsp(250)
- ),
- ),
- SizedBox(
- height: hsp(50),
- child: Row(
- children: [
- Expanded(child: Center(
- child: SkeletonLine(
- style: SkeletonLineStyle(
- height: 15,
- width: 50,
- borderRadius: BorderRadius.circular(8),
- alignment: AlignmentDirectional.center
- ),
- ),
- )),
- Expanded(child: Center(
- child: SkeletonLine(
- style: SkeletonLineStyle(
- height: 15,
- width: 50,
- borderRadius: BorderRadius.circular(8),
- alignment: AlignmentDirectional.center
- ),
- ),
- )),
- ],
- ),
- ),
- Container(
- width: ysWidth(context),
- padding: EdgeInsets.only(left: hsp(15)),
- child: ListView.separated(
- itemBuilder: (context,index){
- return Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SkeletonAvatar(
- style: SkeletonAvatarStyle(
- shape: BoxShape.circle, width: 50, height: 50),
- ),
- const SizedBox(width: 8),
- Expanded(
- child: SkeletonParagraph(
- style: SkeletonParagraphStyle(
- lines: 2,
- spacing: 10,
- lineStyle: SkeletonLineStyle(
- randomLength: true,
- height: 10,
- borderRadius: BorderRadius.circular(8),
- minLength: MediaQuery.of(context).size.width / 6,
- maxLength: MediaQuery.of(context).size.width / 3,
- )
- ),
- ),
- ),
- Expanded(
- child: SkeletonParagraph(
- style: SkeletonParagraphStyle(
- lines: 1,
- lineStyle: SkeletonLineStyle(
- alignment: AlignmentDirectional.centerEnd,
- randomLength: true,
- height: 10,
- borderRadius: BorderRadius.circular(8),
- minLength: MediaQuery.of(context).size.width / 6,
- maxLength: MediaQuery.of(context).size.width / 3,
- )
- ),
- ),
- )
- ],
- );
- },
- separatorBuilder: (context,index){
- return Container(height: hsp(20),);
- },
- itemCount: 3,
- shrinkWrap: true,
- padding: const EdgeInsets.all(0),
- physics: const NeverScrollableScrollPhysics(),
- ),
- ),
- ],
- )
- ],
- ),
- child: LayoutBuilder(
- builder: (context,conSize) {
- return Stack(
- children: [
- const YSHeadView(),
- Padding(
- padding: EdgeInsets.only(top: ysTOP(context)+hsp(10)),
- child: Column(
- children: [
- Container(
- height: hsp(50),
- padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- onTap: () async{
- // ysShowCenterAlertView(context, YSLoadView2(funAction: () async{
- // return await YSBipManager.setMnemonic('habit benefit gallery egg movie moon crumble topple side found aim cement');
- // },valueSetter: (isDone) async{
- // if(isDone&&mounted){
- // if(YSData().isManager){
- // List array = await YSSqflite().rawQuery();
- // if(!mounted)return;
- // YSSqflite.notifier(context, array);
- // Navigator.popUntil(context, ModalRoute.withName("YSWalletManager"));
- // }else{
- // Navigator.of(context).pushAndRemoveUntil(CupertinoPageRoute(builder: (context){
- // return const YSTabBar();
- // }), (route) => false);
- // }
- // }
- // },));
- // return;
- // YSFileWriteRead().readContent();
- // YSFileWriteRead().writeContent('content');
- // return;
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSMessage();
- })
- );
- // Navigator.of(context).push(
- // CupertinoPageRoute(builder: (context){
- // return const YSWalletSetting();
- // })
- // );
- },
- child: Stack(
- children: [
- Image.asset(YSColors.imageStyle(context, '编组 4'),height: hsp(30),width: hsp(20),),
- // Container(
- // height: hsp(5),
- // width: hsp(5),
- // decoration: const BoxDecoration(
- // color: Colors.red,
- // borderRadius: BorderRadius.all(Radius.circular(50))
- // ),
- // margin: EdgeInsets.only(left: hsp(15),top: hsp(5)),
- // )
- ],
- )
- ),
- const YSChangeNetView(),
- const YSScanView(size: 20,)
- ],
- ),
- ),
- if(_wallet.isNotEmpty)Padding(
- padding: EdgeInsets.only(top: hsp(20),bottom: hsp(10),left: hsp(15),right: hsp(15)),
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- child: GestureDetector(
- onTap: (){
- if(_wallet.isEmpty)return;
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSWalletDetail(wallet: _wallet,);
- },)
- );
- },
- behavior: HitTestBehavior.opaque,
- child: SizedBox(
- height: hsp(160),
- width: ysWidth(context),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSWalletManager();
- },settings: const RouteSettings(name: 'YSWalletManager'),)
- ).then((value) {
- // _refeshIndex++;
- // _getTokenArray();
- // getMindToken(context);
- });
- },
- behavior: HitTestBehavior.opaque,
- child: SizedBox(
- height: hsp(20),
- child: RichText(text: TextSpan(
- style: YSColors.subStyle(context),
- children: [
- TextSpan(text: '${_wallet['name']??''} '),
- WidgetSpan(child: Image.asset(YSColors.imageStyle(context, '路径'),height: hsp(5),width: hsp(5),),alignment: PlaceholderAlignment.middle),
- WidgetSpan(child: YSTagView(wallet: YSData().wallet,key: Key(YSData().wallet['public']),))
- ]
- )),
- ),
- ),
- SizedBox(
- height: hsp(40),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Image.asset(YSColors.imageStyle(context, '编组 11'),height: hsp(25),width: hsp(25),),
- Text(YSUserRecord().unit=='RMB'?'¥':'\$',style: TextStyle(fontSize: zsp(25),color: Colors.white),),
- if(_wallet.isNotEmpty)Padding(
- padding: EdgeInsets.only(left: hsp(5),right: hsp(10)),
- child: Container(
- constraints: BoxConstraints(
- maxWidth: ysWidth(context)/2
- ),
- child: _isShow==false?Container(
- padding: EdgeInsets.only(top: hsp(10)),
- child: Text(
- '*****',
- style: TextStyle(fontSize: zsp(25),color: (YSColors.content2Style(context)).color),
- ),
- ):YSBalanceTotalData(style: TextStyle(fontSize: zsp(25),color: (YSColors.content2Style(context)).color),
- key: Key('${YSData().typeId}${_wallet['id']}${YSData().chooseIndex}'),),
- )
- ),
- GestureDetector(
- onTap: (){
- _isShow = !_isShow;
- setState(() {});
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- height: hsp(20),
- alignment: Alignment.topCenter,
- child: Image.asset(YSColors.imageStyle(context, _isShow?'眼睛备份':'yanjing_yincang'),height: hsp(15),width: hsp(15),color: (YSColors.content2Style(context)).color,),
- )
- ),
- ],
- )
- ),
- SizedBox(
- height: hsp(100),
- width: ysWidth(context),
- child: false?Row(//'${_wallet['private']}'.isEmpty
- children: [
- GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSWalletCollection(wallet: _wallet,);
- })
- );
- },
- child: Container(
- // width: (conSize.maxWidth-hsp(30))/_menuArray.length,
- width: hsp(100),
- alignment: Alignment.center,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Image.asset(YSColors.imageStyle(context, '收款_1'),height: hsp(50),width: hsp(50),),
- Container(
- constraints: BoxConstraints(maxWidth: (conSize.maxWidth/_menuArray.length)-hsp(30)),
- child: Text(' ${S.current.SHOUKUAN}',style: YSColors.content3Style(context),maxLines: 1,)
- )
- ],
- ),
- ),
- ),
- ],
- ):ListView.builder(
- itemBuilder: (context,index){
- Map item = _menuArray[index];
- return GestureDetector(
- onTap: (){
- if(index==2){
- CustomerNotification().dispatch(context);
- return;
- }
- // LogUtil.d(_wallet);
- // LogUtil.d(YSData().tokenArray);
- // return;
- if(index==0){
- YSData().contAddress = _wallet['public'];
- YSData().contName = _wallet['name'];
- }
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return index==0?const YSWalletTransfer():index==1?YSWalletCollection(wallet: _wallet,):const YSWalletTransfer();
- })
- );
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- // width: (conSize.maxWidth-hsp(30))/_menuArray.length,
- width: hsp(100),
- alignment: Alignment.center,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Image.asset(YSColors.imageStyle(context, item['type']==1?'转账 (1)':item['type']==2?'收款_1':'交易_闪兑'),height: hsp(50),width: hsp(50),),
- Container(
- constraints: BoxConstraints(maxWidth: (conSize.maxWidth/_menuArray.length)-hsp(30)),
- child: Text(' ${item['title']}',style: YSColors.content3Style(context),maxLines: 1,)
- )
- ],
- ),
- ),
- );
- },
- itemCount: _menuArray.length,
- padding: const EdgeInsets.all(0),
- physics: const NeverScrollableScrollPhysics(),
- scrollDirection: Axis.horizontal,
- ),
- )
- ],
- ),
- ),
- ),
- ),
- ),
- if(_wallet.isNotEmpty)DefaultTabController(
- length: _titles.length,
- child: ClipRRect(
- borderRadius: const BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10)),
- child: Container(
- height: ysHeight(context)-ysTOP(context)-ystabBarHeight-hsp(250),
- width: ysWidth(context),
- color: YSColors.containColor(context),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- height: hsp(50),
- child: Row(
- children: [
- SizedBox(
- width: ysWidth(context)-hsp(90),
- child: Stack(
- children: [
- Container(
- height: hsp(46),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1))),
- ),
- ),
- TabBar(
- controller: _tabController,
- indicatorColor: YSColors.selectedColor(context),
- indicatorWeight: hsp(1),
- tabs: _titles.map((f) {//text: '· ${f['title']}'
- return Tab(
- child: Text(f['title']=='资产'?S.current.ZICHAN:f['title'],style: YSColors.contentStyle(context),),
- );
- }).toList(),
- ),
- ],
- ),
- ),
- Container(
- width: hsp(60),
- height: hsp(46),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1))),
- ),
- alignment: Alignment.center,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Padding(
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- child: Image.asset(YSColors.imageStyle(context, '编组 10'),height: hsp(15),width: hsp(15),),
- ),
- GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSWalletTokenChoose();
- })
- );
- },
- child: Image.asset(YSColors.imageStyle(context, '添加'),height: hsp(15),width: hsp(15),),
- )
- ],
- ),
- )
- ],
- ),
- ),
- Container(
- color: YSColors.containColor(context),
- height: ysHeight(context)-ysTOP(context)-ystabBarHeight-hsp(300),
- child: TabBarView(
- controller: _tabController,
- children: _titles.map((f) {
- return f['type']==0?RefreshIndicator(
- onRefresh: _getTokenArray,
- child: ListView.builder(
- itemBuilder: (context, index) {
- Map item = YSData().tokenArray [index];
- return YSData().allTokenArray.isEmpty?Container():YSWalletListItemView(
- item: item,
- key: Key('${YSData().typeId}${YSData().wallet['id']}${item['name']}${YSData().dataRefresh}'),
- );
- },
- itemCount: YSData().tokenArray.length,
- padding: const EdgeInsets.all(0),
- ),
- ):Container();
- }).toList(),
- ),
- )
- ],
- ),
- ),
- ),
- )
- ],
- ),
- ),
- if(_wallet.isEmpty)Container(
- margin: EdgeInsets.only(top: ysTOP(context)+hsp(60)),
- height: ysHeight(context)-ysTOP(context)-hsp(130),
- width: ysWidth(context),
- child: GestureDetector(
- onTap: (){},
- behavior: HitTestBehavior.opaque,
- child: ClipRRect(
- child: BackdropFilter(
- filter: ImageFilter.blur(sigmaX: 5.0,sigmaY: 5.0),
- child: Padding(
- padding: EdgeInsets.only(top: ysHeight(context)-ysTOP(context)-hsp(430)),
- child: const YSChooseWalletType(isHome: true,),
- ),
- ),
- ),
- ),
- )
- ],
- );
- }
- ),
- );
- }
- ),
- ),
- );
- }
- Future<void> _getTokenArray() async{
- // YSSqflite2 sqflite2 = YSSqflite2().init();
- // List array = await sqflite2.rawQuery();
- // if(!mounted)return;
- YSData().dataRefresh++;
- // YSSqflite2.notifier(context, array);
- addToken(context);
- }
- @override
- bool get wantKeepAlive => false;
- }
- class YSWalletOld extends StatefulWidget {
- const YSWalletOld({Key? key}) : super(key: key);
- @override
- YSWalletOldState createState() => YSWalletOldState();
- }
- class YSWalletOldState extends State<YSWalletOld> with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin{
- final List _titles = [
- {'title':'资产','type':0},
- {'title':'DeFi','type':1},
- {'title':'NFT','type':2},
- ];
- bool _isShow = true;
- late TabController _tabController;
- int _refeshIndex = 0;
- Map _wallet = {};
- Timer? _timer;
- @override
- void initState() {
- _tabController = TabController(
- vsync: this,
- length: _titles.length,
- );
- _getWalletData();
- _startTime();
- super.initState();
- }
- _startTime() {
- _timer = Timer.periodic(const Duration(seconds: 3), (timer){
- _getTokenArray();
- });
- }
- _getPriceData() {
- YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'tokens', parameter: {'chain_id':YSData().typeId,'page':1,'count':100}, successSetter: (dict) async{
- YSData().allTokenArray = dict['data']['list']??[];
- addToken(context);
- getMindToken(context);
- });
- }
- _getWalletData() async{
- YSSqflite sqflite = YSSqflite().init();
- List walletArray = await sqflite.rawQuery();
- if(!mounted)return;
- YSSqflite.notifier(context, walletArray);
- if(walletArray.isNotEmpty){
- YSData().wallet = walletArray.first;
- _getPriceData();
- }
- }
- @override
- void dispose() {
- if(_timer!=null){
- _timer?.cancel();
- }
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- super.build(context);
- List _menuArray = [
- {'title':S.current.ZHUANZHANG,'type':1},
- {'title':S.current.SHOUKUAN,'type':2},
- // {'title':S.current.SHANDUI,'type':3}
- ];
- return Scaffold(
- body: SingleChildScrollView(
- child: Consumer2(
- builder: (context,YSWalletNotifier value,YSTokenNotifier value2,child) {
- if(value.walletArray.isNotEmpty){
- _wallet = value.walletArray.firstWhere((element) => element['chooseType']==1,orElse: ()=>{});
- if(_wallet.isEmpty)_wallet = value.walletArray.first;
- }else{
- _wallet.clear();
- }
- YSData().wallet = _wallet;
- YSData().tokenArray = value2.value;
- // _refeshIndex++;
- return YSData().isLoad==false?Container():LayoutBuilder(
- builder: (context,conSize) {
- return Stack(
- children: [
- const YSHeadView(),
- Padding(
- padding: EdgeInsets.only(top: ysTOP(context)+hsp(10),left: hsp(15),right: hsp(15)),
- child: Column(
- children: [
- SizedBox(
- height: hsp(50),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- onTap: () async{
- // YSSqflite2 sqflite2 = YSSqflite2().init();
- // int count = await sqflite2.delete();
- // LogUtil.d(count);
- },
- child: Image.asset(YSColors.imageStyle(context, '编组 4'),height: hsp(30),width: hsp(20),),
- ),
- const YSChangeNetView(),
- const YSScanView(size: 20,)
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.only(top: hsp(20),bottom: hsp(10)),
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- child: Container(
- height: hsp(160),
- color: YSColors.containColor(context),
- child: Column(
- children: [
- GestureDetector(
- onTap: (){
- if(_wallet.isEmpty)return;
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSWalletDetail(wallet: _wallet,);
- },)
- );
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- width: ysWidth(context)-hsp(30),
- height: hsp(110),
- padding: EdgeInsets.all(hsp(15)),
- decoration: BoxDecoration(
- // image: DecorationImage(image: AssetImage(YSColors.imageStyle(context, '编组备份')),fit: BoxFit.fill),
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- color: YSColors.iconColor(context)
- ),
- child: Stack(
- children: [
- Positioned(
- top: 0,
- right: 0,
- child: GestureDetector(
- onTap: (){
- _isShow = !_isShow;
- setState(() {});
- },
- child: Image.asset(YSColors.imageStyle(context, _isShow?'眼睛备份':'yanjing_yincang'),height: hsp(20),width: hsp(20),color: YSColors.containColor(context),),
- )
- ),
- Positioned(
- top: hsp(15),
- right: hsp(30),
- left: hsp(30),
- child: SizedBox(
- height: hsp(80),
- child: Column(
- children: [
- SizedBox(
- height: hsp(40),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Image.asset(YSColors.imageStyle(context, '编组 11'),height: hsp(25),width: hsp(25),),
- Text('\$',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
- if(_wallet.isNotEmpty)Padding(
- padding: EdgeInsets.only(left: hsp(5)),
- child: Container(
- constraints: BoxConstraints(
- maxWidth: ysWidth(context)/2
- ),
- child: _isShow==false?Container(
- padding: EdgeInsets.only(top: hsp(10)),
- child: Text(
- '*****',
- style: TextStyle(fontSize: zsp(25),color: YSColors.containColor(context)),
- ),
- ):YSBalanceTotalData(style: YSColors.title2Style(context),
- key: Key('${YSData().typeId}${_wallet['id']}7'),),
- )
- )
- ],
- )
- ),
- GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSWalletManager();
- },settings: const RouteSettings(name: 'YSWalletManager'),)
- ).then((value) {
- _refeshIndex++;
- _getTokenArray();
- getMindToken(context);
- });
- },
- behavior: HitTestBehavior.opaque,
- child: SizedBox(
- height: hsp(40),
- child: RichText(text: TextSpan(
- style: YSColors.sub2Style(context),
- children: [
- TextSpan(text: '${_wallet['name']??''} '),
- WidgetSpan(child: Image.asset(YSColors.imageStyle(context, '路径'),height: hsp(5),width: hsp(5),),alignment: PlaceholderAlignment.middle),
- ]
- )),
- ),
- )
- ],
- ),
- )
- )
- ],
- ),
- ),
- ),
- SizedBox(
- height: hsp(50),
- child: ListView.builder(
- itemBuilder: (context,index){
- Map item = _menuArray[index];
- return GestureDetector(
- onTap: (){
- if(index==2)return;
- if(index==0){
- YSData().contAddress = _wallet['public'];
- YSData().contName = _wallet['name'];
- }
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return index==0?const YSWalletTransfer():index==1?YSWalletCollection(wallet: _wallet,):const YSWalletTransfer();
- })
- );
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- width: (conSize.maxWidth-hsp(30))/_menuArray.length,
- alignment: Alignment.center,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Image.asset(YSColors.imageStyle(context, item['type']==1?'转账 (1)':item['type']==2?'收款_1':'交易_闪兑'),height: hsp(30),width: hsp(30),),
- Container(
- constraints: BoxConstraints(maxWidth: (conSize.maxWidth/_menuArray.length)-hsp(30)),
- child: Text(' ${item['title']}',style: YSColors.contentStyle(context),maxLines: 1,)
- )
- ],
- ),
- ),
- );
- },
- itemCount: _menuArray.length,
- padding: const EdgeInsets.all(0),
- physics: const NeverScrollableScrollPhysics(),
- scrollDirection: Axis.horizontal,
- ),
- )
- ],
- ),
- ),
- ),
- ),
- if(_wallet.isNotEmpty)DefaultTabController(
- length: _titles.length,
- child: Container(
- height: ysHeight(context)-ysTOP(context)-ystabBarHeight-hsp(270),
- width: ysWidth(context),
- color: YSColors.containColor(context),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- height: hsp(50),
- child: Row(
- children: [
- SizedBox(
- width: ysWidth(context)-hsp(120),
- child: Stack(
- children: [
- Container(
- height: hsp(46),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1))),
- ),
- ),
- TabBar(
- controller: _tabController,
- indicatorColor: YSColors.selectedColor(context),
- isScrollable: true,
- indicatorWeight: hsp(1),
- tabs: _titles.map((f) {//text: '· ${f['title']}'
- return Tab(
- child: Text(f['title']=='资产'?S.current.ZICHAN:f['title']=='藏品'?S.current.CANGPIN:f['title'],
- style: YSColors.contentStyle(context),),
- );
- }).toList(),
- ),
- ],
- ),
- ),
- Container(
- width: hsp(60),
- height: hsp(46),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: YSColors.lineColor(context),width: hsp(1))),
- ),
- alignment: Alignment.center,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Padding(
- padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
- child: Image.asset(YSColors.imageStyle(context, '编组 10'),height: hsp(15),width: hsp(15),),
- ),
- GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return const YSWalletTokenChoose();
- })
- );
- },
- child: Image.asset(YSColors.imageStyle(context, '添加'),height: hsp(15),width: hsp(15),),
- )
- ],
- ),
- )
- ],
- ),
- ),
- Container(
- color: YSColors.containColor(context),
- height: ysHeight(context)-ysTOP(context)-ystabBarHeight-hsp(330),
- child: TabBarView(
- controller: _tabController,
- children: _titles.map((f) {
- return f['type']==0?RefreshIndicator(
- onRefresh: _getTokenArray,
- child: ListView.builder(
- itemBuilder: (context, index) {
- Map item = YSData().tokenArray [index];
- return YSData().allTokenArray.isEmpty?Container():YSWalletListItemView(
- item: item,
- key: Key('${YSData().typeId}${YSData().wallet['id']}${item['name']}$_refeshIndex'),
- );
- },
- itemCount: YSData().tokenArray.length,
- padding: const EdgeInsets.all(0),
- ),
- ):Container();
- }).toList(),
- ),
- )
- ],
- ),
- ),
- )
- ],
- ),
- ),
- if(_wallet.isEmpty)Container(
- margin: EdgeInsets.only(top: ysTOP(context)+hsp(60)),
- height: ysHeight(context)-ysTOP(context)-hsp(130),
- width: ysWidth(context),
- child: GestureDetector(
- onTap: (){},
- behavior: HitTestBehavior.opaque,
- child: ClipRRect(
- child: BackdropFilter(
- filter: ImageFilter.blur(sigmaX: 5.0,sigmaY: 5.0),
- child: Padding(
- padding: EdgeInsets.only(top: ysHeight(context)-ysTOP(context)-hsp(430)),
- child: const YSChooseWalletType(isHome: true,),
- ),
- ),
- ),
- ),
- )
- ],
- );
- }
- );
- }
- ),
- ),
- );
- }
- Future<void> _getTokenArray() async{
- YSSqflite2 sqflite2 = YSSqflite2().init();
- List array = await sqflite2.rawQuery();
- if(!mounted)return;
- _refeshIndex++;
- YSSqflite2.notifier(context, array);
- }
- @override
- bool get wantKeepAlive => false;
- }
|