Solve config image issue + wip beacon popup
This commit is contained in:
parent
91f43afa97
commit
8e60f08fbf
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","native_build":true,"dependencies":[]},{"name":"flutter_beacon","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_beacon-0.5.1\\\\","native_build":true,"dependencies":[]},{"name":"just_audio","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio-0.9.31\\\\","native_build":true,"dependencies":["audio_session"]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.1.1\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler-8.3.0\\\\","native_build":true,"dependencies":[]},{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.2.4+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","native_build":true,"dependencies":[]},{"name":"flutter_beacon","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_beacon-0.5.1\\\\","native_build":true,"dependencies":[]},{"name":"just_audio","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio-0.9.31\\\\","native_build":true,"dependencies":["audio_session"]},{"name":"path_provider_android","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.0.22\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler-8.3.0\\\\","native_build":true,"dependencies":[]},{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.2.4+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","native_build":true,"dependencies":[]},{"name":"just_audio","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio-0.9.31\\\\","native_build":true,"dependencies":["audio_session"]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.1.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.2.4+1\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.1.7\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.1.3\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","dependencies":[]},{"name":"just_audio_web","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio_web-0.4.7\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"audio_session","dependencies":[]},{"name":"flutter_beacon","dependencies":[]},{"name":"just_audio","dependencies":["just_audio_web","audio_session","path_provider"]},{"name":"just_audio_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2023-02-10 17:36:53.315670","version":"3.7.0"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","native_build":true,"dependencies":[]},{"name":"flutter_beacon","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_beacon-0.5.1\\\\","native_build":true,"dependencies":[]},{"name":"just_audio","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio-0.9.31\\\\","native_build":true,"dependencies":["audio_session"]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.1.1\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler-8.3.0\\\\","native_build":true,"dependencies":[]},{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.2.4+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","native_build":true,"dependencies":[]},{"name":"flutter_beacon","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_beacon-0.5.1\\\\","native_build":true,"dependencies":[]},{"name":"just_audio","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio-0.9.31\\\\","native_build":true,"dependencies":["audio_session"]},{"name":"path_provider_android","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.0.22\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\permission_handler-8.3.0\\\\","native_build":true,"dependencies":[]},{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.2.4+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","native_build":true,"dependencies":[]},{"name":"just_audio","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio-0.9.31\\\\","native_build":true,"dependencies":["audio_session"]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.1.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\sqflite-2.2.4+1\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.1.7\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.1.3\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"audio_session","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\audio_session-0.1.13\\\\","dependencies":[]},{"name":"just_audio_web","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\just_audio_web-0.4.7\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"audio_session","dependencies":[]},{"name":"flutter_beacon","dependencies":[]},{"name":"just_audio","dependencies":["just_audio_web","audio_session","path_provider"]},{"name":"just_audio_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2023-02-14 17:27:05.757016","version":"3.7.0"}
|
||||
@ -21,9 +21,7 @@ class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
Size get preferredSize => Size.fromHeight(_preferredHeight);
|
||||
}
|
||||
|
||||
class _CustomAppBarState extends State<CustomAppBar> with WidgetsBindingObserver {
|
||||
final controller = Get.find<RequirementStateController>();
|
||||
|
||||
class _CustomAppBarState extends State<CustomAppBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
@ -40,11 +38,6 @@ class _CustomAppBarState extends State<CustomAppBar> with WidgetsBindingObserver
|
||||
VisitAppContext visitAppContext = appContext.getContext();
|
||||
visitAppContext.configuration = null;
|
||||
visitAppContext.isBeaconEnabled = false;
|
||||
|
||||
// TODO ADD CHECK IF RUNNING
|
||||
print("PAUSE SCAAAAN");
|
||||
controller.pauseScanning();
|
||||
|
||||
Navigator.of(context).pop();
|
||||
/*Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => const HomePage(),
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchBox.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchNumberBox.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Article/article.dart';
|
||||
@ -30,7 +31,8 @@ class ConfigurationsList extends StatefulWidget {
|
||||
State<ConfigurationsList> createState() => _ConfigurationsListState();
|
||||
}
|
||||
|
||||
class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBindingObserver {
|
||||
final controller = Get.find<RequirementStateController>();
|
||||
List<ConfigurationDTO> configurations = [];
|
||||
List<String?> alreadyDownloaded = [];
|
||||
VisitAppContext? visitAppContext;
|
||||
@ -49,6 +51,14 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
visitAppContext = appContext.getContext();
|
||||
|
||||
|
||||
if(visitAppContext != null) {
|
||||
visitAppContext!.configuration = null;
|
||||
visitAppContext!.isBeaconEnabled = false;
|
||||
print("PAUSE SCAAAAN");
|
||||
controller.pauseScanning();
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
shrinkWrap: true, //I've set this as true here depending on what your listview content is
|
||||
//physics: NeverScrollableScrollPhysics(),//This prevents scrolling, but may inhibit refresh indicator, remove as you need
|
||||
@ -124,14 +134,30 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
future: ApiService.getResource(appContext, configurations[index].imageId!),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
print("RESULLT DATA");
|
||||
print(snapshot.data);
|
||||
return snapshot.data != null ? ClipRRect(
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), bottomLeft: Radius.circular(20)),
|
||||
child: snapshot.data.data != null ? Image.memory(
|
||||
base64Decode(snapshot.data.data!),
|
||||
fit: BoxFit.cover
|
||||
) : null,
|
||||
) : Image.network(
|
||||
configurations[index].imageSource!,
|
||||
fit: BoxFit.cover,
|
||||
loadingBuilder: (BuildContext context, Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) {
|
||||
return child;
|
||||
}
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: kBlue1,
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
) : const Text("");
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext));
|
||||
|
||||
52
lib/Screens/Visit/beaconArticleFound.dart
Normal file
52
lib/Screens/Visit/beaconArticleFound.dart
Normal file
@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchBox.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchNumberBox.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Models/beaconSection.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Article/article.dart';
|
||||
import 'package:mymuseum_visitapp/Services/apiService.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
import 'package:mymuseum_visitapp/constants.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BeaconArticleFound extends StatefulWidget {
|
||||
const BeaconArticleFound({Key? key, required this.beaconSection}) : super(key: key);
|
||||
|
||||
final BeaconSection? beaconSection;
|
||||
|
||||
@override
|
||||
State<BeaconArticleFound> createState() => _BeaconArticleFoundState();
|
||||
}
|
||||
|
||||
class _BeaconArticleFoundState extends State<BeaconArticleFound> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return Container(
|
||||
height: size.height *0.5,
|
||||
width: size.width *0.9,
|
||||
child: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
widget.beaconSection!.macAddress!,
|
||||
)
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Text('close')
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,7 +10,9 @@ import 'package:mymuseum_visitapp/Components/CustomAppBar.dart';
|
||||
import 'package:mymuseum_visitapp/Components/ScannerBouton.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Models/beaconSection.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Visit/beaconArticleFound.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
import 'package:mymuseum_visitapp/constants.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@ -36,6 +38,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
StreamSubscription<RangingResult>? _streamRanging;
|
||||
final _regionBeacons = <Region, List<Beacon>>{};
|
||||
final _beacons = <Beacon>[];
|
||||
bool _isDialogShowing = false;
|
||||
StreamSubscription? listener;
|
||||
|
||||
@override
|
||||
@ -158,12 +161,19 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
|
||||
// TODO SORT BY COMPARE
|
||||
|
||||
print("BEFORE SNACKBAR");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
if(!_isDialogShowing) {
|
||||
_onBeaconFound(visitAppContext, beaconList.first!);
|
||||
} else {
|
||||
print("Already showing làà");
|
||||
}
|
||||
|
||||
|
||||
//print("BEFORE SNACKBAR");
|
||||
/*ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('BEACON - ${result.beacons.first.macAddress} - ${result.beacons.first.accuracy} - ${result.beacons.first.proximity.name}'), backgroundColor: kBlue2),
|
||||
);
|
||||
|
||||
print("AFTER SNACKBAR");
|
||||
print("AFTER SNACKBAR");*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,6 +243,33 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
);
|
||||
}*/
|
||||
|
||||
void _onBeaconFound(VisitAppContext visitAppContext, BeaconSection beaconSection) {
|
||||
_isDialogShowing = true;
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0))
|
||||
),
|
||||
content: BeaconArticleFound(beaconSection: beaconSection),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("CANCEL"),
|
||||
onPressed: () {
|
||||
_isDialogShowing = false; // set it `false` since dialog is closed
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
contentPadding: EdgeInsets.zero,
|
||||
), context: context
|
||||
);
|
||||
/*Future.delayed(const Duration(seconds: 6), () {
|
||||
Navigator.pop(context); //pop dialog
|
||||
_isDialogShowing = false;
|
||||
});*/
|
||||
}
|
||||
|
||||
@override
|
||||
void onDispose() {
|
||||
print("DISPOSE VISIT PAGE");
|
||||
@ -277,6 +314,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
child: FloatingActionButton(
|
||||
heroTag: "beacon",
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if(!visitAppContext.isBeaconEnabled) {
|
||||
print("Start Scan");
|
||||
controller.startScanning();
|
||||
@ -295,6 +333,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
visitAppContext.isBeaconEnabled = false;
|
||||
appContext.setContext(visitAppContext);
|
||||
}
|
||||
});
|
||||
},
|
||||
tooltip: 'Beacon',
|
||||
backgroundColor: visitAppContext.isBeaconEnabled ? kBlue1 : Colors.grey,
|
||||
|
||||
@ -100,11 +100,15 @@ class ApiService {
|
||||
static Future<ResourceModel?> downloadImage(Client client, ImageDTO imageDTO) async {
|
||||
var source = imageDTO.source_;
|
||||
//print("SOURCE getAndDownloadImage");
|
||||
//print(source);
|
||||
if(imageDTO.source_ != null) {
|
||||
if(imageDTO.source_!.contains("localhost:5000")){
|
||||
print("Contains localhost:5000");
|
||||
source = imageDTO.source_!.replaceAll("http://localhost:5000", client.apiApi!.basePath);
|
||||
}
|
||||
} else {
|
||||
source = "https://api.mymuseum.be/api/Resource/"+imageDTO.resourceId!; // TODO UPDATE ROUTE
|
||||
}
|
||||
|
||||
HttpClient client2 = HttpClient();
|
||||
var _downloadData = <int>[];
|
||||
final HttpClientRequest request = await client2.getUrl(Uri.parse(source!));
|
||||
|
||||
@ -29,7 +29,11 @@ class DownloadConfiguration {
|
||||
var imageData = exportConfigurationDTO.resources!.where((element) => element.id == configuration.imageId);
|
||||
if(imageData.isNotEmpty) {
|
||||
ResourceModel resourceModel = ResourceModel(id: imageData.first.id, source: configuration.imageSource, data: imageData.first.data, type: imageData.first.type);
|
||||
try {
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
||||
} catch (e) {
|
||||
print("We got an issue inserting image data ${imageData.first.id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +49,11 @@ class DownloadConfiguration {
|
||||
// Update local DB - Sections
|
||||
for(var section in sectionsToKeep) {
|
||||
section.order = newOrder;
|
||||
try {
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.sections, ModelsHelper.sectionToMap(section));
|
||||
} catch (e) {
|
||||
print("We got an issue inserting section data ${section.id}");
|
||||
}
|
||||
|
||||
// Download section image
|
||||
if(section.imageId != null) {
|
||||
@ -53,7 +61,11 @@ class DownloadConfiguration {
|
||||
var imageData = exportConfigurationDTO.resources!.where((element) => element.id == section.imageId);
|
||||
if(imageData.isNotEmpty) {
|
||||
ResourceModel resourceModel = ResourceModel(id: imageData.first.id, source: section.imageSource, data: imageData.first.data, type: imageData.first.type);
|
||||
try {
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
||||
} catch (e) {
|
||||
print("We got an issue inserting image data ${imageData.first.id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +78,11 @@ class DownloadConfiguration {
|
||||
var imageData = exportConfigurationDTO.resources!.where((element) => element.id == image.resourceId);
|
||||
if(imageData.isNotEmpty) {
|
||||
ResourceModel resourceModel = ResourceModel(id: imageData.first.id, source: image.source_, data: imageData.first.data, type: imageData.first.type);
|
||||
try {
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
||||
} catch (e) {
|
||||
print("We got an issue inserting image data ${imageData.first.id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +93,11 @@ class DownloadConfiguration {
|
||||
var audioData = exportConfigurationDTO.resources!.where((element) => element.id == audioIdArticle.first.value);
|
||||
if(audioData.isNotEmpty) {
|
||||
ResourceModel resourceModel = ResourceModel(id: audioData.first.id, source: "", data: audioData.first.data, type: audioData.first.type);
|
||||
try {
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
||||
} catch (e) {
|
||||
print("We got an issue inserting audio data ${audioData.first.id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +109,11 @@ class DownloadConfiguration {
|
||||
for(var sectionIdToRemove in sectionIdsToRemove) {
|
||||
print("section with id removed");
|
||||
print(sectionIdToRemove);
|
||||
try {
|
||||
await DatabaseHelper.instance.delete(sectionIdToRemove!, DatabaseTableType.sections);
|
||||
} catch (e) {
|
||||
print("We got an issue deleting section id: ${sectionIdToRemove}");
|
||||
}
|
||||
}
|
||||
|
||||
cleanLocalResources(usedImageOrAudioIds, configuration);
|
||||
@ -177,7 +201,11 @@ void cleanLocalResources(List<String> usedImageIds, ConfigurationDTO configurati
|
||||
for(var resourceIdToRemove in resourceIdsToRemove) {
|
||||
print("resource with id removed ________________ !!!!!");
|
||||
print(resourceIdToRemove);
|
||||
try {
|
||||
await DatabaseHelper.instance.delete(resourceIdToRemove!, DatabaseTableType.resources);
|
||||
} catch (e) {
|
||||
print("We got an issue deleting resource id: ${resourceIdToRemove}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user