Null safety !

This commit is contained in:
Fransolet Thomas 2023-04-01 16:52:13 +02:00
parent 6429ea0ad8
commit a3a62d1903
80 changed files with 783 additions and 695 deletions

View File

@ -16,7 +16,7 @@ RUN flutter upgrade
RUN mkdir /app/ RUN mkdir /app/
COPY . /app/ COPY . /app/
WORKDIR /app/ WORKDIR /app/
RUN flutter build web --no-sound-null-safety RUN flutter build web
#--no-sound-null-safety #--no-sound-null-safety
# Stage 2 - Create the run-time image # Stage 2 - Create the run-time image
FROM nginx:1.21.1-alpine FROM nginx:1.21.1-alpine

View File

@ -1,6 +1,7 @@
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_app/Components/loading_common.dart'; import 'package:manager_app/Components/loading_common.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_app/Screens/Resources/select_resource_modal.dart'; import 'package:manager_app/Screens/Resources/select_resource_modal.dart';
@ -10,17 +11,17 @@ import 'package:provider/provider.dart';
class AudioInputContainer extends StatefulWidget { class AudioInputContainer extends StatefulWidget {
final Color color; final Color color;
final String label; final String label;
final String initialValue; final String? initialValue;
final ValueChanged<ResourceDTO> onChanged; final ValueChanged<ResourceDTO> onChanged;
final BoxFit imageFit; final BoxFit imageFit;
final bool isSmall; final bool isSmall;
final double fontSize; final double fontSize;
const AudioInputContainer({ const AudioInputContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.initialValue, this.initialValue,
this.onChanged, required this.onChanged,
this.imageFit = BoxFit.cover, this.imageFit = BoxFit.cover,
this.isSmall = false, this.isSmall = false,
this.fontSize = 20 this.fontSize = 20
@ -31,7 +32,7 @@ class AudioInputContainer extends StatefulWidget {
} }
class _AudioInputContainerState extends State<AudioInputContainer> { class _AudioInputContainerState extends State<AudioInputContainer> {
String resourceIdToShow; String? resourceIdToShow;
@override @override
void initState() { void initState() {
@ -48,7 +49,7 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
Align( Align(
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child: AutoSizeText( child: AutoSizeText(
widget.label, widget.label!,
style: TextStyle(fontSize: widget.fontSize, fontWeight: FontWeight.w300), style: TextStyle(fontSize: widget.fontSize, fontWeight: FontWeight.w300),
maxLines: 2, maxLines: 2,
maxFontSize: widget.fontSize, maxFontSize: widget.fontSize,
@ -64,7 +65,7 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
height: size.width *0.08, height: size.width *0.08,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
ResourceDTO result = await showSelectResourceModal( ResourceDTO? result = await showSelectResourceModal(
"Sélectionner une ressource", "Sélectionner une ressource",
1, 1,
[ResourceType.Audio], [ResourceType.Audio],
@ -93,13 +94,13 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
return FutureBuilder( return FutureBuilder(
future: getResource(resourceIdToShow, appContext), future: getResource(resourceIdToShow!, appContext),
builder: (context, AsyncSnapshot<ResourceDTO> snapshot) { builder: (context, AsyncSnapshot<ResourceDTO?> snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data != null) { if (snapshot.data != null) {
return Container( return Container(
decoration: boxDecoration(snapshot.data, appContext), decoration: boxDecoration(snapshot.data!, appContext),
child: Center(child: AutoSizeText(snapshot.data.label, textAlign: TextAlign.center)), child: Center(child: AutoSizeText(snapshot.data!.label!, textAlign: TextAlign.center)),
); );
} else { } else {
return Text("No data"); return Text("No data");
@ -137,9 +138,9 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
} }
} }
Future<ResourceDTO> getResource(String resourceIdToShow, dynamic appContext) async { Future<ResourceDTO?> getResource(String resourceIdToShow, dynamic appContext) async {
// Just in resource tab detail not here // Just in resource tab detail not here
ResourceDTO resource = await appContext.getContext().clientAPI.resourceApi.resourceGetDetail(resourceIdToShow); ResourceDTO? resource = await (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceGetDetail(resourceIdToShow);
return resource; return resource;
} }

View File

@ -10,7 +10,7 @@ import 'package:just_audio/just_audio.dart';
class AudioPlayerFloatingContainer extends StatefulWidget { class AudioPlayerFloatingContainer extends StatefulWidget {
const AudioPlayerFloatingContainer({Key key, this.audioBytes, this.isAuto}) : super(key: key); const AudioPlayerFloatingContainer({Key? key, required this.audioBytes, required this.isAuto}) : super(key: key);
final Uint8List audioBytes; final Uint8List audioBytes;
final bool isAuto; final bool isAuto;
@ -21,12 +21,12 @@ class AudioPlayerFloatingContainer extends StatefulWidget {
class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContainer> { class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContainer> {
AudioPlayer player = AudioPlayer(); AudioPlayer player = AudioPlayer();
Uint8List audiobytes; late Uint8List audiobytes;
bool isplaying = false; bool isplaying = false;
bool audioplayed = false; bool audioplayed = false;
int currentpos = 0; int currentpos = 0;
int maxduration = 100; int maxduration = 100;
Duration durationAudio; Duration? durationAudio;
String currentpostlabel = "00:00"; String currentpostlabel = "00:00";
@override @override
@ -34,22 +34,24 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
Future.delayed(Duration.zero, () async { Future.delayed(Duration.zero, () async {
audiobytes = widget.audioBytes; audiobytes = widget.audioBytes;
player.durationStream.listen((Duration d) { //get the duration of audio player.durationStream.listen((Duration? d) { //get the duration of audio
maxduration = d.inSeconds; if(d != null) {
durationAudio = d; maxduration = d.inSeconds;
durationAudio = d;
}
}); });
//player.bufferedPositionStream //player.bufferedPositionStream
player.positionStream.listen((event) { player.positionStream.listen((event) {
if(event != null) { if(durationAudio != null) {
currentpos = event.inMilliseconds; //get the current position of playing audio currentpos = event.inMilliseconds; //get the current position of playing audio
//generating the duration label //generating the duration label
int shours = Duration(milliseconds:durationAudio.inMilliseconds - currentpos).inHours; int shours = Duration(milliseconds:durationAudio!.inMilliseconds - currentpos).inHours;
int sminutes = Duration(milliseconds:durationAudio.inMilliseconds - currentpos).inMinutes; int sminutes = Duration(milliseconds:durationAudio!.inMilliseconds - currentpos).inMinutes;
int sseconds = Duration(milliseconds:durationAudio.inMilliseconds - currentpos).inSeconds; int sseconds = Duration(milliseconds:durationAudio!.inMilliseconds - currentpos).inSeconds;
int rminutes = sminutes - (shours * 60); int rminutes = sminutes - (shours * 60);
int rseconds = sseconds - (sminutes * 60 + shours * 60 * 60); int rseconds = sseconds - (sminutes * 60 + shours * 60 * 60);
@ -61,7 +63,7 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
setState(() { setState(() {
//refresh the UI //refresh the UI
if(currentpos > player.duration.inMilliseconds) { if(currentpos > player.duration!.inMilliseconds) {
print("RESET ALL"); print("RESET ALL");
player.stop(); player.stop();
player.seek(const Duration(seconds: 0)); player.seek(const Duration(seconds: 0));
@ -226,7 +228,7 @@ class LoadedSource extends StreamAudioSource {
LoadedSource(this.bytes); LoadedSource(this.bytes);
@override @override
Future<StreamAudioResponse> request([int start, int end]) async { Future<StreamAudioResponse> request([int? start, int? end]) async {
start ??= 0; start ??= 0;
end ??= bytes.length; end ??= bytes.length;
return StreamAudioResponse( return StreamAudioResponse(

View File

@ -4,17 +4,17 @@ import 'package:flutter/material.dart';
import '../constants.dart'; import '../constants.dart';
class CheckInputContainer extends StatefulWidget { class CheckInputContainer extends StatefulWidget {
final bool isChecked; final bool? isChecked;
final IconData icon; final IconData? icon;
final String label; final String label;
final ValueChanged<bool> onChanged; final ValueChanged<bool> onChanged;
final double fontSize; final double fontSize;
const CheckInputContainer({ const CheckInputContainer({
Key key, Key? key,
this.isChecked, this.isChecked,
this.icon, this.icon,
this.label, required this.label,
this.onChanged, required this.onChanged,
this.fontSize = 20 this.fontSize = 20
}) : super(key: key); }) : super(key: key);
@ -23,7 +23,7 @@ class CheckInputContainer extends StatefulWidget {
} }
class _CheckInputContainerState extends State<CheckInputContainer> { class _CheckInputContainerState extends State<CheckInputContainer> {
bool isChecked; bool? isChecked;
@override @override
void initState() { void initState() {
@ -72,11 +72,11 @@ class _CheckInputContainerState extends State<CheckInputContainer> {
value: isChecked, value: isChecked,
checkColor: Colors.white, checkColor: Colors.white,
activeColor: kPrimaryColor, activeColor: kPrimaryColor,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
isChecked = value; isChecked = value;
}); });
widget.onChanged(value); widget.onChanged(value!);
}, },
), ),
), ),

View File

@ -3,16 +3,16 @@ import 'package:flutter/material.dart';
import 'package:manager_app/Components/color_picker.dart'; import 'package:manager_app/Components/color_picker.dart';
class ColorPickerInputContainer extends StatefulWidget { class ColorPickerInputContainer extends StatefulWidget {
final String color; final String? color;
final String label; final String label;
final double fontSize; final double fontSize;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const ColorPickerInputContainer({ const ColorPickerInputContainer({
Key key, Key? key,
this.color, this.color,
this.label, required this.label,
this.fontSize = 25, this.fontSize = 25,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -20,12 +20,12 @@ class ColorPickerInputContainer extends StatefulWidget {
} }
class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> { class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
Color colorVar; Color? colorVar;
@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)); colorVar = widget.color == null ? new Color(0x12345678) : new Color(int.parse(widget.color!.split('(0x')[1].split(')')[0], radix: 16));
}); });
super.initState(); super.initState();
} }
@ -50,7 +50,7 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
showColorPicker( showColorPicker(
colorVar, colorVar!,
(Color color) { (Color color) {
setState(() { setState(() {
colorVar = color; colorVar = color;

View File

@ -1,6 +1,7 @@
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_app/Components/loading_common.dart'; import 'package:manager_app/Components/loading_common.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_app/Screens/Resources/select_resource_modal.dart'; import 'package:manager_app/Screens/Resources/select_resource_modal.dart';
@ -10,17 +11,17 @@ import 'package:provider/provider.dart';
class ImageInputContainer extends StatefulWidget { class ImageInputContainer extends StatefulWidget {
final Color color; final Color color;
final String label; final String label;
final String initialValue; final String? initialValue;
final ValueChanged<ResourceDTO> onChanged; final ValueChanged<ResourceDTO> onChanged;
final BoxFit imageFit; final BoxFit imageFit;
final bool isSmall; final bool isSmall;
final double fontSize; final double fontSize;
const ImageInputContainer({ const ImageInputContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.initialValue, this.initialValue,
this.onChanged, required this.onChanged,
this.imageFit = BoxFit.cover, this.imageFit = BoxFit.cover,
this.isSmall = false, this.isSmall = false,
this.fontSize = 25 this.fontSize = 25
@ -31,7 +32,7 @@ class ImageInputContainer extends StatefulWidget {
} }
class _ImageInputContainerState extends State<ImageInputContainer> { class _ImageInputContainerState extends State<ImageInputContainer> {
String resourceIdToShow; String? resourceIdToShow;
@override @override
void initState() { void initState() {
@ -64,7 +65,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
height: size.width *0.08, height: size.width *0.08,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
ResourceDTO result = await showSelectResourceModal( ResourceDTO? result = await showSelectResourceModal(
"Sélectionner une ressource", "Sélectionner une ressource",
1, 1,
[ResourceType.Image, ResourceType.ImageUrl], [ResourceType.Image, ResourceType.ImageUrl],
@ -88,12 +89,12 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
); );
} }
getElement(String initialValue, BuildContext context, bool isSmall) { getElement(String? initialValue, BuildContext context, bool isSmall) {
if (resourceIdToShow != null) { if (resourceIdToShow != null) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
return FutureBuilder( return FutureBuilder(
future: getResource(resourceIdToShow, appContext), future: getResource(resourceIdToShow!, appContext),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data != null) { if (snapshot.data != null) {
@ -101,7 +102,15 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
decoration: boxDecoration(snapshot.data, appContext), decoration: boxDecoration(snapshot.data, appContext),
); );
} else { } else {
return Text("No data"); return Center(
child: Container(
decoration: boxDecoration(null, appContext),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Aucune image"),
)
)
);
} }
} else if (snapshot.connectionState == ConnectionState.none) { } else if (snapshot.connectionState == ConnectionState.none) {
@ -136,22 +145,22 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
} }
} }
Future<ResourceDTO> getResource(String resourceIdToShow, dynamic appContext) async { Future<ResourceDTO?> getResource(String resourceIdToShow, dynamic appContext) async {
ResourceDTO resource = await appContext.getContext().clientAPI.resourceApi.resourceGetDetail(resourceIdToShow); ResourceDTO? resource = await (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceGetDetail(resourceIdToShow);
return resource; return resource;
} }
boxDecoration(ResourceDTO resourceDTO, appContext) { boxDecoration(ResourceDTO? resourceDTO, AppContext appContext) {
return BoxDecoration( return BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
color: kWhite, color: kWhite,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(30.0),
image: new DecorationImage( image: resourceDTO != null ? resourceDTO.type != null ? new DecorationImage(
fit: widget.imageFit, fit: widget.imageFit,
image: resourceDTO.type != null ? new NetworkImage( image: new NetworkImage(
resourceDTO.type == ResourceType.Image ? appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id : resourceDTO.data, resourceDTO.type! == ResourceType.Image ? (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resourceDTO.id! : resourceDTO.data!,
) : null, ),
), ) : null : null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
spreadRadius: 0.5, spreadRadius: 0.5,

View File

@ -2,7 +2,7 @@ import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class Loading extends StatelessWidget { class Loading extends StatelessWidget {
Loading({Key key}) : super(key: key); Loading({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
class LoadingCommon extends StatefulWidget { class LoadingCommon extends StatefulWidget {
const LoadingCommon({Key key}) : super(key: key); const LoadingCommon({Key? key}) : super(key: key);
@override @override
State<LoadingCommon> createState() => _LoadingCommonState(); State<LoadingCommon> createState() => _LoadingCommonState();
} }
class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateMixin { class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateMixin {
AnimationController _controller; AnimationController? _controller;
@override @override
void initState() { void initState() {
@ -22,25 +22,25 @@ class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateM
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller!.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
_controller.forward(from: 0.0); _controller!.forward(from: 0.0);
_controller.addListener(() { _controller!.addListener(() {
if (_controller.isCompleted) { if (_controller!.isCompleted) {
_controller.reverse(); _controller!.reverse();
} }
if(_controller.isDismissed){ if(_controller!.isDismissed){
_controller.forward(); _controller!.forward();
} }
}); });
return Center( return Center(
child: RotationTransition( child: RotationTransition(
turns: Tween(begin: 0.0, end: 3.0).animate(_controller), turns: Tween(begin: 0.0, end: 3.0).animate(_controller!),
child: Icon(Icons.museum_outlined, color: kPrimaryColor, size: size.height*0.1), child: Icon(Icons.museum_outlined, color: kPrimaryColor, size: size.height*0.1),
), ),
); );

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
showNotification (Color backgroundColor, Color textColor, String text, BuildContext context, int duration) { showNotification (Color backgroundColor, Color textColor, String text, BuildContext context, int? duration) {
final snackBar = SnackBar( final snackBar = SnackBar(
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
duration: duration == null ? Duration(milliseconds: 1500) : Duration(milliseconds: duration), duration: duration == null ? Duration(milliseconds: 1500) : Duration(milliseconds: duration),

View File

@ -93,7 +93,7 @@ showMultiStringInput (String label, String modalLabel, bool isTitle, List<Transl
getTranslations(BuildContext context, AppContext appContext, String label, bool isTitle, bool isAudio, List<TranslationDTO> newValues) { getTranslations(BuildContext context, AppContext appContext, String label, bool isTitle, bool isAudio, List<TranslationDTO> newValues) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add( translations.add(
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -122,7 +122,7 @@ getTranslations(BuildContext context, AppContext appContext, String label, bool
label: label, label: label,
color: kWhite, color: kWhite,
isTitle: isTitle, isTitle: isTitle,
initialValue: newValues.where((element) => element.language == language).first.value, initialValue: newValues.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
newValues.where((element) => element.language == language).first.value = value; newValues.where((element) => element.language == language).first.value = value;
}, },

View File

@ -12,14 +12,14 @@ class MultiSelectContainer extends StatelessWidget {
final bool isAtLeastOne; final bool isAtLeastOne;
final ValueChanged<List<dynamic>> onChanged; final ValueChanged<List<dynamic>> onChanged;
const MultiSelectContainer({ const MultiSelectContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.values, required this.values,
this.initialValue, required this.initialValue,
this.isMultiple, required this.isMultiple,
this.isAtLeastOne = false, this.isAtLeastOne = false,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -64,7 +64,7 @@ class MultiSelectChip extends StatefulWidget {
this.selectedValues, this.selectedValues,
this.isMultiple, this.isMultiple,
this.isAtLeastOne, this.isAtLeastOne,
{this.onSelectionChanged} // +added {required this.onSelectionChanged} // +added
); );
@override @override
_MultiSelectChipState createState() => _MultiSelectChipState(); _MultiSelectChipState createState() => _MultiSelectChipState();

View File

@ -16,15 +16,15 @@ class MultiSelectDropdownContainer extends StatelessWidget {
final double fontSize; final double fontSize;
final ValueChanged<List<dynamic>> onChanged; final ValueChanged<List<dynamic>> onChanged;
const MultiSelectDropdownContainer({ const MultiSelectDropdownContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.values, required this.values,
this.initialValue, required this.initialValue,
this.isMultiple, required this.isMultiple,
this.isAtLeastOne = false, this.isAtLeastOne = false,
this.fontSize = 25, this.fontSize = 25,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -63,6 +63,11 @@ class MultiSelectDropdownContainer extends StatelessWidget {
onSelectionChanged: (selectedList) { onSelectionChanged: (selectedList) {
onChanged(selectedList); onChanged(selectedList);
}, },
onConfirm: (List<dynamic> test)
{
print("onConfirm MultiSelectDialogField");
print(test);
},
), ),
), ),
), ),

View File

@ -17,14 +17,14 @@ class MultiStringContainer extends StatelessWidget {
final bool isAudio; final bool isAudio;
final double fontSize; final double fontSize;
const MultiStringContainer({ const MultiStringContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.modalLabel, required this.modalLabel,
this.initialValue, required this.initialValue,
this.onGetResult, required this.onGetResult,
this.maxLines, required this.maxLines,
this.isTitle, required this.isTitle,
this.isAudio = false, this.isAudio = false,
this.fontSize = 25, this.fontSize = 25,
}) : super(key: key); }) : super(key: key);
@ -61,7 +61,7 @@ class MultiStringContainer extends StatelessWidget {
languages.forEach((value) { languages.forEach((value) {
if(initials.map((iv) => iv.language).contains(value)) { if(initials.map((iv) => iv.language).contains(value)) {
newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value))))); newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!);
} else { } else {
// New language // New language
newValues.add(TranslationDTO(language: value, value: null)); newValues.add(TranslationDTO(language: value, value: null));

View File

@ -14,11 +14,11 @@ class NumberInputContainer extends StatelessWidget {
final double fontSize; final double fontSize;
final double fontSizeText; final double fontSizeText;
const NumberInputContainer({ const NumberInputContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
this.isUrl = false, this.isUrl = false,
this.isSmall = false, this.isSmall = false,
this.maxLength = 50, this.maxLength = 50,

View File

@ -12,10 +12,10 @@ class ResourceTab extends StatefulWidget {
final Function onFileUpload; final Function onFileUpload;
final Function onFileUploadWeb; final Function onFileUploadWeb;
const ResourceTab({ const ResourceTab({
Key key, Key? key,
this.resourceDTO, required this.resourceDTO,
this.onFileUpload, required this.onFileUpload,
this.onFileUploadWeb, required this.onFileUploadWeb,
}) : super(key: key); }) : super(key: key);
@override @override
@ -23,7 +23,7 @@ class ResourceTab extends StatefulWidget {
} }
class _ResourceTabState extends State<ResourceTab> with SingleTickerProviderStateMixin { class _ResourceTabState extends State<ResourceTab> with SingleTickerProviderStateMixin {
TabController _tabController; TabController? _tabController;
List<Tab> tabsToShow = <Tab>[]; List<Tab> tabsToShow = <Tab>[];
@override @override
@ -34,7 +34,7 @@ class _ResourceTabState extends State<ResourceTab> with SingleTickerProviderStat
//tabsToShow.add(new Tab(text: "Vidéo en ligne")); //tabsToShow.add(new Tab(text: "Vidéo en ligne"));
_tabController = new TabController(length: 3, vsync: this); _tabController = new TabController(length: 3, vsync: this);
_tabController.addListener(_handleTabSelection); _tabController!.addListener(_handleTabSelection);
super.initState(); super.initState();
} }
@ -67,7 +67,7 @@ class _ResourceTabState extends State<ResourceTab> with SingleTickerProviderStat
} }
void _handleTabSelection() { void _handleTabSelection() {
switch(_tabController.index) { switch(_tabController!.index) {
case 0: case 0:
setState(() { setState(() {
widget.resourceDTO.data = null; widget.resourceDTO.data = null;
@ -98,11 +98,11 @@ getContent(ResourceDTO resourceDTO, Function onFileUpload, Function onFileUpload
new Padding( new Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16), padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
child: UploadImageContainer( child: UploadImageContainer(
onChanged: (List<File> files) { onChanged: (List<File>? files) {
onFileUpload(files); onFileUpload(files);
resourceDTO.type = ResourceType.Image; resourceDTO.type = ResourceType.Image;
}, },
onChangedWeb: (List<PlatformFile> files) { onChangedWeb: (List<PlatformFile>? files) {
onFileUploadWeb(files); onFileUploadWeb(files);
resourceDTO.type = ResourceType.Image; resourceDTO.type = ResourceType.Image;
}, },

View File

@ -5,20 +5,20 @@ import 'package:manager_app/constants.dart';
class RoundedButton extends StatelessWidget { class RoundedButton extends StatelessWidget {
final String text; final String text;
final Function press; final Function press;
final IconData icon; final IconData? icon;
final Color color, textColor; final Color color, textColor;
final double fontSize; final double fontSize;
final double vertical; final double? vertical;
final double horizontal; final double? horizontal;
const RoundedButton({ const RoundedButton({
Key key, Key? key,
this.text, required this.text,
this.press, required this.press,
this.icon, this.icon,
this.color = kPrimaryColor, this.color = kPrimaryColor,
this.textColor = kWhite, this.textColor = kWhite,
this.fontSize, required this.fontSize,
this.vertical, this.vertical,
this.horizontal this.horizontal
}) : super(key: key); }) : super(key: key);
@ -28,7 +28,7 @@ class RoundedButton extends StatelessWidget {
//Size size = MediaQuery.of(context).size; //Size size = MediaQuery.of(context).size;
return TextButton( return TextButton(
style: ButtonStyle( style: ButtonStyle(
padding: MaterialStateProperty.resolveWith((states) => EdgeInsets.symmetric(vertical: this.vertical != null ? this.vertical : 25, horizontal: this.horizontal != null ? this.horizontal : (icon == null ? 85 : 30))), padding: MaterialStateProperty.resolveWith((states) => EdgeInsets.symmetric(vertical: this.vertical != null ? this.vertical! : 25, horizontal: this.horizontal != null ? this.horizontal!: (icon == null ? 85 : 30))),
backgroundColor: MaterialStateColor.resolveWith((states) => color), backgroundColor: MaterialStateColor.resolveWith((states) => color),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(

View File

@ -4,25 +4,25 @@ import 'package:manager_app/Components/text_field_container.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
class RoundedInputField extends StatelessWidget { class RoundedInputField extends StatelessWidget {
final String hintText; final String? hintText;
final IconData icon; final IconData? icon;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
final String initialValue; final String? initialValue;
final Color color, textColor, iconColor; final Color color, textColor, iconColor;
final int maxLength; final int? maxLength;
final bool isEmail; final bool isEmail;
final double fontSize; final double fontSize;
final String autofill; final String? autofill;
final bool isInt; final bool isInt;
const RoundedInputField({ const RoundedInputField({
Key key, Key? key,
this.hintText, this.hintText,
this.initialValue, this.initialValue,
this.icon, this.icon,
this.color = kSecond, this.color = kSecond,
this.textColor = kBlack, this.textColor = kBlack,
this.iconColor = kPrimaryColor, this.iconColor = kPrimaryColor,
this.onChanged, required this.onChanged,
this.maxLength, // 50 this.maxLength, // 50
this.isEmail = false, this.isEmail = false,
this.fontSize = 20, this.fontSize = 20,
@ -39,7 +39,7 @@ class RoundedInputField extends StatelessWidget {
initialValue: initialValue, initialValue: initialValue,
cursorColor: textColor, cursorColor: textColor,
maxLength: maxLength, maxLength: maxLength,
autofillHints: [autofill], autofillHints: autofill != null ? [autofill!] : [],
keyboardType: isEmail ? TextInputType.emailAddress : isInt ? TextInputType.number : TextInputType.text, keyboardType: isEmail ? TextInputType.emailAddress : isInt ? TextInputType.number : TextInputType.text,
inputFormatters: !isInt ? [] : <TextInputFormatter>[ inputFormatters: !isInt ? [] : <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly FilteringTextInputFormatter.digitsOnly

View File

@ -6,9 +6,9 @@ class RoundedPasswordField extends StatefulWidget {
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
final String initialValue; final String initialValue;
const RoundedPasswordField({ const RoundedPasswordField({
Key key, Key? key,
this.onChanged, required this.onChanged,
this.initialValue required this.initialValue
}) : super(key: key); }) : super(key: key);
@override @override

View File

@ -9,13 +9,13 @@ class SliderInputContainer extends StatefulWidget {
final int max; final int max;
final ValueChanged<double> onChanged; final ValueChanged<double> onChanged;
const SliderInputContainer({ const SliderInputContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.initialValue, required this.initialValue,
this.min, required this.min,
this.max, required this.max,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -23,7 +23,7 @@ class SliderInputContainer extends StatefulWidget {
} }
class _SliderInputContainerState extends State<SliderInputContainer> { class _SliderInputContainerState extends State<SliderInputContainer> {
double currentValue; double? currentValue;
@override @override
void initState() { void initState() {
@ -43,7 +43,7 @@ class _SliderInputContainerState extends State<SliderInputContainer> {
Padding( Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: Slider( child: Slider(
value: currentValue, value: currentValue!,
onChanged: (value) { onChanged: (value) {
setState(() => currentValue = value); setState(() => currentValue = value);
widget.onChanged(value); widget.onChanged(value);

View File

@ -4,9 +4,9 @@ import 'package:manager_app/Components/rounded_input_field.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
class StringInputContainer extends StatelessWidget { class StringInputContainer extends StatelessWidget {
final Color color; final Color? color;
final String label; final String label;
final String initialValue; final String? initialValue;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
final bool isUrl; final bool isUrl;
final bool isSmall; final bool isSmall;
@ -14,11 +14,11 @@ class StringInputContainer extends StatelessWidget {
final double fontSize; final double fontSize;
final double fontSizeText; final double fontSizeText;
const StringInputContainer({ const StringInputContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.initialValue, this.initialValue = "",
this.onChanged, required this.onChanged,
this.isUrl = false, this.isUrl = false,
this.isSmall = false, this.isSmall = false,
this.maxLength = 50, this.maxLength = 50,
@ -29,6 +29,7 @@ class StringInputContainer extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
return Container( return Container(
child: Row( child: Row(
children: [ children: [
@ -47,7 +48,7 @@ class StringInputContainer extends StatelessWidget {
child: Container( child: Container(
width: isUrl ? size.width *0.6 : isSmall ? size.width *0.1 : size.width *0.2, width: isUrl ? size.width *0.6 : isSmall ? size.width *0.1 : size.width *0.2,
child: RoundedInputField( child: RoundedInputField(
color: color, color: color!,
textColor: kBlack, textColor: kBlack,
fontSize: fontSizeText, fontSize: fontSizeText,
initialValue: initialValue, initialValue: initialValue,

View File

@ -5,8 +5,8 @@ class TextFieldContainer extends StatelessWidget {
final Widget child; final Widget child;
final Color color; final Color color;
const TextFieldContainer({ const TextFieldContainer({
Key key, Key? key,
this.child, required this.child,
this.color = kSecond, this.color = kSecond,
}) : super(key: key); }) : super(key: key);

View File

@ -9,13 +9,13 @@ class TextFormInputContainer extends StatelessWidget {
final int maxLines; final int maxLines;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const TextFormInputContainer({ const TextFormInputContainer({
Key key, Key? key,
this.color = kSecond, this.color = kSecond,
this.label, required this.label,
this.initialValue, required this.initialValue,
this.isTitle, required this.isTitle,
this.maxLines = 5, this.maxLines = 5,
this.onChanged required this.onChanged
}) : super(key: key); }) : super(key: key);
@override @override

View File

@ -5,9 +5,9 @@ class TranslationTab extends StatefulWidget {
final List<TranslationDTO> translations; final List<TranslationDTO> translations;
final int maxLines; final int maxLines;
const TranslationTab({ const TranslationTab({
Key key, Key? key,
this.translations, required this.translations,
this.maxLines, required this.maxLines,
}) : super(key: key); }) : super(key: key);
@override @override
@ -15,7 +15,7 @@ class TranslationTab extends StatefulWidget {
} }
class _TranslationTabState extends State<TranslationTab> with SingleTickerProviderStateMixin { class _TranslationTabState extends State<TranslationTab> with SingleTickerProviderStateMixin {
TabController _tabController; TabController? _tabController;
@override @override
void initState() { void initState() {

View File

@ -8,9 +8,9 @@ class UploadAudioContainer extends StatefulWidget {
final ValueChanged<List<File>> onChanged; final ValueChanged<List<File>> onChanged;
final ValueChanged<List<PlatformFile>> onChangedWeb; final ValueChanged<List<PlatformFile>> onChangedWeb;
const UploadAudioContainer({ const UploadAudioContainer({
Key key, Key? key,
this.onChanged, required this.onChanged,
this.onChangedWeb, required this.onChangedWeb,
}) : super(key: key); }) : super(key: key);
@override @override
@ -19,8 +19,8 @@ class UploadAudioContainer extends StatefulWidget {
class _UploadAudioContainerState extends State<UploadAudioContainer> with SingleTickerProviderStateMixin { class _UploadAudioContainerState extends State<UploadAudioContainer> with SingleTickerProviderStateMixin {
var filePath; var filePath;
File fileToShow; File? fileToShow;
String fileToShowWeb; String? fileToShowWeb;
@override @override
void initState() { void initState() {
@ -42,7 +42,7 @@ class _UploadAudioContainerState extends State<UploadAudioContainer> with Single
} }
Future<void> filePicker() async { Future<void> filePicker() async {
FilePickerResult result; FilePickerResult? result;
if (kIsWeb) { if (kIsWeb) {
result = await FilePicker.platform.pickFiles( result = await FilePicker.platform.pickFiles(
type: FileType.custom, type: FileType.custom,
@ -68,13 +68,15 @@ class _UploadAudioContainerState extends State<UploadAudioContainer> with Single
allowedExtensions: ['mp3'], allowedExtensions: ['mp3'],
); );
List<File> files = result.paths.map((path) => File(path)).toList(); if(result != null) {
var file = files[0]; List<File> files = result.paths.map((path) => File(path!)).toList();
setState(() { var file = files[0];
filePath = file.path; // Only show one picture setState(() {
fileToShow = file; // Only show one picture filePath = file.path; // Only show one picture
widget.onChanged(files); fileToShow = file; // Only show one picture
}); widget.onChanged(files);
});
}
} }
/*final file = OpenFilePicker() /*final file = OpenFilePicker()
..filterSpecification = { ..filterSpecification = {

View File

@ -5,12 +5,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
class UploadImageContainer extends StatefulWidget { class UploadImageContainer extends StatefulWidget {
final ValueChanged<List<File>> onChanged; final ValueChanged<List<File>?> onChanged;
final ValueChanged<List<PlatformFile>> onChangedWeb; final ValueChanged<List<PlatformFile>?> onChangedWeb;
const UploadImageContainer({ const UploadImageContainer({
Key key, Key? key,
this.onChanged, required this.onChanged,
this.onChangedWeb, required this.onChangedWeb,
}) : super(key: key); }) : super(key: key);
@override @override
@ -19,8 +19,8 @@ class UploadImageContainer extends StatefulWidget {
class _UploadImageContainerState extends State<UploadImageContainer> with SingleTickerProviderStateMixin { class _UploadImageContainerState extends State<UploadImageContainer> with SingleTickerProviderStateMixin {
var filePath; var filePath;
File fileToShow; File? fileToShow;
String fileToShowWeb; String? fileToShowWeb;
@override @override
void initState() { void initState() {
@ -42,7 +42,7 @@ class _UploadImageContainerState extends State<UploadImageContainer> with Single
} }
Future<void> filePicker() async { Future<void> filePicker() async {
FilePickerResult result; FilePickerResult? result;
if (kIsWeb) { if (kIsWeb) {
result = await FilePicker.platform.pickFiles( result = await FilePicker.platform.pickFiles(
type: FileType.custom, type: FileType.custom,
@ -68,13 +68,15 @@ class _UploadImageContainerState extends State<UploadImageContainer> with Single
allowedExtensions: ['jpg', 'jpeg', 'png'], allowedExtensions: ['jpg', 'jpeg', 'png'],
); );
List<File> files = result.paths.map((path) => File(path)).toList(); if (result != null) {
var file = files[0]; List<File> files = result.paths.map((path) => File(path!)).toList();
setState(() { var file = files[0];
filePath = file.path; // Only show one picture setState(() {
fileToShow = file; // Only show one picture filePath = file.path; // Only show one picture
widget.onChanged(files); fileToShow = file; // Only show one picture
}); widget.onChanged(files);
});
}
} }
/*final file = OpenFilePicker() /*final file = OpenFilePicker()
..filterSpecification = { ..filterSpecification = {
@ -136,11 +138,13 @@ class _UploadImageContainerState extends State<UploadImageContainer> with Single
if (kIsWeb) { if (kIsWeb) {
return null; return null;
} else { } else {
return Image.file( if(fileToShow != null) {
fileToShow, return Image.file(
height: 200, fileToShow!,
fit:BoxFit.scaleDown height: 200,
); fit:BoxFit.scaleDown
);
}
} }
} }
} }

View File

@ -7,9 +7,9 @@ class UploadOnlineResourceContainer extends StatefulWidget {
final ResourceDTO resourceDTO; final ResourceDTO resourceDTO;
final ValueChanged<ResourceDTO> onChanged; final ValueChanged<ResourceDTO> onChanged;
const UploadOnlineResourceContainer({ const UploadOnlineResourceContainer({
Key key, Key? key,
this.resourceDTO, required this.resourceDTO,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -17,7 +17,7 @@ class UploadOnlineResourceContainer extends StatefulWidget {
} }
class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceContainer> with SingleTickerProviderStateMixin { class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceContainer> with SingleTickerProviderStateMixin {
String urlResourceToShow; String? urlResourceToShow;
@override @override
void initState() { void initState() {
@ -64,11 +64,11 @@ class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceCont
/*await Media.file(widget.file)*/ /*await Media.file(widget.file)*/
} else { } else {
return Image.network( return Image.network(
urlResourceToShow, urlResourceToShow!,
height: 200, height: 200,
fit:BoxFit.scaleDown, fit:BoxFit.scaleDown,
loadingBuilder: (BuildContext context, Widget child, loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) { ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) { if (loadingProgress == null) {
return child; return child;
} }
@ -77,7 +77,7 @@ class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceCont
color: kPrimaryColor, color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / ? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes loadingProgress.expectedTotalBytes!
: null, : null,
), ),
); );

View File

@ -30,7 +30,7 @@ class FileHelper {
if (session.password != null) { if (session.password != null) {
var encrypter = Encrypter(AES(key)); var encrypter = Encrypter(AES(key));
var encrypted = encrypter.encrypt(session.password, iv: iv); var encrypted = encrypter.encrypt(session.password!, iv: iv);
session.password = encrypted.base64; session.password = encrypted.base64;
} }
@ -40,20 +40,20 @@ class FileHelper {
Future<File> storeConfiguration(ExportConfigurationDTO exportConfigurationDTO) async { Future<File> storeConfiguration(ExportConfigurationDTO exportConfigurationDTO) async {
final path = await _localPath; final path = await _localPath;
new File('$path/'+exportConfigurationDTO.label+'.json').createSync(recursive: true); new File('$path/'+exportConfigurationDTO.label!+'.json').createSync(recursive: true);
// Write the file // Write the file
File file = File('$path/'+exportConfigurationDTO.label+'.json'); File file = File('$path/'+exportConfigurationDTO.label!+'.json');
return file.writeAsString(jsonEncode(exportConfigurationDTO.toJson())); return file.writeAsString(jsonEncode(exportConfigurationDTO.toJson()));
} }
Future<void> importConfiguration(FilePickerResult filePickerResult, String path, Client client, context) async { Future<void> importConfiguration(FilePickerResult filePickerResult, String? path, Client client, context) async {
var fileTest = filePickerResult.files[0]; var fileTest = filePickerResult.files[0];
String fileContent = utf8.decode(fileTest.bytes); String fileContent = utf8.decode(fileTest.bytes!);
ExportConfigurationDTO export = ExportConfigurationDTO.fromJson(jsonDecode(fileContent)); ExportConfigurationDTO export = ExportConfigurationDTO.fromJson(jsonDecode(fileContent))!;
try { try {
String test = await client.configurationApi.configurationImport(export); String? test = await client.configurationApi!.configurationImport(export);
if (test.contains("successfully")) { if (test != null && test.contains("successfully")) {
showNotification(kSuccess, kWhite, 'La configuration a été importée avec succès', context, null); showNotification(kSuccess, kWhite, 'La configuration a été importée avec succès', context, null);
} else { } else {
showNotification(kPrimaryColor, kWhite, 'Une erreur est survenue lors de l''import de la configuration', context, null); showNotification(kPrimaryColor, kWhite, 'Une erreur est survenue lors de l''import de la configuration', context, null);
@ -76,7 +76,7 @@ class FileHelper {
var encrypter = Encrypter(AES(key)); var encrypter = Encrypter(AES(key));
if (session.password != null) { if (session.password != null) {
session.password = encrypter.decrypt64(session.password, iv: iv); session.password = encrypter.decrypt64(session.password!, iv: iv);
} }
return session; return session;

View File

@ -23,10 +23,10 @@ class PDFHelper {
child: child:
pw.Column( pw.Column(
children: [ children: [
pw.Text(section.label.replaceAll(RegExp("[^A-Za-z0-9---():!éàèëêäâç' ]"), '')), //style: pw.TextStyle(font: ttf, fontSize: 30) pw.Text(section.label!.replaceAll(RegExp("[^A-Za-z0-9---():!éàèëêäâç' ]"), '')), //style: pw.TextStyle(font: ttf, fontSize: 30)
pw.Padding(padding: const pw.EdgeInsets.only(top: 20)), pw.Padding(padding: const pw.EdgeInsets.only(top: 20)),
pw.BarcodeWidget( pw.BarcodeWidget(
data: section.id, data: section.id!,
width: 150, width: 150,
height: 150, height: 150,
barcode: pw.Barcode.qrCode(), barcode: pw.Barcode.qrCode(),

View File

@ -7,7 +7,7 @@ import 'package:password_credential/entity/result.dart';
class Model with ChangeNotifier { class Model with ChangeNotifier {
final _credentials = Credentials(); final _credentials = Credentials();
bool hasCredentialFeature = false; bool? hasCredentialFeature = false;
var idEdit = TextEditingController(); var idEdit = TextEditingController();
var passwordEdit = TextEditingController(); var passwordEdit = TextEditingController();
@ -26,11 +26,11 @@ class Model with ChangeNotifier {
Future<PasswordCredential> get(Mediation mediation) async { Future<PasswordCredential> get(Mediation mediation) async {
var credential = await _credentials.get(mediation: mediation); var credential = await _credentials.get(mediation: mediation);
if (credential != null) { if (credential != null) {
idEdit.text = credential.id; idEdit.text = credential.id!;
passwordEdit.text = credential.password; passwordEdit.text = credential.password!;
notifyListeners(); notifyListeners();
} }
return credential; return credential!;
} }
Future<void> delete() async { Future<void> delete() async {

View File

@ -4,15 +4,15 @@ import 'package:manager_api_new/api.dart';
class ManagerAppContext with ChangeNotifier{ class ManagerAppContext with ChangeNotifier{
String email; String? email;
String instanceId; String? instanceId;
String host; String? host;
String accessToken; String? accessToken;
Client clientAPI; Client? clientAPI;
String currentRoute; String? currentRoute;
ConfigurationDTO selectedConfiguration; ConfigurationDTO? selectedConfiguration;
SectionDTO selectedSection; SectionDTO? selectedSection;
bool isLoading = false; bool? isLoading = false;
ManagerAppContext({this.email, this.accessToken, this.currentRoute}); ManagerAppContext({this.email, this.accessToken, this.currentRoute});

View File

@ -2,9 +2,9 @@ import 'package:manager_app/Models/menuSection.dart';
class Menu { class Menu {
String title; String title;
List<MenuSection> sections; List<MenuSection>? sections;
Menu({this.title, this.sections}); Menu({required this.title, this.sections});
factory Menu.fromJson(Map<String, dynamic> json) { factory Menu.fromJson(Map<String, dynamic> json) {
return new Menu( return new Menu(

View File

@ -3,7 +3,7 @@ class MenuSection {
String type; String type;
int order; int order;
MenuSection({this.name, this.type, this.order}); MenuSection({required this.name, required this.type, required this.order});
factory MenuSection.fromJson(Map<String, dynamic> json) { factory MenuSection.fromJson(Map<String, dynamic> json) {
return new MenuSection( return new MenuSection(

View File

@ -4,7 +4,7 @@ class ResourceTypeModel {
String label; String label;
ResourceType type; ResourceType type;
ResourceTypeModel({this.label, this.type}); ResourceTypeModel({required this.label, required this.type});
factory ResourceTypeModel.fromJson(Map<String, dynamic> json) { factory ResourceTypeModel.fromJson(Map<String, dynamic> json) {
return new ResourceTypeModel( return new ResourceTypeModel(

View File

@ -1,10 +1,10 @@
class Session { class Session {
bool rememberMe; bool rememberMe;
String host; String? host;
String email; String? email;
String password; String? password;
Session({this.rememberMe, this.host, this.email, this.password}); Session({required this.rememberMe, this.host, this.email, this.password});
factory Session.fromJson(Map<String, dynamic> json) { factory Session.fromJson(Map<String, dynamic> json) {
return new Session( return new Session(

View File

@ -13,16 +13,16 @@ import 'package:provider/provider.dart';
class ArticleConfig extends StatefulWidget { class ArticleConfig extends StatefulWidget {
final String color; final String? color;
final String label; final String? label;
final String initialValue; final String initialValue;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const ArticleConfig({ const ArticleConfig({
Key key, Key? key,
this.color, this.color,
this.label, this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -30,16 +30,16 @@ class ArticleConfig extends StatefulWidget {
} }
class _ArticleConfigState extends State<ArticleConfig> { class _ArticleConfigState extends State<ArticleConfig> {
ArticleDTO articleDTO; late ArticleDTO articleDTO;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
articleDTO = ArticleDTO.fromJson(json.decode(widget.initialValue)); articleDTO = ArticleDTO.fromJson(json.decode(widget.initialValue))!;
List<ImageDTO> test = new List<ImageDTO>.from(articleDTO.images); List<ImageDTO> test = new List<ImageDTO>.from(articleDTO.images!);
articleDTO.images = test; articleDTO.images = test;
articleDTO.images.sort((a, b) => a.order.compareTo(b.order)); articleDTO.images!.sort((a, b) => a.order!.compareTo(b.order!));
} }
@override @override
@ -53,11 +53,11 @@ class _ArticleConfigState extends State<ArticleConfig> {
if (newIndex > oldIndex) { if (newIndex > oldIndex) {
newIndex -= 1; newIndex -= 1;
} }
final ImageDTO item = articleDTO.images.removeAt(oldIndex); final ImageDTO item = articleDTO.images!.removeAt(oldIndex);
articleDTO.images.insert(newIndex, item); articleDTO.images!.insert(newIndex, item);
var i = 0; var i = 0;
articleDTO.images.forEach((image) { articleDTO.images!.forEach((image) {
image.order = i; image.order = i;
i++; i++;
}); });
@ -83,11 +83,11 @@ class _ArticleConfigState extends State<ArticleConfig> {
label: "Contenu affiché :", label: "Contenu affiché :",
modalLabel: "Contenu", modalLabel: "Contenu",
color: kPrimaryColor, color: kPrimaryColor,
initialValue: articleDTO != null ? articleDTO.content : [], initialValue: articleDTO != null ? 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(jsonEncode(articleDTO).toString());
@ -117,7 +117,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
isAudio: true, isAudio: true,
modalLabel: "Audio", modalLabel: "Audio",
color: kPrimaryColor, color: kPrimaryColor,
initialValue: articleDTO != null ? articleDTO.audioIds : [], initialValue: articleDTO != null ? articleDTO.audioIds! : [],
isTitle: false, isTitle: false,
onGetResult: (value) { onGetResult: (value) {
setState(() { setState(() {
@ -165,10 +165,10 @@ class _ArticleConfigState extends State<ArticleConfig> {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(vertical: 20.0), padding: const EdgeInsets.symmetric(vertical: 20.0),
children: List.generate( children: List.generate(
articleDTO.images.length, articleDTO.images!.length,
(index) { (index) {
return ListViewCardImage( return ListViewCardImage(
articleDTO.images, articleDTO.images!,
index, index,
Key('$index'), Key('$index'),
appContext, appContext,
@ -212,8 +212,8 @@ class _ArticleConfigState extends State<ArticleConfig> {
if (result != null) if (result != null)
{ {
setState(() { setState(() {
result.order = articleDTO.images.length; result.order = articleDTO.images!.length;
articleDTO.images.add(result); articleDTO.images!.add(result);
widget.onChanged(jsonEncode(articleDTO).toString()); widget.onChanged(jsonEncode(articleDTO).toString());
}); });
} }

View File

@ -6,8 +6,8 @@ import 'package:manager_api_new/api.dart';
class DownloadPDF extends StatefulWidget { class DownloadPDF extends StatefulWidget {
final List<SectionDTO> sections; final List<SectionDTO> sections;
const DownloadPDF({ const DownloadPDF({
Key key, Key? key,
this.sections, required this.sections,
}) : super(key: key); }) : super(key: key);
@override @override

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/listView_card_geoPoint_images.dart'; import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/listView_card_geoPoint_images.dart';
import 'package:manager_app/Screens/Resources/select_resource_modal.dart'; import 'package:manager_app/Screens/Resources/select_resource_modal.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
@ -10,9 +11,9 @@ class GeoPointImageList extends StatefulWidget {
final List<ImageGeoPoint> images; final List<ImageGeoPoint> images;
final ValueChanged<List<ImageGeoPoint>> onChanged; final ValueChanged<List<ImageGeoPoint>> onChanged;
const GeoPointImageList({ const GeoPointImageList({
Key key, Key? key,
this.images, required this.images,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -20,7 +21,7 @@ class GeoPointImageList extends StatefulWidget {
} }
class _GeoPointImageListState extends State<GeoPointImageList> { class _GeoPointImageListState extends State<GeoPointImageList> {
List<ImageGeoPoint> imagesGeo; late List<ImageGeoPoint> imagesGeo;
@override @override
void initState() { void initState() {
@ -96,7 +97,7 @@ class _GeoPointImageListState extends State<GeoPointImageList> {
); );
if (result != null) { if (result != null) {
setState(() { setState(() {
ImageGeoPoint newImage = new ImageGeoPoint(imageResourceId: result.id, imageSource: result.type == ResourceType.ImageUrl ? result.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ result.id); ImageGeoPoint newImage = new ImageGeoPoint(imageResourceId: result.id, imageSource: result.type == ResourceType.ImageUrl ? result.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ result.id);
//print("REULT IMAGES = "); //print("REULT IMAGES = ");
//print(newImage); //print(newImage);
imagesGeo.add(newImage); imagesGeo.add(newImage);

View File

@ -82,10 +82,10 @@ class _ListViewCardGeoPointImagesState extends State<ListViewCardGeoPointImages>
children: [ children: [
Center( Center(
child: Image.network( child: Image.network(
imageGeoPoint.imageSource, imageGeoPoint.imageSource!,
fit:BoxFit.scaleDown, fit:BoxFit.scaleDown,
loadingBuilder: (BuildContext context, Widget child, loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) { ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) { if (loadingProgress == null) {
return child; return child;
} }
@ -94,7 +94,7 @@ class _ListViewCardGeoPointImagesState extends State<ListViewCardGeoPointImages>
color: kPrimaryColor, color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / ? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes loadingProgress.expectedTotalBytes!
: null, : null,
), ),
); );

View File

@ -4,6 +4,7 @@ import 'package:manager_app/Components/fetch_section_icon.dart';
import 'package:manager_app/Components/image_input_container.dart'; import 'package:manager_app/Components/image_input_container.dart';
import 'package:manager_app/Components/multi_select_container.dart'; import 'package:manager_app/Components/multi_select_container.dart';
import 'package:manager_app/Components/slider_input_container.dart'; import 'package:manager_app/Components/slider_input_container.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart'; import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
@ -13,16 +14,16 @@ import 'dart:convert';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class MapConfig extends StatefulWidget { class MapConfig extends StatefulWidget {
final String color; final String? color;
final String label; final String? label;
final String initialValue; final String initialValue;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const MapConfig({ const MapConfig({
Key key, Key? key,
this.color, this.color,
this.label, this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -30,19 +31,19 @@ class MapConfig extends StatefulWidget {
} }
class _MapConfigState extends State<MapConfig> { class _MapConfigState extends State<MapConfig> {
MapDTO mapDTO; late MapDTO mapDTO;
String mapType= "hybrid"; String mapType= "hybrid";
@override @override
void initState() { void initState() {
super.initState(); super.initState();
mapDTO = MapDTO.fromJson(json.decode(widget.initialValue)); mapDTO = MapDTO.fromJson(json.decode(widget.initialValue))!;
List<GeoPointDTO> test = new List<GeoPointDTO>.from(mapDTO.points); List<GeoPointDTO> test = new List<GeoPointDTO>.from(mapDTO.points!);
mapDTO.points = test; mapDTO.points = test;
if(mapDTO.mapType != null) { if(mapDTO.mapType != null) {
switch(mapDTO.mapType.value) { switch(mapDTO.mapType!.value) {
case 0: case 0:
mapType = "none"; mapType = "none";
break; break;
@ -96,7 +97,7 @@ class _MapConfigState extends State<MapConfig> {
mapDTO.iconResourceId = null; mapDTO.iconResourceId = null;
} else { } else {
mapDTO.iconResourceId = resource.id; mapDTO.iconResourceId = resource.id;
mapDTO.iconSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; mapDTO.iconSource = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
widget.onChanged(jsonEncode(mapDTO).toString()); widget.onChanged(jsonEncode(mapDTO).toString());
}, },
@ -119,7 +120,7 @@ class _MapConfigState extends State<MapConfig> {
// Zoom // Zoom
SliderInputContainer( SliderInputContainer(
label: "Zoom:", label: "Zoom:",
initialValue: mapDTO.zoom != null ? mapDTO.zoom.toDouble() : 18, initialValue: mapDTO.zoom != null ? mapDTO.zoom!.toDouble() : 18,
color: kPrimaryColor, color: kPrimaryColor,
min: 0, min: 0,
max: 30, max: 30,
@ -145,14 +146,14 @@ class _MapConfigState extends State<MapConfig> {
child: GridView.builder( child: GridView.builder(
shrinkWrap: true, shrinkWrap: true,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8), gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
itemCount: mapDTO.points.length, itemCount: mapDTO.points!.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return return
Container( Container(
decoration: boxDecoration(mapDTO.points[index], appContext), decoration: boxDecoration(mapDTO.points![index], appContext),
padding: const EdgeInsets.all(5), padding: const EdgeInsets.all(5),
margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10), margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: getElement(index, mapDTO.points[index], size, appContext), child: getElement(index, mapDTO.points![index], size, appContext),
); );
} }
), ),
@ -174,7 +175,7 @@ class _MapConfigState extends State<MapConfig> {
null, null,
(GeoPointDTO geoPoint) { (GeoPointDTO geoPoint) {
setState(() { setState(() {
mapDTO.points.add(geoPoint); mapDTO.points!.add(geoPoint);
widget.onChanged(jsonEncode(mapDTO).toString()); widget.onChanged(jsonEncode(mapDTO).toString());
}); });
}, },
@ -213,7 +214,7 @@ class _MapConfigState extends State<MapConfig> {
); );
} }
getElement(int index, GeoPointDTO point, Size size, AppContext appContext) { getElement(int index, GeoPointDTO? point, Size size, AppContext appContext) {
return Container( return Container(
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
@ -223,7 +224,7 @@ class _MapConfigState extends State<MapConfig> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: AutoSizeText( child: AutoSizeText(
point.title == null ? "" : point.title[0].value, point != null ? point.title == null ? "" : point.title![0].value! : "",
style: new TextStyle(fontSize: 20), style: new TextStyle(fontSize: 20),
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -245,10 +246,10 @@ class _MapConfigState extends State<MapConfig> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
showNewOrUpdateGeoPoint( showNewOrUpdateGeoPoint(
mapDTO.points[index], mapDTO.points![index],
(GeoPointDTO geoPoint) { (GeoPointDTO geoPoint) {
setState(() { setState(() {
mapDTO.points[index] = geoPoint; mapDTO.points![index] = geoPoint;
widget.onChanged(jsonEncode(mapDTO).toString()); widget.onChanged(jsonEncode(mapDTO).toString());
}); });
}, },
@ -268,7 +269,7 @@ class _MapConfigState extends State<MapConfig> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
mapDTO.points.removeAt(index); mapDTO.points!.removeAt(index);
}); });
widget.onChanged(jsonEncode(mapDTO).toString()); widget.onChanged(jsonEncode(mapDTO).toString());
}, },

View File

@ -9,7 +9,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, AppContext appContext, BuildContext context) { void showNewOrUpdateGeoPoint(GeoPointDTO? inputGeoPointDTO, Function getResult, AppContext appContext, BuildContext context) {
GeoPointDTO geoPointDTO = new GeoPointDTO(); GeoPointDTO geoPointDTO = new GeoPointDTO();
if (inputGeoPointDTO != null) { if (inputGeoPointDTO != null) {
@ -20,12 +20,12 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
geoPointDTO.images = <ImageGeoPoint>[]; geoPointDTO.images = <ImageGeoPoint>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) { managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationDTO = new TranslationDTO(); var translationDTO = new TranslationDTO();
translationDTO.language = element; translationDTO.language = element;
translationDTO.value = ""; translationDTO.value = "";
geoPointDTO.title.add(translationDTO); geoPointDTO.title!.add(translationDTO);
geoPointDTO.description.add(translationDTO); geoPointDTO.description!.add(translationDTO);
}); });
} }
@ -87,7 +87,7 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
], ],
), ),
child: GeoPointImageList( child: GeoPointImageList(
images: geoPointDTO.images, images: geoPointDTO.images!,
onChanged: (List<ImageGeoPoint> imagesOutput) { onChanged: (List<ImageGeoPoint> imagesOutput) {
geoPointDTO.images = imagesOutput; geoPointDTO.images = imagesOutput;
}, },
@ -152,7 +152,7 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
getTranslations(BuildContext context, AppContext appContext, GeoPointDTO geoPointDTO) { getTranslations(BuildContext context, AppContext appContext, GeoPointDTO geoPointDTO) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add( translations.add(
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -181,18 +181,18 @@ getTranslations(BuildContext context, AppContext appContext, GeoPointDTO geoPoin
label: "Titre:", label: "Titre:",
color: kWhite, color: kWhite,
isTitle: true, isTitle: true,
initialValue: geoPointDTO.title.where((element) => element.language == language).first.value, initialValue: geoPointDTO.title!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
geoPointDTO.title.where((element) => element.language == language).first.value = value; geoPointDTO.title!.where((element) => element.language == language).first.value = value;
}, },
), ),
TextFormInputContainer( TextFormInputContainer(
label: "Description:", label: "Description:",
color: kWhite, color: kWhite,
isTitle: false, isTitle: false,
initialValue: geoPointDTO.description.where((element) => element.language == language).first.value, initialValue: geoPointDTO.description!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
geoPointDTO.description.where((element) => element.language == language).first.value = value; geoPointDTO.description!.where((element) => element.language == language).first.value = value;
}, },
), ),
], ],

View File

@ -59,7 +59,7 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
showEditSubSection( showEditSubSection(
widget.listItems[widget.index], widget.listItems[widget.index],
(SectionDTO value) async { (SectionDTO value) async {
var result = await (appContext.getContext() as ManagerAppContext).clientAPI.sectionApi.sectionUpdate(value); var result = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(value);
setState(() { setState(() {
widget.listItems[widget.index] = value; widget.listItems[widget.index] = value;
widget.onChanged(widget.listItems); widget.onChanged(widget.listItems);
@ -109,7 +109,7 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: AutoSizeText( child: AutoSizeText(
sectionDTO.label, sectionDTO.label!,
style: new TextStyle(fontSize: 15), style: new TextStyle(fontSize: 15),
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,

View File

@ -1,6 +1,7 @@
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_app/Components/fetch_section_icon.dart'; import 'package:manager_app/Components/fetch_section_icon.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart'; import 'package:manager_app/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart';
import 'package:manager_app/Screens/Configurations/new_section_popup.dart'; import 'package:manager_app/Screens/Configurations/new_section_popup.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
@ -11,16 +12,16 @@ import 'dart:convert';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class MenuConfig extends StatefulWidget { class MenuConfig extends StatefulWidget {
final String color; final String? color;
final String label; final String? label;
final String initialValue; final String initialValue;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const MenuConfig({ const MenuConfig({
Key key, Key? key,
this.color, this.color,
this.label, this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -28,14 +29,14 @@ class MenuConfig extends StatefulWidget {
} }
class _MenuConfigState extends State<MenuConfig> { class _MenuConfigState extends State<MenuConfig> {
MenuDTO menuDTO; late MenuDTO menuDTO;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
menuDTO = MenuDTO.fromJson(json.decode(widget.initialValue)); menuDTO = MenuDTO.fromJson(json.decode(widget.initialValue))!;
List<SectionDTO> test = new List<SectionDTO>.from(menuDTO.sections); List<SectionDTO> test = new List<SectionDTO>.from(menuDTO.sections!);
menuDTO.sections = test; menuDTO.sections = test;
} }
@ -55,8 +56,8 @@ class _MenuConfigState extends State<MenuConfig> {
if (newIndex > oldIndex) { if (newIndex > oldIndex) {
newIndex -= 1; newIndex -= 1;
} }
final SectionDTO item = menuDTO.sections.removeAt(oldIndex); final SectionDTO item = menuDTO.sections!.removeAt(oldIndex);
menuDTO.sections.insert(newIndex, item); menuDTO.sections!.insert(newIndex, item);
/*var i = 0; /*var i = 0;
menuDTO.sections.forEach((image) { menuDTO.sections.forEach((image) {
@ -81,10 +82,10 @@ class _MenuConfigState extends State<MenuConfig> {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(vertical: 20.0), padding: const EdgeInsets.symmetric(vertical: 20.0),
children: List.generate( children: List.generate(
menuDTO.sections.length, menuDTO.sections!.length,
(index) { (index) {
return ListViewCardSubSection( return ListViewCardSubSection(
menuDTO.sections, menuDTO.sections!,
index, index,
Key('$index'), Key('$index'),
appContext, appContext,
@ -107,7 +108,7 @@ class _MenuConfigState extends State<MenuConfig> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
showNewSection( showNewSection(
appContext.getContext().selectedConfiguration.id, (appContext.getContext() as ManagerAppContext).selectedConfiguration!.id!,
appContext, appContext,
context, context,
true, true,
@ -115,7 +116,7 @@ class _MenuConfigState extends State<MenuConfig> {
setState(() { setState(() {
//print("RECEIVED new swubssection"); //print("RECEIVED new swubssection");
//print(newSubsection); //print(newSubsection);
menuDTO.sections.add(newSubsection); menuDTO.sections!.add(newSubsection);
widget.onChanged(jsonEncode(menuDTO).toString()); widget.onChanged(jsonEncode(menuDTO).toString());
}); });
}, },
@ -160,7 +161,7 @@ class _MenuConfigState extends State<MenuConfig> {
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: AutoSizeText( child: AutoSizeText(
sectionDTO.label, sectionDTO.label!,
style: new TextStyle(fontSize: 15), style: new TextStyle(fontSize: 15),
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -196,7 +197,7 @@ class _MenuConfigState extends State<MenuConfig> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
menuDTO.sections.removeAt(index); menuDTO.sections!.removeAt(index);
widget.onChanged(jsonEncode(menuDTO).toString()); widget.onChanged(jsonEncode(menuDTO).toString());
}); });
}, },

View File

@ -52,7 +52,7 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
subSectionDTO.imageSource = null; subSectionDTO.imageSource = null;
} else { } else {
subSectionDTO.imageId = resource.id; subSectionDTO.imageId = resource.id;
subSectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; subSectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
}, },
isSmall: true, isSmall: true,
@ -133,7 +133,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
switch(sectionDTO.type) { switch(sectionDTO.type) {
case SectionType.Map: case SectionType.Map:
return MapConfig( return MapConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent"); //print("Received info in parent");
//print(data); //print(data);
@ -145,7 +145,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
width: MediaQuery.of(context).size.width * 0.5, width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height * 0.5, height: MediaQuery.of(context).size.height * 0.5,
child: SliderConfig( child: SliderConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent"); //print("Received info in parent");
//print(data); //print(data);
@ -157,14 +157,14 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
case SectionType.Web: case SectionType.Web:
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: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
sectionDTO.data = data; sectionDTO.data = data;
}, },
); );
case SectionType.Menu: case SectionType.Menu:
return MenuConfig( return MenuConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent"); //print("Received info in parent");
//print(data); //print(data);
@ -173,7 +173,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
); );
case SectionType.Quizz: case SectionType.Quizz:
return QuizzConfig( return QuizzConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent"); //print("Received info in parent");
//print(data); //print(data);
@ -186,7 +186,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
getTranslations(BuildContext context, AppContext appContext, SectionDTO subSectionDTO) { getTranslations(BuildContext context, AppContext appContext, SectionDTO subSectionDTO) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add( translations.add(
SingleChildScrollView( SingleChildScrollView(
child: Padding( child: Padding(
@ -216,18 +216,18 @@ getTranslations(BuildContext context, AppContext appContext, SectionDTO subSecti
color: kWhite, color: kWhite,
isTitle: true, isTitle: true,
maxLines: 1, maxLines: 1,
initialValue: subSectionDTO.title.where((element) => element.language == language).first.value, initialValue: subSectionDTO.title!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
subSectionDTO.title.where((element) => element.language == language).first.value = value; subSectionDTO.title!.where((element) => element.language == language).first.value = value;
}, },
), ),
TextFormInputContainer( TextFormInputContainer(
label: "Description:", label: "Description:",
color: kWhite, color: kWhite,
isTitle: false, isTitle: false,
initialValue: subSectionDTO.description.where((element) => element.language == language).first.value, initialValue: subSectionDTO.description!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
subSectionDTO.description.where((element) => element.language == language).first.value = value; subSectionDTO.description!.where((element) => element.language == language).first.value = value;
}, },
), ),
], ],

View File

@ -10,7 +10,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, AppContext appContext, BuildContext context, String text) async { Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, AppContext appContext, BuildContext context, String text) async {
QuestionDTO questionDTO = new QuestionDTO(); QuestionDTO questionDTO = new QuestionDTO();
if (inputQuestionDTO != null) { if (inputQuestionDTO != null) {
@ -19,12 +19,12 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
questionDTO.label = <TranslationDTO>[]; questionDTO.label = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) { managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationMessageDTO = new TranslationDTO(); var translationMessageDTO = new TranslationDTO();
translationMessageDTO.language = element; translationMessageDTO.language = element;
translationMessageDTO.value = ""; translationMessageDTO.value = "";
questionDTO.label.add(translationMessageDTO); questionDTO.label!.add(translationMessageDTO);
}); });
} }
@ -59,7 +59,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
questionDTO.source_ = null; questionDTO.source_ = null;
} else { } else {
questionDTO.resourceId = resource.id; questionDTO.resourceId = resource.id;
questionDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; questionDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
}, },
isSmall: true isSmall: true
@ -92,7 +92,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
], ],
), ),
child: QuizzResponseList( child: QuizzResponseList(
responses: questionDTO.responses, responses: questionDTO.responses!,
onChanged: (List<ResponseDTO> responsesOutput) { onChanged: (List<ResponseDTO> responsesOutput) {
questionDTO.responses = responsesOutput; questionDTO.responses = responsesOutput;
}, },
@ -135,7 +135,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
color: kPrimaryColor, color: kPrimaryColor,
textColor: kWhite, textColor: kWhite,
press: () { press: () {
if(!questionDTO.label.any((label) => label.value == null || label.value.trim() == "")) { if(!questionDTO.label!.any((label) => label.value == null || label.value!.trim() == "")) {
Navigator.pop(dialogContext, questionDTO); Navigator.pop(dialogContext, questionDTO);
} else { } else {
showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null); showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null);
@ -156,7 +156,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
getTranslations(BuildContext context, AppContext appContext, QuestionDTO questionDTO) { getTranslations(BuildContext context, AppContext appContext, QuestionDTO questionDTO) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add( translations.add(
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -185,9 +185,9 @@ getTranslations(BuildContext context, AppContext appContext, QuestionDTO questio
label: "Question:", label: "Question:",
color: kWhite, color: kWhite,
isTitle: false, isTitle: false,
initialValue: questionDTO.label.where((element) => element.language == language).first.value, initialValue: questionDTO.label!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
questionDTO.label.where((element) => element.language == language).first.value = value; questionDTO.label!.where((element) => element.language == language).first.value = value;
}, },
), ),
], ],

View File

@ -8,7 +8,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO inputResponseDTO, AppContext appContext, BuildContext context, String text) async { Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO? inputResponseDTO, AppContext appContext, BuildContext context, String text) async {
ResponseDTO responseDTO = new ResponseDTO(); ResponseDTO responseDTO = new ResponseDTO();
if (inputResponseDTO != null) { if (inputResponseDTO != null) {
@ -17,12 +17,12 @@ Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO inputResponseDTO, A
responseDTO.label = <TranslationDTO>[]; responseDTO.label = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) { managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationMessageDTO = new TranslationDTO(); var translationMessageDTO = new TranslationDTO();
translationMessageDTO.language = element; translationMessageDTO.language = element;
translationMessageDTO.value = ""; translationMessageDTO.value = "";
responseDTO.label.add(translationMessageDTO); responseDTO.label!.add(translationMessageDTO);
}); });
} }
@ -107,7 +107,7 @@ Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO inputResponseDTO, A
color: kPrimaryColor, color: kPrimaryColor,
textColor: kWhite, textColor: kWhite,
press: () { press: () {
if(!responseDTO.label.any((label) => label.value == null || label.value.trim() == "")) { if(!responseDTO.label!.any((label) => label.value == null || label.value!.trim() == "")) {
Navigator.pop(dialogContext, responseDTO); Navigator.pop(dialogContext, responseDTO);
} else { } else {
showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null); showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null);
@ -128,7 +128,7 @@ Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO inputResponseDTO, A
getTranslations(BuildContext context, AppContext appContext, ResponseDTO responseDTO) { getTranslations(BuildContext context, AppContext appContext, ResponseDTO responseDTO) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add( translations.add(
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -157,9 +157,9 @@ getTranslations(BuildContext context, AppContext appContext, ResponseDTO respons
label: "Réponse:", label: "Réponse:",
color: kWhite, color: kWhite,
isTitle: true, isTitle: true,
initialValue: responseDTO.label.where((element) => element.language == language).first.value, initialValue: responseDTO.label!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
responseDTO.label.where((element) => element.language == language).first.value = value; responseDTO.label!.where((element) => element.language == language).first.value = value;
}, },
), ),
], ],

View File

@ -8,7 +8,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext appContext, BuildContext context, String text) async { Future<LevelDTO?> showNewOrUpdateScoreQuizz(LevelDTO? inputLevelDTO, AppContext appContext, BuildContext context, String text) async {
LevelDTO levelDTO = new LevelDTO(); LevelDTO levelDTO = new LevelDTO();
if (inputLevelDTO != null) { if (inputLevelDTO != null) {
@ -17,12 +17,12 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
levelDTO.label = <TranslationDTO>[]; levelDTO.label = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) { managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationMessageDTO = new TranslationDTO(); var translationMessageDTO = new TranslationDTO();
translationMessageDTO.language = element; translationMessageDTO.language = element;
translationMessageDTO.value = ""; translationMessageDTO.value = "";
levelDTO.label.add(translationMessageDTO); levelDTO.label!.add(translationMessageDTO);
}); });
} }
@ -53,7 +53,7 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
levelDTO.source_ = null; levelDTO.source_ = null;
} else { } else {
levelDTO.resourceId = resource.id; levelDTO.resourceId = resource.id;
levelDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; levelDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
}, },
isSmall: true isSmall: true
@ -121,7 +121,7 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
getTranslations(BuildContext context, AppContext appContext, LevelDTO levelDTO) { getTranslations(BuildContext context, AppContext appContext, LevelDTO levelDTO) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add( translations.add(
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -150,9 +150,9 @@ getTranslations(BuildContext context, AppContext appContext, LevelDTO levelDTO)
label: "Message:", label: "Message:",
color: kWhite, color: kWhite,
isTitle: false, isTitle: false,
initialValue: levelDTO.label.where((element) => element.language == language).first.value, initialValue: levelDTO.label!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
levelDTO.label.where((element) => element.language == language).first.value = value; levelDTO.label!.where((element) => element.language == language).first.value = value;
}, },
), ),
], ],

View File

@ -11,9 +11,9 @@ class QuizzResponseList extends StatefulWidget {
final List<ResponseDTO> responses; final List<ResponseDTO> responses;
final ValueChanged<List<ResponseDTO>> onChanged; final ValueChanged<List<ResponseDTO>> onChanged;
const QuizzResponseList({ const QuizzResponseList({
Key key, Key? key,
this.responses, required this.responses,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -21,7 +21,7 @@ class QuizzResponseList extends StatefulWidget {
} }
class _QuizzResponseListState extends State<QuizzResponseList> { class _QuizzResponseListState extends State<QuizzResponseList> {
List<ResponseDTO> responsesMiddle; late List<ResponseDTO> responsesMiddle;
@override @override
void initState() { void initState() {
@ -138,7 +138,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(2.0), padding: const EdgeInsets.all(2.0),
child: AutoSizeText( child: AutoSizeText(
response.label == null ? "" : response.label[0].value, response.label == null ? "" : response.label![0].value!,
style: new TextStyle(fontSize: 15), style: new TextStyle(fontSize: 15),
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -161,9 +161,9 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
value: response.isGood, value: response.isGood,
checkColor: Colors.white, checkColor: Colors.white,
activeColor: kPrimaryColor, activeColor: kPrimaryColor,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
response.isGood = !response.isGood; response.isGood = !response.isGood!;
widget.onChanged(responsesMiddle); widget.onChanged(responsesMiddle);
}); });
}, },
@ -183,7 +183,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
if (result != null) { if (result != null) {
setState(() { setState(() {
responsesMiddle[response.order] = result; responsesMiddle[response.order!] = result;
widget.onChanged(responsesMiddle); widget.onChanged(responsesMiddle);
}); });
} }
@ -203,7 +203,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
responsesMiddle.removeAt(response.order); responsesMiddle.removeAt(response.order!);
widget.onChanged(responsesMiddle); widget.onChanged(responsesMiddle);
}); });
}, },

View File

@ -12,16 +12,16 @@ import 'new_update_question_quizz.dart';
import 'new_update_score_quizz.dart'; import 'new_update_score_quizz.dart';
class QuizzConfig extends StatefulWidget { class QuizzConfig extends StatefulWidget {
final String color; final String? color;
final String label; final String? label;
final String initialValue; final String initialValue;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const QuizzConfig({ const QuizzConfig({
Key key, Key? key,
this.color, this.color,
this.label, this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -29,15 +29,15 @@ class QuizzConfig extends StatefulWidget {
} }
class _QuizzConfigState extends State<QuizzConfig> { class _QuizzConfigState extends State<QuizzConfig> {
QuizzDTO quizzDTO; late QuizzDTO quizzDTO;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
quizzDTO = QuizzDTO.fromJson(json.decode(widget.initialValue)); quizzDTO = QuizzDTO.fromJson(json.decode(widget.initialValue))!;
List<QuestionDTO> test = new List<QuestionDTO>.from(quizzDTO.questions); List<QuestionDTO> test = new List<QuestionDTO>.from(quizzDTO.questions!);
quizzDTO.questions = test; quizzDTO.questions = test;
quizzDTO.questions.sort((a, b) => a.order.compareTo(b.order)); quizzDTO.questions!.sort((a, b) => a.order!.compareTo(b.order!));
} }
@override @override
@ -51,11 +51,11 @@ class _QuizzConfigState extends State<QuizzConfig> {
if (newIndex > oldIndex) { if (newIndex > oldIndex) {
newIndex -= 1; newIndex -= 1;
} }
final QuestionDTO item = quizzDTO.questions.removeAt(oldIndex); final QuestionDTO item = quizzDTO.questions!.removeAt(oldIndex);
quizzDTO.questions.insert(newIndex, item); quizzDTO.questions!.insert(newIndex, item);
var i = 0; var i = 0;
quizzDTO.questions.forEach((question) { quizzDTO.questions!.forEach((question) {
question.order = i; question.order = i;
i++; i++;
}); });
@ -182,7 +182,7 @@ class _QuizzConfigState extends State<QuizzConfig> {
Padding( Padding(
padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10), padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10),
child: Container( child: Container(
height: quizzDTO.questions.length == 0 ? 75 : null, height: quizzDTO.questions!.length == 0 ? 75 : null,
child: ReorderableListView.builder( child: ReorderableListView.builder(
shrinkWrap: true, shrinkWrap: true,
padding: const EdgeInsets.only(right: 125), padding: const EdgeInsets.only(right: 125),
@ -192,10 +192,10 @@ class _QuizzConfigState extends State<QuizzConfig> {
decoration: boxDecoration(), decoration: boxDecoration(),
padding: const EdgeInsets.all(2), padding: const EdgeInsets.all(2),
margin: EdgeInsets.symmetric(vertical: 3, horizontal: 3), margin: EdgeInsets.symmetric(vertical: 3, horizontal: 3),
child: getElement(index, quizzDTO.questions[index], size, appContext), child: getElement(index, quizzDTO.questions![index], size, appContext),
); );
}, },
itemCount: quizzDTO.questions.length, itemCount: quizzDTO.questions!.length,
onReorder: _onReorder onReorder: _onReorder
), ),
) )
@ -213,12 +213,12 @@ class _QuizzConfigState extends State<QuizzConfig> {
right: 10, right: 10,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
QuestionDTO result = await showNewOrUpdateQuestionQuizz(null, appContext, context, "Question"); QuestionDTO? result = await showNewOrUpdateQuestionQuizz(null, appContext, context, "Question");
if (result != null) if (result != null)
{ {
setState(() { setState(() {
result.order = quizzDTO.questions.length; result.order = quizzDTO.questions!.length;
quizzDTO.questions.add(result); quizzDTO.questions!.add(result);
widget.onChanged(jsonEncode(quizzDTO).toString()); widget.onChanged(jsonEncode(quizzDTO).toString());
}); });
} }
@ -273,7 +273,7 @@ class _QuizzConfigState extends State<QuizzConfig> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(2.0), padding: const EdgeInsets.all(2.0),
child: AutoSizeText( child: AutoSizeText(
question.label == null ? "" : question.label[0].value, question.label == null ? "" : question.label![0].value!,
style: new TextStyle(fontSize: 15), style: new TextStyle(fontSize: 15),
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -301,7 +301,7 @@ class _QuizzConfigState extends State<QuizzConfig> {
if (result != null) { if (result != null) {
setState(() { setState(() {
quizzDTO.questions[question.order] = result; quizzDTO.questions![question.order!] = result;
widget.onChanged(jsonEncode(quizzDTO).toString()); widget.onChanged(jsonEncode(quizzDTO).toString());
}); });
} }
@ -321,7 +321,7 @@ class _QuizzConfigState extends State<QuizzConfig> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
quizzDTO.questions.removeAt(question.order); quizzDTO.questions!.removeAt(question.order!);
widget.onChanged(jsonEncode(quizzDTO).toString()); widget.onChanged(jsonEncode(quizzDTO).toString());
}); });
}, },
@ -369,7 +369,7 @@ imageBoxDecoration(QuestionDTO questionDTO, appContext) {
image: questionDTO.source_ != null ? new DecorationImage( image: questionDTO.source_ != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
image: new NetworkImage( image: new NetworkImage(
questionDTO.source_, questionDTO.source_!,
), ),
) : null, ) : null,
); );

View File

@ -47,7 +47,7 @@ class _ListViewCard extends State<ListViewCardImage> {
child: Column( child: Column(
children: [ children: [
AutoSizeText( AutoSizeText(
widget.listItems[widget.index].title == null ? "" : widget.listItems[widget.index].title[0].value, widget.listItems[widget.index].title == null ? "" : widget.listItems[widget.index].title![0].value!,
style: new TextStyle(fontSize: 15), style: new TextStyle(fontSize: 15),
maxLines: 1, maxLines: 1,
), ),
@ -134,7 +134,7 @@ boxDecoration(ImageDTO imageDTO, appContext) {
image: imageDTO.title != null && imageDTO.source_ != null ? new DecorationImage( image: imageDTO.title != null && imageDTO.source_ != null ? new DecorationImage(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
image: new NetworkImage( image: new NetworkImage(
imageDTO.source_, imageDTO.source_!,
), ),
) : null, ) : null,
boxShadow: [ boxShadow: [

View File

@ -8,7 +8,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext appContext, BuildContext context, bool showTitle, bool showDescription) async { Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO? inputImageDTO, AppContext appContext, BuildContext context, bool showTitle, bool showDescription) async {
ImageDTO imageDTO = new ImageDTO(); ImageDTO imageDTO = new ImageDTO();
if (inputImageDTO != null) { if (inputImageDTO != null) {
@ -18,7 +18,7 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
imageDTO.description = <TranslationDTO>[]; imageDTO.description = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) { managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationTitleDTO = new TranslationDTO(); var translationTitleDTO = new TranslationDTO();
translationTitleDTO.language = element; translationTitleDTO.language = element;
translationTitleDTO.value = ""; translationTitleDTO.value = "";
@ -27,8 +27,8 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
translationDescriptionDTO.language = element; translationDescriptionDTO.language = element;
translationDescriptionDTO.value = ""; translationDescriptionDTO.value = "";
imageDTO.title.add(translationTitleDTO); imageDTO.title!.add(translationTitleDTO);
imageDTO.description.add(translationDescriptionDTO); imageDTO.description!.add(translationDescriptionDTO);
}); });
} }
@ -59,7 +59,7 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
imageDTO.source_ = null; imageDTO.source_ = null;
} else { } else {
imageDTO.resourceId = resource.id; imageDTO.resourceId = resource.id;
imageDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; imageDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
}, },
isSmall: true isSmall: true
@ -131,22 +131,22 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO, bool showTitle, bool showDescription) { getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO, bool showTitle, bool showDescription) {
List<Widget> translations = <Widget>[]; List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) { for(var language in managerAppContext.selectedConfiguration!.languages!) {
if(imageDTO.title.where((element) => element.language == language).length == 0) { if(imageDTO.title!.where((element) => element.language == language).length == 0) {
imageDTO.title = <TranslationDTO>[]; imageDTO.title = <TranslationDTO>[];
var translationTitleDTO = new TranslationDTO(); var translationTitleDTO = new TranslationDTO();
translationTitleDTO.language = language; translationTitleDTO.language = language;
translationTitleDTO.value = ""; translationTitleDTO.value = "";
imageDTO.title.add(translationTitleDTO); imageDTO.title!.add(translationTitleDTO);
} }
if(imageDTO.description.where((element) => element.language == language).length == 0) { if(imageDTO.description!.where((element) => element.language == language).length == 0) {
imageDTO.description = <TranslationDTO>[]; imageDTO.description = <TranslationDTO>[];
var translationDescriptionDTO = new TranslationDTO(); var translationDescriptionDTO = new TranslationDTO();
translationDescriptionDTO.language = language; translationDescriptionDTO.language = language;
translationDescriptionDTO.value = ""; translationDescriptionDTO.value = "";
imageDTO.description.add(translationDescriptionDTO); imageDTO.description!.add(translationDescriptionDTO);
} }
translations.add( translations.add(
@ -178,9 +178,9 @@ getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO,
label: "Titre:", label: "Titre:",
color: kWhite, color: kWhite,
isTitle: true, isTitle: true,
initialValue: imageDTO.title.where((element) => element.language == language).first.value, initialValue: imageDTO.title!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
imageDTO.title.where((element) => element.language == language).first.value = value; imageDTO.title!.where((element) => element.language == language).first.value = value;
}, },
), ),
if(showDescription) if(showDescription)
@ -188,9 +188,9 @@ getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO,
label: "Description:", label: "Description:",
color: kWhite, color: kWhite,
isTitle: false, isTitle: false,
initialValue: imageDTO.description.where((element) => element.language == language).first.value, initialValue: imageDTO.description!.where((element) => element.language == language).first.value!,
onChanged: (value) { onChanged: (value) {
imageDTO.description.where((element) => element.language == language).first.value = value; imageDTO.description!.where((element) => element.language == language).first.value = value;
}, },
), ),
], ],

View File

@ -9,16 +9,16 @@ import 'dart:convert';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class SliderConfig extends StatefulWidget { class SliderConfig extends StatefulWidget {
final String color; final String? color;
final String label; final String? label;
final String initialValue; final String initialValue;
final ValueChanged<String> onChanged; final ValueChanged<String> onChanged;
const SliderConfig({ const SliderConfig({
Key key, Key? key,
this.color, this.color,
this.label, this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -26,16 +26,16 @@ class SliderConfig extends StatefulWidget {
} }
class _SliderConfigState extends State<SliderConfig> { class _SliderConfigState extends State<SliderConfig> {
SliderDTO sliderDTO; late SliderDTO sliderDTO;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
sliderDTO = SliderDTO.fromJson(json.decode(widget.initialValue)); sliderDTO = SliderDTO.fromJson(json.decode(widget.initialValue))!;
List<ImageDTO> test = new List<ImageDTO>.from(sliderDTO.images); List<ImageDTO> test = new List<ImageDTO>.from(sliderDTO.images!);
sliderDTO.images = test; sliderDTO.images = test;
sliderDTO.images.sort((a, b) => a.order.compareTo(b.order)); sliderDTO.images!.sort((a, b) => a.order!.compareTo(b.order!));
} }
@override @override
@ -49,11 +49,11 @@ class _SliderConfigState extends State<SliderConfig> {
if (newIndex > oldIndex) { if (newIndex > oldIndex) {
newIndex -= 1; newIndex -= 1;
} }
final ImageDTO item = sliderDTO.images.removeAt(oldIndex); final ImageDTO item = sliderDTO.images!.removeAt(oldIndex);
sliderDTO.images.insert(newIndex, item); sliderDTO.images!.insert(newIndex, item);
var i = 0; var i = 0;
sliderDTO.images.forEach((image) { sliderDTO.images!.forEach((image) {
image.order = i; image.order = i;
i++; i++;
}); });
@ -72,10 +72,10 @@ class _SliderConfigState extends State<SliderConfig> {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(vertical: 20.0), padding: const EdgeInsets.symmetric(vertical: 20.0),
children: List.generate( children: List.generate(
sliderDTO.images.length, sliderDTO.images!.length,
(index) { (index) {
return ListViewCardImage( return ListViewCardImage(
sliderDTO.images, sliderDTO.images!,
index, index,
Key('$index'), Key('$index'),
appContext, appContext,
@ -106,8 +106,8 @@ class _SliderConfigState extends State<SliderConfig> {
if (result != null) if (result != null)
{ {
setState(() { setState(() {
result.order = sliderDTO.images.length; result.order = sliderDTO.images!.length;
sliderDTO.images.add(result); sliderDTO.images!.add(result);
widget.onChanged(jsonEncode(sliderDTO).toString()); widget.onChanged(jsonEncode(sliderDTO).toString());
}); });
} }

View File

@ -5,16 +5,16 @@ import 'package:manager_api_new/api.dart';
import 'dart:convert'; import 'dart:convert';
class WebOrVideoConfig extends StatefulWidget { class WebOrVideoConfig extends StatefulWidget {
final String color; final String? color;
final String label; final String? label;
final String initialValue; final String initialValue;
final ValueChanged<String> onChanged; // To return video or web url final ValueChanged<String> onChanged; // To return video or web url
const WebOrVideoConfig({ const WebOrVideoConfig({
Key key, Key? key,
this.color, this.color,
this.label, this.label,
this.initialValue, required this.initialValue,
this.onChanged, required this.onChanged,
}) : super(key: key); }) : super(key: key);
@override @override
@ -22,10 +22,11 @@ class WebOrVideoConfig extends StatefulWidget {
} }
class _WebOrVideoConfigState extends State<WebOrVideoConfig> { class _WebOrVideoConfigState extends State<WebOrVideoConfig> {
WebDTO resourceSource; // WebDTO == VideoDTO late WebDTO resourceSource; // WebDTO == VideoDTO
@override @override
void initState() { void initState() {
WebDTO test = WebDTO.fromJson(json.decode(widget.initialValue)); WebDTO test = WebDTO.fromJson(json.decode(widget.initialValue))!;
resourceSource = test; resourceSource = test;
super.initState(); super.initState();
} }
@ -33,7 +34,7 @@ class _WebOrVideoConfigState extends State<WebOrVideoConfig> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return StringInputContainer( return StringInputContainer(
label: widget.label, label: widget.label!,
initialValue: resourceSource.source_ == null ? '': resourceSource.source_, initialValue: resourceSource.source_ == null ? '': resourceSource.source_,
onChanged: (String url) { onChanged: (String url) {
resourceSource.source_ = url; resourceSource.source_ = url;

View File

@ -28,7 +28,7 @@ import 'package:qr_flutter/qr_flutter.dart';
class SectionDetailScreen extends StatefulWidget { class SectionDetailScreen extends StatefulWidget {
final String id; final String id;
SectionDetailScreen({Key key, @required this.id}) : super(key: key); SectionDetailScreen({Key? key, required this.id}) : super(key: key);
@override @override
_SectionDetailScreenState createState() => _SectionDetailScreenState(); _SectionDetailScreenState createState() => _SectionDetailScreenState();
@ -42,7 +42,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
return FutureBuilder( return FutureBuilder(
future: getSection(widget.id, appContext.getContext().clientAPI), future: getSection(widget.id, (appContext.getContext() as ManagerAppContext).clientAPI!),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
return Stack( return Stack(
@ -71,7 +71,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
); );
} }
Widget bodySection(SectionDTO sectionDTO, Size size, AppContext appContext, BuildContext context) { Widget bodySection(SectionDTO? sectionDTO, Size size, AppContext appContext, BuildContext context) {
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
//mainAxisAlignment: MainAxisAlignment.spaceAround, //mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -100,14 +100,14 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
size: 25, size: 25,
), ),
), ),
Text(sectionDTO != null ? sectionDTO.label : "", style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), Text(sectionDTO != null ? 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(sectionDTO != null ? DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation!) : "", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
), ),
], ],
), ),
@ -149,7 +149,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
if((appContext.getContext() as ManagerAppContext).selectedConfiguration.isMobile) if((appContext.getContext() as ManagerAppContext).selectedConfiguration!.isMobile!)
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -162,17 +162,17 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
height: 125, height: 125,
child: QrImage( child: QrImage(
padding: EdgeInsets.only(left: 0.0, top: 5.0, bottom: 5.0), padding: EdgeInsets.only(left: 0.0, top: 5.0, bottom: 5.0),
data: sectionDTO.id, data: sectionDTO!.id!,
version: QrVersions.auto, version: QrVersions.auto,
size: 50.0, size: 50.0,
), ),
), ),
SelectableText(sectionDTO.id, style: new TextStyle(fontSize: 15)) SelectableText(sectionDTO.id!, style: new TextStyle(fontSize: 15))
], ],
), ),
CheckInputContainer( CheckInputContainer(
label: "Beacon :", label: "Beacon :",
isChecked: sectionDTO.isBeacon, isChecked: sectionDTO.isBeacon!,
fontSize: 25, fontSize: 25,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
@ -181,10 +181,10 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
}); });
}, },
), ),
if(sectionDTO.isBeacon) if(sectionDTO.isBeacon!)
NumberInputContainer( NumberInputContainer(
label: "Identifiant Beacon :", label: "Identifiant Beacon :",
initialValue: sectionDTO != null ? sectionDTO.beaconId : "", initialValue: sectionDTO != null ? sectionDTO.beaconId! : 0,
isSmall: true, isSmall: true,
onChanged: (value) { onChanged: (value) {
try { try {
@ -204,17 +204,17 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
StringInputContainer( StringInputContainer(
label: "Identifiant :", label: "Identifiant :",
initialValue: sectionDTO != null ? sectionDTO.label : "", initialValue: sectionDTO != null ? sectionDTO.label : "",
onChanged: (value) { onChanged: (String value) {
sectionDTO.label = value; sectionDTO!.label = value;
}, },
), ),
MultiStringContainer( MultiStringContainer(
label: "Titre affiché:", label: "Titre affiché:",
modalLabel: "Titre", modalLabel: "Titre",
color: kPrimaryColor, color: kPrimaryColor,
initialValue: sectionDTO != null ? sectionDTO.title : [], initialValue: sectionDTO != null ? 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, sectionDTO, appContext);
} }
@ -222,15 +222,15 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
maxLines: 1, maxLines: 1,
isTitle: true, isTitle: true,
), ),
if(!(appContext.getContext() as ManagerAppContext).selectedConfiguration.isMobile) if(!(appContext.getContext() as ManagerAppContext).selectedConfiguration!.isMobile!)
MultiStringContainer( MultiStringContainer(
label: "Description affichée:", label: "Description affichée:",
modalLabel: "Description", modalLabel: "Description",
color: kPrimaryColor, color: kPrimaryColor,
initialValue: sectionDTO != null ? sectionDTO.description : [], initialValue: sectionDTO != null ? sectionDTO.description! : [],
onGetResult: (value) { onGetResult: (value) {
if (sectionDTO.description != value) { if (sectionDTO!.description != value) {
sectionDTO.description = value; sectionDTO.description = value!;
save(true, sectionDTO, appContext); save(true, sectionDTO, appContext);
} }
}, },
@ -245,15 +245,15 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
children: [ children: [
ImageInputContainer( ImageInputContainer(
label: "Image :", label: "Image :",
initialValue: sectionDTO != null ? sectionDTO.imageId : "", initialValue: sectionDTO != null ? sectionDTO.imageId : null,
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.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; sectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
}, },
), ),
@ -337,7 +337,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
Future<void> cancel(SectionDTO sectionDTO, AppContext appContext) async { Future<void> cancel(SectionDTO sectionDTO, AppContext appContext) async {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
SectionDTO section = await appContext.getContext().clientAPI.sectionApi.sectionGetDetail(sectionDTO.id); SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionGetDetail(sectionDTO.id!);
managerAppContext.selectedSection = section; managerAppContext.selectedSection = section;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
} }
@ -348,7 +348,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
() {}, () {},
() async { () async {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
await appContext.getContext().clientAPI.sectionApi.sectionDelete(sectionDTO.id); await managerAppContext.clientAPI!.sectionApi!.sectionDelete(sectionDTO.id!);
managerAppContext.selectedSection = null; managerAppContext.selectedSection = null;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
}, },
@ -358,7 +358,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
Future<void> save(bool isTraduction, SectionDTO sectionDTO, AppContext appContext) async { Future<void> save(bool isTraduction, SectionDTO sectionDTO, AppContext appContext) async {
if (sectionDTO != null) { if (sectionDTO != null) {
SectionDTO section = await appContext.getContext().clientAPI.sectionApi.sectionUpdate(sectionDTO); SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDTO);
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedSection = section; managerAppContext.selectedSection = section;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
@ -375,7 +375,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
switch(sectionDTO.type) { switch(sectionDTO.type) {
case SectionType.Map: case SectionType.Map:
return MapConfig( return MapConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
sectionDTO.data = data; sectionDTO.data = data;
//save(false, sectionDTO, appContext); //save(false, sectionDTO, appContext);
@ -383,7 +383,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
); );
case SectionType.Slider: case SectionType.Slider:
return SliderConfig( return SliderConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
sectionDTO.data = data; sectionDTO.data = data;
save(false, sectionDTO, appContext); save(false, sectionDTO, appContext);
@ -393,14 +393,14 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
case SectionType.Web: case SectionType.Web:
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: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
sectionDTO.data = data; sectionDTO.data = data;
}, },
); );
case SectionType.Menu: case SectionType.Menu:
return MenuConfig( return MenuConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent"); //print("Received info in parent");
//print(data); //print(data);
@ -409,7 +409,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
); );
case SectionType.Quizz: case SectionType.Quizz:
return QuizzConfig( return QuizzConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent - quizz"); //print("Received info in parent - quizz");
//print(data); //print(data);
@ -418,7 +418,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
); );
case SectionType.Article: case SectionType.Article:
return ArticleConfig( return ArticleConfig(
initialValue: sectionDTO.data, initialValue: sectionDTO.data!,
onChanged: (String data) { onChanged: (String data) {
//print("Received info in parent - article"); //print("Received info in parent - article");
//print(data); //print(data);
@ -430,8 +430,8 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
} }
} }
Future<SectionDTO> getSection(String sectionId, Client client) async { Future<SectionDTO?> getSection(String sectionId, Client client) async {
SectionDTO section = await client.sectionApi.sectionGetDetail(sectionId); SectionDTO? section = await client.sectionApi!.sectionGetDetail(sectionId);
//print(section); //print(section);
return section; return section;
} }

View File

@ -28,23 +28,23 @@ import 'dart:html' as html;
class ConfigurationDetailScreen extends StatefulWidget { class ConfigurationDetailScreen extends StatefulWidget {
final String id; final String id;
ConfigurationDetailScreen({Key key, @required this.id}) : super(key: key); ConfigurationDetailScreen({Key? key, required this.id}) : super(key: key);
@override @override
_ConfigurationDetailScreenState createState() => _ConfigurationDetailScreenState(); _ConfigurationDetailScreenState createState() => _ConfigurationDetailScreenState();
} }
class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> { class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
ConfigurationDTO configurationDTO; ConfigurationDTO? configurationDTO;
SectionDTO selectedSection; SectionDTO? selectedSection;
List<SectionDTO> sections; List<SectionDTO>? sections;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
return FutureBuilder( return FutureBuilder(
future: getConfiguration(this.widget, appContext.getContext().clientAPI), future: getConfiguration(this.widget, (appContext.getContext() as ManagerAppContext).clientAPI!),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
return bodyConfiguration(snapshot.data, size, appContext, context); return bodyConfiguration(snapshot.data, size, appContext, context);
@ -82,17 +82,17 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
children: [ children: [
Row( Row(
children: [ children: [
Text(configurationDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), Text(configurationDTO.label!, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)),
InkWell( InkWell(
onTap: () async { onTap: () async {
try { try {
// Export config // Export config
Client clientAPI = appContext.getContext().clientAPI; Client clientAPI = (appContext.getContext() as ManagerAppContext).clientAPI!;
ExportConfigurationDTO export = await clientAPI.configurationApi.configurationExport(configurationDTO.id); ExportConfigurationDTO export = await clientAPI.configurationApi!.configurationExport(configurationDTO.id!);
if (kIsWeb) { if (kIsWeb) {
html.AnchorElement anchorElement = new html.AnchorElement(); html.AnchorElement anchorElement = new html.AnchorElement();
var uri = (Uri.parse(appContext.getContext().clientAPI.resourceApi.apiClient.basePath+'/api/Configuration/${configurationDTO.id}/export')); var uri = (Uri.parse((appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+'/api/Configuration/${configurationDTO.id}/export'));
anchorElement.href = uri.toString(); anchorElement.href = uri.toString();
anchorElement.download = '${configurationDTO.label}.json'; anchorElement.download = '${configurationDTO.label}.json';
anchorElement.click(); anchorElement.click();
@ -101,7 +101,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
showNotification(Colors.green, kWhite, "L'export de la visite a réussi, le document se trouve là : " + test.path, context, 3000); showNotification(Colors.green, kWhite, "L'export de la visite a réussi, le document se trouve là : " + test.path, context, 3000);
} }
} catch(e) { } catch(e) {
log(e); log(e.toString());
showNotification(kPrimaryColor, kWhite, "L'export de la visite a échoué", context, null); showNotification(kPrimaryColor, kWhite, "L'export de la visite a échoué", context, null);
} }
}, },
@ -114,7 +114,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
), ),
Padding( Padding(
padding: const EdgeInsets.all(5.0), padding: const EdgeInsets.all(5.0),
child: Text(DateFormat('dd/MM/yyyy').format(configurationDTO.dateCreation), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)), child: Text(DateFormat('dd/MM/yyyy').format(configurationDTO.dateCreation!), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
), ),
], ],
), ),
@ -173,7 +173,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
), ),
MultiSelectDropdownContainer( MultiSelectDropdownContainer(
label: "Langues :", label: "Langues :",
initialValue: configurationDTO.languages != null ? configurationDTO.languages: [], initialValue: configurationDTO.languages != null ? configurationDTO.languages!: [],
values: languages, values: languages,
isMultiple: true, isMultiple: true,
fontSize: 20, fontSize: 20,
@ -236,7 +236,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
configurationDTO.isMobile = value; configurationDTO.isMobile = value;
}, },
), ),
if(configurationDTO.isMobile) if(configurationDTO.isMobile!)
RoundedButton( RoundedButton(
text: "Télécharger les QRCodes", text: "Télécharger les QRCodes",
icon: Icons.qr_code, icon: Icons.qr_code,
@ -244,7 +244,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
textColor: Colors.white, textColor: Colors.white,
fontSize: 15, fontSize: 15,
press: () { press: () {
PDFHelper.downloadPDF(sections); PDFHelper.downloadPDF(sections!);
}, },
) )
], ],
@ -253,7 +253,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if(!configurationDTO.isMobile) if(!configurationDTO.isMobile!)
ColorPickerInputContainer( ColorPickerInputContainer(
label: "Couleur fond d'écran :", label: "Couleur fond d'écran :",
fontSize: 20, fontSize: 20,
@ -262,7 +262,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
configurationDTO.secondaryColor = value; configurationDTO.secondaryColor = value;
}, },
), ),
if(configurationDTO.isMobile) if(configurationDTO.isMobile!)
Padding( Padding(
padding: const EdgeInsets.only(bottom: 15), padding: const EdgeInsets.only(bottom: 15),
child: MultiStringContainer( child: MultiStringContainer(
@ -270,7 +270,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
modalLabel: "Titre", modalLabel: "Titre",
fontSize: 20, fontSize: 20,
color: kPrimaryColor, color: kPrimaryColor,
initialValue: configurationDTO != null ? configurationDTO.title : [], initialValue: configurationDTO != null ? configurationDTO.title! : [],
onGetResult: (value) { onGetResult: (value) {
if (configurationDTO.title != value) { if (configurationDTO.title != value) {
configurationDTO.title = value; configurationDTO.title = value;
@ -283,7 +283,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
ImageInputContainer( ImageInputContainer(
label: "Image :", label: "Image :",
fontSize: 20, fontSize: 20,
initialValue: configurationDTO != null ? configurationDTO.imageId : "", initialValue: configurationDTO.imageId,
color: kPrimaryColor, color: kPrimaryColor,
onChanged: (ResourceDTO resource) { onChanged: (ResourceDTO resource) {
if(resource.id == null) { if(resource.id == null) {
@ -291,7 +291,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
configurationDTO.imageSource = null; configurationDTO.imageSource = null;
} else { } else {
configurationDTO.imageId = resource.id; configurationDTO.imageId = resource.id;
configurationDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; configurationDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resource.id!;
} }
}, },
), ),
@ -308,15 +308,15 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
border: Border.all(width: 0.5, color: kSecond) border: Border.all(width: 0.5, color: kSecond)
), ),
child: FutureBuilder( child: FutureBuilder(
future: getSections(configurationDTO, appContext.getContext().clientAPI), future: getSections(configurationDTO, (appContext.getContext() as ManagerAppContext).clientAPI!),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) if (snapshot.connectionState == ConnectionState.done)
{ {
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.Quizz)).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();
} }
return bodyGrid(configurationDTO, size, appContext); return bodyGrid(configurationDTO, size, appContext);
} }
@ -408,14 +408,14 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: SectionReorderList( child: SectionReorderList(
sectionsIn: sections, sectionsIn: sections!,
configurationId: configurationDTO.id, configurationId: configurationDTO.id!,
onChangedOrder: (List<SectionDTO> sectionsOut) async { onChangedOrder: (List<SectionDTO> sectionsOut) async {
sections = sectionsOut; sections = sectionsOut;
// Update section order // Update section order
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
await managerAppContext.clientAPI.sectionApi.sectionUpdateOrder(sections); await managerAppContext.clientAPI!.sectionApi!.sectionUpdateOrder(sections!);
}, },
), ),
), ),
@ -425,7 +425,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
Future<void> cancel(ConfigurationDTO configurationDTO, AppContext appContext) async { Future<void> cancel(ConfigurationDTO configurationDTO, AppContext appContext) async {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
ConfigurationDTO configuration = await appContext.getContext().clientAPI.configurationApi.configurationGetDetail(configurationDTO.id); ConfigurationDTO? configuration = await managerAppContext.clientAPI!.configurationApi!.configurationGetDetail(configurationDTO.id!);
managerAppContext.selectedConfiguration = configuration; managerAppContext.selectedConfiguration = configuration;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
} }
@ -436,7 +436,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
() {}, () {},
() async { () async {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
await appContext.getContext().clientAPI.configurationApi.configurationDelete(configurationDTO.id); await managerAppContext.clientAPI!.configurationApi!.configurationDelete(configurationDTO.id!);
managerAppContext.selectedConfiguration = null; managerAppContext.selectedConfiguration = null;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
}, },
@ -445,22 +445,24 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
} }
Future<void> save(ConfigurationDTO configurationDTO, AppContext appContext) async { Future<void> save(ConfigurationDTO configurationDTO, AppContext appContext) async {
ConfigurationDTO configuration = await appContext.getContext().clientAPI.configurationApi.configurationUpdate(configurationDTO);
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
ConfigurationDTO? configuration = await managerAppContext.clientAPI!.configurationApi!.configurationUpdate(configurationDTO);
managerAppContext.selectedConfiguration = configuration; managerAppContext.selectedConfiguration = configuration;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
showNotification(Colors.green, kWhite, 'La visite a été sauvegardée avec succès', context, null); showNotification(Colors.green, kWhite, 'La visite a été sauvegardée avec succès', context, null);
} }
Future<ConfigurationDTO> getConfiguration(ConfigurationDetailScreen widget, Client client) async { Future<ConfigurationDTO?> getConfiguration(ConfigurationDetailScreen widget, Client client) async {
ConfigurationDTO configuration = await client.configurationApi.configurationGetDetail(widget.id); ConfigurationDTO? configuration = await client.configurationApi!.configurationGetDetail(widget.id);
return configuration; return configuration;
} }
Future<List<SectionDTO>> getSections(ConfigurationDTO configurationDTO, Client client) async { Future<List<SectionDTO>?> getSections(ConfigurationDTO configurationDTO, Client client) async {
List<SectionDTO> sections = await client.sectionApi.sectionGetFromConfiguration(configurationDTO.id); List<SectionDTO>? sections = await client.sectionApi!.sectionGetFromConfiguration(configurationDTO.id!);
sections.sort((a, b) => a.order.compareTo(b.order)); if(sections != null) {
sections.sort((a, b) => a.order!.compareTo(b.order!));
}
return sections; return sections;
} }
} }

View File

@ -13,14 +13,14 @@ import 'package:intl/intl.dart';
import 'Section/section_detail_screen.dart'; import 'Section/section_detail_screen.dart';
class ConfigurationsScreen extends StatefulWidget { class ConfigurationsScreen extends StatefulWidget {
ConfigurationsScreen({Key key}) : super(key: key); ConfigurationsScreen({Key? key}) : super(key: key);
@override @override
_ConfigurationsScreenState createState() => _ConfigurationsScreenState(); _ConfigurationsScreenState createState() => _ConfigurationsScreenState();
} }
class _ConfigurationsScreenState extends State<ConfigurationsScreen> { class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
ConfigurationDTO selectedConfiguration; ConfigurationDTO? selectedConfiguration;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -30,10 +30,10 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
if (managerAppContext.selectedSection != null) { if (managerAppContext.selectedSection != null) {
return SectionDetailScreen(id: managerAppContext.selectedSection.id); return SectionDetailScreen(id: managerAppContext.selectedSection!.id!);
} }
if (managerAppContext.selectedConfiguration != null) { if (managerAppContext.selectedConfiguration != null) {
return ConfigurationDetailScreen(id: managerAppContext.selectedConfiguration.id); return ConfigurationDetailScreen(id: managerAppContext.selectedConfiguration!.id!);
} else { } else {
return Align( return Align(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
@ -108,7 +108,7 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: AutoSizeText( child: AutoSizeText(
configuration.label, configuration.label!,
style: new TextStyle(fontSize: 25), style: new TextStyle(fontSize: 25),
maxLines: 1, maxLines: 1,
), ),
@ -116,7 +116,7 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
Align( Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
child: AutoSizeText( child: AutoSizeText(
DateFormat('dd/MM/yyyy').format(configuration.dateCreation), DateFormat('dd/MM/yyyy').format(configuration.dateCreation!),
style: new TextStyle(fontSize: 18, fontFamily: ""), style: new TextStyle(fontSize: 18, fontFamily: ""),
maxLines: 1, maxLines: 1,
), ),
@ -133,12 +133,15 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
} }
} }
Future<List<ConfigurationDTO>> getConfigurations(ManagerAppContext managerAppContext) async { Future<List<ConfigurationDTO>?> getConfigurations(ManagerAppContext managerAppContext) async {
List<ConfigurationDTO> configurations = await managerAppContext.clientAPI.configurationApi.configurationGet(instanceId: managerAppContext.instanceId); List<ConfigurationDTO>? configurations = await managerAppContext.clientAPI!.configurationApi!.configurationGet(instanceId: managerAppContext.instanceId);
//print("number of configurations " + configurations.length.toString()); //print("number of configurations " + configurations.length.toString());
configurations.forEach((element) { if(configurations != null) {
//print(element); configurations.forEach((element) {
}); //print(element);
});
}
return configurations; return configurations;
} }
@ -151,7 +154,7 @@ boxDecoration(ConfigurationDTO configurationDTO) {
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.18), BlendMode.dstATop), colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.18), BlendMode.dstATop),
image: new NetworkImage( image: new NetworkImage(
configurationDTO.imageSource, configurationDTO.imageSource!,
), ),
) : null, ) : null,
boxShadow: [ boxShadow: [

View File

@ -69,7 +69,7 @@ class _ListViewCardSectionsState extends State<ListViewCardSections> {
), ),
), ),
child: Text( child: Text(
"${sectionDTO.order+1}", "${sectionDTO.order!+1}",
style: const TextStyle(color: Colors.white) style: const TextStyle(color: Colors.white)
), ),
), ),
@ -94,7 +94,7 @@ class _ListViewCardSectionsState extends State<ListViewCardSections> {
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: AutoSizeText( child: AutoSizeText(
element.label, element.label!,
style: new TextStyle(fontSize: 15), style: new TextStyle(fontSize: 15),
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -123,7 +123,7 @@ boxDecoration(SectionDTO sectionDTO, appContext) {
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.18), BlendMode.dstATop), colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.18), BlendMode.dstATop),
image: new NetworkImage( image: new NetworkImage(
sectionDTO.imageSource, sectionDTO.imageSource!,
), ),
) : null, ) : null,
boxShadow: [ boxShadow: [

View File

@ -13,6 +13,7 @@ import 'package:manager_api_new/api.dart';
void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, BuildContext context, BuildContext mainContext) { void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, BuildContext context, BuildContext mainContext) {
ConfigurationDTO configurationDTO = new ConfigurationDTO(); ConfigurationDTO configurationDTO = new ConfigurationDTO();
Size size = MediaQuery.of(mainContext).size; Size size = MediaQuery.of(mainContext).size;
configurationDTO.label = "";
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
@ -46,12 +47,12 @@ void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, Bu
), ),
InkWell( InkWell(
onTap: () async { onTap: () async {
FilePickerResult result = await FilePicker.platform.pickFiles(); FilePickerResult? result = await FilePicker.platform.pickFiles();
//String result = filePicker(); //String result = filePicker();
if (result != null) { if (result != null) {
await FileHelper().importConfiguration(result, null, appContext.getContext().clientAPI, mainContext); await FileHelper().importConfiguration(result, null, (appContext.getContext() as ManagerAppContext).clientAPI!, mainContext);
isImport(true); isImport(true);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
@ -102,7 +103,11 @@ void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, Bu
color: kPrimaryColor, color: kPrimaryColor,
textColor: kWhite, textColor: kWhite,
press: () { press: () {
create(configurationDTO, appContext, context); if(configurationDTO.label != null && configurationDTO.label!.length > 2) {
create(configurationDTO, appContext, context);
} else {
showNotification(Colors.orange, kWhite, 'Veuillez spécifier un nom pour la nouvelle visite', context, null);
}
}, },
fontSize: 20, fontSize: 20,
), ),
@ -134,7 +139,7 @@ String filePicker() {
void create(ConfigurationDTO configurationDTO, AppContext appContext, context) async { void create(ConfigurationDTO configurationDTO, AppContext appContext, context) async {
if (configurationDTO.label != null) { if (configurationDTO.label != null) {
configurationDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId; configurationDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId;
await appContext.getContext().clientAPI.configurationApi.configurationCreate(configurationDTO); await (appContext.getContext() as ManagerAppContext).clientAPI!.configurationApi!.configurationCreate(configurationDTO);
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration = null; managerAppContext.selectedConfiguration = null;
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);

View File

@ -8,11 +8,12 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
void showNewSection(String configurationId, AppContext appContext, BuildContext contextBuild, bool isSubSection, Function sendSubSection, bool isMobile) { void showNewSection(String configurationId, AppContext appContext, BuildContext contextBuild, bool isSubSection, Function? sendSubSection, bool isMobile) {
SectionDTO sectionDTO = new SectionDTO(); SectionDTO sectionDTO = new SectionDTO();
sectionDTO.label = "";
sectionDTO.configurationId = configurationId; sectionDTO.configurationId = configurationId;
sectionDTO.isSubSection = isSubSection; sectionDTO.isSubSection = isSubSection;
sectionDTO.parentId = isSubSection ? appContext.getContext().selectedSection.id : null; sectionDTO.parentId = isSubSection ? (appContext.getContext() as ManagerAppContext).selectedSection!.id : null;
Size size = MediaQuery.of(contextBuild).size; Size size = MediaQuery.of(contextBuild).size;
sectionDTO.type = isMobile ? SectionType.Article : SectionType.Map; sectionDTO.type = isMobile ? SectionType.Article : SectionType.Map;
@ -84,8 +85,12 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
color: kPrimaryColor, color: kPrimaryColor,
textColor: kWhite, textColor: kWhite,
press: () { press: () {
//onYes(); if(sectionDTO.label != null && sectionDTO.label!.length > 2) {
create(sectionDTO, appContext, context, isSubSection, sendSubSection); //onYes();
create(sectionDTO, appContext, context, isSubSection, sendSubSection);
} else {
showNotification(Colors.orange, kWhite, 'Veuillez spécifier un nom pour la nouvelle section', context, null);
}
}, },
fontSize: 20, fontSize: 20,
), ),
@ -98,13 +103,13 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
); );
} }
void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context, bool isSubSection, Function sendSubSection) async { void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context, bool isSubSection, Function? sendSubSection) async {
if (sectionDTO.label != null) { if (sectionDTO.label != null) {
sectionDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId; ManagerAppContext managerAppContext = appContext.getContext();
SectionDTO newSection = await appContext.getContext().clientAPI.sectionApi.sectionCreate(sectionDTO); sectionDTO.instanceId = managerAppContext.instanceId;
SectionDTO? newSection = await managerAppContext.clientAPI!.sectionApi!.sectionCreate(sectionDTO);
if (!isSubSection) { if (!isSubSection) {
ManagerAppContext managerAppContext = appContext.getContext();
/*if (managerAppContext.selectedConfiguration.sectionIds == null) { /*if (managerAppContext.selectedConfiguration.sectionIds == null) {
managerAppContext.selectedConfiguration.sectionIds = <String>[]; managerAppContext.selectedConfiguration.sectionIds = <String>[];
} }
@ -112,7 +117,7 @@ void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context,
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
showNotification(Colors.green, kWhite, 'La section a été créée avec succès !', context, null); showNotification(Colors.green, kWhite, 'La section a été créée avec succès !', context, null);
} else { } else {
sendSubSection(newSection); sendSubSection!(newSection);
} }
Navigator.of(context).pop(); Navigator.of(context).pop();
} }

View File

@ -14,10 +14,10 @@ class SectionReorderList extends StatefulWidget {
final List<SectionDTO> sectionsIn; final List<SectionDTO> sectionsIn;
final ValueChanged<List<SectionDTO>> onChangedOrder; final ValueChanged<List<SectionDTO>> onChangedOrder;
const SectionReorderList({ const SectionReorderList({
Key key, Key? key,
this.configurationId, required this.configurationId,
this.sectionsIn, required this.sectionsIn,
this.onChangedOrder, required this.onChangedOrder,
}) : super(key: key); }) : super(key: key);
@override @override
@ -25,7 +25,7 @@ class SectionReorderList extends StatefulWidget {
} }
class _SectionReorderListState extends State<SectionReorderList> { class _SectionReorderListState extends State<SectionReorderList> {
List<SectionDTO> sections; late List<SectionDTO> sections;
String filterSearch = ''; String filterSearch = '';
@override @override
@ -60,7 +60,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
ConfigurationDTO currentConfiguration = managerAppContext.selectedConfiguration; ConfigurationDTO currentConfiguration = managerAppContext.selectedConfiguration!;
return Stack( return Stack(
children: [ children: [
@ -79,7 +79,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
sections, sections,
index, index,
Key('$index'), Key('$index'),
currentConfiguration.isMobile, currentConfiguration.isMobile!,
appContext, appContext,
(section) { (section) {
setState(() { setState(() {
@ -143,7 +143,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
right: 10, right: 10,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile); showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile!);
}, },
child: Container( child: Container(
height: MediaQuery.of(context).size.width * 0.04, height: MediaQuery.of(context).size.width * 0.04,
@ -174,6 +174,6 @@ class _SectionReorderListState extends State<SectionReorderList> {
} }
void filterResource() { void filterResource() {
sections = filterSearch.isEmpty ? widget.sectionsIn: widget.sectionsIn.where((SectionDTO section) => removeDiacritics(section.label.toUpperCase()).contains(removeDiacritics(filterSearch.toUpperCase()))).toList(); sections = filterSearch.isEmpty ? widget.sectionsIn: widget.sectionsIn.where((SectionDTO section) => removeDiacritics(section.label!.toUpperCase()).contains(removeDiacritics(filterSearch.toUpperCase()))).toList();
} }
} }

View File

@ -55,7 +55,7 @@ showChangeInfo (String text, DeviceDTO inputDevice, Function onGetResult, int ma
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: DropDownConfig( child: DropDownConfig(
configurations: snapshot.data, configurations: snapshot.data,
selectedConfigurationId: inputDevice.configurationId, selectedConfigurationId: inputDevice.configurationId!,
onChange: (ConfigurationDTO configurationOut) { onChange: (ConfigurationDTO configurationOut) {
inputDevice.configuration = configurationOut.label; inputDevice.configuration = configurationOut.label;
inputDevice.configurationId = configurationOut.id; inputDevice.configurationId = configurationOut.id;
@ -136,7 +136,7 @@ getConfigurationsElement(DeviceDTO inputDevice, data, Function onGetResult) {
color: inputDevice.configurationId == configuration.id ? kPrimaryColor : null, color: inputDevice.configurationId == configuration.id ? kPrimaryColor : null,
child: ListTile( child: ListTile(
leading: Icon(Icons.account_tree_rounded), leading: Icon(Icons.account_tree_rounded),
title: Text(configuration.label), title: Text(configuration.label!),
), ),
), ),
); );
@ -145,12 +145,16 @@ getConfigurationsElement(DeviceDTO inputDevice, data, Function onGetResult) {
return widgets; return widgets;
} }
Future<List<ConfigurationDTO>> getConfigurations(AppContext appContext) async { Future<List<ConfigurationDTO>?> getConfigurations(AppContext appContext) async {
List<ConfigurationDTO> configurations = await (appContext.getContext() as ManagerAppContext).clientAPI.configurationApi.configurationGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId); List<ConfigurationDTO>? configurations = await (appContext.getContext() as ManagerAppContext).clientAPI!.configurationApi!.configurationGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId);
//print("number of configurations " + configurations.length.toString()); //print("number of configurations " + configurations.length.toString());
configurations.forEach((element) {
//print(element); if(configurations != null) {
}); configurations.forEach((element) {
//print(element);
});
}
return configurations; return configurations;
} }

View File

@ -10,8 +10,8 @@ import 'package:provider/provider.dart';
class DeviceElement extends StatefulWidget { class DeviceElement extends StatefulWidget {
final DeviceDTO deviceDTO; final DeviceDTO deviceDTO;
const DeviceElement({ const DeviceElement({
Key key, Key? key,
this.deviceDTO, required this.deviceDTO,
}) : super(key: key); }) : super(key: key);
@override @override
@ -19,7 +19,7 @@ class DeviceElement extends StatefulWidget {
} }
class _DeviceElementState extends State<DeviceElement> { class _DeviceElementState extends State<DeviceElement> {
DeviceDTO deviceDTO; late DeviceDTO deviceDTO;
@override @override
void initState() { void initState() {
@ -40,7 +40,7 @@ class _DeviceElementState extends State<DeviceElement> {
width: 15, width: 15,
height: 15, height: 15,
decoration: BoxDecoration( decoration: BoxDecoration(
color: deviceDTO.connected ? Colors.green : Colors.red, color: deviceDTO.connected! ? Colors.green : Colors.red,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(25.0), borderRadius: BorderRadius.circular(25.0),
boxShadow: [ boxShadow: [
@ -60,7 +60,7 @@ class _DeviceElementState extends State<DeviceElement> {
child: Row( child: Row(
children: [ children: [
AutoSizeText( AutoSizeText(
deviceDTO.name, deviceDTO.name!,
style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w300), style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w300),
maxLines: 1, maxLines: 1,
), ),
@ -78,7 +78,7 @@ class _DeviceElementState extends State<DeviceElement> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
AutoSizeText( AutoSizeText(
deviceDTO.configuration != null ? deviceDTO.configuration : "Aucune configuration", deviceDTO.configuration != null ? deviceDTO.configuration! : "Aucune configuration",
style: new TextStyle(fontSize: 20), style: new TextStyle(fontSize: 20),
maxLines: 1, maxLines: 1,
), ),
@ -118,10 +118,10 @@ class _DeviceElementState extends State<DeviceElement> {
); );
} }
Future<DeviceDTO> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async { Future<DeviceDTO?> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
//print(deviceToUpdate); //print(deviceToUpdate);
DeviceDTO device = await managerAppContext.clientAPI.deviceApi.deviceUpdateMainInfos(deviceToUpdate); DeviceDTO? device = await managerAppContext.clientAPI!.deviceApi!.deviceUpdateMainInfos(deviceToUpdate);
//print(device); //print(device);
return device; return device;
} }

View File

@ -8,7 +8,7 @@ import 'package:manager_api_new/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class DevicesScreen extends StatefulWidget { class DevicesScreen extends StatefulWidget {
DevicesScreen({Key key}) : super(key: key); DevicesScreen({Key? key}) : super(key: key);
@override @override
_DevicesScreenState createState() => _DevicesScreenState(); _DevicesScreenState createState() => _DevicesScreenState();
@ -203,7 +203,7 @@ class _DevicesScreenState extends State<DevicesScreen> {
Future<void> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async { Future<void> updateMainInfos(DeviceDTO deviceToUpdate, dynamic appContext) async {
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
await managerAppContext.clientAPI.deviceApi.deviceUpdateMainInfos(deviceToUpdate); await managerAppContext.clientAPI!.deviceApi!.deviceUpdateMainInfos(deviceToUpdate);
} }
boxDecoration() { boxDecoration() {
@ -222,11 +222,15 @@ boxDecoration() {
); );
} }
Future<List<DeviceDTO>> getDevices(AppContext appContext) async { Future<List<DeviceDTO>?> getDevices(AppContext appContext) async {
List<DeviceDTO> devices = await (appContext.getContext() as ManagerAppContext).clientAPI.deviceApi.deviceGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId); List<DeviceDTO>? devices = await (appContext.getContext() as ManagerAppContext).clientAPI!.deviceApi!.deviceGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId);
//print("number of devices " + devices.length.toString()); //print("number of devices " + devices.length.toString());
devices.forEach((element) {
//print(element); if(devices != null) {
}); devices.forEach((element) {
//print(element);
});
}
return devices; return devices;
} }

View File

@ -7,10 +7,10 @@ class DropDownConfig extends StatefulWidget {
final String selectedConfigurationId; final String selectedConfigurationId;
final ValueChanged<ConfigurationDTO> onChange; final ValueChanged<ConfigurationDTO> onChange;
const DropDownConfig({ const DropDownConfig({
Key key, Key? key,
this.configurations, required this.configurations,
this.selectedConfigurationId, required this.selectedConfigurationId,
this.onChange, required this.onChange,
}) : super(key: key); }) : super(key: key);
@override @override
@ -18,7 +18,7 @@ class DropDownConfig extends StatefulWidget {
} }
class _DropDownConfigState extends State<DropDownConfig> { class _DropDownConfigState extends State<DropDownConfig> {
ConfigurationDTO configurationDTO; late ConfigurationDTO configurationDTO;
@override @override
void initState() { void initState() {
@ -41,16 +41,18 @@ class _DropDownConfigState extends State<DropDownConfig> {
height: 2, height: 2,
color: kPrimaryColor, color: kPrimaryColor,
), ),
onChanged: (ConfigurationDTO newValue) { onChanged: (ConfigurationDTO? newValue) {
setState(() { if(newValue != null) {
configurationDTO = newValue; setState(() {
widget.onChange(configurationDTO); configurationDTO = newValue;
}); widget.onChange(configurationDTO);
});
}
}, },
items: widget.configurations.map<DropdownMenuItem<ConfigurationDTO>>((ConfigurationDTO value) { items: widget.configurations.map<DropdownMenuItem<ConfigurationDTO>>((ConfigurationDTO value) {
return DropdownMenuItem<ConfigurationDTO>( return DropdownMenuItem<ConfigurationDTO>(
value: value, value: value,
child: Text(value.label, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400)), child: Text(value.label!, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400)),
); );
}).toList(), }).toList(),
); );

View File

@ -4,8 +4,8 @@ import 'package:manager_app/constants.dart';
class Background extends StatelessWidget { class Background extends StatelessWidget {
final Widget child; final Widget child;
const Background({ const Background({
Key key, Key? key,
@required this.child, required this.child,
}) : super(key: key); }) : super(key: key);
@override @override

View File

@ -18,7 +18,7 @@ import 'package:provider/provider.dart';
class Body extends StatefulWidget { class Body extends StatefulWidget {
Body({Key key}) : super(key: key); Body({Key? key}) : super(key: key);
@override @override
_BodyState createState() => _BodyState(); _BodyState createState() => _BodyState();
@ -42,8 +42,8 @@ class _BodyState extends State<Body> {
menu.sections = <MenuSection>[]; menu.sections = <MenuSection>[];
//menu.sections.add(devices); //menu.sections.add(devices);
menu.sections.add(configurations); menu.sections!.add(configurations);
menu.sections.add(resources); menu.sections!.add(resources);
selectedElement = initElementToShow(currentPosition, menu); selectedElement = initElementToShow(currentPosition, menu);
@ -85,7 +85,7 @@ class _BodyState extends State<Body> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
for (var section in menu.sections) for (var section in menu.sections!)
InkWell( InkWell(
onTap: () => { onTap: () => {
setState(() { setState(() {
@ -125,7 +125,7 @@ class _BodyState extends State<Body> {
child: Column( child: Column(
children: [ children: [
AutoSizeText( AutoSizeText(
appContext.getContext().email, (appContext.getContext() as ManagerAppContext).email!,
style: new TextStyle(color: kBodyTextColor, fontSize: 20, fontWeight: FontWeight.w300, fontFamily: "Helvetica"), style: new TextStyle(color: kBodyTextColor, fontSize: 20, fontWeight: FontWeight.w300, fontFamily: "Helvetica"),
maxLines: 1, maxLines: 1,
), ),
@ -177,7 +177,7 @@ class _BodyState extends State<Body> {
} }
initElementToShow(int currentPosition, Menu menu) { initElementToShow(int currentPosition, Menu menu) {
MenuSection elementToShow = menu.sections.where((s) => s.order == currentPosition).first; MenuSection elementToShow = menu.sections!.where((s) => s.order == currentPosition).first;
switch (elementToShow.type) { switch (elementToShow.type) {
case 'devices' : case 'devices' :

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:manager_app/Screens/Main/components/body.dart'; import 'package:manager_app/Screens/Main/components/body.dart';
class MainScreen extends StatefulWidget { class MainScreen extends StatefulWidget {
MainScreen({Key key}) : super(key: key); MainScreen({Key? key}) : super(key: key);
@override @override
_MainScreenState createState() => _MainScreenState(); _MainScreenState createState() => _MainScreenState();

View File

@ -11,7 +11,7 @@ import 'package:manager_app/app_context.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class PolicyScreen extends StatefulWidget { class PolicyScreen extends StatefulWidget {
PolicyScreen({Key key}) : super(key: key); PolicyScreen({Key? key}) : super(key: key);
@override @override
_PolicyScreenState createState() => _PolicyScreenState(); _PolicyScreenState createState() => _PolicyScreenState();

View File

@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class WebView extends StatefulWidget { class WebView extends StatefulWidget {
WebView({this.htmlText}); WebView({required this.htmlText});
final String htmlText; final String htmlText;
@ -27,7 +27,7 @@ class _WebViewWidget extends State<WebView> {
_iframeElement.innerHtml = widget.htmlText; _iframeElement.innerHtml = widget.htmlText;
document.body.innerHtml = widget.htmlText; document.body!.innerHtml = widget.htmlText;
//document.title = "Privacy Policy"; //document.title = "Privacy Policy";
//document.body. = widget.htmlText; //document.body. = widget.htmlText;

View File

@ -14,10 +14,10 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
switch(resourceDTO.type) { switch(resourceDTO.type) {
case ResourceType.Image: case ResourceType.Image:
return Image.network( return Image.network(
appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id, (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resourceDTO.id,
fit:BoxFit.fill, fit:BoxFit.fill,
loadingBuilder: (BuildContext context, Widget child, loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) { ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) { if (loadingProgress == null) {
return child; return child;
} }
@ -26,7 +26,7 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
color: kPrimaryColor, color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / ? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes loadingProgress.expectedTotalBytes!
: null, : null,
), ),
); );
@ -38,7 +38,7 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
resourceDTO.data, resourceDTO.data,
fit:BoxFit.fill, fit:BoxFit.fill,
loadingBuilder: (BuildContext context, Widget child, loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) { ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) { if (loadingProgress == null) {
return child; return child;
} }
@ -47,7 +47,7 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
color: kPrimaryColor, color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / ? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes loadingProgress.expectedTotalBytes!
: null, : null,
), ),
); );
@ -92,10 +92,10 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
} }
} }
Future<Uint8List> getAudio(String resourceId, AppContext appContext) async { Future<Uint8List?> getAudio(String resourceId, AppContext appContext) async {
try { try {
ManagerAppContext managerAppContext = appContext.getContext() as ManagerAppContext; ManagerAppContext managerAppContext = appContext.getContext() as ManagerAppContext;
var url = managerAppContext.host + "/api/Resource/" + resourceId; // TO TEST TODO UPDATE ROUTE var url = managerAppContext.host! + "/api/Resource/" + resourceId; // TO TEST TODO UPDATE ROUTE
var test2 = await http.readBytes(Uri.parse(url)); var test2 = await http.readBytes(Uri.parse(url));
final base64Str = base64.encode(test2); final base64Str = base64.encode(test2);
Uint8List base64String = base64Decode(base64Str); // LOAD DATA Uint8List base64String = base64Decode(base64Str); // LOAD DATA

View File

@ -15,8 +15,8 @@ dynamic showNewResource(AppContext appContext, BuildContext context) async {
ResourceDTO resourceDetailDTO = new ResourceDTO(); ResourceDTO resourceDetailDTO = new ResourceDTO();
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
var fileName; var fileName;
List<File> filesToSend; List<File>? filesToSend;
List<PlatformFile> filesToSendWeb; List<PlatformFile>? filesToSendWeb;
var result = await showDialog( var result = await showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
@ -89,7 +89,7 @@ dynamic showNewResource(AppContext appContext, BuildContext context) async {
color: kPrimaryColor, color: kPrimaryColor,
textColor: kWhite, textColor: kWhite,
press: () { press: () {
if (resourceDetailDTO.label != null && resourceDetailDTO.label.trim() != '') { if (resourceDetailDTO.label != null && resourceDetailDTO.label!.trim() != '') {
if(kIsWeb) { if(kIsWeb) {
if(resourceDetailDTO.data != null || filesToSendWeb != null) { if(resourceDetailDTO.data != null || filesToSendWeb != null) {
Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]); Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]);
@ -97,7 +97,7 @@ dynamic showNewResource(AppContext appContext, BuildContext context) async {
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null); showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null);
} }
} else { } else {
if (resourceDetailDTO.data != null || filesToSendWeb.length > 0 || filesToSend.length > 0) { if (resourceDetailDTO.data != null || filesToSendWeb!.length > 0 || filesToSend!.length > 0) {
Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]); Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]);
} else { } else {
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null); showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null);

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:manager_app/Components/fetch_resource_icon.dart'; import 'package:manager_app/Components/fetch_resource_icon.dart';
import 'package:manager_app/Components/multi_select_container.dart'; import 'package:manager_app/Components/multi_select_container.dart';
import 'package:manager_app/Components/string_input_container.dart'; import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:manager_api_new/api.dart'; import 'package:manager_api_new/api.dart';
@ -15,11 +16,11 @@ class ResourceBodyGrid extends StatefulWidget {
final bool isAddButton; final bool isAddButton;
final List<ResourceType> resourceTypesIn; final List<ResourceType> resourceTypesIn;
const ResourceBodyGrid({ const ResourceBodyGrid({
Key key, Key? key,
this.resources, required this.resources,
this.onSelect, required this.onSelect,
this.isAddButton, required this.isAddButton,
this.resourceTypesIn, required this.resourceTypesIn,
}) : super(key: key); }) : super(key: key);
@override @override
@ -27,11 +28,11 @@ class ResourceBodyGrid extends StatefulWidget {
} }
class _ResourceBodyGridState extends State<ResourceBodyGrid> { class _ResourceBodyGridState extends State<ResourceBodyGrid> {
List<String> filterTypes; late List<String> filterTypes;
List<String> currentFilterTypes; late List<String> currentFilterTypes;
String filterSearch = ''; String filterSearch = '';
List<String> selectedTypes; late List<String> selectedTypes;
List<ResourceDTO> resourcesToShow; late List<ResourceDTO> resourcesToShow;
@override @override
void initState() { void initState() {
@ -77,7 +78,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
isMultiple: true, isMultiple: true,
onChanged: (result) { onChanged: (result) {
setState(() { setState(() {
selectedTypes = result; selectedTypes = result as List<String>; // TO TEST
filterResource(); filterResource();
}); });
}, },
@ -158,7 +159,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: AutoSizeText( child: AutoSizeText(
resource.label == null ? "" : resource.label, resource.label == null ? "" : resource.label!,
style: new TextStyle(fontSize: 20), style: new TextStyle(fontSize: 20),
maxLines: 1, maxLines: 1,
), ),
@ -183,7 +184,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
} }
void filterResource() { void filterResource() {
resourcesToShow = filterSearch.isEmpty ? widget.resources: widget.resources.where((ResourceDTO resource) => resource.id == null || removeDiacritics(resource.label.toUpperCase()).contains(removeDiacritics(filterSearch.toUpperCase()))).toList(); resourcesToShow = filterSearch.isEmpty ? widget.resources: widget.resources.where((ResourceDTO resource) => resource.id == null || removeDiacritics(resource.label!.toUpperCase()).contains(removeDiacritics(filterSearch.toUpperCase()))).toList();
var getTypesInSelected = resource_types.where((ft) => selectedTypes.contains(ft.label)).map((rt) => rt.type).toList(); var getTypesInSelected = resource_types.where((ft) => selectedTypes.contains(ft.label)).map((rt) => rt.type).toList();
resourcesToShow = resourcesToShow.where((resource) => resource.id == null || getTypesInSelected.contains(resource.type)).toList(); resourcesToShow = resourcesToShow.where((resource) => resource.id == null || getTypesInSelected.contains(resource.type)).toList();
} }
@ -198,7 +199,7 @@ boxDecoration(dynamic resourceDetailDTO, appContext) {
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.3), BlendMode.dstATop), colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.3), BlendMode.dstATop),
image: new NetworkImage( image: new NetworkImage(
resourceDetailDTO.type == ResourceType.Image ? appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDetailDTO.id : resourceDetailDTO.data, resourceDetailDTO.type == ResourceType.Image ? (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/"+ resourceDetailDTO.id : resourceDetailDTO.data,
), ),
) : null, ) : null,
boxShadow: [ boxShadow: [

View File

@ -15,17 +15,17 @@ import 'package:http/http.dart' as http;
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
class ResourcesScreen extends StatefulWidget { class ResourcesScreen extends StatefulWidget {
final Function onGetResult; //return ResourceDTO final Function? onGetResult; //return ResourceDTO
final bool isImage; final bool isImage;
final bool isAddButton; final bool isAddButton;
final bool isFilter; final bool isFilter;
final List<ResourceType> resourceTypes; final List<ResourceType> resourceTypes;
const ResourcesScreen({ const ResourcesScreen({
Key key, Key? key,
this.isImage = false, this.isImage = false,
this.onGetResult, this.onGetResult,
this.isAddButton = true, this.isAddButton = true,
this.resourceTypes, required this.resourceTypes,
this.isFilter = true this.isFilter = true
}) : super(key: key); }) : super(key: key);
@ -34,8 +34,8 @@ class ResourcesScreen extends StatefulWidget {
} }
class _ResourcesScreenState extends State<ResourcesScreen> { class _ResourcesScreenState extends State<ResourcesScreen> {
String filter; String? filter;
bool isLoading; bool? isLoading;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -63,7 +63,7 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
if (widget.onGetResult == null) { if (widget.onGetResult == null) {
// Main screen // Main screen
if (value.id == null) { if (value.id == null) {
var result = await showNewResource(appContext, context); List<dynamic>? result = await showNewResource(appContext, context);
if (result != null) if (result != null)
{ {
await create(result[0], result[1], result[2], appContext, context); await create(result[0], result[1], result[2], appContext, context);
@ -75,7 +75,7 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
// Update resource // Update resource
ManagerAppContext managerAppContext = appContext.getContext() as ManagerAppContext; ManagerAppContext managerAppContext = appContext.getContext() as ManagerAppContext;
try{ try{
var resourceUpdated = managerAppContext.clientAPI.resourceApi.resourceUpdate(result); var resourceUpdated = managerAppContext.clientAPI!.resourceApi!.resourceUpdate(result);
setState(() { setState(() {
// refresh ui // refresh ui
showNotification(kSuccess, kWhite, 'La ressource a été mise à jour avec succès', context, null); showNotification(kSuccess, kWhite, 'La ressource a été mise à jour avec succès', context, null);
@ -87,7 +87,7 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
} }
} else { } else {
// Result for select modal // Result for select modal
widget.onGetResult(value); widget.onGetResult!(value);
} }
});//bodyGrid(tempOutput, size, appContext); });//bodyGrid(tempOutput, size, appContext);
} else { } else {
@ -108,35 +108,35 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
} }
} }
Future<void> getResources(Function onGetResult, bool isImage, AppContext appContext, List<ResourceType> types) async { Future<List<ResourceDTO>?> getResources(Function? onGetResult, bool isImage, AppContext appContext, List<ResourceType> types) async {
types = types != null ? types : []; types = types != null ? types : [];
List<ResourceDTO> resources = await (appContext.getContext() as ManagerAppContext).clientAPI.resourceApi.resourceGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId, types: types); List<ResourceDTO>? resources = await (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId, types: types);
if (onGetResult != null && isImage) { if (onGetResult != null && isImage && resources != null) {
resources = resources.where((element) => element.type == ResourceType.Image || element.type == ResourceType.ImageUrl || element.type == ResourceType.Audio).toList(); resources = resources.where((element) => element.type == ResourceType.Image || element.type == ResourceType.ImageUrl || element.type == ResourceType.Audio).toList();
} }
return resources; return resources;
} }
Future<ResourceDTO> create(ResourceDTO resourceDTO, List<File> files, List<PlatformFile> filesWeb, AppContext appContext, context) async { Future<ResourceDTO?> create(ResourceDTO resourceDTO, List<File>? files, List<PlatformFile>? filesWeb, AppContext appContext, context) async {
switch(resourceDTO.type) { switch(resourceDTO.type) {
case ResourceType.Audio: case ResourceType.Audio:
case ResourceType.Image: case ResourceType.Image:
case ResourceType.Video: case ResourceType.Video:
var request = http.MultipartRequest('POST', Uri.parse(appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/upload")); var request = http.MultipartRequest('POST', Uri.parse((appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.apiClient.basePath+"/api/Resource/upload"));
if (kIsWeb) { if (kIsWeb) {
for (PlatformFile file in filesWeb) { for (PlatformFile file in filesWeb!) {
request.files.add( request.files.add(
await http.MultipartFile.fromBytes( await http.MultipartFile.fromBytes(
'picture', 'picture',
file.bytes, file.bytes!,
filename: file.name filename: file.name
) )
); );
} }
} else { } else {
for (File file in files) { for (File file in files!) {
request.files.add( request.files.add(
await http.MultipartFile( await http.MultipartFile(
'picture', 'picture',
@ -150,9 +150,9 @@ Future<ResourceDTO> create(ResourceDTO resourceDTO, List<File> files, List<Platf
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
request.headers["authorization"]="Bearer ${managerAppContext.accessToken}"; request.headers["authorization"]="Bearer ${managerAppContext.accessToken}";
request.fields['label'] = resourceDTO.label; request.fields['label'] = resourceDTO.label!;
request.fields['type'] = resourceDTO.type.toString(); request.fields['type'] = resourceDTO.type.toString();
request.fields['instanceId'] = managerAppContext.instanceId; request.fields['instanceId'] = managerAppContext.instanceId!;
var res = await request.send(); var res = await request.send();
await res.stream.bytesToString(); await res.stream.bytesToString();
@ -168,10 +168,10 @@ Future<ResourceDTO> create(ResourceDTO resourceDTO, List<File> files, List<Platf
case ResourceType.VideoUrl: case ResourceType.VideoUrl:
if (resourceDTO.data != null) { if (resourceDTO.data != null) {
// test if Correct url // test if Correct url
bool _validURL = Uri.parse(resourceDTO.data).isAbsolute; bool _validURL = Uri.parse(resourceDTO.data!).isAbsolute;
if(_validURL) { if(_validURL) {
resourceDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId; resourceDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId;
ResourceDTO newResource = await (appContext.getContext() as ManagerAppContext).clientAPI.resourceApi.resourceCreate(resourceDTO); ResourceDTO? newResource = await (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceCreate(resourceDTO);
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context, null); showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context, null);
return newResource; return newResource;

View File

@ -22,7 +22,7 @@ dynamic showSelectResourceModal (String text, int maxLines, List<ResourceType> r
height: size.height * 0.75, height: size.height * 0.75,
child: ResourcesScreen( child: ResourcesScreen(
isAddButton: false, isAddButton: false,
onGetResult: (ResourceDTO resource) { onGetResult: (ResourceDTO? resource) {
if (resource != null) { if (resource != null) {
var result = resource; var result = resource;
Navigator.pop(context, result); Navigator.pop(context, result);
@ -65,7 +65,7 @@ showValues(List<TranslationDTO> newValues) {
valuesToShow.add( valuesToShow.add(
new StringInputContainer( new StringInputContainer(
color: Colors.lightBlue, color: Colors.lightBlue,
label: newValue.language, label: newValue.language!,
initialValue: newValue.value, initialValue: newValue.value,
onChanged: (String value) { onChanged: (String value) {
newValue.value = value; newValue.value = value;

View File

@ -10,7 +10,7 @@ import 'package:manager_api_new/api.dart';
import 'get_element_for_resource.dart'; import 'get_element_for_resource.dart';
Future<ResourceDTO> showResource(ResourceDTO resourceDTO, AppContext appContext, BuildContext context, Size size) async { Future<ResourceDTO?> showResource(ResourceDTO resourceDTO, AppContext appContext, BuildContext context, Size size) async {
var result = await showDialog( var result = await showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -112,7 +112,7 @@ Future<ResourceDTO> showResource(ResourceDTO resourceDTO, AppContext appContext,
icon: Icons.check, icon: Icons.check,
color: kPrimaryColor, color: kPrimaryColor,
press: () { press: () {
if (resourceDTO.label != null && resourceDTO.label.length > 2) { if (resourceDTO.label != null && resourceDTO.label!.length > 2) {
Navigator.pop(context, resourceDTO); Navigator.pop(context, resourceDTO);
} }
}, },
@ -134,7 +134,7 @@ Future<void> delete(ResourceDTO resourceDTO, AppContext appContext, context) asy
"Êtes-vous sûr de vouloir supprimer cette ressource ?", "Êtes-vous sûr de vouloir supprimer cette ressource ?",
() {}, () {},
() async { () async {
await appContext.getContext().clientAPI.resourceApi.resourceDelete(resourceDTO.id); await (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceDelete(resourceDTO.id!);
// just to refresh // just to refresh
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);

View File

@ -20,33 +20,35 @@ import 'package:provider/provider.dart';
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
class LoginScreen extends StatefulWidget { class LoginScreen extends StatefulWidget {
final Session session; final Session? session;
LoginScreen({Key key, this.session}) : super(key: key); LoginScreen({Key? key, this.session}) : super(key: key);
@override @override
_LoginScreenState createState() => _LoginScreenState(); _LoginScreenState createState() => _LoginScreenState();
} }
class _LoginScreenState extends State<LoginScreen> { class _LoginScreenState extends State<LoginScreen> {
String email; // DEV "test@email.be" String email = ""; // DEV "test@email.be"
String password; // DEV = "kljqsdkljqsd" String password = ""; // DEV = "kljqsdkljqsd"
String host; // DEV = "http://192.168.31.96" String? host; // DEV = "http://192.168.31.96"
Client clientAPI; Client? clientAPI;
bool isLoading = false; bool isLoading = false;
bool isRememberMe = false; bool isRememberMe = false;
String pageTitle = "MyMuseum"; String pageTitle = "MyMuseum";
String token; String? token;
String instanceId; String? instanceId;
Storage localStorage = window.localStorage; Storage localStorage = window.localStorage;
void authenticateTRY(dynamic appContext, bool fromClick) async { void authenticateTRY(AppContext appContext, bool fromClick) async {
//print("try auth.. "); //print("try auth.. ");
/*this.host = "http://localhost:5000"; /*this.host = "http://localhost:5000";
this.email = "test@email.be"; this.email = "test@email.be";
this.password = "kljqsdkljqsd";*/ this.password = "kljqsdkljqsd";*/
clientAPI = Client(this.host); if(this.host != null) {
clientAPI = Client(this.host!);
}
if (this.email != null && this.password != null || this.token != null) { if (this.email != null && this.password != null || this.token != null) {
@ -64,73 +66,76 @@ class _LoginScreenState extends State<LoginScreen> {
var instanceId = this.instanceId; var instanceId = this.instanceId;
if(accessToken == null) { if(accessToken == null) {
LoginDTO loginDTO = new LoginDTO(email: email, password: password); LoginDTO loginDTO = new LoginDTO(email: email, password: password);
TokenDTO token = await clientAPI.authenticationApi.authenticationAuthenticateWithJson(loginDTO); TokenDTO? token = await clientAPI!.authenticationApi!.authenticationAuthenticateWithJson(loginDTO);
accessToken = token.accessToken;
instanceId = token.instanceId;
showNotification(kSuccess, kWhite, 'Connexion réussie', context, null); if(token != null) {
accessToken = token.accessToken!;
instanceId = token.instanceId!;
if(isRememberMe) { showNotification(kSuccess, kWhite, 'Connexion réussie', context, null);
if(!localStorage.containsKey("remember")) {
localStorage.addEntries({"remember": "true"}.entries); if(isRememberMe) {
if(!localStorage.containsKey("remember")) {
localStorage.addEntries({"remember": "true"}.entries);
}
if(!localStorage.containsKey("email") && !localStorage.containsKey("token")) {
localStorage.addEntries({"email": email!}.entries);
localStorage.addEntries({"token": token.accessToken!}.entries);
localStorage.addEntries({"instanceId": token.instanceId!}.entries);
}
} else {
localStorage.clear();
} }
// Desktop
if(!localStorage.containsKey("email") && !localStorage.containsKey("token")) { /*if (isRememberMe) {
localStorage.addEntries({"email": email}.entries);
localStorage.addEntries({"token": token.accessToken}.entries);
localStorage.addEntries({"instanceId": token.instanceId}.entries);
}
} else {
localStorage.clear();
}
}
// Desktop
/*if (isRememberMe) {
Session updatedSession = new Session(rememberMe: isRememberMe, host: host, email: email, password: password); Session updatedSession = new Session(rememberMe: isRememberMe, host: host, email: email, password: password);
// update JSON FILE // update JSON FILE
FileHelper().writeSession(updatedSession); FileHelper().writeSession(updatedSession);
}*/ }*/
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext? managerAppContext = appContext.getContext();
// Set the appContext // Set the appContext
if (managerAppContext == null) { if (managerAppContext == null) {
managerAppContext = new ManagerAppContext(); managerAppContext = new ManagerAppContext();
} }
// store user info locally // store user info locally
managerAppContext.email = email; managerAppContext.email = email;
managerAppContext.host = host; managerAppContext.host = host;
managerAppContext.instanceId = instanceId; managerAppContext.instanceId = instanceId;
managerAppContext.accessToken = accessToken; managerAppContext.accessToken = accessToken;
managerAppContext.clientAPI = clientAPI; managerAppContext.clientAPI = clientAPI;
setAccessToken(accessToken); setAccessToken(accessToken);
//print(managerAppContext); //print(managerAppContext);
appContext.setContext(managerAppContext); appContext.setContext(managerAppContext);
if(fromClick) { if(fromClick) {
setState(() { setState(() {
isLoading = false; isLoading = false;
}); });
} }
//Navigator.pushNamed(context, '/main'); //Navigator.pushNamed(context, '/main');
/*Navigator.pushNamedAndRemoveUntil( /*Navigator.pushNamedAndRemoveUntil(
context, context,
'/main', '/main',
(Route<dynamic> route) => false // For pushAndRemoveUntil (Route<dynamic> route) => false // For pushAndRemoveUntil
);*/ );*/
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) { builder: (context) {
return MainScreen(); return MainScreen();
}, },
), ),
(Route<dynamic> route) => false // For pushAndRemoveUntil (Route<dynamic> route) => false // For pushAndRemoveUntil
); );
}
}
} }
catch (e) { catch (e) {
print("error auth"); print("error auth");
@ -147,7 +152,7 @@ class _LoginScreenState extends State<LoginScreen> {
void setAccessToken(String accessToken) { void setAccessToken(String accessToken) {
//clientAPI.resourceApi.apiClient.addDefaultHeader('authorization', 'Bearer '+accessToken); //clientAPI.resourceApi.apiClient.addDefaultHeader('authorization', 'Bearer '+accessToken);
clientAPI.apiApi.addDefaultHeader('authorization', 'Bearer '+accessToken); clientAPI!.apiApi!.addDefaultHeader('authorization', 'Bearer '+accessToken);
//clientAPI.resourceApi.addDefaultHeader('Bearer', accessToken); //clientAPI.resourceApi.addDefaultHeader('Bearer', accessToken);
//clientAPI.apiApi.authentication.applyToParams([], Map.from({'Bearer': accessToken})); //clientAPI.apiApi.authentication.applyToParams([], Map.from({'Bearer': accessToken}));
@ -309,10 +314,12 @@ class _LoginScreenState extends State<LoginScreen> {
checkColor: kTextLightColor, checkColor: kTextLightColor,
activeColor: kPrimaryColor, activeColor: kPrimaryColor,
value: this.isRememberMe, value: this.isRememberMe,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { if(value != null) {
this.isRememberMe = value; setState(() {
}); this.isRememberMe = value;
});
}
}, },
), ),
), ),

View File

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'Models/managerContext.dart'; import 'Models/managerContext.dart';
class AppContext with ChangeNotifier { class AppContext with ChangeNotifier {
ManagerAppContext _managerContext; ManagerAppContext? _managerContext;
AppContext(this._managerContext); AppContext(this._managerContext);

View File

@ -2,33 +2,33 @@ import 'package:manager_api_new/api.dart';
//import 'package:openapi_dart_common/openapi.dart'; //import 'package:openapi_dart_common/openapi.dart';
class Client { class Client {
ApiClient _apiClient; ApiClient? _apiClient;
ApiClient get apiApi => _apiClient; ApiClient? get apiApi => _apiClient;
AuthenticationApi _authenticationApi; AuthenticationApi? _authenticationApi;
AuthenticationApi get authenticationApi => _authenticationApi; AuthenticationApi? get authenticationApi => _authenticationApi;
UserApi _userApi; UserApi? _userApi;
UserApi get userApi => _userApi; UserApi? get userApi => _userApi;
ConfigurationApi _configurationApi; ConfigurationApi? _configurationApi;
ConfigurationApi get configurationApi => _configurationApi; ConfigurationApi? get configurationApi => _configurationApi;
SectionApi _sectionApi; SectionApi? _sectionApi;
SectionApi get sectionApi => _sectionApi; SectionApi? get sectionApi => _sectionApi;
ResourceApi _resourceApi; ResourceApi? _resourceApi;
ResourceApi get resourceApi => _resourceApi; ResourceApi? get resourceApi => _resourceApi;
DeviceApi _deviceApi; DeviceApi? _deviceApi;
DeviceApi get deviceApi => _deviceApi; DeviceApi? get deviceApi => _deviceApi;
Client(String path) { Client(String path) {
_apiClient = ApiClient( _apiClient = ApiClient(
basePath: path); basePath: path);
//basePath: "https://192.168.31.140"); //basePath: "https://192.168.31.140");
//basePath: "https://localhost:44339"); //basePath: "https://localhost:44339");
_apiClient.addDefaultHeader("Access-Control_Allow_Origin", "*"); _apiClient!.addDefaultHeader("Access-Control_Allow_Origin", "*");
_authenticationApi = AuthenticationApi(_apiClient); _authenticationApi = AuthenticationApi(_apiClient);
_userApi = UserApi(_apiClient); _userApi = UserApi(_apiClient);
_configurationApi = ConfigurationApi(_apiClient); _configurationApi = ConfigurationApi(_apiClient);

View File

@ -21,9 +21,12 @@ Future<void> main() async {
var session = await loadJsonSessionFile(); var session = await loadJsonSessionFile();
ManagerAppContext managerAppContext = new ManagerAppContext();
final MyApp myApp = MyApp( final MyApp myApp = MyApp(
initialRoute: initialRoute, initialRoute: initialRoute,
session: session session: session,
managerAppContext: managerAppContext
//context: localContext, //context: localContext,
); );
@ -34,7 +37,7 @@ class MyApp extends StatefulWidget {
final String initialRoute; final String initialRoute;
final Session session; final Session session;
final ManagerAppContext managerAppContext; final ManagerAppContext managerAppContext;
MyApp({this.initialRoute, this.session, this.managerAppContext}); MyApp({required this.initialRoute, required this.session, required this.managerAppContext});
// This widget is the root of your application. // This widget is the root of your application.
@override @override

View File

@ -49,14 +49,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.10.0" version: "2.10.0"
audioplayers: audio_session:
dependency: "direct main" dependency: transitive
description: description:
name: audioplayers name: audio_session
sha256: d50acc9659568fe0c14a5fd81ec51cdd5948b5362186572a58d76bc745302202 sha256: e4acc4e9eaa32436dfc5d7aed7f0a370f2d7bb27ee27de30d6c4f220c2a05c73
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.18.3" version: "0.1.13"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -408,6 +408,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.8.0" version: "4.8.0"
just_audio:
dependency: "direct main"
description:
name: just_audio
sha256: "7e6d31508dacd01a066e3889caf6282e5f1eb60707c230203b21a83af5c55586"
url: "https://pub.dev"
source: hosted
version: "0.9.32"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
sha256: eff112d5138bea3ba544b6338b1e0537a32b5e1425e4d0dc38f732771cda7c84
url: "https://pub.dev"
source: hosted
version: "4.2.0"
just_audio_web:
dependency: transitive
description:
name: just_audio_web
sha256: "89d8db6f19f3821bb6bf908c4bfb846079afb2ab575b783d781a6bf119e3abaf"
url: "https://pub.dev"
source: hosted
version: "0.4.7"
logging: logging:
dependency: transitive dependency: transitive
description: description:
@ -861,5 +885,5 @@ packages:
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.18.0 <3.0.1" dart: ">=2.18.0 <3.0.0"
flutter: ">=3.0.0" flutter: ">=3.0.0"

View File

@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.7.0 <3.0.1" sdk: ">=2.16.2 <3.0.1"
dependencies: dependencies:
flutter: flutter: