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/
COPY . /app/
WORKDIR /app/
RUN flutter build web --no-sound-null-safety
RUN flutter build web
#--no-sound-null-safety
# Stage 2 - Create the run-time image
FROM nginx:1.21.1-alpine

View File

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

View File

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

View File

@ -4,17 +4,17 @@ import 'package:flutter/material.dart';
import '../constants.dart';
class CheckInputContainer extends StatefulWidget {
final bool isChecked;
final IconData icon;
final bool? isChecked;
final IconData? icon;
final String label;
final ValueChanged<bool> onChanged;
final double fontSize;
const CheckInputContainer({
Key key,
Key? key,
this.isChecked,
this.icon,
this.label,
this.onChanged,
required this.label,
required this.onChanged,
this.fontSize = 20
}) : super(key: key);
@ -23,7 +23,7 @@ class CheckInputContainer extends StatefulWidget {
}
class _CheckInputContainerState extends State<CheckInputContainer> {
bool isChecked;
bool? isChecked;
@override
void initState() {
@ -72,11 +72,11 @@ class _CheckInputContainerState extends State<CheckInputContainer> {
value: isChecked,
checkColor: Colors.white,
activeColor: kPrimaryColor,
onChanged: (bool value) {
onChanged: (bool? value) {
setState(() {
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';
class ColorPickerInputContainer extends StatefulWidget {
final String color;
final String? color;
final String label;
final double fontSize;
final ValueChanged<String> onChanged;
const ColorPickerInputContainer({
Key key,
Key? key,
this.color,
this.label,
required this.label,
this.fontSize = 25,
this.onChanged,
required this.onChanged,
}) : super(key: key);
@override
@ -20,12 +20,12 @@ class ColorPickerInputContainer extends StatefulWidget {
}
class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
Color colorVar;
Color? colorVar;
@override
void initState() {
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();
}
@ -50,7 +50,7 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
child: InkWell(
onTap: () {
showColorPicker(
colorVar,
colorVar!,
(Color color) {
setState(() {
colorVar = color;

View File

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

View File

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

View File

@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
import 'package:manager_app/constants.dart';
class LoadingCommon extends StatefulWidget {
const LoadingCommon({Key key}) : super(key: key);
const LoadingCommon({Key? key}) : super(key: key);
@override
State<LoadingCommon> createState() => _LoadingCommonState();
}
class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateMixin {
AnimationController _controller;
AnimationController? _controller;
@override
void initState() {
@ -22,25 +22,25 @@ class _LoadingCommonState extends State<LoadingCommon> with TickerProviderStateM
@override
void dispose() {
_controller.dispose();
_controller!.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
_controller.forward(from: 0.0);
_controller.addListener(() {
if (_controller.isCompleted) {
_controller.reverse();
_controller!.forward(from: 0.0);
_controller!.addListener(() {
if (_controller!.isCompleted) {
_controller!.reverse();
}
if(_controller.isDismissed){
_controller.forward();
if(_controller!.isDismissed){
_controller!.forward();
}
});
return Center(
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),
),
);

View File

@ -1,6 +1,6 @@
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(
behavior: SnackBarBehavior.floating,
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) {
List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) {
for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add(
Padding(
padding: const EdgeInsets.all(8.0),
@ -122,7 +122,7 @@ getTranslations(BuildContext context, AppContext appContext, String label, bool
label: label,
color: kWhite,
isTitle: isTitle,
initialValue: newValues.where((element) => element.language == language).first.value,
initialValue: newValues.where((element) => element.language == language).first.value!,
onChanged: (value) {
newValues.where((element) => element.language == language).first.value = value;
},

View File

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

View File

@ -16,15 +16,15 @@ class MultiSelectDropdownContainer extends StatelessWidget {
final double fontSize;
final ValueChanged<List<dynamic>> onChanged;
const MultiSelectDropdownContainer({
Key key,
Key? key,
this.color = kSecond,
this.label,
this.values,
this.initialValue,
this.isMultiple,
required this.label,
required this.values,
required this.initialValue,
required this.isMultiple,
this.isAtLeastOne = false,
this.fontSize = 25,
this.onChanged,
required this.onChanged,
}) : super(key: key);
@override
@ -63,6 +63,11 @@ class MultiSelectDropdownContainer extends StatelessWidget {
onSelectionChanged: (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 double fontSize;
const MultiStringContainer({
Key key,
Key? key,
this.color = kSecond,
this.label,
this.modalLabel,
this.initialValue,
this.onGetResult,
this.maxLines,
this.isTitle,
required this.label,
required this.modalLabel,
required this.initialValue,
required this.onGetResult,
required this.maxLines,
required this.isTitle,
this.isAudio = false,
this.fontSize = 25,
}) : super(key: key);
@ -61,7 +61,7 @@ class MultiStringContainer extends StatelessWidget {
languages.forEach((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 {
// New language
newValues.add(TranslationDTO(language: value, value: null));

View File

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

View File

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

View File

@ -5,20 +5,20 @@ import 'package:manager_app/constants.dart';
class RoundedButton extends StatelessWidget {
final String text;
final Function press;
final IconData icon;
final IconData? icon;
final Color color, textColor;
final double fontSize;
final double vertical;
final double horizontal;
final double? vertical;
final double? horizontal;
const RoundedButton({
Key key,
this.text,
this.press,
Key? key,
required this.text,
required this.press,
this.icon,
this.color = kPrimaryColor,
this.textColor = kWhite,
this.fontSize,
required this.fontSize,
this.vertical,
this.horizontal
}) : super(key: key);
@ -28,7 +28,7 @@ class RoundedButton extends StatelessWidget {
//Size size = MediaQuery.of(context).size;
return TextButton(
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),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(

View File

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

View File

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

View File

@ -9,13 +9,13 @@ class SliderInputContainer extends StatefulWidget {
final int max;
final ValueChanged<double> onChanged;
const SliderInputContainer({
Key key,
Key? key,
this.color = kSecond,
this.label,
this.initialValue,
this.min,
this.max,
this.onChanged,
required this.label,
required this.initialValue,
required this.min,
required this.max,
required this.onChanged,
}) : super(key: key);
@override
@ -23,7 +23,7 @@ class SliderInputContainer extends StatefulWidget {
}
class _SliderInputContainerState extends State<SliderInputContainer> {
double currentValue;
double? currentValue;
@override
void initState() {
@ -43,7 +43,7 @@ class _SliderInputContainerState extends State<SliderInputContainer> {
Padding(
padding: const EdgeInsets.all(10.0),
child: Slider(
value: currentValue,
value: currentValue!,
onChanged: (value) {
setState(() => currentValue = 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';
class StringInputContainer extends StatelessWidget {
final Color color;
final Color? color;
final String label;
final String initialValue;
final String? initialValue;
final ValueChanged<String> onChanged;
final bool isUrl;
final bool isSmall;
@ -14,11 +14,11 @@ class StringInputContainer extends StatelessWidget {
final double fontSize;
final double fontSizeText;
const StringInputContainer({
Key key,
Key? key,
this.color = kSecond,
this.label,
this.initialValue,
this.onChanged,
required this.label,
this.initialValue = "",
required this.onChanged,
this.isUrl = false,
this.isSmall = false,
this.maxLength = 50,
@ -29,6 +29,7 @@ class StringInputContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
child: Row(
children: [
@ -47,7 +48,7 @@ class StringInputContainer extends StatelessWidget {
child: Container(
width: isUrl ? size.width *0.6 : isSmall ? size.width *0.1 : size.width *0.2,
child: RoundedInputField(
color: color,
color: color!,
textColor: kBlack,
fontSize: fontSizeText,
initialValue: initialValue,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ class FileHelper {
if (session.password != null) {
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;
}
@ -40,20 +40,20 @@ class FileHelper {
Future<File> storeConfiguration(ExportConfigurationDTO exportConfigurationDTO) async {
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
File file = File('$path/'+exportConfigurationDTO.label+'.json');
File file = File('$path/'+exportConfigurationDTO.label!+'.json');
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];
String fileContent = utf8.decode(fileTest.bytes);
ExportConfigurationDTO export = ExportConfigurationDTO.fromJson(jsonDecode(fileContent));
String fileContent = utf8.decode(fileTest.bytes!);
ExportConfigurationDTO export = ExportConfigurationDTO.fromJson(jsonDecode(fileContent))!;
try {
String test = await client.configurationApi.configurationImport(export);
if (test.contains("successfully")) {
String? test = await client.configurationApi!.configurationImport(export);
if (test != null && test.contains("successfully")) {
showNotification(kSuccess, kWhite, 'La configuration a été importée avec succès', context, null);
} else {
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));
if (session.password != null) {
session.password = encrypter.decrypt64(session.password, iv: iv);
session.password = encrypter.decrypt64(session.password!, iv: iv);
}
return session;

View File

@ -23,10 +23,10 @@ class PDFHelper {
child:
pw.Column(
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.BarcodeWidget(
data: section.id,
data: section.id!,
width: 150,
height: 150,
barcode: pw.Barcode.qrCode(),

View File

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

View File

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

View File

@ -2,9 +2,9 @@ import 'package:manager_app/Models/menuSection.dart';
class Menu {
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) {
return new Menu(

View File

@ -3,7 +3,7 @@ class MenuSection {
String type;
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) {
return new MenuSection(

View File

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

View File

@ -1,10 +1,10 @@
class Session {
bool rememberMe;
String host;
String email;
String password;
String? host;
String? email;
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) {
return new Session(

View File

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

View File

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

View File

@ -1,4 +1,5 @@
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/Resources/select_resource_modal.dart';
import 'package:manager_app/app_context.dart';
@ -10,9 +11,9 @@ class GeoPointImageList extends StatefulWidget {
final List<ImageGeoPoint> images;
final ValueChanged<List<ImageGeoPoint>> onChanged;
const GeoPointImageList({
Key key,
this.images,
this.onChanged,
Key? key,
required this.images,
required this.onChanged,
}) : super(key: key);
@override
@ -20,7 +21,7 @@ class GeoPointImageList extends StatefulWidget {
}
class _GeoPointImageListState extends State<GeoPointImageList> {
List<ImageGeoPoint> imagesGeo;
late List<ImageGeoPoint> imagesGeo;
@override
void initState() {
@ -96,7 +97,7 @@ class _GeoPointImageListState extends State<GeoPointImageList> {
);
if (result != null) {
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(newImage);
imagesGeo.add(newImage);

View File

@ -82,10 +82,10 @@ class _ListViewCardGeoPointImagesState extends State<ListViewCardGeoPointImages>
children: [
Center(
child: Image.network(
imageGeoPoint.imageSource,
imageGeoPoint.imageSource!,
fit:BoxFit.scaleDown,
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) {
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) {
return child;
}
@ -94,7 +94,7 @@ class _ListViewCardGeoPointImagesState extends State<ListViewCardGeoPointImages>
color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes
loadingProgress.expectedTotalBytes!
: 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/multi_select_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/app_context.dart';
import 'package:manager_app/constants.dart';
@ -13,16 +14,16 @@ import 'dart:convert';
import 'package:provider/provider.dart';
class MapConfig extends StatefulWidget {
final String color;
final String label;
final String? color;
final String? label;
final String initialValue;
final ValueChanged<String> onChanged;
const MapConfig({
Key key,
Key? key,
this.color,
this.label,
this.initialValue,
this.onChanged,
required this.initialValue,
required this.onChanged,
}) : super(key: key);
@override
@ -30,19 +31,19 @@ class MapConfig extends StatefulWidget {
}
class _MapConfigState extends State<MapConfig> {
MapDTO mapDTO;
late MapDTO mapDTO;
String mapType= "hybrid";
@override
void initState() {
super.initState();
mapDTO = MapDTO.fromJson(json.decode(widget.initialValue));
List<GeoPointDTO> test = new List<GeoPointDTO>.from(mapDTO.points);
mapDTO = MapDTO.fromJson(json.decode(widget.initialValue))!;
List<GeoPointDTO> test = new List<GeoPointDTO>.from(mapDTO.points!);
mapDTO.points = test;
if(mapDTO.mapType != null) {
switch(mapDTO.mapType.value) {
switch(mapDTO.mapType!.value) {
case 0:
mapType = "none";
break;
@ -96,7 +97,7 @@ class _MapConfigState extends State<MapConfig> {
mapDTO.iconResourceId = null;
} else {
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());
},
@ -119,7 +120,7 @@ class _MapConfigState extends State<MapConfig> {
// Zoom
SliderInputContainer(
label: "Zoom:",
initialValue: mapDTO.zoom != null ? mapDTO.zoom.toDouble() : 18,
initialValue: mapDTO.zoom != null ? mapDTO.zoom!.toDouble() : 18,
color: kPrimaryColor,
min: 0,
max: 30,
@ -145,14 +146,14 @@ class _MapConfigState extends State<MapConfig> {
child: GridView.builder(
shrinkWrap: true,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
itemCount: mapDTO.points.length,
itemCount: mapDTO.points!.length,
itemBuilder: (BuildContext context, int index) {
return
Container(
decoration: boxDecoration(mapDTO.points[index], appContext),
decoration: boxDecoration(mapDTO.points![index], appContext),
padding: const EdgeInsets.all(5),
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,
(GeoPointDTO geoPoint) {
setState(() {
mapDTO.points.add(geoPoint);
mapDTO.points!.add(geoPoint);
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(
width: double.infinity,
height: double.infinity,
@ -223,7 +224,7 @@ class _MapConfigState extends State<MapConfig> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AutoSizeText(
point.title == null ? "" : point.title[0].value,
point != null ? point.title == null ? "" : point.title![0].value! : "",
style: new TextStyle(fontSize: 20),
maxLines: 2,
textAlign: TextAlign.center,
@ -245,10 +246,10 @@ class _MapConfigState extends State<MapConfig> {
child: InkWell(
onTap: () {
showNewOrUpdateGeoPoint(
mapDTO.points[index],
mapDTO.points![index],
(GeoPointDTO geoPoint) {
setState(() {
mapDTO.points[index] = geoPoint;
mapDTO.points![index] = geoPoint;
widget.onChanged(jsonEncode(mapDTO).toString());
});
},
@ -268,7 +269,7 @@ class _MapConfigState extends State<MapConfig> {
child: InkWell(
onTap: () {
setState(() {
mapDTO.points.removeAt(index);
mapDTO.points!.removeAt(index);
});
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_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();
if (inputGeoPointDTO != null) {
@ -20,12 +20,12 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
geoPointDTO.images = <ImageGeoPoint>[];
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) {
managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationDTO = new TranslationDTO();
translationDTO.language = element;
translationDTO.value = "";
geoPointDTO.title.add(translationDTO);
geoPointDTO.description.add(translationDTO);
geoPointDTO.title!.add(translationDTO);
geoPointDTO.description!.add(translationDTO);
});
}
@ -87,7 +87,7 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
],
),
child: GeoPointImageList(
images: geoPointDTO.images,
images: geoPointDTO.images!,
onChanged: (List<ImageGeoPoint> imagesOutput) {
geoPointDTO.images = imagesOutput;
},
@ -152,7 +152,7 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
getTranslations(BuildContext context, AppContext appContext, GeoPointDTO geoPointDTO) {
List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) {
for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add(
Padding(
padding: const EdgeInsets.all(8.0),
@ -181,18 +181,18 @@ getTranslations(BuildContext context, AppContext appContext, GeoPointDTO geoPoin
label: "Titre:",
color: kWhite,
isTitle: true,
initialValue: geoPointDTO.title.where((element) => element.language == language).first.value,
initialValue: geoPointDTO.title!.where((element) => element.language == language).first.value!,
onChanged: (value) {
geoPointDTO.title.where((element) => element.language == language).first.value = value;
geoPointDTO.title!.where((element) => element.language == language).first.value = value;
},
),
TextFormInputContainer(
label: "Description:",
color: kWhite,
isTitle: false,
initialValue: geoPointDTO.description.where((element) => element.language == language).first.value,
initialValue: geoPointDTO.description!.where((element) => element.language == language).first.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(
widget.listItems[widget.index],
(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(() {
widget.listItems[widget.index] = value;
widget.onChanged(widget.listItems);
@ -109,7 +109,7 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
Align(
alignment: Alignment.center,
child: AutoSizeText(
sectionDTO.label,
sectionDTO.label!,
style: new TextStyle(fontSize: 15),
maxLines: 2,
textAlign: TextAlign.center,

View File

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

View File

@ -52,7 +52,7 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
subSectionDTO.imageSource = null;
} else {
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,
@ -133,7 +133,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
switch(sectionDTO.type) {
case SectionType.Map:
return MapConfig(
initialValue: sectionDTO.data,
initialValue: sectionDTO.data!,
onChanged: (String data) {
//print("Received info in parent");
//print(data);
@ -145,7 +145,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height * 0.5,
child: SliderConfig(
initialValue: sectionDTO.data,
initialValue: sectionDTO.data!,
onChanged: (String data) {
//print("Received info in parent");
//print(data);
@ -157,14 +157,14 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
case SectionType.Web:
return WebOrVideoConfig(
label: sectionDTO.type == SectionType.Video ? "Url de la vidéo:": "Url du site web:",
initialValue: sectionDTO.data,
initialValue: sectionDTO.data!,
onChanged: (String data) {
sectionDTO.data = data;
},
);
case SectionType.Menu:
return MenuConfig(
initialValue: sectionDTO.data,
initialValue: sectionDTO.data!,
onChanged: (String data) {
//print("Received info in parent");
//print(data);
@ -173,7 +173,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
);
case SectionType.Quizz:
return QuizzConfig(
initialValue: sectionDTO.data,
initialValue: sectionDTO.data!,
onChanged: (String data) {
//print("Received info in parent");
//print(data);
@ -186,7 +186,7 @@ getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appConte
getTranslations(BuildContext context, AppContext appContext, SectionDTO subSectionDTO) {
List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) {
for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add(
SingleChildScrollView(
child: Padding(
@ -216,18 +216,18 @@ getTranslations(BuildContext context, AppContext appContext, SectionDTO subSecti
color: kWhite,
isTitle: true,
maxLines: 1,
initialValue: subSectionDTO.title.where((element) => element.language == language).first.value,
initialValue: subSectionDTO.title!.where((element) => element.language == language).first.value!,
onChanged: (value) {
subSectionDTO.title.where((element) => element.language == language).first.value = value;
subSectionDTO.title!.where((element) => element.language == language).first.value = value;
},
),
TextFormInputContainer(
label: "Description:",
color: kWhite,
isTitle: false,
initialValue: subSectionDTO.description.where((element) => element.language == language).first.value,
initialValue: subSectionDTO.description!.where((element) => element.language == language).first.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_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();
if (inputQuestionDTO != null) {
@ -19,12 +19,12 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
questionDTO.label = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) {
managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationMessageDTO = new TranslationDTO();
translationMessageDTO.language = element;
translationMessageDTO.value = "";
questionDTO.label.add(translationMessageDTO);
questionDTO.label!.add(translationMessageDTO);
});
}
@ -59,7 +59,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
questionDTO.source_ = null;
} else {
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
@ -92,7 +92,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
],
),
child: QuizzResponseList(
responses: questionDTO.responses,
responses: questionDTO.responses!,
onChanged: (List<ResponseDTO> responsesOutput) {
questionDTO.responses = responsesOutput;
},
@ -135,7 +135,7 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
color: kPrimaryColor,
textColor: kWhite,
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);
} else {
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) {
List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) {
for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add(
Padding(
padding: const EdgeInsets.all(8.0),
@ -185,9 +185,9 @@ getTranslations(BuildContext context, AppContext appContext, QuestionDTO questio
label: "Question:",
color: kWhite,
isTitle: false,
initialValue: questionDTO.label.where((element) => element.language == language).first.value,
initialValue: questionDTO.label!.where((element) => element.language == language).first.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_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();
if (inputResponseDTO != null) {
@ -17,12 +17,12 @@ Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO inputResponseDTO, A
responseDTO.label = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) {
managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationMessageDTO = new TranslationDTO();
translationMessageDTO.language = element;
translationMessageDTO.value = "";
responseDTO.label.add(translationMessageDTO);
responseDTO.label!.add(translationMessageDTO);
});
}
@ -107,7 +107,7 @@ Future<ResponseDTO> showNewOrUpdateResponseQuizz(ResponseDTO inputResponseDTO, A
color: kPrimaryColor,
textColor: kWhite,
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);
} else {
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) {
List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) {
for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add(
Padding(
padding: const EdgeInsets.all(8.0),
@ -157,9 +157,9 @@ getTranslations(BuildContext context, AppContext appContext, ResponseDTO respons
label: "Réponse:",
color: kWhite,
isTitle: true,
initialValue: responseDTO.label.where((element) => element.language == language).first.value,
initialValue: responseDTO.label!.where((element) => element.language == language).first.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_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();
if (inputLevelDTO != null) {
@ -17,12 +17,12 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
levelDTO.label = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) {
managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationMessageDTO = new TranslationDTO();
translationMessageDTO.language = element;
translationMessageDTO.value = "";
levelDTO.label.add(translationMessageDTO);
levelDTO.label!.add(translationMessageDTO);
});
}
@ -53,7 +53,7 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
levelDTO.source_ = null;
} else {
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
@ -121,7 +121,7 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
getTranslations(BuildContext context, AppContext appContext, LevelDTO levelDTO) {
List<Widget> translations = <Widget>[];
ManagerAppContext managerAppContext = appContext.getContext();
for(var language in managerAppContext.selectedConfiguration.languages) {
for(var language in managerAppContext.selectedConfiguration!.languages!) {
translations.add(
Padding(
padding: const EdgeInsets.all(8.0),
@ -150,9 +150,9 @@ getTranslations(BuildContext context, AppContext appContext, LevelDTO levelDTO)
label: "Message:",
color: kWhite,
isTitle: false,
initialValue: levelDTO.label.where((element) => element.language == language).first.value,
initialValue: levelDTO.label!.where((element) => element.language == language).first.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 ValueChanged<List<ResponseDTO>> onChanged;
const QuizzResponseList({
Key key,
this.responses,
this.onChanged,
Key? key,
required this.responses,
required this.onChanged,
}) : super(key: key);
@override
@ -21,7 +21,7 @@ class QuizzResponseList extends StatefulWidget {
}
class _QuizzResponseListState extends State<QuizzResponseList> {
List<ResponseDTO> responsesMiddle;
late List<ResponseDTO> responsesMiddle;
@override
void initState() {
@ -138,7 +138,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
child: Padding(
padding: const EdgeInsets.all(2.0),
child: AutoSizeText(
response.label == null ? "" : response.label[0].value,
response.label == null ? "" : response.label![0].value!,
style: new TextStyle(fontSize: 15),
maxLines: 2,
textAlign: TextAlign.center,
@ -161,9 +161,9 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
value: response.isGood,
checkColor: Colors.white,
activeColor: kPrimaryColor,
onChanged: (bool value) {
onChanged: (bool? value) {
setState(() {
response.isGood = !response.isGood;
response.isGood = !response.isGood!;
widget.onChanged(responsesMiddle);
});
},
@ -183,7 +183,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
if (result != null) {
setState(() {
responsesMiddle[response.order] = result;
responsesMiddle[response.order!] = result;
widget.onChanged(responsesMiddle);
});
}
@ -203,7 +203,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
child: InkWell(
onTap: () {
setState(() {
responsesMiddle.removeAt(response.order);
responsesMiddle.removeAt(response.order!);
widget.onChanged(responsesMiddle);
});
},

View File

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

View File

@ -47,7 +47,7 @@ class _ListViewCard extends State<ListViewCardImage> {
child: Column(
children: [
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),
maxLines: 1,
),
@ -134,7 +134,7 @@ boxDecoration(ImageDTO imageDTO, appContext) {
image: imageDTO.title != null && imageDTO.source_ != null ? new DecorationImage(
fit: BoxFit.scaleDown,
image: new NetworkImage(
imageDTO.source_,
imageDTO.source_!,
),
) : null,
boxShadow: [

View File

@ -8,7 +8,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.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();
if (inputImageDTO != null) {
@ -18,7 +18,7 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
imageDTO.description = <TranslationDTO>[];
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedConfiguration.languages.forEach((element) {
managerAppContext.selectedConfiguration!.languages!.forEach((element) {
var translationTitleDTO = new TranslationDTO();
translationTitleDTO.language = element;
translationTitleDTO.value = "";
@ -27,8 +27,8 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
translationDescriptionDTO.language = element;
translationDescriptionDTO.value = "";
imageDTO.title.add(translationTitleDTO);
imageDTO.description.add(translationDescriptionDTO);
imageDTO.title!.add(translationTitleDTO);
imageDTO.description!.add(translationDescriptionDTO);
});
}
@ -59,7 +59,7 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
imageDTO.source_ = null;
} else {
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
@ -131,22 +131,22 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO, bool showTitle, bool showDescription) {
List<Widget> translations = <Widget>[];
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>[];
var translationTitleDTO = new TranslationDTO();
translationTitleDTO.language = language;
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>[];
var translationDescriptionDTO = new TranslationDTO();
translationDescriptionDTO.language = language;
translationDescriptionDTO.value = "";
imageDTO.description.add(translationDescriptionDTO);
imageDTO.description!.add(translationDescriptionDTO);
}
translations.add(
@ -178,9 +178,9 @@ getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO,
label: "Titre:",
color: kWhite,
isTitle: true,
initialValue: imageDTO.title.where((element) => element.language == language).first.value,
initialValue: imageDTO.title!.where((element) => element.language == language).first.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)
@ -188,9 +188,9 @@ getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO,
label: "Description:",
color: kWhite,
isTitle: false,
initialValue: imageDTO.description.where((element) => element.language == language).first.value,
initialValue: imageDTO.description!.where((element) => element.language == language).first.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';
class SliderConfig extends StatefulWidget {
final String color;
final String label;
final String? color;
final String? label;
final String initialValue;
final ValueChanged<String> onChanged;
const SliderConfig({
Key key,
Key? key,
this.color,
this.label,
this.initialValue,
this.onChanged,
required this.initialValue,
required this.onChanged,
}) : super(key: key);
@override
@ -26,16 +26,16 @@ class SliderConfig extends StatefulWidget {
}
class _SliderConfigState extends State<SliderConfig> {
SliderDTO sliderDTO;
late SliderDTO sliderDTO;
@override
void initState() {
super.initState();
sliderDTO = SliderDTO.fromJson(json.decode(widget.initialValue));
List<ImageDTO> test = new List<ImageDTO>.from(sliderDTO.images);
sliderDTO = SliderDTO.fromJson(json.decode(widget.initialValue))!;
List<ImageDTO> test = new List<ImageDTO>.from(sliderDTO.images!);
sliderDTO.images = test;
sliderDTO.images.sort((a, b) => a.order.compareTo(b.order));
sliderDTO.images!.sort((a, b) => a.order!.compareTo(b.order!));
}
@override
@ -49,11 +49,11 @@ class _SliderConfigState extends State<SliderConfig> {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final ImageDTO item = sliderDTO.images.removeAt(oldIndex);
sliderDTO.images.insert(newIndex, item);
final ImageDTO item = sliderDTO.images!.removeAt(oldIndex);
sliderDTO.images!.insert(newIndex, item);
var i = 0;
sliderDTO.images.forEach((image) {
sliderDTO.images!.forEach((image) {
image.order = i;
i++;
});
@ -72,10 +72,10 @@ class _SliderConfigState extends State<SliderConfig> {
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(vertical: 20.0),
children: List.generate(
sliderDTO.images.length,
sliderDTO.images!.length,
(index) {
return ListViewCardImage(
sliderDTO.images,
sliderDTO.images!,
index,
Key('$index'),
appContext,
@ -106,8 +106,8 @@ class _SliderConfigState extends State<SliderConfig> {
if (result != null)
{
setState(() {
result.order = sliderDTO.images.length;
sliderDTO.images.add(result);
result.order = sliderDTO.images!.length;
sliderDTO.images!.add(result);
widget.onChanged(jsonEncode(sliderDTO).toString());
});
}

View File

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

View File

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

View File

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

View File

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

View File

@ -69,7 +69,7 @@ class _ListViewCardSectionsState extends State<ListViewCardSections> {
),
),
child: Text(
"${sectionDTO.order+1}",
"${sectionDTO.order!+1}",
style: const TextStyle(color: Colors.white)
),
),
@ -94,7 +94,7 @@ class _ListViewCardSectionsState extends State<ListViewCardSections> {
Align(
alignment: Alignment.center,
child: AutoSizeText(
element.label,
element.label!,
style: new TextStyle(fontSize: 15),
maxLines: 2,
textAlign: TextAlign.center,
@ -123,7 +123,7 @@ boxDecoration(SectionDTO sectionDTO, appContext) {
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.18), BlendMode.dstATop),
image: new NetworkImage(
sectionDTO.imageSource,
sectionDTO.imageSource!,
),
) : null,
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) {
ConfigurationDTO configurationDTO = new ConfigurationDTO();
Size size = MediaQuery.of(mainContext).size;
configurationDTO.label = "";
showDialog(
builder: (BuildContext context) => AlertDialog(
@ -46,12 +47,12 @@ void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, Bu
),
InkWell(
onTap: () async {
FilePickerResult result = await FilePicker.platform.pickFiles();
FilePickerResult? result = await FilePicker.platform.pickFiles();
//String result = filePicker();
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);
Navigator.of(context).pop();
}
@ -102,7 +103,11 @@ void showNewConfiguration(AppContext appContext, ValueChanged<bool> isImport, Bu
color: kPrimaryColor,
textColor: kWhite,
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,
),
@ -134,7 +139,7 @@ String filePicker() {
void create(ConfigurationDTO configurationDTO, AppContext appContext, context) async {
if (configurationDTO.label != null) {
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.selectedConfiguration = null;
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_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.label = "";
sectionDTO.configurationId = configurationId;
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;
sectionDTO.type = isMobile ? SectionType.Article : SectionType.Map;
@ -84,8 +85,12 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
color: kPrimaryColor,
textColor: kWhite,
press: () {
//onYes();
create(sectionDTO, appContext, context, isSubSection, sendSubSection);
if(sectionDTO.label != null && sectionDTO.label!.length > 2) {
//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,
),
@ -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) {
sectionDTO.instanceId = (appContext.getContext() as ManagerAppContext).instanceId;
SectionDTO newSection = await appContext.getContext().clientAPI.sectionApi.sectionCreate(sectionDTO);
ManagerAppContext managerAppContext = appContext.getContext();
sectionDTO.instanceId = managerAppContext.instanceId;
SectionDTO? newSection = await managerAppContext.clientAPI!.sectionApi!.sectionCreate(sectionDTO);
if (!isSubSection) {
ManagerAppContext managerAppContext = appContext.getContext();
/*if (managerAppContext.selectedConfiguration.sectionIds == null) {
managerAppContext.selectedConfiguration.sectionIds = <String>[];
}
@ -112,7 +117,7 @@ void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context,
appContext.setContext(managerAppContext);
showNotification(Colors.green, kWhite, 'La section a été créée avec succès !', context, null);
} else {
sendSubSection(newSection);
sendSubSection!(newSection);
}
Navigator.of(context).pop();
}

View File

@ -14,10 +14,10 @@ class SectionReorderList extends StatefulWidget {
final List<SectionDTO> sectionsIn;
final ValueChanged<List<SectionDTO>> onChangedOrder;
const SectionReorderList({
Key key,
this.configurationId,
this.sectionsIn,
this.onChangedOrder,
Key? key,
required this.configurationId,
required this.sectionsIn,
required this.onChangedOrder,
}) : super(key: key);
@override
@ -25,7 +25,7 @@ class SectionReorderList extends StatefulWidget {
}
class _SectionReorderListState extends State<SectionReorderList> {
List<SectionDTO> sections;
late List<SectionDTO> sections;
String filterSearch = '';
@override
@ -60,7 +60,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
Size size = MediaQuery.of(context).size;
ManagerAppContext managerAppContext = appContext.getContext();
ConfigurationDTO currentConfiguration = managerAppContext.selectedConfiguration;
ConfigurationDTO currentConfiguration = managerAppContext.selectedConfiguration!;
return Stack(
children: [
@ -79,7 +79,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
sections,
index,
Key('$index'),
currentConfiguration.isMobile,
currentConfiguration.isMobile!,
appContext,
(section) {
setState(() {
@ -143,7 +143,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
right: 10,
child: InkWell(
onTap: () {
showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile);
showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile!);
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,
@ -174,6 +174,6 @@ class _SectionReorderListState extends State<SectionReorderList> {
}
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),
child: DropDownConfig(
configurations: snapshot.data,
selectedConfigurationId: inputDevice.configurationId,
selectedConfigurationId: inputDevice.configurationId!,
onChange: (ConfigurationDTO configurationOut) {
inputDevice.configuration = configurationOut.label;
inputDevice.configurationId = configurationOut.id;
@ -136,7 +136,7 @@ getConfigurationsElement(DeviceDTO inputDevice, data, Function onGetResult) {
color: inputDevice.configurationId == configuration.id ? kPrimaryColor : null,
child: ListTile(
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;
}
Future<List<ConfigurationDTO>> getConfigurations(AppContext appContext) async {
List<ConfigurationDTO> configurations = await (appContext.getContext() as ManagerAppContext).clientAPI.configurationApi.configurationGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId);
Future<List<ConfigurationDTO>?> getConfigurations(AppContext appContext) async {
List<ConfigurationDTO>? configurations = await (appContext.getContext() as ManagerAppContext).clientAPI!.configurationApi!.configurationGet(instanceId: (appContext.getContext() as ManagerAppContext).instanceId);
//print("number of configurations " + configurations.length.toString());
configurations.forEach((element) {
//print(element);
});
if(configurations != null) {
configurations.forEach((element) {
//print(element);
});
}
return configurations;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,10 +14,10 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
switch(resourceDTO.type) {
case ResourceType.Image:
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,
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) {
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) {
return child;
}
@ -26,7 +26,7 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes
loadingProgress.expectedTotalBytes!
: null,
),
);
@ -38,7 +38,7 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
resourceDTO.data,
fit:BoxFit.fill,
loadingBuilder: (BuildContext context, Widget child,
ImageChunkEvent loadingProgress) {
ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) {
return child;
}
@ -47,7 +47,7 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
color: kPrimaryColor,
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes
loadingProgress.expectedTotalBytes!
: 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 {
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));
final base64Str = base64.encode(test2);
Uint8List base64String = base64Decode(base64Str); // LOAD DATA

View File

@ -15,8 +15,8 @@ dynamic showNewResource(AppContext appContext, BuildContext context) async {
ResourceDTO resourceDetailDTO = new ResourceDTO();
Size size = MediaQuery.of(context).size;
var fileName;
List<File> filesToSend;
List<PlatformFile> filesToSendWeb;
List<File>? filesToSend;
List<PlatformFile>? filesToSendWeb;
var result = await showDialog(
builder: (BuildContext context) => AlertDialog(
@ -89,7 +89,7 @@ dynamic showNewResource(AppContext appContext, BuildContext context) async {
color: kPrimaryColor,
textColor: kWhite,
press: () {
if (resourceDetailDTO.label != null && resourceDetailDTO.label.trim() != '') {
if (resourceDetailDTO.label != null && resourceDetailDTO.label!.trim() != '') {
if(kIsWeb) {
if(resourceDetailDTO.data != null || filesToSendWeb != null) {
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);
}
} 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]);
} else {
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/multi_select_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/constants.dart';
import 'package:manager_api_new/api.dart';
@ -15,11 +16,11 @@ class ResourceBodyGrid extends StatefulWidget {
final bool isAddButton;
final List<ResourceType> resourceTypesIn;
const ResourceBodyGrid({
Key key,
this.resources,
this.onSelect,
this.isAddButton,
this.resourceTypesIn,
Key? key,
required this.resources,
required this.onSelect,
required this.isAddButton,
required this.resourceTypesIn,
}) : super(key: key);
@override
@ -27,11 +28,11 @@ class ResourceBodyGrid extends StatefulWidget {
}
class _ResourceBodyGridState extends State<ResourceBodyGrid> {
List<String> filterTypes;
List<String> currentFilterTypes;
late List<String> filterTypes;
late List<String> currentFilterTypes;
String filterSearch = '';
List<String> selectedTypes;
List<ResourceDTO> resourcesToShow;
late List<String> selectedTypes;
late List<ResourceDTO> resourcesToShow;
@override
void initState() {
@ -77,7 +78,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
isMultiple: true,
onChanged: (result) {
setState(() {
selectedTypes = result;
selectedTypes = result as List<String>; // TO TEST
filterResource();
});
},
@ -158,7 +159,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
Align(
alignment: Alignment.center,
child: AutoSizeText(
resource.label == null ? "" : resource.label,
resource.label == null ? "" : resource.label!,
style: new TextStyle(fontSize: 20),
maxLines: 1,
),
@ -183,7 +184,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
}
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();
resourcesToShow = resourcesToShow.where((resource) => resource.id == null || getTypesInSelected.contains(resource.type)).toList();
}
@ -198,7 +199,7 @@ boxDecoration(dynamic resourceDetailDTO, appContext) {
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.3), BlendMode.dstATop),
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,
boxShadow: [

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import 'package:manager_api_new/api.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(
builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
@ -112,7 +112,7 @@ Future<ResourceDTO> showResource(ResourceDTO resourceDTO, AppContext appContext,
icon: Icons.check,
color: kPrimaryColor,
press: () {
if (resourceDTO.label != null && resourceDTO.label.length > 2) {
if (resourceDTO.label != null && resourceDTO.label!.length > 2) {
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 ?",
() {},
() async {
await appContext.getContext().clientAPI.resourceApi.resourceDelete(resourceDTO.id);
await (appContext.getContext() as ManagerAppContext).clientAPI!.resourceApi!.resourceDelete(resourceDTO.id!);
// just to refresh
ManagerAppContext managerAppContext = appContext.getContext();
appContext.setContext(managerAppContext);

View File

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

View File

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

View File

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

View File

@ -21,9 +21,12 @@ Future<void> main() async {
var session = await loadJsonSessionFile();
ManagerAppContext managerAppContext = new ManagerAppContext();
final MyApp myApp = MyApp(
initialRoute: initialRoute,
session: session
session: session,
managerAppContext: managerAppContext
//context: localContext,
);
@ -34,7 +37,7 @@ class MyApp extends StatefulWidget {
final String initialRoute;
final Session session;
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.
@override

View File

@ -49,14 +49,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.10.0"
audioplayers:
dependency: "direct main"
audio_session:
dependency: transitive
description:
name: audioplayers
sha256: d50acc9659568fe0c14a5fd81ec51cdd5948b5362186572a58d76bc745302202
name: audio_session
sha256: e4acc4e9eaa32436dfc5d7aed7f0a370f2d7bb27ee27de30d6c4f220c2a05c73
url: "https://pub.dev"
source: hosted
version: "0.18.3"
version: "0.1.13"
auto_size_text:
dependency: "direct main"
description:
@ -408,6 +408,30 @@ packages:
url: "https://pub.dev"
source: hosted
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:
dependency: transitive
description:
@ -861,5 +885,5 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.18.0 <3.0.1"
dart: ">=2.18.0 <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
environment:
sdk: ">=2.7.0 <3.0.1"
sdk: ">=2.16.2 <3.0.1"
dependencies:
flutter: