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,24 +162,27 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
// Build history list // Build history list
return NotificationListener( return NotificationListener(
child: Expanded( child: Builder(
builder: (context) => Expanded(
child: ListView( child: ListView(
controller: scrollController, controller: scrollController,
children: <Widget>[ children: <Widget>[
SizedBox(height: 20), SizedBox(height: 20),
if (_historyProvider.pubkey != '') if (_historyProvider.pubkey != '')
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
if (_isFirstExec) if (_isFirstExec)
Container( Container(
padding: padding: const EdgeInsets.fromLTRB(
const EdgeInsets.fromLTRB(12, 0, 5, 0), 12, 0, 5, 0),
child: FutureBuilder( child: FutureBuilder(
future: _cesiumPlusProvider future:
.getAvatar(_historyProvider.pubkey), _cesiumPlusProvider.getAvatar(
_historyProvider.pubkey),
initialData: [ initialData: [
File(appPath.path + File(appPath.path +
'/default_avatar.png') '/default_avatar.png')
@ -203,8 +206,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
} }
if (_avatar.hasData) { if (_avatar.hasData) {
return SingleChildScrollView( return SingleChildScrollView(
padding: EdgeInsets.all(0.0), padding:
child: Image.file(_avatar.data[0], EdgeInsets.all(0.0),
child: Image.file(
_avatar.data[0],
height: avatarsSize)); height: avatarsSize));
} }
return Image.file( return Image.file(
@ -219,8 +224,8 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
_historyProvider.snackCopyKey(context); _historyProvider.snackCopyKey(context);
}, },
child: Text( child: Text(
_historyProvider _historyProvider.getShortPubkey(
.getShortPubkey(_historyProvider.pubkey), _historyProvider.pubkey),
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
@ -234,28 +239,32 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
]), ]),
if (_isFirstExec) if (_isFirstExec)
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(
0, 0, 0, 0),
// padding: const EdgeInsets., // padding: const EdgeInsets.,
child: FutureBuilder( child: FutureBuilder(
future: _cesiumPlusProvider future: _cesiumPlusProvider.getName(
.getName(_historyProvider.pubkey), _historyProvider.pubkey),
initialData: '...', initialData: '...',
builder: (context, snapshot) { builder: (context, snapshot) {
return Text( return Text(
snapshot.data != '' snapshot.data != ''
? snapshot.data ? snapshot.data
: '-', : '-',
style: TextStyle(fontSize: 20)); style:
TextStyle(fontSize: 20));
})) }))
]), ]),
SizedBox(height: 18), SizedBox(height: 18),
if (_isFirstExec) if (_isFirstExec)
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding:
const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(balance.toString() + ' Ğ1', child: Text(balance.toString() + ' Ğ1',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(fontSize: 18.0))), style: TextStyle(fontSize: 18.0))),
@ -269,9 +278,11 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
onPressed: () { onPressed: () {
_historyProvider.switchProfileView(); _historyProvider.switchProfileView();
}, },
child: Text(_historyProvider.historySwitchButtun, child: Text(
_historyProvider.historySwitchButtun,
style: TextStyle( style: TextStyle(
fontSize: 15, color: Color(0xffD28928)))), fontSize: 15,
color: Color(0xffD28928)))),
// const Divider( // const Divider(
// color: Colors.grey, // color: Colors.grey,
// height: 5, // height: 5,
@ -283,7 +294,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
? historyView(context, result) ? historyView(context, result)
: payView(context), : 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,12 +107,14 @@ 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);
});
},
child: Column(children: <Widget>[
Padding( Padding(
padding: EdgeInsets.only(top: 22), padding: EdgeInsets.only(top: 22),
child: Row( child: Row(
@ -128,7 +122,8 @@ class HomeScreen extends StatelessWidget {
children: <Widget>[ children: <Widget>[
SizedBox(width: 7), SizedBox(width: 7),
Image( Image(
image: AssetImage('assets/icon/gecko_final.png'), image:
AssetImage('assets/icon/gecko_final.png'),
height: 180), height: 180),
])), ])),
Padding( Padding(
@ -139,7 +134,8 @@ class HomeScreen extends StatelessWidget {
Text( Text(
"Lapplication de paiement Ğ1\nplus mobile quun lésard du Vietnam", "Lapplication de paiement Ğ1\nplus mobile quun lésard du Vietnam",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 15), style: TextStyle(
color: Colors.black, fontSize: 15),
) )
])), ])),
Padding( Padding(
@ -153,8 +149,8 @@ class HomeScreen extends StatelessWidget {
child: Material( child: Material(
color: Color(0xffFFD58D), // button color color: Color(0xffFFD58D), // button color
child: InkWell( child: InkWell(
splashColor: splashColor: Color(
Color(0xffD28928), // inkwell color 0xffD28928), // inkwell color
child: Padding( child: Padding(
padding: EdgeInsets.all(17), padding: EdgeInsets.all(17),
child: Image( child: Image(
@ -162,7 +158,8 @@ class HomeScreen extends StatelessWidget {
'assets/qrcode-scan.png'), 'assets/qrcode-scan.png'),
height: 58)), height: 58)),
onTap: () async { onTap: () async {
await _historyProvider.scan(context); await _historyProvider
.scan(context);
}), }),
), ),
), ),
@ -182,28 +179,30 @@ class HomeScreen extends StatelessWidget {
Text( Text(
"Payer par QR-Code", "Payer par QR-Code",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 13), style: TextStyle(
color: Colors.black, fontSize: 13),
) )
]) ])
])), ])),
Padding( Padding(
padding: EdgeInsets.only(top: 60), padding: EdgeInsets.only(top: 60),
child: child: Row(
Row(mainAxisAlignment: MainAxisAlignment.center, children: < mainAxisAlignment: MainAxisAlignment.center,
Widget>[ children: <Widget>[
Column(children: <Widget>[ Column(children: <Widget>[
Container( Container(
child: ClipOval( child: ClipOval(
child: Material( child: Material(
color: Color(0xffFFD58D), // button color color: Color(0xffFFD58D), // button color
child: InkWell( child: InkWell(
splashColor: Color(0xffD28928), // inkwell color splashColor: Color(
0xffD28928), // inkwell color
child: Padding( child: Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: 18, vertical: 14), horizontal: 18, vertical: 14),
child: Image( child: Image(
image: image: AssetImage(
AssetImage('assets/blockchain.png'), 'assets/blockchain.png'),
height: 65)), height: 65)),
onTap: () {}), onTap: () {}),
), ),
@ -224,7 +223,8 @@ class HomeScreen extends StatelessWidget {
Text( Text(
"Explorer\n", "Explorer\n",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 13), style: TextStyle(
color: Colors.black, fontSize: 13),
) )
]), ]),
SizedBox(width: 140), SizedBox(width: 140),
@ -234,16 +234,19 @@ class HomeScreen extends StatelessWidget {
child: Material( child: Material(
color: Color(0xffFFD58D), // button color color: Color(0xffFFD58D), // button color
child: InkWell( child: InkWell(
splashColor: Color(0xffD28928), // inkwell color splashColor: Color(
0xffD28928), // inkwell color
child: Padding( child: Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Image( child: Image(
image: AssetImage('assets/lock.png'), image: AssetImage(
'assets/lock.png'),
height: 50)), height: 50)),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(
builder: (context) {
return WalletsHome(); return WalletsHome();
}), }),
); );
@ -266,7 +269,8 @@ class HomeScreen extends StatelessWidget {
Text( Text(
"Gérer mes\nportefeuilles", "Gérer mes\nportefeuilles",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 13), style: TextStyle(
color: Colors.black, fontSize: 13),
) )
]) ])
])) ]))
@ -292,6 +296,29 @@ class HomeScreen extends StatelessWidget {
// ), // ),
// ], // ],
// ), // ),
)); )));
}
}
class StatefulWrapper extends StatefulWidget {
final Function onInit;
final Widget child;
const StatefulWrapper({@required this.onInit, @required this.child});
@override
_StatefulWrapperState createState() => _StatefulWrapperState();
}
class _StatefulWrapperState extends State<StatefulWrapper> {
@override
void initState() {
if (widget.onInit != null) {
widget.onInit();
}
super.initState();
}
@override
Widget build(BuildContext context) {
return widget.child;
} }
} }