service generation + wip agenda + cache PDF file

This commit is contained in:
Thomas Fransolet 2024-01-26 15:52:25 +01:00
parent 29e4863493
commit cdda7d1470
19 changed files with 409 additions and 165 deletions

View File

@ -0,0 +1,29 @@
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/app_context.dart';
class ImageCustomProvider {
static ImageProvider<Object> getImageProvider(AppContext appContext, String imageId, String imageSource) {
TabletAppContext tabletAppContext = appContext.getContext();
if(appContext.getContext().localPath != null && tabletAppContext.configuration != null) {
Directory configurationDirectory = Directory('${tabletAppContext.localPath!}/${tabletAppContext.configuration!.id!}');
List<FileSystemEntity> fileList = configurationDirectory.listSync();
print(fileList);
if (fileList.isNotEmpty) {
File file = File(fileList.first.path);
print("FILE EXISTT");
return FileImage(file);
}
}
// If localpath not found or file missing
print("MISSINGG FILE");
return CachedNetworkImageProvider(imageSource);
}
}

124
lib/Models/agenda.dart Normal file
View File

@ -0,0 +1,124 @@
import 'dart:convert';
class Agenda {
List<EventAgenda> events;
Agenda({required this.events});
factory Agenda.fromJson(String jsonString) {
final List<dynamic> jsonList = json.decode(jsonString);
List<EventAgenda> events = [];
for (var eventData in jsonList) {
events.add(EventAgenda.fromJson(eventData));
}
return Agenda(events: events);
}
}
class EventAgenda {
String name;
String description;
String type;
DateTime dateAdded;
DateTime dateFrom;
DateTime dateTo;
String dateHour;
EventAddress address;
String website;
String phone;
String idVideoYoutube;
String email;
String image;
EventAgenda({
required this.name,
required this.description,
required this.type,
required this.dateAdded,
required this.dateFrom,
required this.dateTo,
required this.dateHour,
required this.address,
required this.website,
required this.phone,
required this.idVideoYoutube,
required this.email,
required this.image,
});
factory EventAgenda.fromJson(Map<String, dynamic> json) {
return EventAgenda(
name: json['name'],
description: json['description'],
type: json['type'],
dateAdded: DateTime.parse(json['date_added']),
dateFrom: DateTime.parse(json['date_from']),
dateTo: DateTime.parse(json['date_to']),
dateHour: json['date_hour'],
address: EventAddress.fromJson(json['address']),
website: json['website'],
phone: json['phone'],
idVideoYoutube: json['id_video_youtube'],
email: json['email'],
image: json['image'],
);
}
}
class EventAddress {
String address;
double lat;
double lng;
int zoom;
String placeId;
String name;
String streetNumber;
String streetName;
String streetNameShort;
String city;
String state;
String stateShort;
String postCode;
String country;
String countryShort;
EventAddress({
required this.address,
required this.lat,
required this.lng,
required this.zoom,
required this.placeId,
required this.name,
required this.streetNumber,
required this.streetName,
required this.streetNameShort,
required this.city,
required this.state,
required this.stateShort,
required this.postCode,
required this.country,
required this.countryShort,
});
factory EventAddress.fromJson(Map<String, dynamic> json) {
return EventAddress(
address: json['address'],
lat: json['lat'],
lng: json['lng'],
zoom: json['zoom'],
placeId: json['place_id'],
name: json['name'],
streetNumber: json['street_number'],
streetName: json['street_name'],
streetNameShort: json['street_name_short'],
city: json['city'],
state: json['state'],
stateShort: json['state_short'],
postCode: json['post_code'],
country: json['country'],
countryShort: json['country_short'],
);
}
}

View File

