misc !
This commit is contained in:
parent
4818a1af52
commit
e644cd487f
@ -25,7 +25,11 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
setState(() {
|
setState(() {
|
||||||
colorVar = widget.color == null ? new Color(0x12345678) : new Color(int.parse(widget.color!.split('(0x')[1].split(')')[0], radix: 16));
|
try {
|
||||||
|
colorVar = widget.color == null || widget.color!.isEmpty ? new Color(0x12345678) : new Color(int.parse(widget.color!.split('(0x')[1].split(')')[0], radix: 16));
|
||||||
|
} catch(e) {
|
||||||
|
colorVar = new Color(0x12345678);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
@ -55,7 +59,7 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
colorVar = color;
|
colorVar = color;
|
||||||
});
|
});
|
||||||
widget.onChanged(color.toString());
|
widget.onChanged(colorToString(color));
|
||||||
},
|
},
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
@ -74,4 +78,20 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String colorToString(Color color) {
|
||||||
|
int a = (color.a * 255).round();
|
||||||
|
int r = (color.r * 255).round();
|
||||||
|
int g = (color.g * 255).round();
|
||||||
|
int b = (color.b * 255).round();
|
||||||
|
|
||||||
|
final aHex = a.toRadixString(16).padLeft(2, '0');
|
||||||
|
final rHex = r.toRadixString(16).padLeft(2, '0');
|
||||||
|
final gHex = g.toRadixString(16).padLeft(2, '0');
|
||||||
|
final bHex = b.toRadixString(16).padLeft(2, '0');
|
||||||
|
|
||||||
|
return 'Color(0x$aHex$rHex$gHex$bHex)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -13,7 +13,7 @@ IconData getSectionIcon(elementType) {
|
|||||||
return Icons.web;
|
return Icons.web;
|
||||||
case SectionType.Menu:
|
case SectionType.Menu:
|
||||||
return Icons.apps_sharp;
|
return Icons.apps_sharp;
|
||||||
case SectionType.Quizz:
|
case SectionType.Quiz:
|
||||||
return Icons.question_answer;
|
return Icons.question_answer;
|
||||||
case SectionType.Article:
|
case SectionType.Article:
|
||||||
return Icons.article_outlined;
|
return Icons.article_outlined;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import 'dart:html' as html;
|
|||||||
|
|
||||||
class PDFHelper {
|
class PDFHelper {
|
||||||
static downloadPDF(ManagerAppContext managerAppContext, List<SectionDTO> sections) async {
|
static downloadPDF(ManagerAppContext managerAppContext, List<SectionDTO> sections) async {
|
||||||
var sectionsArticle = sections.where((section) => section.type == SectionType.Article || section.type == SectionType.Quizz); // TODO HERE Support more section types
|
var sectionsArticle = sections.where((section) => section.type == SectionType.Article || section.type == SectionType.Quiz); // TODO HERE Support more section types
|
||||||
if(sectionsArticle.length > 0) {
|
if(sectionsArticle.length > 0) {
|
||||||
//final font = await rootBundle.load("fonts/OpenSans-Medium.ttf");
|
//final font = await rootBundle.load("fonts/OpenSans-Medium.ttf");
|
||||||
//Uint8List byteData = new File("fonts/OpenSans-Medium.ttf").readAsBytesSync();
|
//Uint8List byteData = new File("fonts/OpenSans-Medium.ttf").readAsBytesSync();
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class ArticleConfig extends StatefulWidget {
|
|||||||
final String? color;
|
final String? color;
|
||||||
final String? label;
|
final String? label;
|
||||||
final ArticleDTO initialValue;
|
final ArticleDTO initialValue;
|
||||||
final ValueChanged<String> onChanged;
|
final ValueChanged<ArticleDTO> onChanged;
|
||||||
const ArticleConfig({
|
const ArticleConfig({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.color,
|
this.color,
|
||||||
@ -61,7 +61,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
i++;
|
i++;
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(articleDTO);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -83,14 +83,14 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
modalLabel: "Contenu",
|
modalLabel: "Contenu",
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
isHTML: true,
|
isHTML: true,
|
||||||
initialValue: articleDTO != null ? articleDTO.content! : [],
|
initialValue: articleDTO.content!,
|
||||||
isTitle: false,
|
isTitle: false,
|
||||||
onGetResult: (value) {
|
onGetResult: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (articleDTO.content! != value) {
|
if (articleDTO.content! != value) {
|
||||||
articleDTO.content = value;
|
articleDTO.content = value;
|
||||||
//save(true, articleDTO, appContext);
|
//save(true, articleDTO, appContext);
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(articleDTO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -103,7 +103,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
//print(value);
|
//print(value);
|
||||||
articleDTO.isContentTop = value;
|
articleDTO.isContentTop = value;
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(articleDTO);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -117,14 +117,14 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
resourceTypes: [ResourceType.Audio],
|
resourceTypes: [ResourceType.Audio],
|
||||||
modalLabel: "Audio",
|
modalLabel: "Audio",
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
initialValue: articleDTO != null ? articleDTO.audioIds! : [],
|
initialValue: articleDTO.audioIds!,
|
||||||
isTitle: false,
|
isTitle: false,
|
||||||
onGetResult: (value) {
|
onGetResult: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (articleDTO.audioIds != value) {
|
if (articleDTO.audioIds != value) {
|
||||||
articleDTO.audioIds = value;
|
articleDTO.audioIds = value;
|
||||||
//save(true, articleDTO, appContext);
|
//save(true, articleDTO, appContext);
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(articleDTO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -137,7 +137,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
//print(value);
|
//print(value);
|
||||||
articleDTO.isReadAudioAuto = value;
|
articleDTO.isReadAudioAuto = value;
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(articleDTO);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -184,7 +184,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
articleToSend.isContentTop = articleDTO.isContentTop;
|
articleToSend.isContentTop = articleDTO.isContentTop;
|
||||||
articleToSend.content = articleDTO.content;
|
articleToSend.content = articleDTO.content;
|
||||||
articleToSend.isReadAudioAuto = articleDTO.isReadAudioAuto;
|
articleToSend.isReadAudioAuto = articleDTO.isReadAudioAuto;
|
||||||
widget.onChanged(jsonEncode(articleToSend).toString());
|
widget.onChanged(articleToSend);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
true, // don't show titles
|
true, // don't show titles
|
||||||
@ -213,7 +213,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
result.order = articleDTO.contents!.length;
|
result.order = articleDTO.contents!.length;
|
||||||
articleDTO.contents!.add(result);
|
articleDTO.contents!.add(result);
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(articleDTO);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -133,6 +133,9 @@ class _CategoryListState extends State<CategoryList> {
|
|||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
setState(() {
|
setState(() {
|
||||||
|
if(result.id == null) {
|
||||||
|
result.id = categoriesMiddle.isEmpty ? 1 : categoriesMiddle.map((c) => c.id!).reduce((a, b) => a > b ? a : b) + 1;
|
||||||
|
}
|
||||||
result.order = categoriesMiddle.length;
|
result.order = categoriesMiddle.length;
|
||||||
categoriesMiddle.add(result);
|
categoriesMiddle.add(result);
|
||||||
widget.onChanged(categoriesMiddle);
|
widget.onChanged(categoriesMiddle);
|
||||||
|
|||||||
@ -99,12 +99,11 @@ class _GeoPointContentListState extends State<GeoPointContentList> {
|
|||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
print("TODO CHECK !!");
|
ContentDTO newImage = new ContentDTO(resourceId: result.id, resource: result);
|
||||||
ContentDTO newImage = new ContentDTO(resourceId: result.id, resource: ResourceDTO(url: result.url, label: result.label, type: result.type));
|
if(newImage.order == null) {
|
||||||
//print("RESULT IMAGES = ");
|
newImage.order = contentsGeo.isEmpty ? 1 : contentsGeo.map((cg) => cg.order!).reduce((a, b) => a > b ? a : b) + 1;
|
||||||
//print(newImage);
|
}
|
||||||
contentsGeo.add(newImage);
|
contentsGeo.add(newImage);
|
||||||
//print(imagesGeo);
|
|
||||||
widget.onChanged(contentsGeo);
|
widget.onChanged(contentsGeo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
|||||||
import 'package:location_picker_flutter_map/location_picker_flutter_map.dart';
|
import 'package:location_picker_flutter_map/location_picker_flutter_map.dart';
|
||||||
import 'package:manager_app/Components/geoloc_input_container.dart';
|
import 'package:manager_app/Components/geoloc_input_container.dart';
|
||||||
import 'package:manager_app/Components/multi_select_dropdown_language_container.dart';
|
import 'package:manager_app/Components/multi_select_dropdown_language_container.dart';
|
||||||
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/category_input_container.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/category_input_container.dart';
|
||||||
import 'package:manager_app/Components/dropDown_input_container.dart';
|
import 'package:manager_app/Components/dropDown_input_container.dart';
|
||||||
import 'package:manager_app/Components/fetch_section_icon.dart';
|
import 'package:manager_app/Components/fetch_section_icon.dart';
|
||||||
@ -400,7 +401,7 @@ class _MapConfigState extends State<MapConfig> {
|
|||||||
showNewOrUpdateGeoPoint(
|
showNewOrUpdateGeoPoint(
|
||||||
mapDTO,
|
mapDTO,
|
||||||
null,
|
null,
|
||||||
(GeoPointDTO geoPoint) {
|
(GeoPointDTO geoPoint) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
mapDTO.points!.add(geoPoint);
|
mapDTO.points!.add(geoPoint);
|
||||||
mapDTO.points!.sort((a, b) => a.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase().compareTo(b.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase()));
|
mapDTO.points!.sort((a, b) => a.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase().compareTo(b.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase()));
|
||||||
@ -416,6 +417,9 @@ class _MapConfigState extends State<MapConfig> {
|
|||||||
//widget.onChanged(jsonEncode(mapDTO).toString());
|
//widget.onChanged(jsonEncode(mapDTO).toString());
|
||||||
widget.onChanged(mapDTO);
|
widget.onChanged(mapDTO);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionMapApi!.sectionMapCreate(mapDTO.id!, geoPoint);
|
||||||
|
// TODO refresh points list
|
||||||
},
|
},
|
||||||
appContext,
|
appContext,
|
||||||
context);
|
context);
|
||||||
|
|||||||
@ -84,13 +84,15 @@ Future<CategorieDTO?> showNewOrUpdateCategory(CategorieDTO? inputCategorieDTO, A
|
|||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
onChanged: (ResourceDTO resource) {
|
onChanged: (ResourceDTO resource) {
|
||||||
if(resource.id == null) {
|
if(resource.id == null) {
|
||||||
categorieDTO.resourceDTO?.id = null;
|
categorieDTO.resourceDTO = null;
|
||||||
|
/*categorieDTO.resourceDTO?.id = null;
|
||||||
categorieDTO.resourceDTO?.url = null;
|
categorieDTO.resourceDTO?.url = null;
|
||||||
categorieDTO.resourceDTO?.label = null;
|
categorieDTO.resourceDTO?.label = null;*/
|
||||||
} else {
|
} else {
|
||||||
categorieDTO.resourceDTO?.id = resource.id;
|
categorieDTO.resourceDTO = resource;
|
||||||
|
/*categorieDTO.resourceDTO?.id = resource.id;
|
||||||
categorieDTO.resourceDTO?.url = resource.url;
|
categorieDTO.resourceDTO?.url = resource.url;
|
||||||
categorieDTO.resourceDTO?.label = resource.label;
|
categorieDTO.resourceDTO?.label = resource.label;*/
|
||||||
print("Icône catégorie Icône catégorie");
|
print("Icône catégorie Icône catégorie");
|
||||||
print(categorieDTO);
|
print(categorieDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,7 @@ class SectionDetailScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||||
late SectionDTO sectionDTO;
|
late SectionDTO sectionDTO;
|
||||||
|
late Object sectionDetailDTO;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -63,9 +64,11 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
rawSectionData = snapshot.data;
|
rawSectionData = snapshot.data;
|
||||||
sectionDTO = SectionDTO.fromJson(rawSectionData)!; // TODO handle null value !
|
|
||||||
|
|
||||||
if(sectionDTO != null) {
|
var nullableSection = SectionDTO.fromJson(rawSectionData);
|
||||||
|
|
||||||
|
if(nullableSection != null) {
|
||||||
|
sectionDTO = nullableSection;
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
bodySection(rawSectionData, size, appContext, context, globalKey),
|
bodySection(rawSectionData, size, appContext, context, globalKey),
|
||||||
@ -73,7 +76,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
alignment: AlignmentDirectional.bottomCenter,
|
alignment: AlignmentDirectional.bottomCenter,
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 80,
|
height: 80,
|
||||||
child: getButtons(sectionDTO!, appContext),
|
child: getButtons(sectionDTO, appContext),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -122,19 +125,19 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
sectionDTO != null ? getSectionIcon(sectionDTO.type) : Icons.add,
|
getSectionIcon(sectionDTO.type),
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
size: 25,
|
size: 25,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(sectionDTO != null ? sectionDTO.label! : "", style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)),
|
Text(sectionDTO.label!, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)),
|
||||||
if((appContext.getContext() as ManagerAppContext).selectedConfiguration!.isMobile!)
|
if((appContext.getContext() as ManagerAppContext).selectedConfiguration!.isMobile!)
|
||||||
DownloadPDF(sections: [sectionDTO!]),
|
DownloadPDF(sections: [sectionDTO]),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(5.0),
|
padding: const EdgeInsets.all(5.0),
|
||||||
child: Text(sectionDTO != null ? DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation!) : "", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
|
child: Text(DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation!), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -197,7 +200,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
key: globalKey,
|
key: globalKey,
|
||||||
child: QrImageView(
|
child: QrImageView(
|
||||||
padding: EdgeInsets.only(left: 5.0, top: 5.0, bottom: 5.0, right: 5.0),
|
padding: EdgeInsets.only(left: 5.0, top: 5.0, bottom: 5.0, right: 5.0),
|
||||||
data: "${managerAppContext.host!.replaceFirst("api", "web")}/${managerAppContext.instanceId}/${managerAppContext.selectedConfiguration!.id}/${sectionDTO!.id!}",
|
data: "${managerAppContext.host!.replaceFirst("api", "web")}/${managerAppContext.instanceId}/${managerAppContext.selectedConfiguration!.id}/${sectionDTO.id!}",
|
||||||
version: QrVersions.auto,
|
version: QrVersions.auto,
|
||||||
size: 50.0,
|
size: 50.0,
|
||||||
),
|
),
|
||||||
@ -214,7 +217,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
sectionDTO.isBeacon = value;
|
sectionDTO.isBeacon = value;
|
||||||
save(false, sectionDTO, appContext);
|
save(false, appContext);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -242,9 +245,9 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
height: 100,
|
height: 100,
|
||||||
child: StringInputContainer(
|
child: StringInputContainer(
|
||||||
label: "Identifiant :",
|
label: "Identifiant :",
|
||||||
initialValue: sectionDTO != null ? sectionDTO.label : "",
|
initialValue: sectionDTO.label,
|
||||||
onChanged: (String value) {
|
onChanged: (String value) {
|
||||||
sectionDTO!.label = value;
|
sectionDTO.label = value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -252,11 +255,11 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
label: "Titre affiché:",
|
label: "Titre affiché:",
|
||||||
modalLabel: "Titre",
|
modalLabel: "Titre",
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
initialValue: sectionDTO != null ? sectionDTO.title! : [],
|
initialValue: sectionDTO.title!,
|
||||||
onGetResult: (value) {
|
onGetResult: (value) {
|
||||||
if (sectionDTO!.title! != value) {
|
if (sectionDTO.title! != value) {
|
||||||
sectionDTO.title = value;
|
sectionDTO.title = value;
|
||||||
save(true, sectionDTO, appContext);
|
save(true, appContext);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
@ -269,12 +272,12 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
modalLabel: "Description",
|
modalLabel: "Description",
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
isHTML: true,
|
isHTML: true,
|
||||||
initialValue: sectionDTO != null ? sectionDTO.description! : [],
|
initialValue: sectionDTO.description!,
|
||||||
isMandatory: false,
|
isMandatory: false,
|
||||||
onGetResult: (value) {
|
onGetResult: (value) {
|
||||||
if (sectionDTO!.description != value) {
|
if (sectionDTO.description != value) {
|
||||||
sectionDTO.description = value!;
|
sectionDTO.description = value!;
|
||||||
save(true, sectionDTO, appContext);
|
save(true, appContext);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
@ -288,14 +291,14 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
children: [
|
children: [
|
||||||
ResourceInputContainer(
|
ResourceInputContainer(
|
||||||
label: "Image :",
|
label: "Image :",
|
||||||
initialValue: sectionDTO != null ? sectionDTO.imageId : null,
|
initialValue: sectionDTO.imageId,
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
onChanged: (ResourceDTO resource) {
|
onChanged: (ResourceDTO resource) {
|
||||||
if(resource.id == null) {
|
if(resource.id == null) {
|
||||||
sectionDTO!.imageId = null;
|
sectionDTO.imageId = null;
|
||||||
sectionDTO.imageSource = null;
|
sectionDTO.imageSource = null;
|
||||||
} else {
|
} else {
|
||||||
sectionDTO!.imageId = resource.id;
|
sectionDTO.imageId = resource.id;
|
||||||
sectionDTO.imageSource = resource.url;
|
sectionDTO.imageSource = resource.url;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -315,7 +318,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
height: size.height * 0.5,
|
height: size.height * 0.5,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: sectionDTO != null ? getSpecificData(sectionDTO, rawSectionDTO, appContext) : null,
|
child: getSpecificData(rawSectionDTO, appContext),
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
//color: Colors.lightGreen,
|
//color: Colors.lightGreen,
|
||||||
@ -343,7 +346,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
press: () {
|
press: () {
|
||||||
cancel(sectionDTO, appContext);
|
cancel(appContext);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -356,7 +359,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
press: () {
|
press: () {
|
||||||
delete(sectionDTO, appContext);
|
delete(appContext);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -369,7 +372,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
press: () {
|
press: () {
|
||||||
save(false, sectionDTO, appContext);
|
save(false, appContext);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -378,15 +381,18 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cancel(SectionDTO sectionDTO, AppContext appContext) async {
|
Future<void> cancel(AppContext appContext) async {
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
Object? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionGetDetail(sectionDTO.id!);
|
Object? rawData = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionGetDetail(sectionDTO.id!);
|
||||||
// TODO parse as SectionDTO
|
var nullableSection = SectionDTO.fromJson(rawData);
|
||||||
managerAppContext.selectedSection = section as SectionDTO;
|
if(nullableSection != null)
|
||||||
appContext.setContext(managerAppContext);
|
{
|
||||||
|
managerAppContext.selectedSection = nullableSection!;
|
||||||
|
appContext.setContext(managerAppContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> delete(SectionDTO sectionDTO, AppContext appContext) async {
|
Future<void> delete(AppContext appContext) async {
|
||||||
showConfirmationDialog(
|
showConfirmationDialog(
|
||||||
"Êtes-vous sûr de vouloir supprimer cette section ?",
|
"Êtes-vous sûr de vouloir supprimer cette section ?",
|
||||||
() {},
|
() {},
|
||||||
@ -400,8 +406,8 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> save(bool isTraduction, SectionDTO sectionDTO, AppContext appContext) async {
|
Future<void> save(bool isTraduction, AppContext appContext) async {
|
||||||
SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDTO);
|
SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDetailDTO);
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
managerAppContext.selectedSection = section;
|
managerAppContext.selectedSection = section;
|
||||||
appContext.setContext(managerAppContext);
|
appContext.setContext(managerAppContext);
|
||||||
@ -413,22 +419,20 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpecificData(SectionDTO sectionDTO, Object? rawSectionData, AppContext appContext) {
|
getSpecificData(Object? rawSectionData, AppContext appContext) {
|
||||||
// TODO handle null value !
|
|
||||||
|
|
||||||
switch(sectionDTO.type) {
|
switch(sectionDTO.type) {
|
||||||
case SectionType.Map:
|
case SectionType.Map:
|
||||||
MapDTO mapDTO = MapDTO.fromJson(rawSectionData)!;
|
MapDTO mapDTO = MapDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = mapDTO;
|
||||||
return MapConfig(
|
return MapConfig(
|
||||||
initialValue: mapDTO,
|
initialValue: mapDTO,
|
||||||
onChanged: (MapDTO mapDTO) {
|
onChanged: (MapDTO changedMap) {
|
||||||
// TODO DO something
|
sectionDetailDTO = changedMap;
|
||||||
//sectionDTO.data = data;
|
|
||||||
//save(false, sectionDTO, appContext);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Slider:
|
case SectionType.Slider:
|
||||||
SliderDTO sliderDTO = SliderDTO.fromJson(rawSectionData)!;
|
SliderDTO sliderDTO = SliderDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = sliderDTO;
|
||||||
return SliderConfig(
|
return SliderConfig(
|
||||||
initialValue: sliderDTO,
|
initialValue: sliderDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
@ -440,6 +444,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
case SectionType.Video:
|
case SectionType.Video:
|
||||||
case SectionType.Web:
|
case SectionType.Web:
|
||||||
WebDTO webDTO = WebDTO.fromJson(rawSectionData)!;
|
WebDTO webDTO = WebDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = webDTO;
|
||||||
return WebOrVideoConfig(
|
return WebOrVideoConfig(
|
||||||
label: sectionDTO.type == SectionType.Video ? "Url de la vidéo:": "Url du site web:",
|
label: sectionDTO.type == SectionType.Video ? "Url de la vidéo:": "Url du site web:",
|
||||||
initialValue: webDTO,
|
initialValue: webDTO,
|
||||||
@ -450,14 +455,16 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
case SectionType.Menu:
|
case SectionType.Menu:
|
||||||
MenuDTO menuDTO = MenuDTO.fromJson(rawSectionData)!;
|
MenuDTO menuDTO = MenuDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = menuDTO;
|
||||||
return MenuConfig(
|
return MenuConfig(
|
||||||
initialValue: menuDTO,
|
initialValue: menuDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
//sectionDTO.data = data;
|
//sectionDTO.data = data;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Quizz:
|
case SectionType.Quiz:
|
||||||
QuizDTO quizDTO = QuizDTO.fromJson(rawSectionData)!;
|
QuizDTO quizDTO = QuizDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = quizDTO;
|
||||||
return QuizzConfig(
|
return QuizzConfig(
|
||||||
initialValue: quizDTO,
|
initialValue: quizDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
@ -466,15 +473,17 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
case SectionType.Article:
|
case SectionType.Article:
|
||||||
ArticleDTO articleDTO = ArticleDTO.fromJson(rawSectionData)!;
|
ArticleDTO articleDTO = ArticleDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = articleDTO;
|
||||||
return ArticleConfig(
|
return ArticleConfig(
|
||||||
initialValue: articleDTO,
|
initialValue: articleDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (ArticleDTO changedArticle)
|
||||||
/*sectionDTO.data = data;
|
{
|
||||||
save(false, sectionDTO, appContext);*/
|
sectionDetailDTO = changedArticle;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Pdf:
|
case SectionType.Pdf:
|
||||||
PdfDTO pdfDTO = PdfDTO.fromJson(rawSectionData)!;
|
PdfDTO pdfDTO = PdfDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = pdfDTO;
|
||||||
return PDFConfig(
|
return PDFConfig(
|
||||||
initialValue: pdfDTO,
|
initialValue: pdfDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
@ -484,6 +493,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
case SectionType.Puzzle:
|
case SectionType.Puzzle:
|
||||||
PuzzleDTO puzzleDTO = PuzzleDTO.fromJson(rawSectionData)!;
|
PuzzleDTO puzzleDTO = PuzzleDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = puzzleDTO;
|
||||||
return PuzzleConfig(
|
return PuzzleConfig(
|
||||||
initialValue: puzzleDTO,
|
initialValue: puzzleDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
@ -492,6 +502,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
case SectionType.Agenda:
|
case SectionType.Agenda:
|
||||||
AgendaDTO agendaDTO = AgendaDTO.fromJson(rawSectionData)!;
|
AgendaDTO agendaDTO = AgendaDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = agendaDTO;
|
||||||
return AgendaConfig(
|
return AgendaConfig(
|
||||||
initialValue: agendaDTO,
|
initialValue: agendaDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
@ -501,6 +512,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
);
|
);
|
||||||
case SectionType.Weather:
|
case SectionType.Weather:
|
||||||
WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!;
|
WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = weatherDTO;
|
||||||
return WeatherConfig(
|
return WeatherConfig(
|
||||||
initialValue: weatherDTO,
|
initialValue: weatherDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (String data) {
|
||||||
|
|||||||
@ -237,6 +237,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
isChecked: configurationDTO.isTablet,
|
isChecked: configurationDTO.isTablet,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
configurationDTO.isTablet = value;
|
configurationDTO.isTablet = value;
|
||||||
|
save(configurationDTO, appContext);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
CheckInputContainer(
|
CheckInputContainer(
|
||||||
@ -246,6 +247,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
isChecked: configurationDTO.isMobile,
|
isChecked: configurationDTO.isMobile,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
configurationDTO.isMobile = value;
|
configurationDTO.isMobile = value;
|
||||||
|
save(configurationDTO, appContext);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if(configurationDTO.isMobile != null && configurationDTO.isMobile!)
|
if(configurationDTO.isMobile != null && configurationDTO.isMobile!)
|
||||||
@ -404,7 +406,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
{
|
{
|
||||||
if(configurationDTO.isMobile!) {
|
if(configurationDTO.isMobile!) {
|
||||||
// Only see Article and Quizz type
|
// Only see Article and Quizz type
|
||||||
sections = new List<SectionDTO>.from(snapshot.data).where((section) => !section.isSubSection! && (section.type == SectionType.Article || section.type == SectionType.Quizz)).toList();
|
sections = new List<SectionDTO>.from(snapshot.data).where((section) => !section.isSubSection! && (section.type == SectionType.Article || section.type == SectionType.Quiz)).toList();
|
||||||
} else {
|
} else {
|
||||||
sections = new List<SectionDTO>.from(snapshot.data).where((section) => !section.isSubSection!).toList();
|
sections = new List<SectionDTO>.from(snapshot.data).where((section) => !section.isSubSection!).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,12 @@ class Client {
|
|||||||
DeviceApi? _deviceApi;
|
DeviceApi? _deviceApi;
|
||||||
DeviceApi? get deviceApi => _deviceApi;
|
DeviceApi? get deviceApi => _deviceApi;
|
||||||
|
|
||||||
|
SectionMapApi? _sectionMapApi;
|
||||||
|
SectionMapApi? get sectionMapApi => _sectionMapApi;
|
||||||
|
|
||||||
|
SectionQuizApi? _sectionQuizApi;
|
||||||
|
SectionQuizApi? get sectionQuizApi => _sectionQuizApi;
|
||||||
|
|
||||||
Client(String path) {
|
Client(String path) {
|
||||||
_apiClient = ApiClient(
|
_apiClient = ApiClient(
|
||||||
basePath: path);
|
basePath: path);
|
||||||
@ -35,5 +41,7 @@ class Client {
|
|||||||
_sectionApi = SectionApi(_apiClient);
|
_sectionApi = SectionApi(_apiClient);
|
||||||
_resourceApi = ResourceApi(_apiClient);
|
_resourceApi = ResourceApi(_apiClient);
|
||||||
_deviceApi = DeviceApi(_apiClient);
|
_deviceApi = DeviceApi(_apiClient);
|
||||||
|
_sectionMapApi = SectionMapApi(_apiClient);
|
||||||
|
_sectionQuizApi = SectionQuizApi(_apiClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ class CategorieDTO {
|
|||||||
|
|
||||||
String? icon;
|
String? icon;
|
||||||
|
|
||||||
ContentDTOResource? resourceDTO;
|
ResourceDTO? resourceDTO;
|
||||||
|
|
||||||
int? order;
|
int? order;
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ class CategorieDTO {
|
|||||||
id: mapValueOfType<int>(json, r'id'),
|
id: mapValueOfType<int>(json, r'id'),
|
||||||
label: TranslationDTO.listFromJson(json[r'label']),
|
label: TranslationDTO.listFromJson(json[r'label']),
|
||||||
icon: mapValueOfType<String>(json, r'icon'),
|
icon: mapValueOfType<String>(json, r'icon'),
|
||||||
resourceDTO: ContentDTOResource.fromJson(json[r'resourceDTO']),
|
resourceDTO: ResourceDTO.fromJson(json[r'resourceDTO']),
|
||||||
order: mapValueOfType<int>(json, r'order'),
|
order: mapValueOfType<int>(json, r'order'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
part of openapi.api;
|
part of openapi.api;
|
||||||
|
|
||||||
/// 0 = Map 1 = Slider 2 = Video 3 = Web 4 = Menu 5 = Quizz 6 = Article 7 = PDF 8 = Puzzle 9 = Agenda
|
/// 0 = Map 1 = Slider 2 = Video 3 = Web 4 = Menu 5 = Quiz 6 = Article 7 = PDF 8 = Puzzle 9 = Agenda
|
||||||
class SectionType {
|
class SectionType {
|
||||||
/// Instantiate a new enum with the provided [value].
|
/// Instantiate a new enum with the provided [value].
|
||||||
const SectionType._(this.value);
|
const SectionType._(this.value);
|
||||||
@ -28,7 +28,7 @@ class SectionType {
|
|||||||
static const Video = SectionType._(2);
|
static const Video = SectionType._(2);
|
||||||
static const Web = SectionType._(3);
|
static const Web = SectionType._(3);
|
||||||
static const Menu = SectionType._(4);
|
static const Menu = SectionType._(4);
|
||||||
static const Quizz = SectionType._(5);
|
static const Quiz = SectionType._(5);
|
||||||
static const Article = SectionType._(6);
|
static const Article = SectionType._(6);
|
||||||
static const Pdf = SectionType._(7);
|
static const Pdf = SectionType._(7);
|
||||||
static const Puzzle = SectionType._(8);
|
static const Puzzle = SectionType._(8);
|
||||||
@ -42,7 +42,7 @@ class SectionType {
|
|||||||
Video,
|
Video,
|
||||||
Web,
|
Web,
|
||||||
Menu,
|
Menu,
|
||||||
Quizz,
|
Quiz,
|
||||||
Article,
|
Article,
|
||||||
Pdf,
|
Pdf,
|
||||||
Puzzle,
|
Puzzle,
|
||||||
@ -92,7 +92,7 @@ class SectionTypeTypeTransformer {
|
|||||||
case r'Video': return SectionType.Video;
|
case r'Video': return SectionType.Video;
|
||||||
case r'Web': return SectionType.Web;
|
case r'Web': return SectionType.Web;
|
||||||
case r'Menu': return SectionType.Menu;
|
case r'Menu': return SectionType.Menu;
|
||||||
case r'Quizz': return SectionType.Quizz;
|
case r'Quiz': return SectionType.Quiz;
|
||||||
case r'Article': return SectionType.Article;
|
case r'Article': return SectionType.Article;
|
||||||
case r'PDF': return SectionType.Pdf;
|
case r'PDF': return SectionType.Pdf;
|
||||||
case r'Puzzle': return SectionType.Puzzle;
|
case r'Puzzle': return SectionType.Puzzle;
|
||||||
@ -111,7 +111,7 @@ class SectionTypeTypeTransformer {
|
|||||||
case 2: return SectionType.Video;
|
case 2: return SectionType.Video;
|
||||||
case 3: return SectionType.Web;
|
case 3: return SectionType.Web;
|
||||||
case 4: return SectionType.Menu;
|
case 4: return SectionType.Menu;
|
||||||
case 5: return SectionType.Quizz;
|
case 5: return SectionType.Quiz;
|
||||||
case 6: return SectionType.Article;
|
case 6: return SectionType.Article;
|
||||||
case 7: return SectionType.Pdf;
|
case 7: return SectionType.Pdf;
|
||||||
case 8: return SectionType.Puzzle;
|
case 8: return SectionType.Puzzle;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user