diff --git a/magnet_app/lib/app_state_model.dart b/magnet_app/lib/app_state_model.dart index edd9c8b..e582e03 100644 --- a/magnet_app/lib/app_state_model.dart +++ b/magnet_app/lib/app_state_model.dart @@ -27,6 +27,7 @@ class AppState extends BLEProvider { String? app_screen = "splash"; String? prev_screen = null; bool timerStatus = false; + bool isBusy = false; AsyncDatabase? _db; RxList _devices = RxList(); /* = [ @@ -58,6 +59,7 @@ class AppState extends BLEProvider { } AppState() { + isBusy = false; Timer(const Duration(seconds: 5), () { // scanAndConnectToDevice(); print("Move to home screen"); @@ -177,6 +179,7 @@ class AppState extends BLEProvider { scanDeviceStream.cancel(); print("scan stopped"); scanStarted = false; + isBusy = false; if (!connected) { print("Not connected"); diff --git a/magnet_app/lib/main.dart b/magnet_app/lib/main.dart index e51aa0a..53b0d00 100644 --- a/magnet_app/lib/main.dart +++ b/magnet_app/lib/main.dart @@ -12,6 +12,8 @@ import 'package:magnet_app/about.dart'; import 'package:magnet_app/app_state_model.dart'; import 'package:magnet_app/provider/ble_provider.dart'; import 'package:audioplayers/audioplayers.dart'; +import 'package:overlay_loader_with_app_icon/overlay_loader_with_app_icon.dart'; + // import 'package:horizontal_data_table/horizontal_data_table.dart'; @@ -73,7 +75,8 @@ class MyHomePage extends StatefulWidget { class _MyHomePageWidgetState extends State { final player = AudioPlayer(); - + bool _isLoading=false; + List _devicesScannedNow = [ ]; @@ -83,8 +86,13 @@ class _MyHomePageWidgetState extends State { Widget build(BuildContext context) { final appState = Provider.of(context, listen: false); - - return Scaffold( + //This manage state of modal progress widget + return OverlayLoaderWithAppIcon( + isLoading: appState.isBusy, + overlayBackgroundColor: Colors.black, + circularProgressColor: Color(0xff670099), + appIcon: Icon(Icons.tips_and_updates), // Image.asset('assets/images/magnet_icon.png'), + child: Scaffold( floatingActionButton: NeumorphicFloatingActionButton( child: Icon(Icons.add, size: 30), tooltip: "SCAN", @@ -104,6 +112,7 @@ class _MyHomePageWidgetState extends State { } }); */ + appState.isBusy = true; appState.scanAndConnectToDevice(); _devicesScannedNow = appState.getDevices(); }, @@ -217,6 +226,7 @@ class _MyHomePageWidgetState extends State { ), //), ), + ) ); } diff --git a/magnet_app/pubspec.lock b/magnet_app/pubspec.lock index f0960b8..63106b5 100644 --- a/magnet_app/pubspec.lock +++ b/magnet_app/pubspec.lock @@ -441,6 +441,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.8" + overlay_loader_with_app_icon: + dependency: "direct main" + description: + name: overlay_loader_with_app_icon + sha256: "707eea85584ec5d50668819fb56ee1cf60222abcc7c6dcd32304b0bbc0e59f12" + url: "https://pub.dev" + source: hosted + version: "0.0.3" page_transition: dependency: "direct main" description: diff --git a/magnet_app/pubspec.yaml b/magnet_app/pubspec.yaml index cfe2386..a9ccd6e 100644 --- a/magnet_app/pubspec.yaml +++ b/magnet_app/pubspec.yaml @@ -50,6 +50,7 @@ dependencies: iconic: ^0.0.3 # horizontal_data_table: ^4.3.1 observable_ish: ^4.0.8 + overlay_loader_with_app_icon: ^0.0.3 flutter_neumorphic: git: url: https://github.com/truedat101/Flutter-Neumorphic