Add order beacon by section order
This commit is contained in:
parent
ec2d9df690
commit
67a228d2e6
@ -2,6 +2,7 @@ import 'package:manager_api/api.dart';
|
||||
|
||||
class BeaconSection {
|
||||
int? minorBeaconId;
|
||||
int? orderInConfig;
|
||||
String? configurationId;
|
||||
String? sectionId;
|
||||
/*int? rssi;
|
||||
@ -9,11 +10,12 @@ class BeaconSection {
|
||||
String? proximityUUID;*/
|
||||
bool? found = false;
|
||||
|
||||
BeaconSection({this.minorBeaconId, this.configurationId, this.sectionId, this.found});
|
||||
BeaconSection({this.minorBeaconId, this.orderInConfig, this.configurationId, this.sectionId, this.found});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'minorBeaconId': minorBeaconId,
|
||||
'orderInConfig': orderInConfig,
|
||||
'configurationId': configurationId,
|
||||
'sectionId': sectionId,
|
||||
/*'rssi': rssi,
|
||||
@ -26,6 +28,7 @@ class BeaconSection {
|
||||
factory BeaconSection.fromJson(Map<String, dynamic> json) {
|
||||
return BeaconSection(
|
||||
minorBeaconId: json['minorBeaconId'] as int,
|
||||
orderInConfig: json['orderInConfig'] as int,
|
||||
configurationId: json['configurationId'] as String,
|
||||
sectionId: json['sectionId'] as String,
|
||||
/*rssi: json['rssi'] as int,
|
||||
@ -37,6 +40,6 @@ class BeaconSection {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeaconSection{minorBeaconId: $minorBeaconId, sectionId: $sectionId, configurationId: $configurationId, found: $found}';
|
||||
return 'BeaconSection{minorBeaconId: $minorBeaconId, orderInConfig: $orderInConfig, sectionId: $sectionId, configurationId: $configurationId, found: $found}';
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
if(visitAppContext.beaconSections == null) {
|
||||
List<SectionDTO>? sections = await ApiService.getAllBeacons(client, visitAppContext.instanceId!);
|
||||
if(sections != null && sections.isNotEmpty) {
|
||||
List<BeaconSection> beaconSections = sections.map((e) => BeaconSection(minorBeaconId: e.beaconId, configurationId: e.configurationId, sectionId: e.id)).toList();
|
||||
List<BeaconSection> beaconSections = sections.map((e) => BeaconSection(minorBeaconId: e.beaconId, orderInConfig: e.order, configurationId: e.configurationId, sectionId: e.id)).toList();
|
||||
visitAppContext.beaconSections = beaconSections;
|
||||
print("Got some Beacons for you");
|
||||
print(beaconSections);
|
||||
|
||||
@ -188,6 +188,11 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
var checkIfMoreThanSec = (DateTime.now().millisecondsSinceEpoch - milliLastTime) > timeBetweenBeaconPopUp;
|
||||
|
||||
if(!_isDialogShowing && !visitAppContext.isArticleCurrentlyShown && checkIfMoreThanSec && visitAppContext.isScanningBeacons) {
|
||||
print("Before sorting");
|
||||
print(beaconList);
|
||||
beaconList.toList().sort((a, b) => a!.orderInConfig!.compareTo(b!.orderInConfig!));
|
||||
print("after storting");
|
||||
print(beaconList);
|
||||
_onBeaconFound(visitAppContext, beaconList.first);
|
||||
} else {
|
||||
print("Non pas possible d'afficher pour le moment");
|
||||
@ -389,7 +394,6 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
|
||||
|
||||
if(!isCancel) {
|
||||
listeningState();
|
||||
if(Platform.isIOS) {
|
||||
Map<Permission, PermissionStatus> statuses0 = await [
|
||||
Permission.bluetooth,
|
||||
@ -437,6 +441,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
var status = await Permission.bluetoothScan.status;
|
||||
print(status);
|
||||
}
|
||||
listeningState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user