fix: bad parent widget in search; improve lost connection info
This commit is contained in:
parent
7cbf328123
commit
1a49035cbf
|
@ -121,10 +121,10 @@ class HomeScreen extends StatelessWidget {
|
|||
|
||||
var connectivityResult =
|
||||
await (Connectivity().checkConnectivity());
|
||||
HomeProvider _homeProvider =
|
||||
Provider.of<HomeProvider>(ctx, listen: false);
|
||||
if (connectivityResult != ConnectivityResult.mobile &&
|
||||
connectivityResult != ConnectivityResult.wifi) {
|
||||
HomeProvider _homeProvider =
|
||||
Provider.of<HomeProvider>(ctx, listen: false);
|
||||
_homeProvider.changeMessage(
|
||||
"Vous n'êtes pas connecté à internet", 0);
|
||||
_sub.nodeConnected = false;
|
||||
|
@ -134,7 +134,15 @@ class HomeScreen extends StatelessWidget {
|
|||
.onConnectivityChanged
|
||||
.listen((ConnectivityResult result) async {
|
||||
log.d('Network changed: $result');
|
||||
await _sub.connectNode(ctx);
|
||||
if (result == ConnectivityResult.none) {
|
||||
_sub.nodeConnected = false;
|
||||
await _sub.sdk.api.setting.unsubscribeBestNumber();
|
||||
_homeProvider.changeMessage(
|
||||
"Vous n'êtes pas connecté à internet", 0);
|
||||
_sub.reload();
|
||||
} else {
|
||||
await _sub.connectNode(ctx);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,31 +21,31 @@ class SearchScreen extends StatelessWidget {
|
|||
// Provider.of<HomeProvider>(context, listen: false);
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
_searchProvider.searchController.text = '';
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: backgroundColor,
|
||||
onWillPop: () {
|
||||
_searchProvider.searchController.text = '';
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: backgroundColor,
|
||||
|
||||
appBar: AppBar(
|
||||
elevation: 1,
|
||||
toolbarHeight: 60 * ratio,
|
||||
title: const SizedBox(
|
||||
height: 22,
|
||||
child: Text('Rechercher'),
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
_searchProvider.searchController.text = '';
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
appBar: AppBar(
|
||||
elevation: 1,
|
||||
toolbarHeight: 60 * ratio,
|
||||
title: const SizedBox(
|
||||
height: 22,
|
||||
child: Text('Rechercher'),
|
||||
),
|
||||
// bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
||||
body: SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
CommonElements().offlineInfo(context),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
_searchProvider.searchController.text = '';
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
),
|
||||
// bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
||||
body: SafeArea(
|
||||
child: Stack(children: [
|
||||
Column(children: <Widget>[
|
||||
SizedBox(height: isTall ? 200 : 100),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
|
@ -113,7 +113,10 @@ class SearchScreen extends StatelessWidget {
|
|||
),
|
||||
Spacer(flex: screenHeight <= 800 ? 1 : 2),
|
||||
]),
|
||||
),
|
||||
));
|
||||
CommonElements().offlineInfo(context),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,163 +42,167 @@ class SearchResultScreen extends StatelessWidget {
|
|||
),
|
||||
bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
CommonElements().offlineInfo(context),
|
||||
const SizedBox(height: 30),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: Colors.grey[700],
|
||||
child: Stack(children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 30),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
children: <TextSpan>[
|
||||
const TextSpan(
|
||||
text: "Résultats pour ",
|
||||
),
|
||||
TextSpan(
|
||||
text: '"${_searchProvider.searchController.text}"',
|
||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
],
|
||||
),
|
||||
children: <TextSpan>[
|
||||
const TextSpan(
|
||||
text: "Résultats pour ",
|
||||
),
|
||||
TextSpan(
|
||||
text: '"${_searchProvider.searchController.text}"',
|
||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
'Dans la blockchain $currencyName',
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
FutureBuilder(
|
||||
future: _searchProvider.searchAddress(),
|
||||
builder: (context, AsyncSnapshot<List?> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
log.d(snapshot.data);
|
||||
if (snapshot.data?.isEmpty ?? true) {
|
||||
return const Text('Aucun résultat');
|
||||
} else {
|
||||
return Expanded(
|
||||
child: ListView(children: <Widget>[
|
||||
for (G1WalletsList g1Wallet in snapshot.data ?? [])
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 5),
|
||||
child: ListTile(
|
||||
key: Key('searchResult${keyID++}'),
|
||||
horizontalTitleGap: 40,
|
||||
contentPadding: const EdgeInsets.all(5),
|
||||
leading:
|
||||
// g1WalletsBox.get(g1Wallet.pubkey)
|
||||
// ?.avatar !=
|
||||
// null
|
||||
// ?
|
||||
_cesiumPlusProvider
|
||||
.defaultAvatar(_avatarSize),
|
||||
// : FutureBuilder(
|
||||
// future: _cesiumPlusProvider.getAvatar(
|
||||
// g1Wallet.pubkey, _avatarSize),
|
||||
// builder: (BuildContext context,
|
||||
// AsyncSnapshot<Image?> _avatar) {
|
||||
// if (_avatar.connectionState !=
|
||||
// ConnectionState.done ||
|
||||
// _avatar.hasError) {
|
||||
// return Stack(children: [
|
||||
// _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize),
|
||||
// Positioned(
|
||||
// top: 8,
|
||||
// right: 0,
|
||||
// width: 12,
|
||||
// height: 12,
|
||||
// child: CircularProgressIndicator(
|
||||
// strokeWidth: 1,
|
||||
// color: orangeC,
|
||||
// ),
|
||||
// ),
|
||||
// ]);
|
||||
// }
|
||||
// if (_avatar.hasData) {
|
||||
// final _w =
|
||||
// g1WalletsBox.get(g1Wallet.pubkey);
|
||||
// if (_w != null) {
|
||||
// _w.avatar = _avatar.data;
|
||||
// }
|
||||
// return ClipOval(child: _avatar.data);
|
||||
// } else {
|
||||
// g1WalletsBox
|
||||
// .get(g1Wallet.pubkey)!
|
||||
// .avatar =
|
||||
// _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize);
|
||||
// return _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize);
|
||||
// }
|
||||
// }),
|
||||
title: Row(children: <Widget>[
|
||||
Text(getShortPubkey(g1Wallet.pubkey!),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: 'Monospace',
|
||||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
trailing: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(context, g1Wallet.pubkey!, 16)
|
||||
]),
|
||||
subtitle: Row(children: <Widget>[
|
||||
Text(g1Wallet.id?.username ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
dense: false,
|
||||
isThreeLine: false,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
_walletsProfilesClass.address =
|
||||
g1Wallet.pubkey;
|
||||
return WalletViewScreen(
|
||||
pubkey: g1Wallet.pubkey,
|
||||
username: g1WalletsBox
|
||||
.get(g1Wallet.pubkey)
|
||||
?.id
|
||||
?.username,
|
||||
avatar: g1WalletsBox
|
||||
.get(g1Wallet.pubkey)
|
||||
?.avatar,
|
||||
);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
),
|
||||
]),
|
||||
);
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
'Dans la blockchain $currencyName',
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
FutureBuilder(
|
||||
future: _searchProvider.searchAddress(),
|
||||
builder: (context, AsyncSnapshot<List?> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
log.d(snapshot.data);
|
||||
if (snapshot.data?.isEmpty ?? true) {
|
||||
return const Text('Aucun résultat');
|
||||
} else {
|
||||
return Expanded(
|
||||
child: ListView(children: <Widget>[
|
||||
for (G1WalletsList g1Wallet
|
||||
in snapshot.data ?? [])
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 5),
|
||||
child: ListTile(
|
||||
key: Key('searchResult${keyID++}'),
|
||||
horizontalTitleGap: 40,
|
||||
contentPadding: const EdgeInsets.all(5),
|
||||
leading:
|
||||
// g1WalletsBox.get(g1Wallet.pubkey)
|
||||
// ?.avatar !=
|
||||
// null
|
||||
// ?
|
||||
_cesiumPlusProvider
|
||||
.defaultAvatar(_avatarSize),
|
||||
// : FutureBuilder(
|
||||
// future: _cesiumPlusProvider.getAvatar(
|
||||
// g1Wallet.pubkey, _avatarSize),
|
||||
// builder: (BuildContext context,
|
||||
// AsyncSnapshot<Image?> _avatar) {
|
||||
// if (_avatar.connectionState !=
|
||||
// ConnectionState.done ||
|
||||
// _avatar.hasError) {
|
||||
// return Stack(children: [
|
||||
// _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize),
|
||||
// Positioned(
|
||||
// top: 8,
|
||||
// right: 0,
|
||||
// width: 12,
|
||||
// height: 12,
|
||||
// child: CircularProgressIndicator(
|
||||
// strokeWidth: 1,
|
||||
// color: orangeC,
|
||||
// ),
|
||||
// ),
|
||||
// ]);
|
||||
// }
|
||||
// if (_avatar.hasData) {
|
||||
// final _w =
|
||||
// g1WalletsBox.get(g1Wallet.pubkey);
|
||||
// if (_w != null) {
|
||||
// _w.avatar = _avatar.data;
|
||||
// }
|
||||
// return ClipOval(child: _avatar.data);
|
||||
// } else {
|
||||
// g1WalletsBox
|
||||
// .get(g1Wallet.pubkey)!
|
||||
// .avatar =
|
||||
// _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize);
|
||||
// return _cesiumPlusProvider
|
||||
// .defaultAvatar(_avatarSize);
|
||||
// }
|
||||
// }),
|
||||
title: Row(children: <Widget>[
|
||||
Text(getShortPubkey(g1Wallet.pubkey!),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: 'Monospace',
|
||||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
trailing: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(
|
||||
context, g1Wallet.pubkey!, 16)
|
||||
]),
|
||||
subtitle: Row(children: <Widget>[
|
||||
Text(g1Wallet.id?.username ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
dense: false,
|
||||
isThreeLine: false,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
_walletsProfilesClass.address =
|
||||
g1Wallet.pubkey;
|
||||
return WalletViewScreen(
|
||||
pubkey: g1Wallet.pubkey,
|
||||
username: g1WalletsBox
|
||||
.get(g1Wallet.pubkey)
|
||||
?.id
|
||||
?.username,
|
||||
avatar: g1WalletsBox
|
||||
.get(g1Wallet.pubkey)
|
||||
?.avatar,
|
||||
);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Center(
|
||||
heightFactor: 5,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 3,
|
||||
backgroundColor: yellowC,
|
||||
color: orangeC,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// Text(
|
||||
// _searchProvider.searchResult.toString(),
|
||||
// )
|
||||
]),
|
||||
),
|
||||
return Center(
|
||||
heightFactor: 5,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 3,
|
||||
backgroundColor: yellowC,
|
||||
color: orangeC,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// Text(
|
||||
// _searchProvider.searchResult.toString(),
|
||||
// )
|
||||
]),
|
||||
),
|
||||
CommonElements().offlineInfo(context),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue