Update translations + add language selection on download + beacon update
This commit is contained in:
parent
30dda83111
commit
6d6871e440
@ -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 14:23:51.471028","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 16:22:54.587703","version":"3.7.0"}
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
||||
import 'package:mymuseum_visitapp/Models/resourceModel.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:path/path.dart';
|
||||
@ -10,7 +11,8 @@ enum DatabaseTableType {
|
||||
main,
|
||||
configurations,
|
||||
sections,
|
||||
resources
|
||||
resources,
|
||||
articleRead
|
||||
}
|
||||
|
||||
class DatabaseHelper {
|
||||
@ -49,6 +51,9 @@ class DatabaseHelper {
|
||||
|
||||
static final columnSource = 'source';
|
||||
|
||||
static final articleReadTable = 'articleRead';
|
||||
static final columnLastTimeOpen = 'readTime';
|
||||
|
||||
DatabaseHelper._privateConstructor();
|
||||
static final DatabaseHelper instance = DatabaseHelper._privateConstructor();
|
||||
|
||||
@ -71,6 +76,7 @@ class DatabaseHelper {
|
||||
$columnInstanceId TEXT NOT NULL
|
||||
)
|
||||
''');
|
||||
|
||||
await db.execute('''
|
||||
CREATE TABLE $configurationsTable (
|
||||
$columnId TEXT NOT NULL PRIMARY KEY,
|
||||
@ -116,6 +122,13 @@ class DatabaseHelper {
|
||||
$columnType INT NOT NULL
|
||||
)
|
||||
''');
|
||||
|
||||
await db.execute('''
|
||||
CREATE TABLE $articleReadTable (
|
||||
$columnId TEXT NOT NULL PRIMARY KEY,
|
||||
$columnLastTimeOpen INT NOT NULL
|
||||
)
|
||||
''');
|
||||
}
|
||||
|
||||
Future<int> insert(DatabaseTableType type, Map<String, Object?> info) async {
|
||||
@ -221,21 +234,21 @@ class DatabaseHelper {
|
||||
);
|
||||
break;
|
||||
case DatabaseTableType.configurations:
|
||||
var test = getConfigurationFromDB(element);
|
||||
dataToReturn.add(getConfigurationFromDB(element));
|
||||
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
case DatabaseTableType.sections:
|
||||
var test = getSectionFromDB(element);
|
||||
dataToReturn.add(getSectionFromDB(element));
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
case DatabaseTableType.resources:
|
||||
var test = getResourceFromDB(element);
|
||||
dataToReturn.add(getResourceFromDB(element));
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
case DatabaseTableType.articleRead:
|
||||
dataToReturn.add(getArticleReadFromDB(element));
|
||||
//print("DB - dataToReturn --- $test --> ");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}).catchError((error) {
|
||||
@ -254,6 +267,8 @@ class DatabaseHelper {
|
||||
return sectionsTable;
|
||||
case DatabaseTableType.resources:
|
||||
return resourcesTable;
|
||||
case DatabaseTableType.articleRead:
|
||||
return articleReadTable;
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,4 +318,11 @@ class DatabaseHelper {
|
||||
type: ResourceType.values[element["type"]]
|
||||
);
|
||||
}
|
||||
|
||||
ArticleRead getArticleReadFromDB(dynamic element) {
|
||||
return ArticleRead(
|
||||
id: element["id"],
|
||||
readTime: element["readTime"]
|
||||
);
|
||||
}
|
||||
}
|
||||
28
lib/Models/articleRead.dart
Normal file
28
lib/Models/articleRead.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
|
||||
class ArticleRead {
|
||||
String id = "";
|
||||
int readTime;
|
||||
|
||||
ArticleRead({required this.id, required this.readTime});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'readTime': readTime
|
||||
};
|
||||
}
|
||||
|
||||
factory ArticleRead.fromJson(Map<String, dynamic> json) {
|
||||
return ArticleRead(
|
||||
id: json['id'] as String,
|
||||
readTime: json['readTime'] as int
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ArticleRead{id: $id, readTime: $readTime}';
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
||||
import 'package:mymuseum_visitapp/Models/beaconSection.dart';
|
||||
|
||||
class VisitAppContext with ChangeNotifier{
|
||||
@ -11,6 +12,7 @@ class VisitAppContext with ChangeNotifier{
|
||||
List<String?>? sectionIds; // Use to valid QR code found
|
||||
List<BeaconSection?>? beaconSections;
|
||||
List<SectionDTO?>? currentSections;
|
||||
List<ArticleRead> readArticles = [];
|
||||
bool isArticleCurrentlyShown = false;
|
||||
bool isScanningBeacons = false;
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:mymuseum_visitapp/Components/SliderImages.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/networkCheck.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
||||
import 'package:mymuseum_visitapp/Models/resourceModel.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Article/audio_player.dart';
|
||||
@ -255,6 +256,16 @@ 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);
|
||||
try {
|
||||
ArticleRead articleRead = ArticleRead(id: sectionDTO!.id!, readTime: DateTime.now().millisecondsSinceEpoch);
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.articleRead, articleRead.toMap());
|
||||
visitAppContext!.readArticles.add(articleRead);
|
||||
|
||||
appContext.setContext(visitAppContext!);
|
||||
} catch (e) {
|
||||
print("DATABASE ERROR ARTICLEREAD");
|
||||
print(e);
|
||||
}
|
||||
} else {
|
||||
print("EMPTY SECTION");
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Components/LanguageSelection.dart';
|
||||
import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchBox.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchNumberBox.dart';
|
||||
@ -213,7 +214,50 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
}
|
||||
|
||||
Future<void> downloadClicked(AppContext appContext, ConfigurationDTO configuration) async {
|
||||
String loadingtext = TranslationHelper.getFromLocale("downloadConfiguration", appContext.getContext());
|
||||
bool isCancel = false;
|
||||
if(alreadyDownloaded.any((c) => c == configuration.id)) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
content: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(TranslationHelper.getFromLocale("downloadLanguage", appContext.getContext()), style: TextStyle(color: kMainColor)),
|
||||
const SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
LanguageSelection()
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(TranslationHelper.getFromLocale("close", appContext.getContext()), style: TextStyle(color: kMainColor)),
|
||||
onPressed: () {
|
||||
isCancel = true;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(TranslationHelper.getFromLocale("ok", appContext.getContext()), style: TextStyle(color: kMainColor)),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
actionsAlignment: MainAxisAlignment.spaceAround,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if(!isCancel) {
|
||||
String loadingText = TranslationHelper.getFromLocale("downloadConfiguration", appContext.getContext());
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
@ -229,20 +273,21 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Text(loadingtext)
|
||||
Text(loadingText)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
var isFinish = await DownloadConfiguration.downloadClicked(appContext, configuration);
|
||||
var isFinish = await DownloadConfiguration.download(appContext, configuration);
|
||||
print("C4EST FINIITO");
|
||||
print(isFinish);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boxDecoration(ConfigurationDTO configuration, bool isSelected) {
|
||||
return BoxDecoration(
|
||||
|
||||
@ -5,6 +5,7 @@ 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/articleRead.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Article/article.dart';
|
||||
import 'package:mymuseum_visitapp/Services/apiService.dart';
|
||||
|
||||
@ -3,7 +3,9 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Services/apiService.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
@ -29,6 +31,7 @@ class SectionCard extends StatelessWidget {
|
||||
// It will provide us total height and width of our screen
|
||||
Size size = MediaQuery.of(context).size;
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
VisitAppContext visitAppContext = appContext.getContext();
|
||||
bool isOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
||||
|
||||
return Container(
|
||||
@ -56,7 +59,7 @@ class SectionCard extends StatelessWidget {
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: visitAppContext.readArticles.any((element) => element.id == sectionDTO.id) ? kBackgroundGrey : Colors.white,
|
||||
border: Border.all(
|
||||
color: kBlue2,
|
||||
width: 0.2,
|
||||
@ -157,7 +160,7 @@ class SectionCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"${itemIndex+1}",
|
||||
"${sectionDTO.order!+1}",
|
||||
//style: Theme.of(context).textTheme.button,
|
||||
style: const TextStyle(color: Colors.white)
|
||||
),
|
||||
@ -171,6 +174,4 @@ class SectionCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -33,7 +33,9 @@ class VisitPage extends StatefulWidget {
|
||||
class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
ConfigurationDTO? configuration;
|
||||
|
||||
int timeBetweenBeaconPopUp = 25000; // 25 sec
|
||||
int timeBetweenBeaconPopUp = 20000; // 20 sec
|
||||
int meterToBeacon = 15; // 15 meters
|
||||
bool modeDebugBeacon = true;
|
||||
|
||||
// Beacon specific
|
||||
final controller = Get.find<RequirementStateController>();
|
||||
@ -73,20 +75,10 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
controller.updateAuthorizationStatus(authorizationStatus);
|
||||
print('AUTHORIZATION $authorizationStatus');
|
||||
|
||||
final locationServiceEnabled =
|
||||
await flutterBeacon.checkLocationServicesIfEnabled;
|
||||
final locationServiceEnabled = await flutterBeacon.checkLocationServicesIfEnabled;
|
||||
controller.updateLocationService(locationServiceEnabled);
|
||||
print('LOCATION SERVICE $locationServiceEnabled');
|
||||
|
||||
if (controller.bluetoothEnabled &&
|
||||
controller.authorizationStatusOk &&
|
||||
controller.locationServiceEnabled) {
|
||||
print('STATE READY');
|
||||
//if (currentIndex == 0) {
|
||||
print('SCANNING');
|
||||
//controller.startScanning();
|
||||
|
||||
|
||||
var status = await Permission.bluetoothScan.status;
|
||||
|
||||
if (status.isDenied) {
|
||||
@ -103,6 +95,14 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
print(statuses[Permission.bluetoothConnect]);
|
||||
print(status);
|
||||
|
||||
if (controller.bluetoothEnabled &&
|
||||
controller.authorizationStatusOk &&
|
||||
controller.locationServiceEnabled) {
|
||||
print('STATE READY');
|
||||
//if (currentIndex == 0) {
|
||||
print('SCANNING');
|
||||
//controller.startScanning();
|
||||
|
||||
/*controller.startStream.listen((flag) {
|
||||
if (flag == true) {
|
||||
initScanBeacon();
|
||||
@ -156,35 +156,32 @@ 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 && element.accuracy < 15)); // less than 15 meter away
|
||||
var beaconList = visitAppContext.beaconSections!.where((bs) => result.beacons.any((element) => element.macAddress == bs!.macAddress && element.accuracy < meterToBeacon));
|
||||
|
||||
if(beaconList.isNotEmpty) {
|
||||
// FILTER CONFIG
|
||||
beaconList = beaconList.where((beacon) => beacon!.configurationId == visitAppContext.configuration!.id!);
|
||||
}
|
||||
|
||||
if(beaconList.isNotEmpty && !modeDebugBeacon) {
|
||||
// FILTER ALREADY READ
|
||||
beaconList = beaconList.where((b) => !visitAppContext.readArticles.any((ra) => ra.id == b!.sectionId));
|
||||
}
|
||||
|
||||
if(beaconList.isNotEmpty)
|
||||
{
|
||||
print("GOT ONE BEACON THAT I KNOOOOOOOOW");
|
||||
print(beaconList);
|
||||
|
||||
var milliLastTime = lastTimePopUpWasClosed == null ? 0 : lastTimePopUpWasClosed!.millisecondsSinceEpoch;
|
||||
var checkIfMoreThanSec = (DateTime.now().millisecondsSinceEpoch - milliLastTime) > timeBetweenBeaconPopUp;
|
||||
|
||||
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);
|
||||
_onBeaconFound(visitAppContext, beaconList.first);
|
||||
} else {
|
||||
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),
|
||||
);
|
||||
|
||||
print("AFTER SNACKBAR");*/
|
||||
);*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,7 +206,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
}
|
||||
}*/
|
||||
|
||||
int _compareParameters(Beacon a, Beacon b) {
|
||||
/*int _compareParameters(Beacon a, Beacon b) {
|
||||
int compare = a.proximityUUID.compareTo(b.proximityUUID);
|
||||
|
||||
if (compare == 0) {
|
||||
@ -221,7 +218,7 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
return compare;
|
||||
}
|
||||
}*/
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||
@ -287,10 +284,6 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
print("DISPOSE VISIT PAGE -------------------------------");
|
||||
/*listener = null;
|
||||
controller.dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);*/
|
||||
controller.pauseScanning();
|
||||
super.dispose();
|
||||
}
|
||||
@ -331,6 +324,26 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
||||
child: FloatingActionButton(
|
||||
heroTag: "beacon",
|
||||
onPressed: () async {
|
||||
|
||||
if(!controller.authorizationStatusOk) {
|
||||
//await handleOpenLocationSettings();
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
Permission.location,
|
||||
].request();
|
||||
print("STATUUSSSS ? ");
|
||||
|
||||
print(statuses[Permission.bluetoothScan]);
|
||||
print(statuses[Permission.bluetoothConnect]);
|
||||
print(statuses[Permission.location]);
|
||||
|
||||
var status = await Permission.bluetoothScan.status;
|
||||
|
||||
print(status);
|
||||
}
|
||||
|
||||
|
||||
if(!visitAppContext.isScanningBeacons) {
|
||||
print("Start Scan");
|
||||
print(_streamRanging);
|
||||
|
||||
@ -9,7 +9,7 @@ import 'package:mymuseum_visitapp/Services/apiService.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
|
||||
class DownloadConfiguration {
|
||||
static Future<bool> downloadClicked(AppContext appContext, ConfigurationDTO configuration) async {
|
||||
static Future<bool> download(AppContext appContext, ConfigurationDTO configuration) async {
|
||||
|
||||
print("COUCOUCOU IIIIINNNN");
|
||||
// TODO ADD POPUP LANGUAGE SELECTION
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_beacon/flutter_beacon.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart';
|
||||
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Home/home.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'Helpers/DatabaseHelper.dart';
|
||||
@ -23,9 +24,17 @@ void main() async {
|
||||
if(localContext != null) {
|
||||
print("we've got an local db !");
|
||||
print(localContext);
|
||||
|
||||
List<ArticleRead> articleReadTest = List<ArticleRead>.from(await DatabaseHelper.instance.getData(DatabaseTableType.articleRead));
|
||||
localContext.readArticles = articleReadTest;
|
||||
} else {
|
||||
localContext = VisitAppContext(language: "FR", id: "UserId_Init", instanceId: "633ee379d9405f32f166f047");
|
||||
DatabaseHelper.instance.insert(DatabaseTableType.main, localContext.toMap());
|
||||
|
||||
List<ArticleRead> articleReadTest = List<ArticleRead>.from(await DatabaseHelper.instance.getData(DatabaseTableType.articleRead));
|
||||
localContext.readArticles = articleReadTest;
|
||||
print(localContext.readArticles);
|
||||
|
||||
print("NO LOCAL DB !");
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,9 @@ List<Translation> translations = [
|
||||
"pause": "Pause",
|
||||
"stop": "Arrêt",
|
||||
"open": "Ouvrir",
|
||||
"close": "Fermer"
|
||||
"close": "Fermer",
|
||||
"downloadLanguage": "Sélectionner la langue de la visite",
|
||||
"ok": "OK"
|
||||
}),
|
||||
Translation(language: "EN", data: {
|
||||
"visitTitle": "List of tours",
|
||||
@ -29,7 +31,9 @@ List<Translation> translations = [
|
||||
"pause": "Pause",
|
||||
"stop": "Stop",
|
||||
"open": "Open",
|
||||
"close": "Close"
|
||||
"close": "Close",
|
||||
"downloadLanguage": "Select the tour language",
|
||||
"ok": "OK"
|
||||
}),
|
||||
Translation(language: "DE", data: {
|
||||
"visitTitle": "Liste der Touren",
|
||||
@ -44,7 +48,9 @@ List<Translation> translations = [
|
||||
"pause": "Pause",
|
||||
"stop": "Stopp",
|
||||
"open": "Offen",
|
||||
"close": "Schließen"
|
||||
"close": "Schließen",
|
||||
"downloadLanguage": "Wählen Sie die Sprache des Besuchs aus",
|
||||
"ok": "OK"
|
||||
}),
|
||||
Translation(language: "NL", data: {
|
||||
"visitTitle": "Lijst met rondleidingen",
|
||||
@ -59,7 +65,9 @@ List<Translation> translations = [
|
||||
"pause": "Pauze",
|
||||
"stop": "Stop",
|
||||
"open": "Open",
|
||||
"close": "Sluiten"
|
||||
"close": "Sluiten",
|
||||
"downloadLanguage": "Selecteer de taal van de tour",
|
||||
"ok": "OK"
|
||||
}),
|
||||
Translation(language: "IT", data: {
|
||||
"visitTitle": "Elenco dei tour",
|
||||
@ -74,7 +82,9 @@ List<Translation> translations = [
|
||||
"pause": "Pausa",
|
||||
"stop": "Fermare",
|
||||
"open": "Aprire",
|
||||
"close": "Chiudere"
|
||||
"close": "Chiudere",
|
||||
"downloadLanguage": "Seleziona la lingua del tour",
|
||||
"ok": "OK"
|
||||
}),
|
||||
Translation(language: "ES", data: {
|
||||
"visitTitle": "Lista de recorridos",
|
||||
@ -89,7 +99,9 @@ List<Translation> translations = [
|
||||
"pause": "Pausa",
|
||||
"stop": "Parada",
|
||||
"open": "Abrir",
|
||||
"close": "Cerca"
|
||||
"close": "Cerca",
|
||||
"downloadLanguage": "Selecciona el idioma del tour",
|
||||
"ok": "Ok"
|
||||
}),
|
||||
Translation(language: "PL", data: {
|
||||
"visitTitle": "Lista wycieczek",
|
||||
@ -104,7 +116,9 @@ List<Translation> translations = [
|
||||
"pause": "Pauza",
|
||||
"stop": "Stop",
|
||||
"open": "Otwarty",
|
||||
"close": "Zamknąć"
|
||||
"close": "Zamknąć",
|
||||
"downloadLanguage": "Wybierz język wycieczki",
|
||||
"ok": "OK"
|
||||
}),
|
||||
Translation(language: "CN", data: {
|
||||
"visitTitle": "旅游清单",
|
||||
@ -119,7 +133,9 @@ List<Translation> translations = [
|
||||
"pause": "暫停",
|
||||
"stop": "停止",
|
||||
"open": "打开",
|
||||
"close": "关闭"
|
||||
"close": "关闭",
|
||||
"downloadLanguage": "选择游览语言",
|
||||
"ok": "好的"
|
||||
}),
|
||||
Translation(language: "UK", data: {
|
||||
"visitTitle": "Список турів",
|
||||
@ -134,7 +150,9 @@ List<Translation> translations = [
|
||||
"pause": "Пауза",
|
||||
"stop": "Стоп",
|
||||
"open": "ВІДЧИНЕНО",
|
||||
"close": "Закрити"
|
||||
"close": "Закрити",
|
||||
"downloadLanguage": "Виберіть мову туру",
|
||||
"ok": "В порядку"
|
||||
}),
|
||||
Translation(language: "AR", data: {
|
||||
"visitTitle": "قائمة الجولات",
|
||||
@ -149,6 +167,8 @@ List<Translation> translations = [
|
||||
"pause": "وقفة",
|
||||
"stop": "قف",
|
||||
"open": "يفتح",
|
||||
"close": "يغلق"
|
||||
"close": "يغلق",
|
||||
"downloadLanguage": "حدد لغة الجولة",
|
||||
"ok": "نعم"
|
||||
}),
|
||||
];
|
||||
Loading…
x
Reference in New Issue
Block a user