@ -35,7 +35,6 @@ class _AgendaView extends State<AgendaView> {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Center( return new Center(

View File

@ -15,6 +15,7 @@ import 'package:tablet_app/Components/loading_common.dart';
import 'package:tablet_app/Components/rounded_input_field.dart'; import 'package:tablet_app/Components/rounded_input_field.dart';
import 'package:tablet_app/Helpers/DatabaseHelper.dart'; import 'package:tablet_app/Helpers/DatabaseHelper.dart';
import 'package:tablet_app/Helpers/DeviceInfoHelper.dart'; import 'package:tablet_app/Helpers/DeviceInfoHelper.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Helpers/MQTTHelper.dart'; import 'package:tablet_app/Helpers/MQTTHelper.dart';
import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/Screens/MainView/dropDown_configuration.dart'; import 'package:tablet_app/Screens/MainView/dropDown_configuration.dart';
@ -351,29 +352,6 @@ Future<String?> getIP(bool isWLAN) async {
return null; return null;
} }
boxDecoration(SectionDTO section) {
return BoxDecoration(
color: kBackgroundLight,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0),
image: new DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop),
image: CachedNetworkImageProvider(section.imageSource!), /*new NetworkImage(
section.imageSource!,
),*/
),
boxShadow: [
BoxShadow(
color: kBackgroundSecondGrey,
spreadRadius: 0.5,
blurRadius: 5,
offset: Offset(0, 1.5), // changes position of shadow
),
],
);
}
Future<List<ConfigurationDTO>?> getConfigurations(dynamic appContext) async { Future<List<ConfigurationDTO>?> getConfigurations(dynamic appContext) async {
TabletAppContext tabletAppContext = (appContext.getContext() as TabletAppContext); TabletAppContext tabletAppContext = (appContext.getContext() as TabletAppContext);
print(tabletAppContext); print(tabletAppContext);

View File

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
@ -12,6 +13,7 @@ import 'package:provider/provider.dart';
import 'package:tablet_app/Components/loading.dart'; import 'package:tablet_app/Components/loading.dart';
import 'package:tablet_app/Components/loading_common.dart'; import 'package:tablet_app/Components/loading_common.dart';
import 'package:tablet_app/Helpers/DatabaseHelper.dart'; import 'package:tablet_app/Helpers/DatabaseHelper.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Helpers/MQTTHelper.dart'; import 'package:tablet_app/Helpers/MQTTHelper.dart';
import 'package:tablet_app/Screens/Agenda/agenda_view.dart'; import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
import 'package:tablet_app/Screens/Article/article_view.dart'; import 'package:tablet_app/Screens/Article/article_view.dart';
@ -141,9 +143,7 @@ class _MainViewWidget extends State<MainViewWidget> {
image: new DecorationImage( image: new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.white.withOpacity(0.8), BlendMode.lighten), colorFilter: new ColorFilter.mode(Colors.white.withOpacity(0.8), BlendMode.lighten),
image: CachedNetworkImageProvider(configurationDTO.imageSource!),/*new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!),
configurationDTO.imageSource!,
),*/
), ),
) : null, ) : null,
child: Column( child: Column(
@ -160,7 +160,7 @@ class _MainViewWidget extends State<MainViewWidget> {
child: Container( child: Container(
/*width: 125, /*width: 125,
height: 125,*/ height: 125,*/
decoration: boxDecoration(sectionSelected!, true), decoration: boxDecoration(appContext, sectionSelected!, true),
), ),
), ),
), ),
@ -258,9 +258,7 @@ class _MainViewWidget extends State<MainViewWidget> {
image: new DecorationImage( image: new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(0.1), BlendMode.color), colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(0.1), BlendMode.color),
image: CachedNetworkImageProvider(configurationDTO.imageSource!),/*new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!)
configurationDTO.imageSource!,
),*/
), ),
) : null, ) : null,
child: Stack( child: Stack(
@ -282,12 +280,10 @@ class _MainViewWidget extends State<MainViewWidget> {
Text(DateFormat('HH:mm').format(value), style: TextStyle(fontSize: 20, color: textColor)), Text(DateFormat('HH:mm').format(value), style: TextStyle(fontSize: 20, color: textColor)),
if(value != null && configurationDTO.isDate!) if(value != null && configurationDTO.isDate!)
if(appContext.getContext().language.toString().toUpperCase() == "EN") if(appContext.getContext().language.toString().toUpperCase() == "EN")
Text(DateFormat('MM/dd/yy').format(value), style: TextStyle(fontSize: 15, color: textColor)), Text(DateFormat('MM/dd').format(value), style: TextStyle(fontSize: 15, color: textColor)),
if(value != null && configurationDTO.isDate!) if(value != null && configurationDTO.isDate!)
if(appContext.getContext().language.toString().toUpperCase() != "EN") if(appContext.getContext().language.toString().toUpperCase() != "EN")
Text(DateFormat('dd/MM/yy').format(value), style: TextStyle(fontSize: 15, color: textColor)), Text(DateFormat('dd/MM').format(value), style: TextStyle(fontSize: 15, color: textColor)),
if(configurationDTO.weatherCity != null) // TODO Weather
Text('TODO - ' + configurationDTO.weatherCity!, style: TextStyle(fontSize: 15, color: textColor))
], ],
), ),
) )
@ -321,7 +317,7 @@ class _MainViewWidget extends State<MainViewWidget> {
}); });
}, },
child: Container( child: Container(
decoration: boxDecoration(snapshot.data[index], false), decoration: boxDecoration(appContext, snapshot.data[index], false),
padding: const EdgeInsets.all(25), padding: const EdgeInsets.all(25),
margin: EdgeInsets.symmetric(vertical: 25, horizontal: 25), margin: EdgeInsets.symmetric(vertical: 25, horizontal: 25),
child: Align( child: Align(
@ -418,6 +414,14 @@ class _MainViewWidget extends State<MainViewWidget> {
), ),
), ),
), ),
if(configurationDTO.weatherCity != null)
Positioned(
bottom: 0,
left: 0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Weather - ' + configurationDTO.weatherCity!, style: TextStyle(fontSize: 15, color: textColor))
))
]), ]),
), ),
floatingActionButton: InkWell( floatingActionButton: InkWell(
@ -524,7 +528,7 @@ double calculateFontSize(double parentWidth, double parentHeight, double baseSiz
return calculatedFontSize < baseSize ? calculatedFontSize : baseSize; return calculatedFontSize < baseSize ? calculatedFontSize : baseSize;
} }
boxDecoration(SectionDTO section, bool isSelected) { boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
return BoxDecoration( return BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
@ -532,9 +536,7 @@ boxDecoration(SectionDTO section, bool isSelected) {
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: !isSelected || kIsWeb ? BoxFit.cover : BoxFit.contain, fit: !isSelected || kIsWeb ? BoxFit.cover : BoxFit.contain,
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(kIsWeb ? 0.3 : 0.3), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(kIsWeb ? 0.3 : 0.3), BlendMode.dstATop) : null,
image: CachedNetworkImageProvider(section.imageSource!),/*new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, section.imageId!, section.imageSource!),
section.imageSource!,
),*/
): null, ): null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(

View File

@ -7,6 +7,7 @@ import 'package:manager_api/api.dart';
import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/map-marker.dart'; import 'package:tablet_app/Models/map-marker.dart';
import 'package:tablet_app/Screens/Quizz/quizz_view.dart'; import 'package:tablet_app/Screens/Quizz/quizz_view.dart';
import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/app_context.dart';
@ -265,9 +266,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
aspectRatio: 16 / 9, aspectRatio: 16 / 9,
child: ClipRect( child: ClipRect(
child: i.resourceUrl != null ? PhotoView( child: i.resourceUrl != null ? PhotoView(
imageProvider: CachedNetworkImageProvider(i.resourceUrl!), /*new NetworkImage( imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!),
i.imageSource,
),*/
minScale: PhotoViewComputedScale.contained * 0.8, minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.contained * 3.0, maxScale: PhotoViewComputedScale.contained * 3.0,
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(

View File

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/map-marker.dart'; import 'package:tablet_app/Models/map-marker.dart';
import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/Screens/Agenda/agenda_view.dart'; import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
@ -171,7 +172,7 @@ class _MenuView extends State<MenuView> {
}); });
}, },
child: Container( child: Container(
decoration: boxDecoration(menuDTO.sections![index], false), decoration: boxDecoration(appContext, menuDTO.sections![index], false),
padding: const EdgeInsets.all(25), padding: const EdgeInsets.all(25),
margin: EdgeInsets.symmetric(vertical: kIsWeb ? 15 : 25, horizontal: kIsWeb ? 15 : 25), margin: EdgeInsets.symmetric(vertical: kIsWeb ? 15 : 25, horizontal: kIsWeb ? 15 : 25),
child: Align( child: Align(
@ -213,7 +214,7 @@ class _MenuView extends State<MenuView> {
} }
} }
boxDecoration(SectionDTO section, bool isSelected) { boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
return BoxDecoration( return BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
@ -221,9 +222,7 @@ boxDecoration(SectionDTO section, bool isSelected) {
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: kIsWeb ? BoxFit.cover : BoxFit.contain, fit: kIsWeb ? BoxFit.cover : BoxFit.contain,
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.3), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.3), BlendMode.dstATop) : null,
image: CachedNetworkImageProvider(section.imageSource!), /*new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, section.imageId!, section.imageSource!),
section.imageSource!,
),*/
): null, ): null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(

View File

@ -9,7 +9,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart'; import 'package:flutter_pdfview/flutter_pdfview.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:tablet_app/Components/loading_common.dart'; import 'package:tablet_app/Components/loading_common.dart';
import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/app_context.dart';
class PDFViewWidget extends StatefulWidget { class PDFViewWidget extends StatefulWidget {
@ -46,13 +49,17 @@ class _PDFViewWidget extends State<PDFViewWidget> {
});*/ });*/
} }
Future<File> createFileOfPdfUrl(String source_) async { Future<File> createFileOfPdfUrl(TabletAppContext tabletAppContext, PdfDTO pdfDTO) async {
Completer<File> completer = Completer(); Completer<File> completer = Completer();
var file = await _checkIfLocalResourceExists(tabletAppContext, pdfDTO.resourceId!);
if(file == null) {
print("Start download file from internet!"); print("Start download file from internet!");
try { try {
// "https://berlin2017.droidcon.cod.newthinking.net/sites/global.droidcon.cod.newthinking.net/files/media/documents/Flutter%20-%2060FPS%20UI%20of%20the%20future%20%20-%20DroidconDE%2017.pdf"; // "https://berlin2017.droidcon.cod.newthinking.net/sites/global.droidcon.cod.newthinking.net/files/media/documents/Flutter%20-%2060FPS%20UI%20of%20the%20future%20%20-%20DroidconDE%2017.pdf";
// final url = "https://pdfkit.org/docs/guide.pdf"; // final url = "https://pdfkit.org/docs/guide.pdf";
final url = source_; final url = pdfDTO.resourceUrl!;
final filename = url.substring(url.lastIndexOf("/") + 1); final filename = url.substring(url.lastIndexOf("/") + 1);
var request = await HttpClient().getUrl(Uri.parse(url)); var request = await HttpClient().getUrl(Uri.parse(url));
var response = await request.close(); var response = await request.close();
@ -67,6 +74,10 @@ class _PDFViewWidget extends State<PDFViewWidget> {
} catch (e) { } catch (e) {
throw Exception('Error parsing asset file!'); throw Exception('Error parsing asset file!');
} }
} else {
print("FOUND FILE PDF");
completer.complete(file);
}
return completer.future; return completer.future;
} }
@ -77,13 +88,16 @@ class _PDFViewWidget extends State<PDFViewWidget> {
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) => pdfDTO.resourceUrl != null && pdfDTO.resourceUrl!.length > 0 ? Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
TabletAppContext tabletAppContext = appContext.getContext();
return pdfDTO.resourceUrl != null && pdfDTO.resourceUrl!.length > 0 ?
Padding( Padding(
padding: const EdgeInsets.all(12.5), padding: const EdgeInsets.all(12.5),
child: FutureBuilder( child: FutureBuilder(
future: createFileOfPdfUrl(pdfDTO.resourceUrl!), future: createFileOfPdfUrl(tabletAppContext, pdfDTO),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
print("snapshot.data"); print("snapshot.data");
print(snapshot.data); print(snapshot.data);
@ -147,4 +161,19 @@ class _PDFViewWidget extends State<PDFViewWidget> {
), ),
) : ) :
Center(child: Text("Le PDF ne peut pas être affiché, il n'existe pas")); Center(child: Text("Le PDF ne peut pas être affiché, il n'existe pas"));
}
} //_webView } //_webView
Future<File?> _checkIfLocalResourceExists(TabletAppContext tabletAppContext, String resourceId) async {
Directory? appDocumentsDirectory = await getDownloadsDirectory();
String localPath = appDocumentsDirectory!.path;
Directory configurationDirectory = Directory('$localPath/${tabletAppContext.configuration!.id}');
List<FileSystemEntity> fileList = configurationDirectory.listSync();
if(fileList.any((fileL) => fileL.uri.pathSegments.last.contains(resourceId))) {
File file = File(fileList.firstWhere((fileL) => fileL.uri.pathSegments.last.contains(resourceId)).path);
return file;
}
return null;
}

