Fix beacon scan not working on button tap
This commit is contained in:
parent
f43d23fe44
commit
8bb5511d37
@ -15,6 +15,7 @@ class VisitAppContext with ChangeNotifier{
|
||||
List<SectionRead> readSections = [];
|
||||
bool isContentCurrentlyShown = false;
|
||||
bool isScanningBeacons = false;
|
||||
bool isScanBeaconAlreadyAllowed = false;
|
||||
|
||||
VisitAppContext({this.language, this.id, this.configuration, this.instanceId});
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
VisitPage(configurationId: configurations[index].id!),
|
||||
VisitPage(configurationId: configurations[index].id!, isAlreadyAllowed: visitAppContext.isScanBeaconAlreadyAllowed),
|
||||
));
|
||||
/*Navigator.push(
|
||||
context,
|
||||
@ -110,7 +110,7 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
VisitPage(configurationId: configurations[index].id!),
|
||||
VisitPage(configurationId: configurations[index].id!, isAlreadyAllowed: visitAppContext.isScanBeaconAlreadyAllowed),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,9 +23,10 @@ import 'package:provider/provider.dart';
|
||||
import 'components/body.dart';
|
||||
|
||||
class VisitPage extends StatefulWidget {
|
||||
const VisitPage({Key? key, required this.configurationId}) : super(key: key);
|
||||
const VisitPage({Key? key, required this.configurationId, required this.isAlreadyAllowed}) : super(key: key);
|
||||
|
||||
final String configurationId;
|
||||
final bool isAlreadyAllowed;
|
||||
|
||||
@override
|
||||
State<VisitPage> createState() => _VisitPageState();
|
||||
@ -69,7 +70,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
|
||||
super.initState();
|
||||
|
||||
if(controller.authorizationStatusOk) {
|
||||
if(widget.isAlreadyAllowed) {
|
||||
listeningState();
|
||||
}
|
||||
//listeningState();
|
||||
@ -466,6 +467,13 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
if(!isCancel) {
|
||||
if(!controller.bluetoothEnabled) {
|
||||
await handleOpenBluetooth();
|
||||
}
|
||||
|
||||
if(!controller.locationServiceEnabled) {
|
||||
await handleOpenLocationSettings();
|
||||
}
|
||||
if(!visitAppContext.isScanningBeacons) {
|
||||
print("Start Scan");
|
||||
print(_streamRanging);
|
||||
@ -477,6 +485,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
|
||||
controller.startScanning();
|
||||
visitAppContext.isScanningBeacons = true;
|
||||
visitAppContext.isScanBeaconAlreadyAllowed = true;
|
||||
appContext.setContext(visitAppContext);
|
||||
} else {
|
||||
print("Pause Scan");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user