Beacon show popup + update get translate local
This commit is contained in:
parent
3f03f9d77e
commit
30dda83111
@ -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-15 10:23:40.765589","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-15 14:23:51.471028","version":"3.7.0"}
|
||||
@ -37,11 +37,11 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
setState(() {
|
||||
VisitAppContext visitAppContext = appContext.getContext();
|
||||
visitAppContext.configuration = null;
|
||||
visitAppContext.isBeaconEnabled = false;
|
||||
Navigator.of(context).pop();
|
||||
/*Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
visitAppContext.isScanningBeacons = false;
|
||||
//Navigator.of(context).pop();
|
||||
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(
|
||||
builder: (context) => const HomePage(),
|
||||
));*/
|
||||
),(route) => false);
|
||||
});
|
||||
}
|
||||
) : null,
|
||||
|
||||
@ -147,7 +147,7 @@ class _ScannerDialogState extends State<ScannerDialog> {
|
||||
VisitAppContext visitAppContext = widget.appContext!.getContext();
|
||||
if(!visitAppContext.sectionIds!.contains(code)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale('invalidQRCode', widget.appContext!)), backgroundColor: kBlue2),
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale('invalidQRCode', widget.appContext!.getContext())), backgroundColor: kBlue2),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@ -156,7 +156,7 @@ class _ScannerDialogState extends State<ScannerDialog> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ArticlePage(articleId: code);
|
||||
return ArticlePage(visitAppContextIn: visitAppContext, articleId: code);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -43,7 +43,7 @@ class _SearchBoxState extends State<SearchBox> {
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: const Icon(Icons.search, color: Colors.white),
|
||||
hintText: TranslationHelper.getFromLocale("search", appContext),
|
||||
hintText: TranslationHelper.getFromLocale("search", appContext.getContext()),
|
||||
hintStyle: const TextStyle(color: Colors.white),
|
||||
suffixIcon: _controller.value.text.isNotEmpty ? InkWell(
|
||||
onTap: () {
|
||||
|
||||
@ -18,11 +18,11 @@ void showImagePopup(ImageDTO imageDTO, ResourceModel resourceModel, AppContext a
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if(TranslationHelper.get(imageDTO.title, appContext).isNotEmpty)
|
||||
if(TranslationHelper.get(imageDTO.title, appContext.getContext()).isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, left:8.0, right: 8.0),
|
||||
child: Text(
|
||||
TranslationHelper.get(imageDTO.title, appContext),
|
||||
TranslationHelper.get(imageDTO.title, appContext.getContext()),
|
||||
style: const TextStyle(fontSize: kArticleContentSize, fontWeight: FontWeight.w400)),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
@ -210,7 +210,7 @@ class DatabaseHelper {
|
||||
}
|
||||
|
||||
await DatabaseHelper.instance.queryAllRows(type).then((value) {
|
||||
print("DB - getData - CONTEXT --- $type --> ");
|
||||
//print("DB - getData - CONTEXT --- $type --> ");
|
||||
value.forEach((element) {
|
||||
switch(type) {
|
||||
case DatabaseTableType.main:
|
||||
@ -224,17 +224,17 @@ class DatabaseHelper {
|
||||
var test = getConfigurationFromDB(element);
|
||||
dataToReturn.add(getConfigurationFromDB(element));
|
||||
|
||||
print("DB - dataToReturn --- $test --> ");
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
case DatabaseTableType.sections:
|
||||
var test = getSectionFromDB(element);
|
||||
dataToReturn.add(getSectionFromDB(element));
|
||||
print("DB - dataToReturn --- $test --> ");
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
case DatabaseTableType.resources:
|
||||
var test = getResourceFromDB(element);
|
||||
dataToReturn.add(getResourceFromDB(element));
|
||||
print("DB - dataToReturn --- $test --> ");
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
import 'package:mymuseum_visitapp/translations.dart';
|
||||
|
||||
class TranslationHelper {
|
||||
static String get(List<TranslationDTO>? translationDTO, AppContext appContext) {
|
||||
static String get(List<TranslationDTO>? translationDTO, VisitAppContext visitAppContext) {
|
||||
try {
|
||||
return translationDTO!.where((element) => element.language == appContext.getContext().language).first.value!;
|
||||
return translationDTO!.where((element) => element.language == visitAppContext.language).first.value!;
|
||||
} catch (_) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
static String getFromLocale(String valueToGet, AppContext appContext) {
|
||||
static String getFromLocale(String valueToGet, VisitAppContext visitAppContext) {
|
||||
try {
|
||||
return translations.where((element) => element.language == appContext.getContext().language).first.data![valueToGet]!;
|
||||
return translations.where((element) => element.language == visitAppContext.language).first.data![valueToGet]!;
|
||||
} catch (_) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -4,21 +4,21 @@ class BeaconSection {
|
||||
String? macAddress;
|
||||
String? configurationId;
|
||||
String? sectionId;
|
||||
int? rssi;
|
||||
/*int? rssi;
|
||||
int? accuracy;
|
||||
String? proximityUUID;
|
||||
String? proximityUUID;*/
|
||||
bool? found = false;
|
||||
|
||||
BeaconSection({this.macAddress, this.configurationId, this.sectionId, this.rssi, this.accuracy, this.proximityUUID, this.found});
|
||||
BeaconSection({this.macAddress, this.configurationId, this.sectionId, this.found});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'macAddress': macAddress,
|
||||
'configurationId': configurationId,
|
||||
'sectionId': sectionId,
|
||||
'rssi': rssi,
|
||||
/*'rssi': rssi,
|
||||
'accuracy': accuracy,
|
||||
'proximityUUID': proximityUUID,
|
||||
'proximityUUID': proximityUUID,*/
|
||||
'found': found
|
||||
};
|
||||
}
|
||||
@ -28,15 +28,15 @@ class BeaconSection {
|
||||
macAddress: json['macAddress'] as String,
|
||||
configurationId: json['configurationId'] as String,
|
||||
sectionId: json['sectionId'] as String,
|
||||
rssi: json['rssi'] as int,
|
||||
/*rssi: json['rssi'] as int,
|
||||
accuracy: json['accuracy'] as int,
|
||||
proximityUUID: json['proximityUUID'] as String,
|
||||
proximityUUID: json['proximityUUID'] as String,*/
|
||||
found: json['found'] as bool
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BeaconSection{macAddress: $macAddress, sectionId: $sectionId, configurationId: $configurationId, rssi: $rssi, accuracy: $accuracy, proximityUUID: $proximityUUID, found: $found}';
|
||||
return 'BeaconSection{macAddress: $macAddress, sectionId: $sectionId, configurationId: $configurationId, found: $found}';
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,9 @@ class VisitAppContext with ChangeNotifier{
|
||||
ConfigurationDTO? configuration;
|
||||
List<String?>? sectionIds; // Use to valid QR code found
|
||||
List<BeaconSection?>? beaconSections;
|
||||
bool isBeaconEnabled = false;
|
||||
List<SectionDTO?>? currentSections;
|
||||
bool isArticleCurrentlyShown = false;
|
||||
bool isScanningBeacons = false;
|
||||
|
||||
VisitAppContext({this.language, this.id, this.configuration, this.instanceId});
|
||||
|
||||
|
||||
@ -20,9 +20,10 @@ import 'package:mymuseum_visitapp/constants.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ArticlePage extends StatefulWidget {
|
||||
const ArticlePage({Key? key, required this.articleId}) : super(key: key);
|
||||
const ArticlePage({Key? key, required this.visitAppContextIn, required this.articleId}) : super(key: key);
|
||||
|
||||
final String articleId;
|
||||
final VisitAppContext visitAppContextIn;
|
||||
|
||||
@override
|
||||
State<ArticlePage> createState() => _ArticlePageState();
|
||||
@ -35,6 +36,19 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
ResourceModel? audioResourceModel;
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
late Uint8List audiobytes;
|
||||
VisitAppContext? visitAppContext;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
widget.visitAppContextIn.isArticleCurrentlyShown = true;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
visitAppContext!.isArticleCurrentlyShown = false;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -42,10 +56,12 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
final notchInset = MediaQuery.of(context).padding;
|
||||
|
||||
visitAppContext = appContext.getContext();
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: CustomAppBar(
|
||||
title: sectionDTO != null ? TranslationHelper.get(sectionDTO!.title, appContext) : "",
|
||||
title: sectionDTO != null ? TranslationHelper.get(sectionDTO!.title, visitAppContext!) : "",
|
||||
isHomeButton: false,
|
||||
),
|
||||
body: FutureBuilder(
|
||||
@ -182,7 +198,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
TranslationHelper.get(articleDTO!.content, appContext),
|
||||
TranslationHelper.get(articleDTO!.content, appContext.getContext()),
|
||||
textAlign: TextAlign.left,
|
||||
style: const TextStyle(fontSize: kArticleContentSize)
|
||||
),
|
||||
@ -215,7 +231,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
TranslationHelper.get(articleDTO!.content, appContext),
|
||||
TranslationHelper.get(articleDTO!.content, appContext.getContext()),
|
||||
textAlign: TextAlign.left,
|
||||
style: const TextStyle(fontSize: kArticleContentSize)
|
||||
),
|
||||
@ -239,7 +255,6 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
List<Map<String, dynamic>> sectionTest = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.sections, articleId);
|
||||
if(sectionTest.isNotEmpty) {
|
||||
sectionDTO = DatabaseHelper.instance.getSectionFromDB(sectionTest.first);
|
||||
print("sectionDTO!.datasectionDTO!.datasectionDTO!.datasectionDTO!.data");
|
||||
} else {
|
||||
print("EMPTY SECTION");
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class _AudioPlayerContainerState extends State<AudioPlayerContainer> {
|
||||
}
|
||||
},
|
||||
icon: Icon(isplaying?Icons.pause:Icons.play_arrow),
|
||||
label:Text(isplaying?TranslationHelper.getFromLocale("pause", appContext):TranslationHelper.getFromLocale("play", appContext))
|
||||
label:Text(isplaying?TranslationHelper.getFromLocale("pause", appContext.getContext()):TranslationHelper.getFromLocale("play", appContext.getContext()))
|
||||
),
|
||||
|
||||
ElevatedButton.icon(
|
||||
@ -162,7 +162,7 @@ class _AudioPlayerContainerState extends State<AudioPlayerContainer> {
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.stop),
|
||||
label: Text(TranslationHelper.getFromLocale("stop", appContext))
|
||||
label: Text(TranslationHelper.getFromLocale("stop", appContext.getContext()))
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@ -31,8 +31,7 @@ class ConfigurationsList extends StatefulWidget {
|
||||
State<ConfigurationsList> createState() => _ConfigurationsListState();
|
||||
}
|
||||
|
||||
class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBindingObserver {
|
||||
final controller = Get.find<RequirementStateController>();
|
||||
class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
List<ConfigurationDTO> configurations = [];
|
||||
List<String?> alreadyDownloaded = [];
|
||||
VisitAppContext? visitAppContext;
|
||||
@ -51,14 +50,6 @@ class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBin
|
||||
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
|
||||
@ -69,49 +60,48 @@ class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBin
|
||||
if(configurations[index].isOffline! && alreadyDownloaded.any((c) => c == configurations[index].id)) {
|
||||
if(!configurations[index].languages!.contains(visitAppContext.language)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale("languageNotSupported", appContext)), backgroundColor: kBlue2),
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale("languageNotSupported", appContext.getContext())), backgroundColor: kBlue2),
|
||||
);
|
||||
} else {
|
||||
// Update context
|
||||
visitAppContext.configuration = configurations[index];
|
||||
visitAppContext.sectionIds = configurations[index].sectionIds;
|
||||
|
||||
//visitAppContext.sectionIds = List<SectionDTO>.from(await DatabaseHelper.instance.queryWithConfigurationId(DatabaseTableType.sections, visitAppContext.configuration!.id!)).map((e) => e.id).toList();
|
||||
appContext.setContext(visitAppContext);
|
||||
|
||||
Navigator.push(
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => VisitPage(configurationId: configurations[index].id!),
|
||||
));
|
||||
/*Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => VisitPage(configurationId: configurations[index].id!)
|
||||
),
|
||||
);
|
||||
/*Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => VisitPage(configurationId: configurations[index].id!),
|
||||
));*/
|
||||
);*/
|
||||
/**/
|
||||
}
|
||||
} else {
|
||||
if(configurations[index].isOffline!) {
|
||||
// Not already downloaded
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale("visitDownloadWarning", appContext)), backgroundColor: kBlue2),
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale("visitDownloadWarning", appContext.getContext())), backgroundColor: kBlue2),
|
||||
);
|
||||
} else {
|
||||
// Online mode
|
||||
// Update context
|
||||
visitAppContext.configuration = configurations[index];
|
||||
//List<SectionDTO>? sections = await ApiService.getAllSections(appContext.clientAPI, visitAppContext.configuration!.id!);
|
||||
visitAppContext.sectionIds = configurations[index].sectionIds;
|
||||
|
||||
Navigator.push(
|
||||
/*Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => VisitPage(configurationId: configurations[index].id!)
|
||||
),
|
||||
);
|
||||
);*/
|
||||
|
||||
/*Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => VisitPage(configurationId: configurations[index].id!),
|
||||
));*/
|
||||
));
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -159,7 +149,7 @@ class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBin
|
||||
),
|
||||
) : const Text("");
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext));
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext.getContext()));
|
||||
} else {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
@ -179,7 +169,7 @@ class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBin
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: AutoSizeText(
|
||||
TranslationHelper.get(configurations[index].title, appContext),
|
||||
TranslationHelper.get(configurations[index].title, appContext.getContext()),
|
||||
style: const TextStyle(fontSize: kMenuTitleDetailSize),
|
||||
maxFontSize: 18,
|
||||
maxLines: 2,
|
||||
@ -223,7 +213,7 @@ class _ConfigurationsListState extends State<ConfigurationsList> with WidgetsBin
|
||||
}
|
||||
|
||||
Future<void> downloadClicked(AppContext appContext, ConfigurationDTO configuration) async {
|
||||
String loadingtext = TranslationHelper.getFromLocale("downloadConfiguration", appContext);
|
||||
String loadingtext = TranslationHelper.getFromLocale("downloadConfiguration", appContext.getContext());
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
|
||||
@ -45,7 +45,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: TranslationHelper.getFromLocale("visitTitle", appContext),
|
||||
title: TranslationHelper.getFromLocale("visitTitle", appContext.getContext()),
|
||||
isHomeButton: false,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
@ -72,7 +72,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
),
|
||||
);
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext));
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext.getContext()));
|
||||
} else {
|
||||
return Center(
|
||||
child: Container(
|
||||
@ -123,12 +123,9 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
configurations = List<ConfigurationDTO>.from(await DatabaseHelper.instance.getData(DatabaseTableType.configurations));
|
||||
alreadyDownloaded = configurations.map((c) => c.id).toList();
|
||||
|
||||
print("alreadyDownloadedalreadyDownloadedalreadyDownloadedalreadyDownloadedalreadyDownloadedalreadyDownloaded");
|
||||
print(alreadyDownloaded);
|
||||
|
||||
if(!isOnline) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale("noInternet", appContext)), backgroundColor: kBlue2),
|
||||
SnackBar(content: Text(TranslationHelper.getFromLocale("noInternet", appContext.getContext())), backgroundColor: kBlue2),
|
||||
);
|
||||
|
||||
// TODO HANDLE BEACON IN LOCAL (CREATE TABLE)
|
||||
|
||||
@ -4,7 +4,9 @@ import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mymuseum_visitapp/Components/CustomAppBar.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Article/article.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||
|
||||
// NOT USED ANYMORE
|
||||
@ -178,7 +180,7 @@ class _ScannerPageState extends State<ScannerPage> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ArticlePage(articleId: code);
|
||||
return ArticlePage(articleId: code, visitAppContextIn: VisitAppContext()); // will not work..
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
@ -6,11 +8,14 @@ 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/resourceModel.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/client.dart';
|
||||
import 'package:mymuseum_visitapp/constants.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BeaconArticleFound extends StatefulWidget {
|
||||
@ -23,30 +28,108 @@ class BeaconArticleFound extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BeaconArticleFoundState extends State<BeaconArticleFound> {
|
||||
VisitAppContext? visitAppContext;
|
||||
SectionDTO? sectionFound;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return Container(
|
||||
height: size.height *0.5,
|
||||
visitAppContext = appContext.getContext();
|
||||
|
||||
if(widget.beaconSection != null && visitAppContext!.currentSections != null && visitAppContext!.currentSections!.isNotEmpty)
|
||||
{
|
||||
var testSection = visitAppContext!.currentSections!.where((section) => section!.id.toString() == widget.beaconSection!.sectionId.toString()).toList();
|
||||
sectionFound = testSection.isNotEmpty ? testSection.first : null;
|
||||
}
|
||||
|
||||
return FutureBuilder(
|
||||
future: getSectionImage(appContext, appContext.clientAPI, sectionFound),
|
||||
builder: (context, AsyncSnapshot<ResourceModel?> snapshot) {
|
||||
return SizedBox(
|
||||
height: size.height *0.4,
|
||||
width: size.width *0.9,
|
||||
child: Stack(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
widget.beaconSection!.macAddress!,
|
||||
)
|
||||
if(snapshot.data != null)
|
||||
SizedBox(
|
||||
height: size.height * 0.25,
|
||||
width: size.width * 0.75,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
child: visitAppContext!.configuration!.isOffline! ?
|
||||
Image.memory(
|
||||
base64Decode(snapshot.data!.data!),
|
||||
fit: BoxFit.cover
|
||||
) :
|
||||
Image.network(
|
||||
snapshot.data!.source!,
|
||||
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,
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Text('close')
|
||||
)
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
TranslationHelper.get(sectionFound!.title, appContext.getContext()), style: TextStyle(fontSize: kMenuTitleDetailSize), textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
/*Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text("Non"),
|
||||
Text("Ouvrir")
|
||||
],
|
||||
)*/
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Future<ResourceModel?> getSectionImage(AppContext appContext, Client clientAPI, SectionDTO? sectionFound) async {
|
||||
if(sectionFound == null) {
|
||||
return null;
|
||||
}
|
||||
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
||||
if(isConfigOffline) {
|
||||
List<Map<String, dynamic>> resource = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, sectionFound.imageId!);
|
||||
if(resource.isNotEmpty) {
|
||||
return DatabaseHelper.instance.getResourceFromDB(resource.first);
|
||||
} else {
|
||||
print("EMPTY resourcesModel - getSectionImage");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@ class _BodyState extends State<Body> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ArticlePage(
|
||||
visitAppContextIn: appContext.getContext(),
|
||||
articleId: sectionsToDisplay[index].id!,
|
||||
),
|
||||
),
|
||||
@ -113,7 +114,7 @@ class _BodyState extends State<Body> {
|
||||
),
|
||||
);
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext));
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext.getContext()));
|
||||
} else {
|
||||
return Center(
|
||||
child: Container(
|
||||
@ -133,7 +134,8 @@ class _BodyState extends State<Body> {
|
||||
}
|
||||
|
||||
getSections(AppContext appContext) async {
|
||||
if((appContext.getContext() as VisitAppContext).configuration!.isOffline!)
|
||||
VisitAppContext visitAppContext = (appContext.getContext() as VisitAppContext);
|
||||
if(visitAppContext.configuration!.isOffline!)
|
||||
{
|
||||
// OFFLINE
|
||||
sections = List<SectionDTO>.from(await DatabaseHelper.instance.getData(DatabaseTableType.sections));
|
||||
@ -141,7 +143,7 @@ class _BodyState extends State<Body> {
|
||||
else
|
||||
{
|
||||
// ONLINE
|
||||
List<SectionDTO>? sectionsDownloaded = await ApiService.getAllSections(appContext.clientAPI, (appContext.getContext() as VisitAppContext).configuration!.id!);
|
||||
List<SectionDTO>? sectionsDownloaded = await ApiService.getAllSections(appContext.clientAPI, visitAppContext.configuration!.id!);
|
||||
print(sectionsDownloaded);
|
||||
if(sectionsDownloaded!.isNotEmpty) {
|
||||
sections = sectionsDownloaded.where((s) => s.type == SectionType.Article).toList(); // HERE TODO IF support more than article type
|
||||
@ -153,8 +155,10 @@ class _BodyState extends State<Body> {
|
||||
sections.sort((a,b) => a.order!.compareTo(b.order!));
|
||||
sectionsToDisplay = sections;
|
||||
|
||||
visitAppContext.currentSections = sectionsToDisplay;
|
||||
|
||||
if(searchValue != '' && searchValue != null) {
|
||||
sectionsToDisplay = sections.where((s) => TranslationHelper.get(s.title, appContext).toLowerCase().contains(searchValue.toString().toLowerCase())).toList();
|
||||
sectionsToDisplay = sections.where((s) => TranslationHelper.get(s.title, appContext.getContext()).toLowerCase().contains(searchValue.toString().toLowerCase())).toList();
|
||||
} else {
|
||||
if(searchNumberValue != null) {
|
||||
sectionsToDisplay = sections.where((s) => s.order!+1 == searchNumberValue).toList();
|
||||
|
||||
@ -81,8 +81,7 @@ class SectionCard extends StatelessWidget {
|
||||
future: ApiService.getResource(appContext, sectionDTO.imageId!),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return snapshot.data != null ? Container(
|
||||
child: ClipRRect(
|
||||
return snapshot.data != null ? ClipRRect(
|
||||
borderRadius: const BorderRadius.only(topRight: Radius.circular(20), bottomRight: Radius.circular(20)),
|
||||
child: isOffline ?
|
||||
Image.memory(
|
||||
@ -108,10 +107,9 @@ class SectionCard extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
) : const Text("");
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext));
|
||||
return Text(TranslationHelper.getFromLocale("noData", appContext.getContext()));
|
||||
} else {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
@ -140,7 +138,7 @@ class SectionCard extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
|
||||
child: Text(
|
||||
TranslationHelper.get(sectionDTO.title, appContext),
|
||||
TranslationHelper.get(sectionDTO.title, appContext.getContext()),
|
||||
style: Theme.of(context).textTheme.button,
|
||||
),
|
||||
),
|
||||
|
||||
@ -12,6 +12,7 @@ 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/Article/article.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Visit/beaconArticleFound.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
import 'package:mymuseum_visitapp/constants.dart';
|
||||
@ -32,13 +33,17 @@ class VisitPage extends StatefulWidget {
|
||||
class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
ConfigurationDTO? configuration;
|
||||
|
||||
int timeBetweenBeaconPopUp = 25000; // 25 sec
|
||||
|
||||
// Beacon specific
|
||||
final controller = Get.find<RequirementStateController>();
|
||||
StreamSubscription<BluetoothState>? _streamBluetooth;
|
||||
StreamSubscription<RangingResult>? _streamRanging;
|
||||
final _regionBeacons = <Region, List<Beacon>>{};
|
||||
final _beacons = <Beacon>[];
|
||||
/*final _regionBeacons = <Region, List<Beacon>>{};
|
||||
final _beacons = <Beacon>[];*/
|
||||
bool _isDialogShowing = false;
|
||||
DateTime? lastTimePopUpWasClosed;
|
||||
//bool _isArticleOpened = false;
|
||||
StreamSubscription? listener;
|
||||
|
||||
@override
|
||||
@ -46,7 +51,6 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
super.initState();
|
||||
|
||||
listeningState();
|
||||
}
|
||||
|
||||
@ -97,7 +101,6 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
].request();
|
||||
print(statuses[Permission.bluetoothScan]);
|
||||
print(statuses[Permission.bluetoothConnect]);
|
||||
|
||||
print(status);
|
||||
|
||||
/*controller.startStream.listen((flag) {
|
||||
@ -153,21 +156,29 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
print(result.beacons.map((b) => b.macAddress));
|
||||
print(visitAppContext.beaconSections!.map((bb) => bb!.macAddress));
|
||||
|
||||
var beaconList = visitAppContext.beaconSections!.where((bs) => result.beacons.any((element) => element.macAddress == bs!.macAddress));
|
||||
var beaconList = visitAppContext.beaconSections!.where((bs) => result.beacons.any((element) => element.macAddress == bs!.macAddress && element.accuracy < 15)); // less than 15 meter away
|
||||
if(beaconList.isNotEmpty)
|
||||
{
|
||||
print("GOT ONE BEACON THAT I KNOOOOOOOOW");
|
||||
print(beaconList);
|
||||
|
||||
// TODO SORT BY COMPARE
|
||||
var milliLastTime = lastTimePopUpWasClosed == null ? 0 : lastTimePopUpWasClosed!.millisecondsSinceEpoch;
|
||||
var checkIfMoreThanSec = (DateTime.now().millisecondsSinceEpoch - milliLastTime) > timeBetweenBeaconPopUp;
|
||||
|
||||
if(!_isDialogShowing) {
|
||||
_onBeaconFound(visitAppContext, beaconList.first!);
|
||||
if(!_isDialogShowing && !visitAppContext.isArticleCurrentlyShown && checkIfMoreThanSec && visitAppContext.isScanningBeacons) {
|
||||
print("CONFIGURATIOON");
|
||||
print(visitAppContext.configuration!.id);
|
||||
|
||||
var beaconListConfig = beaconList.where((beacon) => beacon!.configurationId == visitAppContext.configuration!.id!);
|
||||
|
||||
print("AFTERRRR");
|
||||
print(beaconListConfig);
|
||||
|
||||
_onBeaconFound(visitAppContext, beaconListConfig.first);
|
||||
} else {
|
||||
print("Already showing làà");
|
||||
print("Non pas possible d'afficher pour le moment");
|
||||
}
|
||||
|
||||
|
||||
//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),
|
||||
@ -227,23 +238,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
/*Widget build(BuildContext context) {
|
||||
return new WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("data"),
|
||||
leading: new IconButton(
|
||||
icon: new Icon(Icons.ac_unit),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}*/
|
||||
|
||||
void _onBeaconFound(VisitAppContext visitAppContext, BeaconSection beaconSection) {
|
||||
void _onBeaconFound(VisitAppContext visitAppContext, BeaconSection? beaconSection) {
|
||||
_isDialogShowing = true;
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
@ -254,13 +249,33 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
content: BeaconArticleFound(beaconSection: beaconSection),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("CANCEL"),
|
||||
child: Text(TranslationHelper.getFromLocale("close", visitAppContext), style: TextStyle(color: kMainColor)),
|
||||
onPressed: () {
|
||||
_isDialogShowing = false; // set it `false` since dialog is closed
|
||||
Navigator.of(context).pop();
|
||||
lastTimePopUpWasClosed = DateTime.now();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(TranslationHelper.getFromLocale("open", visitAppContext), style: TextStyle(color: kMainColor)),
|
||||
onPressed: () {
|
||||
_isDialogShowing = false; // set it `false` since dialog is closed
|
||||
Navigator.of(context).pop();
|
||||
//visitAppContext.isArticleCurrentlyShown = true;
|
||||
lastTimePopUpWasClosed = DateTime.now();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ArticlePage(
|
||||
visitAppContextIn: visitAppContext,
|
||||
articleId: beaconSection!.sectionId!,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
actionsAlignment: MainAxisAlignment.spaceAround,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
), context: context
|
||||
);
|
||||
@ -271,18 +286,21 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
@override
|
||||
void onDispose() {
|
||||
print("DISPOSE VISIT PAGE");
|
||||
|
||||
void dispose() {
|
||||
print("DISPOSE VISIT PAGE -------------------------------");
|
||||
/*listener = null;
|
||||
controller.dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);*/
|
||||
controller.pauseScanning();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
VisitAppContext visitAppContext = appContext.getContext();
|
||||
configuration = visitAppContext.configuration;
|
||||
|
||||
//if(visitAppContext.isBeaconEnabled) {
|
||||
listener = controller.startStream.listen((flag) async {
|
||||
print(flag);
|
||||
if (flag == true) {
|
||||
@ -291,12 +309,11 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
controller.startScanning();
|
||||
}
|
||||
});
|
||||
//}
|
||||
|
||||
return /*WillPopScope(
|
||||
child:*/ Scaffold(
|
||||
return WillPopScope(
|
||||
child: Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: TranslationHelper.get(configuration!.title, appContext),
|
||||
title: TranslationHelper.get(configuration!.title, visitAppContext),
|
||||
isHomeButton: true,
|
||||
),
|
||||
backgroundColor: kBackgroundGrey,
|
||||
@ -313,30 +330,28 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
child: FittedBox(
|
||||
child: FloatingActionButton(
|
||||
heroTag: "beacon",
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if(!visitAppContext.isBeaconEnabled) {
|
||||
onPressed: () async {
|
||||
if(!visitAppContext.isScanningBeacons) {
|
||||
print("Start Scan");
|
||||
controller.startScanning();
|
||||
listener!.resume();
|
||||
print(_streamRanging);
|
||||
if (_streamRanging != null) {
|
||||
_streamRanging?.resume();
|
||||
} else {
|
||||
await initScanBeacon(visitAppContext);
|
||||
}
|
||||
|
||||
visitAppContext.isBeaconEnabled = true;
|
||||
controller.startScanning();
|
||||
visitAppContext.isScanningBeacons = true;
|
||||
appContext.setContext(visitAppContext);
|
||||
} else {
|
||||
print("Pause Scan");
|
||||
controller.pauseScanning(); // PAUSE OR DISPOSE ?
|
||||
//controller.dispose(); // PAUSE OR DISPOSE ?
|
||||
print(controller.pauseStream);
|
||||
listener!.cancel();
|
||||
listener!.pause();
|
||||
//controller.removeListenerId(listener.i, () { });
|
||||
visitAppContext.isBeaconEnabled = false;
|
||||
visitAppContext.isScanningBeacons = false;
|
||||
appContext.setContext(visitAppContext);
|
||||
}
|
||||
});
|
||||
},
|
||||
tooltip: 'Beacon',
|
||||
backgroundColor: visitAppContext.isBeaconEnabled ? kBlue1 : Colors.grey,
|
||||
backgroundColor: visitAppContext.isScanningBeacons ? kBlue1 : Colors.grey,
|
||||
child: const Icon(Icons.my_location),
|
||||
),
|
||||
),
|
||||
@ -348,30 +363,10 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
child: ScannerBouton(appContext: appContext),
|
||||
),
|
||||
],
|
||||
),/*Padding(
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
height: 65.0,
|
||||
width: 65.0,
|
||||
child: FittedBox(
|
||||
child: FloatingActionButton(
|
||||
heroTag: "beacon",
|
||||
onPressed: () {},
|
||||
tooltip: 'Beacon',
|
||||
backgroundColor: kBlue1,
|
||||
child: const Icon(Icons.qr_code_scanner),
|
||||
),
|
||||
),
|
||||
),
|
||||
ScannerBouton(appContext: appContext),
|
||||
],
|
||||
),
|
||||
),*/
|
||||
);//,
|
||||
//onWillPop: () async => false,
|
||||
//);
|
||||
onWillPop: () async => false,
|
||||
);
|
||||
}
|
||||
|
||||
handleOpenLocationSettings() async {
|
||||
|
||||
@ -12,7 +12,9 @@ List<Translation> translations = [
|
||||
"search": "Rechercher",
|
||||
"play": "Lecture",
|
||||
"pause": "Pause",
|
||||
"stop": "Arrêt"
|
||||
"stop": "Arrêt",
|
||||
"open": "Ouvrir",
|
||||
"close": "Fermer"
|
||||
}),
|
||||
Translation(language: "EN", data: {
|
||||
"visitTitle": "List of tours",
|
||||
@ -25,7 +27,9 @@ List<Translation> translations = [
|
||||
"search": "Search",
|
||||
"play": "Play",
|
||||
"pause": "Pause",
|
||||
"stop": "Stop"
|
||||
"stop": "Stop",
|
||||
"open": "Open",
|
||||
"close": "Close"
|
||||
}),
|
||||
Translation(language: "DE", data: {
|
||||
"visitTitle": "Liste der Touren",
|
||||
@ -38,7 +42,9 @@ List<Translation> translations = [
|
||||
"search": "Suche",
|
||||
"play": "Spiel",
|
||||
"pause": "Pause",
|
||||
"stop": "Stopp"
|
||||
"stop": "Stopp",
|
||||
"open": "Offen",
|
||||
"close": "Schließen"
|
||||
}),
|
||||
Translation(language: "NL", data: {
|
||||
"visitTitle": "Lijst met rondleidingen",
|
||||
@ -51,7 +57,9 @@ List<Translation> translations = [
|
||||
"search": "Zoeken",
|
||||
"play": "Speel",
|
||||
"pause": "Pauze",
|
||||
"stop": "Stop"
|
||||
"stop": "Stop",
|
||||
"open": "Open",
|
||||
"close": "Sluiten"
|
||||
}),
|
||||
Translation(language: "IT", data: {
|
||||
"visitTitle": "Elenco dei tour",
|
||||
@ -64,7 +72,9 @@ List<Translation> translations = [
|
||||
"search": "Ricerca",
|
||||
"play": "Giocare a",
|
||||
"pause": "Pausa",
|
||||
"stop": "Fermare"
|
||||
"stop": "Fermare",
|
||||
"open": "Aprire",
|
||||
"close": "Chiudere"
|
||||
}),
|
||||
Translation(language: "ES", data: {
|
||||
"visitTitle": "Lista de recorridos",
|
||||
@ -77,7 +87,9 @@ List<Translation> translations = [
|
||||
"search": "Búsqueda",
|
||||
"play": "Tocar",
|
||||
"pause": "Pausa",
|
||||
"stop": "Parada"
|
||||
"stop": "Parada",
|
||||
"open": "Abrir",
|
||||
"close": "Cerca"
|
||||
}),
|
||||
Translation(language: "PL", data: {
|
||||
"visitTitle": "Lista wycieczek",
|
||||
@ -90,7 +102,9 @@ List<Translation> translations = [
|
||||
"search": "Szukaj",
|
||||
"play": "Bawić się",
|
||||
"pause": "Pauza",
|
||||
"stop": "Stop"
|
||||
"stop": "Stop",
|
||||
"open": "Otwarty",
|
||||
"close": "Zamknąć"
|
||||
}),
|
||||
Translation(language: "CN", data: {
|
||||
"visitTitle": "旅游清单",
|
||||
@ -103,7 +117,9 @@ List<Translation> translations = [
|
||||
"search": "搜索",
|
||||
"play": "玩",
|
||||
"pause": "暫停",
|
||||
"stop": "停止"
|
||||
"stop": "停止",
|
||||
"open": "打开",
|
||||
"close": "关闭"
|
||||
}),
|
||||
Translation(language: "UK", data: {
|
||||
"visitTitle": "Список турів",
|
||||
@ -116,7 +132,9 @@ List<Translation> translations = [
|
||||
"search": "Пошук",
|
||||
"play": "грати",
|
||||
"pause": "Пауза",
|
||||
"stop": "Стоп"
|
||||
"stop": "Стоп",
|
||||
"open": "ВІДЧИНЕНО",
|
||||
"close": "Закрити"
|
||||
}),
|
||||
Translation(language: "AR", data: {
|
||||
"visitTitle": "قائمة الجولات",
|
||||
@ -129,6 +147,8 @@ List<Translation> translations = [
|
||||
"search": "يبحث",
|
||||
"play": "لعب",
|
||||
"pause": "وقفة",
|
||||
"stop": "قف"
|
||||
"stop": "قف",
|
||||
"open": "يفتح",
|
||||
"close": "يغلق"
|
||||
}),
|
||||
];
|
||||
Loading…
x
Reference in New Issue
Block a user