fix: bad parent widget in search; improve lost connection info

This commit is contained in:
poka 2022-06-12 19:43:13 +02:00
parent 7cbf328123
commit 1a49035cbf
3 changed files with 197 additions and 182 deletions

View File

@ -121,10 +121,10 @@ class HomeScreen extends StatelessWidget {
var connectivityResult = var connectivityResult =
await (Connectivity().checkConnectivity()); await (Connectivity().checkConnectivity());
if (connectivityResult != ConnectivityResult.mobile &&
connectivityResult != ConnectivityResult.wifi) {
HomeProvider _homeProvider = HomeProvider _homeProvider =
Provider.of<HomeProvider>(ctx, listen: false); Provider.of<HomeProvider>(ctx, listen: false);
if (connectivityResult != ConnectivityResult.mobile &&
connectivityResult != ConnectivityResult.wifi) {
_homeProvider.changeMessage( _homeProvider.changeMessage(
"Vous n'êtes pas connecté à internet", 0); "Vous n'êtes pas connecté à internet", 0);
_sub.nodeConnected = false; _sub.nodeConnected = false;
@ -134,7 +134,15 @@ class HomeScreen extends StatelessWidget {
.onConnectivityChanged .onConnectivityChanged
.listen((ConnectivityResult result) async { .listen((ConnectivityResult result) async {
log.d('Network changed: $result'); log.d('Network changed: $result');
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); await _sub.connectNode(ctx);
}
}); });
} }
}); });

View File

@ -44,8 +44,8 @@ class SearchScreen extends StatelessWidget {
), ),
// bottomNavigationBar: _homeProvider.bottomAppBar(context), // bottomNavigationBar: _homeProvider.bottomAppBar(context),
body: SafeArea( body: SafeArea(
child: Column(children: <Widget>[ child: Stack(children: [
CommonElements().offlineInfo(context), Column(children: <Widget>[
SizedBox(height: isTall ? 200 : 100), SizedBox(height: isTall ? 200 : 100),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 17), padding: const EdgeInsets.symmetric(horizontal: 17),
@ -113,7 +113,10 @@ class SearchScreen extends StatelessWidget {
), ),
Spacer(flex: screenHeight <= 800 ? 1 : 2), Spacer(flex: screenHeight <= 800 ? 1 : 2),
]), ]),
CommonElements().offlineInfo(context),
]),
), ),
)); ),
);
} }
} }

View File

@ -42,12 +42,12 @@ class SearchResultScreen extends StatelessWidget {
), ),
bottomNavigationBar: _homeProvider.bottomAppBar(context), bottomNavigationBar: _homeProvider.bottomAppBar(context),
body: SafeArea( body: SafeArea(
child: Padding( child: Stack(children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
CommonElements().offlineInfo(context),
const SizedBox(height: 30), const SizedBox(height: 30),
RichText( RichText(
text: TextSpan( text: TextSpan(
@ -82,7 +82,8 @@ class SearchResultScreen extends StatelessWidget {
} else { } else {
return Expanded( return Expanded(
child: ListView(children: <Widget>[ child: ListView(children: <Widget>[
for (G1WalletsList g1Wallet in snapshot.data ?? []) for (G1WalletsList g1Wallet
in snapshot.data ?? [])
Padding( Padding(
padding: padding:
const EdgeInsets.symmetric(horizontal: 5), const EdgeInsets.symmetric(horizontal: 5),
@ -149,7 +150,8 @@ class SearchResultScreen extends StatelessWidget {
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
children: [ children: [
balance(context, g1Wallet.pubkey!, 16) balance(
context, g1Wallet.pubkey!, 16)
]), ]),
subtitle: Row(children: <Widget>[ subtitle: Row(children: <Widget>[
Text(g1Wallet.id?.username ?? '', Text(g1Wallet.id?.username ?? '',
@ -199,6 +201,8 @@ class SearchResultScreen extends StatelessWidget {
// ) // )
]), ]),
), ),
CommonElements().offlineInfo(context),
]),
), ),
); );
} }