Skip to content

Commit

Permalink
refs IoTone#26 Add a busy thing to the scan button
Browse files Browse the repository at this point in the history
  • Loading branch information
truedat101 authored and pedroalvesbatista committed May 7, 2024
1 parent cf65d08 commit 57896be
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions magnet_app/lib/app_state_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map> _devices = RxList<Map>(); /* = [
Expand Down Expand Up @@ -58,6 +59,7 @@ class AppState extends BLEProvider {
}

AppState() {
isBusy = false;
Timer(const Duration(seconds: 5), () {
// scanAndConnectToDevice();
print("Move to home screen");
Expand Down Expand Up @@ -177,6 +179,7 @@ class AppState extends BLEProvider {
scanDeviceStream.cancel();
print("scan stopped");
scanStarted = false;
isBusy = false;

if (!connected) {
print("Not connected");
Expand Down
16 changes: 13 additions & 3 deletions magnet_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -73,7 +75,8 @@ class MyHomePage extends StatefulWidget {

class _MyHomePageWidgetState extends State<MyHomePage> {
final player = AudioPlayer();

bool _isLoading=false;

List<Map> _devicesScannedNow = [

];
Expand All @@ -83,8 +86,13 @@ class _MyHomePageWidgetState extends State<MyHomePage> {

Widget build(BuildContext context) {
final appState = Provider.of<AppState>(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",
Expand All @@ -104,6 +112,7 @@ class _MyHomePageWidgetState extends State<MyHomePage> {
}
});
*/
appState.isBusy = true;
appState.scanAndConnectToDevice();
_devicesScannedNow = appState.getDevices();
},
Expand Down Expand Up @@ -217,6 +226,7 @@ class _MyHomePageWidgetState extends State<MyHomePage> {
),
//),
),
)
);
}

Expand Down
8 changes: 8 additions & 0 deletions magnet_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions magnet_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57896be

Please sign in to comment.