View File

@ -11,6 +11,7 @@ import 'package:manager_api/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Components/Buttons/rounded_button.dart'; import 'package:tablet_app/Components/Buttons/rounded_button.dart';
import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/ResponseSubDTO.dart'; import 'package:tablet_app/Models/ResponseSubDTO.dart';
import 'package:tablet_app/Screens/Quizz/showResponses.dart'; import 'package:tablet_app/Screens/Quizz/showResponses.dart';
import 'package:tablet_app/Screens/Slider/slider_view.dart'; import 'package:tablet_app/Screens/Slider/slider_view.dart';
@ -282,9 +283,7 @@ class _QuizzView extends State<QuizzView> {
image: i.resourceUrl != null ? new DecorationImage( image: i.resourceUrl != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
opacity: 0.35, opacity: 0.35,
image: CachedNetworkImageProvider(i.resourceUrl!),/* new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!)
i.resourceUrl!,
),*/
): null, ): null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
@ -532,9 +531,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xff7c94b6), color: const Color(0xff7c94b6),
image: DecorationImage( image: DecorationImage(
image: CachedNetworkImageProvider(i.resourceUrl!),/*new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!),
levelToShow.source_,
),*/
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
borderRadius: BorderRadius.all(Radius.circular(15.0)), borderRadius: BorderRadius.all(Radius.circular(15.0)),

View File

@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/ResponseSubDTO.dart'; import 'package:tablet_app/Models/ResponseSubDTO.dart';
import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
@ -80,9 +81,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
image: i.resourceUrl != null ? new DecorationImage( image: i.resourceUrl != null ? new DecorationImage(
fit: BoxFit.contain, fit: BoxFit.contain,
opacity: 0.35, opacity: 0.35,
image: CachedNetworkImageProvider(i.resourceUrl!),/*new NetworkImage( image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!),
i.resourceUrl!,
),*/
): null, ): null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(

View File

@ -11,6 +11,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart';
import 'package:tablet_app/Components/video_viewer.dart'; import 'package:tablet_app/Components/video_viewer.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
@ -254,20 +255,8 @@ class _SliderView extends State<SliderView> {
switch(i.resourceType) { switch(i.resourceType) {
case ResourceType.Image: case ResourceType.Image:
TabletAppContext tabletAppContext = appContext.getContext();
Directory configurationDirectory = Directory('${tabletAppContext.localPath}/${tabletAppContext.configuration!.id}');
List<FileSystemEntity> fileList = configurationDirectory.listSync();
var imageProvider = null;
if(fileList.any((fileL) => fileL.uri.pathSegments.last.contains(i.resourceId!))) {
File file = File(fileList.firstWhere((fileL) => fileL.uri.pathSegments.last.contains(i.resourceId!)).path);
imageProvider = FileImage(file);
} else {
imageProvider = new CachedNetworkImageProvider(i.resourceUrl!,);
}
widgetToInclude = PhotoView( widgetToInclude = PhotoView(
imageProvider: imageProvider, imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!),
minScale: PhotoViewComputedScale.contained * 0.8, minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.contained * 3.0, maxScale: PhotoViewComputedScale.contained * 3.0,
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
@ -279,9 +268,7 @@ class _SliderView extends State<SliderView> {
break; break;
case ResourceType.ImageUrl: case ResourceType.ImageUrl:
widgetToInclude = PhotoView( widgetToInclude = PhotoView(
imageProvider: CachedNetworkImageProvider(i.resourceUrl!),/*new NetworkImage( imageProvider: CachedNetworkImageProvider(i.resourceUrl!),
i.resourceUrl!,
),*/
minScale: PhotoViewComputedScale.contained * 0.8, minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.contained * 3.0, maxScale: PhotoViewComputedScale.contained * 3.0,
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(

View File

@ -113,7 +113,7 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
print("Already exist TRIPLE NIGAUD!"); print("Already exist TRIPLE NIGAUD!");
currentResourceIndex.value++; currentResourceIndex.value++;
} else { } else {
if(resource.type != ResourceType.ImageUrl && resource.type != ResourceType.VideoUrl && resource.url != null) { if(resource.type != ResourceType.ImageUrl && resource.type != ResourceType.VideoUrl && resource.type != ResourceType.JsonUrl && resource.url != null) {
bool success = await downloadResource(tabletAppContext, resource, localPath); bool success = await downloadResource(tabletAppContext, resource, localPath);
if (success) { if (success) {

View File

@ -1814,6 +1814,15 @@ components:
weatherCity: weatherCity:
type: string type: string
nullable: true nullable: true
weatherUpdatedDate:
type: string
format: date-time
nullable: true
weatherResult:
type: string
nullable: true
isWeather:
type: boolean
isDate: isDate:
type: boolean type: boolean
isHour: isHour:
@ -1975,6 +1984,7 @@ components:
4 = Audio 4 = Audio
5 = PDF 5 = PDF
6 = JSON 6 = JSON
7 = JSONUrl
x-enumNames: x-enumNames:
- Image - Image
- Video - Video
@ -1983,6 +1993,7 @@ components:
- Audio - Audio
- PDF - PDF
- JSON - JSON
- JSONUrl
enum: enum:
- 0 - 0
- 1 - 1
@ -1991,6 +2002,7 @@ components:
- 4 - 4
- 5 - 5
- 6 - 6
- 7
DeviceDTO: DeviceDTO:
type: object type: object
additionalProperties: false additionalProperties: false
@ -2322,7 +2334,9 @@ components:
type: string type: string
nullable: true nullable: true
resourceType: resourceType:
$ref: '#/components/schemas/ResourceType' nullable: true
oneOf:
- $ref: '#/components/schemas/ResourceType'
resourceUrl: resourceUrl:
type: string type: string
nullable: true nullable: true

View File

@ -60,7 +60,7 @@ try {
## Documentation for API Endpoints ## Documentation for API Endpoints
All URIs are relative to *http://localhost:5000* All URIs are relative to *https://api.myinfomate.be*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------

View File

@ -25,6 +25,9 @@ Name | Type | Description | Notes
**loaderImageId** | **String** | | [optional] **loaderImageId** | **String** | | [optional]
**loaderImageUrl** | **String** | | [optional] **loaderImageUrl** | **String** | | [optional]
**weatherCity** | **String** | | [optional] **weatherCity** | **String** | | [optional]
**weatherUpdatedDate** | [**DateTime**](DateTime.md) | | [optional]
**weatherResult** | **String** | | [optional]
**isWeather** | **bool** | | [optional]
**isDate** | **bool** | | [optional] **isDate** | **bool** | | [optional]
**isHour** | **bool** | | [optional] **isHour** | **bool** | | [optional]

View File

@ -25,6 +25,9 @@ Name | Type | Description | Notes
**loaderImageId** | **String** | | [optional] **loaderImageId** | **String** | | [optional]
**loaderImageUrl** | **String** | | [optional] **loaderImageUrl** | **String** | | [optional]
**weatherCity** | **String** | | [optional] **weatherCity** | **String** | | [optional]
**weatherUpdatedDate** | [**DateTime**](DateTime.md) | | [optional]
**weatherResult** | **String** | | [optional]
**isWeather** | **bool** | | [optional]
**isDate** | **bool** | | [optional] **isDate** | **bool** | | [optional]
**isHour** | **bool** | | [optional] **isHour** | **bool** | | [optional]
**sections** | [**List<SectionDTO>**](SectionDTO.md) | | [optional] [default to const []] **sections** | [**List<SectionDTO>**](SectionDTO.md) | | [optional] [default to const []]

View File

@ -30,6 +30,9 @@ class ConfigurationDTO {
this.loaderImageId, this.loaderImageId,
this.loaderImageUrl, this.loaderImageUrl,
this.weatherCity, this.weatherCity,
this.weatherUpdatedDate,
this.weatherResult,
this.isWeather,
this.isDate, this.isDate,
this.isHour, this.isHour,
}); });
@ -92,6 +95,18 @@ class ConfigurationDTO {
String? weatherCity; String? weatherCity;
DateTime? weatherUpdatedDate;
String? weatherResult;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? isWeather;
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated /// does not include a default value (using the "default:" property), however, the generated
@ -127,6 +142,9 @@ class ConfigurationDTO {
other.loaderImageId == loaderImageId && other.loaderImageId == loaderImageId &&
other.loaderImageUrl == loaderImageUrl && other.loaderImageUrl == loaderImageUrl &&
other.weatherCity == weatherCity && other.weatherCity == weatherCity &&
other.weatherUpdatedDate == weatherUpdatedDate &&
other.weatherResult == weatherResult &&
other.isWeather == isWeather &&
other.isDate == isDate && other.isDate == isDate &&
other.isHour == isHour; other.isHour == isHour;
@ -150,11 +168,14 @@ class ConfigurationDTO {
(loaderImageId == null ? 0 : loaderImageId!.hashCode) + (loaderImageId == null ? 0 : loaderImageId!.hashCode) +
(loaderImageUrl == null ? 0 : loaderImageUrl!.hashCode) + (loaderImageUrl == null ? 0 : loaderImageUrl!.hashCode) +
(weatherCity == null ? 0 : weatherCity!.hashCode) + (weatherCity == null ? 0 : weatherCity!.hashCode) +
(weatherUpdatedDate == null ? 0 : weatherUpdatedDate!.hashCode) +
(weatherResult == null ? 0 : weatherResult!.hashCode) +
(isWeather == null ? 0 : isWeather!.hashCode) +
(isDate == null ? 0 : isDate!.hashCode) + (isDate == null ? 0 : isDate!.hashCode) +
(isHour == null ? 0 : isHour!.hashCode); (isHour == null ? 0 : isHour!.hashCode);
@override @override
String toString() => 'ConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, isDate=$isDate, isHour=$isHour]'; String toString() => 'ConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, weatherUpdatedDate=$weatherUpdatedDate, weatherResult=$weatherResult, isWeather=$isWeather, isDate=$isDate, isHour=$isHour]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -243,6 +264,21 @@ class ConfigurationDTO {
} else { } else {
json[r'weatherCity'] = null; json[r'weatherCity'] = null;
} }
if (this.weatherUpdatedDate != null) {
json[r'weatherUpdatedDate'] = this.weatherUpdatedDate!.toUtc().toIso8601String();
} else {
json[r'weatherUpdatedDate'] = null;
}
if (this.weatherResult != null) {
json[r'weatherResult'] = this.weatherResult;
} else {
json[r'weatherResult'] = null;
}
if (this.isWeather != null) {
json[r'isWeather'] = this.isWeather;
} else {
json[r'isWeather'] = null;
}
if (this.isDate != null) { if (this.isDate != null) {
json[r'isDate'] = this.isDate; json[r'isDate'] = this.isDate;
} else { } else {
@ -296,6 +332,9 @@ class ConfigurationDTO {
loaderImageId: mapValueOfType<String>(json, r'loaderImageId'), loaderImageId: mapValueOfType<String>(json, r'loaderImageId'),
loaderImageUrl: mapValueOfType<String>(json, r'loaderImageUrl'), loaderImageUrl: mapValueOfType<String>(json, r'loaderImageUrl'),
weatherCity: mapValueOfType<String>(json, r'weatherCity'), weatherCity: mapValueOfType<String>(json, r'weatherCity'),
weatherUpdatedDate: mapDateTime(json, r'weatherUpdatedDate', ''),
weatherResult: mapValueOfType<String>(json, r'weatherResult'),
isWeather: mapValueOfType<bool>(json, r'isWeather'),
isDate: mapValueOfType<bool>(json, r'isDate'), isDate: mapValueOfType<bool>(json, r'isDate'),
isHour: mapValueOfType<bool>(json, r'isHour'), isHour: mapValueOfType<bool>(json, r'isHour'),
); );

View File

@ -30,6 +30,9 @@ class ExportConfigurationDTO {
this.loaderImageId, this.loaderImageId,
this.loaderImageUrl, this.loaderImageUrl,
this.weatherCity, this.weatherCity,
this.weatherUpdatedDate,
this.weatherResult,
this.isWeather,
this.isDate, this.isDate,
this.isHour, this.isHour,
this.sections = const [], this.sections = const [],
@ -94,6 +97,18 @@ class ExportConfigurationDTO {
String? weatherCity; String? weatherCity;
DateTime? weatherUpdatedDate;
String? weatherResult;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? isWeather;
/// ///
/// Please note: This property should have been non-nullable! Since the specification file /// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated /// does not include a default value (using the "default:" property), however, the generated
@ -133,6 +148,9 @@ class ExportConfigurationDTO {
other.loaderImageId == loaderImageId && other.loaderImageId == loaderImageId &&
other.loaderImageUrl == loaderImageUrl && other.loaderImageUrl == loaderImageUrl &&
other.weatherCity == weatherCity && other.weatherCity == weatherCity &&
other.weatherUpdatedDate == weatherUpdatedDate &&
other.weatherResult == weatherResult &&
other.isWeather == isWeather &&
other.isDate == isDate && other.isDate == isDate &&
other.isHour == isHour && other.isHour == isHour &&
other.sections == sections && other.sections == sections &&
@ -158,13 +176,16 @@ class ExportConfigurationDTO {
(loaderImageId == null ? 0 : loaderImageId!.hashCode) + (loaderImageId == null ? 0 : loaderImageId!.hashCode) +
(loaderImageUrl == null ? 0 : loaderImageUrl!.hashCode) + (loaderImageUrl == null ? 0 : loaderImageUrl!.hashCode) +
(weatherCity == null ? 0 : weatherCity!.hashCode) + (weatherCity == null ? 0 : weatherCity!.hashCode) +
(weatherUpdatedDate == null ? 0 : weatherUpdatedDate!.hashCode) +
(weatherResult == null ? 0 : weatherResult!.hashCode) +
(isWeather == null ? 0 : isWeather!.hashCode) +
(isDate == null ? 0 : isDate!.hashCode) + (isDate == null ? 0 : isDate!.hashCode) +
(isHour == null ? 0 : isHour!.hashCode) + (isHour == null ? 0 : isHour!.hashCode) +
(sections == null ? 0 : sections!.hashCode) + (sections == null ? 0 : sections!.hashCode) +
(resources == null ? 0 : resources!.hashCode); (resources == null ? 0 : resources!.hashCode);
@override @override
String toString() => 'ExportConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, isDate=$isDate, isHour=$isHour, sections=$sections, resources=$resources]'; String toString() => 'ExportConfigurationDTO[id=$id, label=$label, title=$title, imageId=$imageId, imageSource=$imageSource, primaryColor=$primaryColor, secondaryColor=$secondaryColor, languages=$languages, dateCreation=$dateCreation, isMobile=$isMobile, isTablet=$isTablet, isOffline=$isOffline, instanceId=$instanceId, sectionIds=$sectionIds, loaderImageId=$loaderImageId, loaderImageUrl=$loaderImageUrl, weatherCity=$weatherCity, weatherUpdatedDate=$weatherUpdatedDate, weatherResult=$weatherResult, isWeather=$isWeather, isDate=$isDate, isHour=$isHour, sections=$sections, resources=$resources]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -253,6 +274,21 @@ class ExportConfigurationDTO {
} else { } else {
json[r'weatherCity'] = null; json[r'weatherCity'] = null;
} }
if (this.weatherUpdatedDate != null) {
json[r'weatherUpdatedDate'] = this.weatherUpdatedDate!.toUtc().toIso8601String();
} else {
json[r'weatherUpdatedDate'] = null;
}
if (this.weatherResult != null) {
json[r'weatherResult'] = this.weatherResult;
} else {
json[r'weatherResult'] = null;
}
if (this.isWeather != null) {
json[r'isWeather'] = this.isWeather;
} else {
json[r'isWeather'] = null;
}
if (this.isDate != null) { if (this.isDate != null) {
json[r'isDate'] = this.isDate; json[r'isDate'] = this.isDate;
} else { } else {
@ -316,6 +352,9 @@ class ExportConfigurationDTO {
loaderImageId: mapValueOfType<String>(json, r'loaderImageId'), loaderImageId: mapValueOfType<String>(json, r'loaderImageId'),
loaderImageUrl: mapValueOfType<String>(json, r'loaderImageUrl'), loaderImageUrl: mapValueOfType<String>(json, r'loaderImageUrl'),
weatherCity: mapValueOfType<String>(json, r'weatherCity'), weatherCity: mapValueOfType<String>(json, r'weatherCity'),
weatherUpdatedDate: mapDateTime(json, r'weatherUpdatedDate', ''),
weatherResult: mapValueOfType<String>(json, r'weatherResult'),
isWeather: mapValueOfType<bool>(json, r'isWeather'),
isDate: mapValueOfType<bool>(json, r'isDate'), isDate: mapValueOfType<bool>(json, r'isDate'),
isHour: mapValueOfType<bool>(json, r'isHour'), isHour: mapValueOfType<bool>(json, r'isHour'),
sections: SectionDTO.listFromJson(json[r'sections']), sections: SectionDTO.listFromJson(json[r'sections']),

View File

@ -10,7 +10,7 @@
part of openapi.api; part of openapi.api;
/// 0 = Image 1 = Video 2 = ImageUrl 3 = VideoUrl 4 = Audio 5 = PDF 6 = JSON /// 0 = Image 1 = Video 2 = ImageUrl 3 = VideoUrl 4 = Audio 5 = PDF 6 = JSON 7 = JSONUrl
class ResourceType { class ResourceType {
/// Instantiate a new enum with the provided [value]. /// Instantiate a new enum with the provided [value].
const ResourceType._(this.value); const ResourceType._(this.value);
@ -30,6 +30,7 @@ class ResourceType {
static const Audio = ResourceType._(4); static const Audio = ResourceType._(4);
static const Pdf = ResourceType._(5); static const Pdf = ResourceType._(5);
static const Json = ResourceType._(6); static const Json = ResourceType._(6);
static const JsonUrl = ResourceType._(7);
/// List of all possible values in this [enum][ResourceType]. /// List of all possible values in this [enum][ResourceType].
static const values = <ResourceType>[ static const values = <ResourceType>[
@ -39,7 +40,8 @@ class ResourceType {
VideoUrl, VideoUrl,
Audio, Audio,
Pdf, Pdf,
Json Json,
JsonUrl
]; ];
static ResourceType? fromJson(dynamic value) => ResourceTypeTypeTransformer().decode(value); static ResourceType? fromJson(dynamic value) => ResourceTypeTypeTransformer().decode(value);
@ -86,6 +88,7 @@ class ResourceTypeTypeTransformer {
case "Audio": return ResourceType.Audio; case "Audio": return ResourceType.Audio;
case "PDF": return ResourceType.Pdf; case "PDF": return ResourceType.Pdf;
case "JSON": return ResourceType.Json; case "JSON": return ResourceType.Json;
case "JSONUrl": return ResourceType.JsonUrl;
default: default:
if (!allowNull) { if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data'); throw ArgumentError('Unknown enum value to decode: $data');
@ -101,6 +104,7 @@ class ResourceTypeTypeTransformer {
case 4: return ResourceType.Audio; case 4: return ResourceType.Audio;
case 5: return ResourceType.Pdf; case 5: return ResourceType.Pdf;
case 6: return ResourceType.Json; case 6: return ResourceType.Json;
case 7: return ResourceType.JsonUrl;
default: default:
if (!allowNull) { if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data'); throw ArgumentError('Unknown enum value to decode: $data');