From 87afa91d3a137dce582f75f074173767f5eb21da Mon Sep 17 00:00:00 2001 From: SHAKEEB KHAN Date: Thu, 6 Jun 2024 17:37:02 +0500 Subject: [PATCH] resolve screenreset issues (#41) * resolve screenreset issues in mobile screen * change hintText in textformfield * Don't show success message twice * simplify toggle switch logic --------- Co-authored-by: Muzzammil Shahid --- lib/screens/mobile/mobile_home.dart | 17 ++++++----------- lib/screens/mobile/router_dialogbox.dart | 13 ------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/lib/screens/mobile/mobile_home.dart b/lib/screens/mobile/mobile_home.dart index 04eaab4..709138c 100644 --- a/lib/screens/mobile/mobile_home.dart +++ b/lib/screens/mobile/mobile_home.dart @@ -244,16 +244,9 @@ class _MobileHomeScaffoldState extends State with TickerProv scaffoldMessenger.showSnackBar(SnackBar(content: Text("An error occurred. Please try again. $e"))); } - if (!routerResult.isServerStarted) { - scaffoldMessenger.showSnackBar( - const SnackBar( - content: Text("Failed to start the server."), - duration: Duration(seconds: 3), - ), - ); - return; + if (routerResult.isServerStarted) { + routerResult.toggleSwitch(value: true); } - routerResult.toggleSwitch(value: true); } Future _showCloseRouterDialog( @@ -267,11 +260,10 @@ class _MobileHomeScaffoldState extends State with TickerProv context: context, builder: (BuildContext context) { return AlertDialog( - title: Text( + title: const Text( "Router Connection", style: TextStyle( fontWeight: FontWeight.w700, - color: homeAppBarTextColor, fontSize: iconSize, ), ), @@ -408,6 +400,7 @@ class _MobileHomeScaffoldState extends State with TickerProv controller: _tabData[index].linkController, decoration: const InputDecoration( hintText: "ws://localhost:8080/ws", + hintStyle: TextStyle(fontWeight: FontWeight.w200), labelText: "Enter URL here", border: InputBorder.none, contentPadding: EdgeInsets.all(10), @@ -454,6 +447,7 @@ class _MobileHomeScaffoldState extends State with TickerProv controller: _tabData[index].realmController, decoration: InputDecoration( hintText: "Enter realm here", + hintStyle: const TextStyle(fontWeight: FontWeight.w200), labelText: "Enter realm here", border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), @@ -887,6 +881,7 @@ class _MobileHomeScaffoldState extends State with TickerProv hintText: sendButtonText.contains("Publish") || sendButtonText.contains("Subscribe") ? "Enter topic here" : "Enter procedure here", + hintStyle: const TextStyle(fontWeight: FontWeight.w200), labelText: sendButtonText.contains("Publish") || sendButtonText.contains("Subscribe") ? "Enter topic here" : "Enter procedure here", diff --git a/lib/screens/mobile/router_dialogbox.dart b/lib/screens/mobile/router_dialogbox.dart index 007b504..110a2c9 100644 --- a/lib/screens/mobile/router_dialogbox.dart +++ b/lib/screens/mobile/router_dialogbox.dart @@ -5,7 +5,6 @@ import "package:wick_ui/constants.dart"; import "package:wick_ui/providers/router_realm_provider.dart"; import "package:wick_ui/providers/router_state_provider.dart"; import "package:wick_ui/providers/router_toggleswitch_provider.dart"; -import "package:wick_ui/screens/mobile/mobile_home.dart"; import "package:wick_ui/wamp_util.dart"; class RouterDialogBox extends StatefulWidget { @@ -222,23 +221,11 @@ class _RouterDialogBoxState extends State { const Duration(milliseconds: 500), onTimeout: () { Navigator.pop(context); - Navigator.pushReplacement( - context, - MaterialPageRoute(builder: (context) => const MobileHomeScaffold()), - ); throw TimeoutException("Server is running on this host localhost: $host and on this port $port"); }, ); realmProvider.resetControllers(); - scaffoldMessenger.showSnackBar( - SnackBar( - content: Text( - "Server is running on this host localhost: $host and on this port $port", - ), - duration: const Duration(seconds: 3), - ), - ); } on TimeoutException catch (_) { scaffoldMessenger.showSnackBar( SnackBar(