Fix Snack display

This commit is contained in:
poka 2021-02-22 19:44:58 +01:00
parent b3cd00749d
commit 3b915be9d3
2 changed files with 343 additions and 305 deletions

View File

@ -162,128 +162,139 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
// Build history list // Build history list
return NotificationListener( return NotificationListener(
child: Expanded( child: Builder(
child: ListView( builder: (context) => Expanded(
controller: scrollController, child: ListView(
children: <Widget>[ controller: scrollController,
SizedBox(height: 20), children: <Widget>[
if (_historyProvider.pubkey != '') SizedBox(height: 20),
Row( if (_historyProvider.pubkey != '')
mainAxisAlignment: MainAxisAlignment.spaceBetween, Row(
mainAxisSize: MainAxisSize.min, mainAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.center, MainAxisAlignment.spaceBetween,
children: [ mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (_isFirstExec)
Container(
padding: const EdgeInsets.fromLTRB(
12, 0, 5, 0),
child: FutureBuilder(
future:
_cesiumPlusProvider.getAvatar(
_historyProvider.pubkey),
initialData: [
File(appPath.path +
'/default_avatar.png')
],
builder: (BuildContext context,
AsyncSnapshot<List> _avatar) {
cesiumData = _avatar.data;
// _cesiumPlusProvider.isComplete = true;
if (_avatar.connectionState !=
ConnectionState.done) {
return Image.file(
File(appPath.path +
'/default_avatar.png'),
height: avatarsSize);
}
if (_avatar.hasError) {
return Image.file(
File(appPath.path +
'/default_avatar.png'),
height: avatarsSize);
}
if (_avatar.hasData) {
return SingleChildScrollView(
padding:
EdgeInsets.all(0.0),
child: Image.file(
_avatar.data[0],
height: avatarsSize));
}
return Image.file(
File(appPath.path +
'/default_avatar.png'),
height: avatarsSize);
})),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(
text: _historyProvider.pubkey));
_historyProvider.snackCopyKey(context);
},
child: Text(
_historyProvider.getShortPubkey(
_historyProvider.pubkey),
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w800,
fontFamily: 'Monospace')),
),
Container(
padding: const EdgeInsets.fromLTRB(
30, 0, 5, 0), // .only(right: 15),
child: Text('TODO')),
SizedBox(width: 0)
]),
if (_isFirstExec)
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.fromLTRB(
0, 0, 0, 0),
// padding: const EdgeInsets.,
child: FutureBuilder(
future: _cesiumPlusProvider.getName(
_historyProvider.pubkey),
initialData: '...',
builder: (context, snapshot) {
return Text(
snapshot.data != ''
? snapshot.data
: '-',
style:
TextStyle(fontSize: 20));
}))
]),
SizedBox(height: 18),
if (_isFirstExec) if (_isFirstExec)
Container( Container(
padding: padding:
const EdgeInsets.fromLTRB(12, 0, 5, 0), const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: FutureBuilder( child: Text(balance.toString() + ' Ğ1',
future: _cesiumPlusProvider textAlign: TextAlign.center,
.getAvatar(_historyProvider.pubkey), style: TextStyle(fontSize: 18.0))),
initialData: [ SizedBox(height: 20),
File(appPath.path + ElevatedButton(
'/default_avatar.png') style: ElevatedButton.styleFrom(
], elevation: 1,
builder: (BuildContext context, primary: Colors.grey[50], // background
AsyncSnapshot<List> _avatar) { onPrimary: Colors.black, // foreground
cesiumData = _avatar.data; ),
// _cesiumPlusProvider.isComplete = true; onPressed: () {
if (_avatar.connectionState != _historyProvider.switchProfileView();
ConnectionState.done) { },
return Image.file( child: Text(
File(appPath.path + _historyProvider.historySwitchButtun,
'/default_avatar.png'), style: TextStyle(
height: avatarsSize); fontSize: 15,
} color: Color(0xffD28928)))),
if (_avatar.hasError) { // const Divider(
return Image.file( // color: Colors.grey,
File(appPath.path + // height: 5,
'/default_avatar.png'), // thickness: 0.5,
height: avatarsSize); // indent: 0,
} // endIndent: 0,
if (_avatar.hasData) { // ),
return SingleChildScrollView( _historyProvider.isHistoryScreen
padding: EdgeInsets.all(0.0), ? historyView(context, result)
child: Image.file(_avatar.data[0], : payView(context),
height: avatarsSize)); ],
} ))),
return Image.file(
File(appPath.path +
'/default_avatar.png'),
height: avatarsSize);
})),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(
text: _historyProvider.pubkey));
_historyProvider.snackCopyKey(context);
},
child: Text(
_historyProvider
.getShortPubkey(_historyProvider.pubkey),
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w800,
fontFamily: 'Monospace')),
),
Container(
padding: const EdgeInsets.fromLTRB(
30, 0, 5, 0), // .only(right: 15),
child: Text('TODO')),
SizedBox(width: 0)
]),
if (_isFirstExec)
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
// padding: const EdgeInsets.,
child: FutureBuilder(
future: _cesiumPlusProvider
.getName(_historyProvider.pubkey),
initialData: '...',
builder: (context, snapshot) {
return Text(
snapshot.data != ''
? snapshot.data
: '-',
style: TextStyle(fontSize: 20));
}))
]),
SizedBox(height: 18),
if (_isFirstExec)
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(balance.toString() + ' Ğ1',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18.0))),
SizedBox(height: 20),
ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 1,
primary: Colors.grey[50], // background
onPrimary: Colors.black, // foreground
),
onPressed: () {
_historyProvider.switchProfileView();
},
child: Text(_historyProvider.historySwitchButtun,
style: TextStyle(
fontSize: 15, color: Color(0xffD28928)))),
// const Divider(
// color: Colors.grey,
// height: 5,
// thickness: 0.5,
// indent: 0,
// endIndent: 0,
// ),
_historyProvider.isHistoryScreen
? historyView(context, result)
: payView(context),
],
)),
onNotification: (t) { onNotification: (t) {
if (t is ScrollEndNotification && if (t is ScrollEndNotification &&
scrollController.position.pixels >= scrollController.position.pixels >=

View File

@ -12,8 +12,7 @@ class HomeScreen extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
HomeProvider _homeProvider = Provider.of<HomeProvider>(context); HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context); HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
// _historyProvider.snackNode(context); HistoryProvider _historyStatic = HistoryProvider('');
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
drawer: Drawer( drawer: Drawer(
@ -74,13 +73,6 @@ class HomeScreen extends StatelessWidget {
icon: _homeProvider.searchIcon, icon: _homeProvider.searchIcon,
color: Colors.grey[850], color: Colors.grey[850],
onPressed: () { onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) {
// return SearchList();
// }),
// );
if (_homeProvider.searchIcon.icon == Icons.search) { if (_homeProvider.searchIcon.icon == Icons.search) {
_homeProvider.searchIcon = Icon( _homeProvider.searchIcon = Icon(
Icons.close, Icons.close,
@ -115,183 +107,218 @@ class HomeScreen extends StatelessWidget {
backgroundColor: Color(0xffFFD58D), backgroundColor: Color(0xffFFD58D),
), ),
backgroundColor: Color(0xffF9F9F1), backgroundColor: Color(0xffF9F9F1),
body: // _homeProvider.currentTab[_homeProvider.currentIndex], body: Builder(
Builder( builder: (ctx) => StatefulWrapper(
builder: (context) => Column(children: <Widget>[ onInit: () {
// _historyProvider.snackNode(context), WidgetsBinding.instance.addPostFrameCallback((_) {
// SnackBar(content: Text('tataaa')), _historyStatic.snackNode(ctx);
});
Padding( },
padding: EdgeInsets.only(top: 22), child: Column(children: <Widget>[
child: Row( Padding(
mainAxisAlignment: MainAxisAlignment.center, padding: EdgeInsets.only(top: 22),
children: <Widget>[ child: Row(
SizedBox(width: 7), mainAxisAlignment: MainAxisAlignment.center,
Image( children: <Widget>[
image: AssetImage('assets/icon/gecko_final.png'), SizedBox(width: 7),
height: 180), Image(
])), image:
Padding( AssetImage('assets/icon/gecko_final.png'),
padding: EdgeInsets.only(top: 15), height: 180),
child: Row( ])),
mainAxisAlignment: MainAxisAlignment.center, Padding(
children: <Widget>[ padding: EdgeInsets.only(top: 15),
Text( child: Row(
"Lapplication de paiement Ğ1\nplus mobile quun lésard du Vietnam", mainAxisAlignment: MainAxisAlignment.center,
textAlign: TextAlign.center, children: <Widget>[
style: TextStyle(color: Colors.black, fontSize: 15), Text(
) "Lapplication de paiement Ğ1\nplus mobile quun lésard du Vietnam",
])), textAlign: TextAlign.center,
Padding( style: TextStyle(
padding: EdgeInsets.only(top: 60), color: Colors.black, fontSize: 15),
child: Row( )
mainAxisAlignment: MainAxisAlignment.center, ])),
children: <Widget>[ Padding(
Column(children: <Widget>[ padding: EdgeInsets.only(top: 60),
Container( child: Row(
child: ClipOval( mainAxisAlignment: MainAxisAlignment.center,
child: Material( children: <Widget>[
color: Color(0xffFFD58D), // button color Column(children: <Widget>[
child: InkWell( Container(
splashColor: child: ClipOval(
Color(0xffD28928), // inkwell color child: Material(
child: Padding( color: Color(0xffFFD58D), // button color
padding: EdgeInsets.all(17), child: InkWell(
child: Image( splashColor: Color(
image: AssetImage( 0xffD28928), // inkwell color
'assets/qrcode-scan.png'), child: Padding(
height: 58)), padding: EdgeInsets.all(17),
onTap: () async { child: Image(
await _historyProvider.scan(context); image: AssetImage(
}), 'assets/qrcode-scan.png'),
), height: 58)),
), onTap: () async {
decoration: BoxDecoration( await _historyProvider
shape: BoxShape.circle, .scan(context);
color: Colors.white, }),
boxShadow: [ ),
BoxShadow( ),
color: Colors.grey, decoration: BoxDecoration(
blurRadius: 4.0, shape: BoxShape.circle,
offset: Offset(2.0, 2.5), color: Colors.white,
spreadRadius: 0.5) boxShadow: [
], BoxShadow(
), color: Colors.grey,
), blurRadius: 4.0,
SizedBox(height: 10), offset: Offset(2.0, 2.5),
Text( spreadRadius: 0.5)
"Payer par QR-Code", ],
textAlign: TextAlign.center, ),
style: TextStyle(color: Colors.black, fontSize: 13), ),
) SizedBox(height: 10),
]) Text(
])), "Payer par QR-Code",
Padding( textAlign: TextAlign.center,
padding: EdgeInsets.only(top: 60), style: TextStyle(
child: color: Colors.black, fontSize: 13),
Row(mainAxisAlignment: MainAxisAlignment.center, children: < )
Widget>[ ])
Column(children: <Widget>[ ])),
Container( Padding(
child: ClipOval( padding: EdgeInsets.only(top: 60),
child: Material( child: Row(
color: Color(0xffFFD58D), // button color mainAxisAlignment: MainAxisAlignment.center,
child: InkWell( children: <Widget>[
splashColor: Color(0xffD28928), // inkwell color Column(children: <Widget>[
child: Padding( Container(
padding: EdgeInsets.symmetric( child: ClipOval(
horizontal: 18, vertical: 14), child: Material(
child: Image( color: Color(0xffFFD58D), // button color
image: child: InkWell(
AssetImage('assets/blockchain.png'), splashColor: Color(
height: 65)), 0xffD28928), // inkwell color
onTap: () {}), child: Padding(
), padding: EdgeInsets.symmetric(
), horizontal: 18, vertical: 14),
decoration: BoxDecoration( child: Image(
shape: BoxShape.circle, image: AssetImage(
color: Colors.white, 'assets/blockchain.png'),
boxShadow: [ height: 65)),
BoxShadow( onTap: () {}),
color: Colors.grey, ),
blurRadius: 4.0, ),
offset: Offset(2.0, 2.5), decoration: BoxDecoration(
spreadRadius: 0.5) shape: BoxShape.circle,
], color: Colors.white,
), boxShadow: [
), BoxShadow(
SizedBox(height: 10), color: Colors.grey,
Text( blurRadius: 4.0,
"Explorer\n", offset: Offset(2.0, 2.5),
textAlign: TextAlign.center, spreadRadius: 0.5)
style: TextStyle(color: Colors.black, fontSize: 13), ],
) ),
),
SizedBox(height: 10),
Text(
"Explorer\n",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 13),
)
]),
SizedBox(width: 140),
Column(children: <Widget>[
Container(
child: ClipOval(
child: Material(
color: Color(0xffFFD58D), // button color
child: InkWell(
splashColor: Color(
0xffD28928), // inkwell color
child: Padding(
padding: EdgeInsets.all(20),
child: Image(
image: AssetImage(
'assets/lock.png'),
height: 50)),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return WalletsHome();
}),
);
}),
),
),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 4.0,
offset: Offset(2.0, 2.5),
spreadRadius: 0.5)
],
),
),
SizedBox(height: 10),
Text(
"Gérer mes\nportefeuilles",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 13),
)
])
]))
]), ]),
SizedBox(width: 140), // bottomNavigationBar: BottomNavigationBar(
Column(children: <Widget>[ // backgroundColor: Color(0xffFFD58D),
Container( // fixedColor: Colors.grey[850],
child: ClipOval( // unselectedItemColor: Color(0xffBD935C),
child: Material( // type: BottomNavigationBarType.fixed,
color: Color(0xffFFD58D), // button color // onTap: (index) {
child: InkWell( // _homeProvider.currentIndex = index;
splashColor: Color(0xffD28928), // inkwell color // },
child: Padding( // currentIndex: _homeProvider.currentIndex,
padding: EdgeInsets.all(20), // items: [
child: Image( // BottomNavigationBarItem(
image: AssetImage('assets/lock.png'), // icon: Image.asset('assets/block-space-disabled.png', height: 26),
height: 50)), // activeIcon: Image.asset('assets/blockchain.png', height: 26),
onTap: () { // label: 'Explorateur',
Navigator.push( // ),
context, // BottomNavigationBarItem(
MaterialPageRoute(builder: (context) { // icon: Icon(Icons.lock),
return WalletsHome(); // label: 'Mes portefeuilles',
}), // ),
); // ],
}), // ),
), )));
), }
decoration: BoxDecoration( }
shape: BoxShape.circle,
color: Colors.white, class StatefulWrapper extends StatefulWidget {
boxShadow: [ final Function onInit;
BoxShadow( final Widget child;
color: Colors.grey, const StatefulWrapper({@required this.onInit, @required this.child});
blurRadius: 4.0, @override
offset: Offset(2.0, 2.5), _StatefulWrapperState createState() => _StatefulWrapperState();
spreadRadius: 0.5) }
],
), class _StatefulWrapperState extends State<StatefulWrapper> {
), @override
SizedBox(height: 10), void initState() {
Text( if (widget.onInit != null) {
"Gérer mes\nportefeuilles", widget.onInit();
textAlign: TextAlign.center, }
style: TextStyle(color: Colors.black, fontSize: 13), super.initState();
) }
])
])) @override
]), Widget build(BuildContext context) {
// bottomNavigationBar: BottomNavigationBar( return widget.child;
// backgroundColor: Color(0xffFFD58D),
// fixedColor: Colors.grey[850],
// unselectedItemColor: Color(0xffBD935C),
// type: BottomNavigationBarType.fixed,
// onTap: (index) {
// _homeProvider.currentIndex = index;
// },
// currentIndex: _homeProvider.currentIndex,
// items: [
// BottomNavigationBarItem(
// icon: Image.asset('assets/block-space-disabled.png', height: 26),
// activeIcon: Image.asset('assets/blockchain.png', height: 26),
// label: 'Explorateur',
// ),
// BottomNavigationBarItem(
// icon: Icon(Icons.lock),
// label: 'Mes portefeuilles',
// ),
// ],
// ),
));
} }
} }