224 lines
8.7 KiB
Dart
224 lines
8.7 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:manager_app/Components/image_input_container.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/multi_string_input_container.dart';
|
|
import 'package:manager_app/Components/rounded_button.dart';
|
|
import 'package:manager_app/Components/string_input_container.dart';
|
|
import 'package:manager_app/Components/text_form_input_container.dart';
|
|
import 'package:manager_app/Models/managerContext.dart';
|
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart';
|
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Slider/slider_config.dart';
|
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/WebOrVideo/web_video_config.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:manager_api_new/api.dart';
|
|
|
|
import '../Map/map_config.dart';
|
|
import 'menu_config.dart';
|
|
|
|
void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext appContext, BuildContext context) {
|
|
|
|
Size size = MediaQuery.of(context).size;
|
|
showDialog(
|
|
builder: (BuildContext context) => AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
|
),
|
|
content: Container(
|
|
width: size.width *0.85,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Text("Modifier sous section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
StringInputContainer(
|
|
label: "Nom :",
|
|
initialValue: subSectionDTO.label,
|
|
onChanged: (String name) {
|
|
subSectionDTO.label = name;
|
|
},
|
|
),
|
|
ImageInputContainer(
|
|
label: "Image :",
|
|
initialValue: subSectionDTO.imageId,
|
|
color: kPrimaryColor,
|
|
onChanged: (ResourceDTO resource) {
|
|
if(resource.id == null) {
|
|
subSectionDTO.imageId = null;
|
|
subSectionDTO.imageSource = null;
|
|
} else {
|
|
subSectionDTO.imageId = resource.id;
|
|
subSectionDTO.imageSource = resource.url;
|
|
}
|
|
},
|
|
isSmall: true,
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
height: size.height * 0.1,
|
|
width: double.infinity,
|
|
constraints: BoxConstraints(minHeight: 50),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Container(
|
|
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
|
child: MultiStringInputContainer(
|
|
label: "Titre affiché:",
|
|
modalLabel: "Titre",
|
|
fontSize: 20,
|
|
isHTML: true,
|
|
color: kPrimaryColor,
|
|
initialValue: subSectionDTO.title != null ? subSectionDTO.title! : [],
|
|
onGetResult: (value) {
|
|
if (subSectionDTO.title != value) {
|
|
subSectionDTO.title = value;
|
|
}
|
|
},
|
|
maxLines: 1,
|
|
isTitle: true
|
|
),
|
|
),
|
|
Container(
|
|
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
|
child: MultiStringInputContainer(
|
|
label: "Description affichée:",
|
|
modalLabel: "Description",
|
|
fontSize: 20,
|
|
isHTML: true,
|
|
color: kPrimaryColor,
|
|
initialValue: subSectionDTO.description != null ? subSectionDTO.description! : [],
|
|
onGetResult: (value) {
|
|
if (subSectionDTO.description != value) {
|
|
subSectionDTO.description = value;
|
|
}
|
|
},
|
|
maxLines: 1,
|
|
isTitle: false
|
|
),
|
|
),
|
|
],
|
|
)
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: kWhite,
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: Border.all(width: 0.5, color: kSecond)
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: getSpecificData(subSectionDTO, context, appContext),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
child: Container(
|
|
width: 175,
|
|
height: 70,
|
|
child: RoundedButton(
|
|
text: "Annuler",
|
|
icon: Icons.undo,
|
|
color: kSecond,
|
|
press: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
Align(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
child: Container(
|
|
width: subSectionDTO != null ? 220: 150,
|
|
height: 70,
|
|
child: RoundedButton(
|
|
text: "Sauvegarder",
|
|
icon: Icons.check,
|
|
color: kPrimaryColor,
|
|
textColor: kWhite,
|
|
press: () {
|
|
getResult(subSectionDTO);
|
|
Navigator.of(context).pop();
|
|
},
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
), context: context
|
|
);
|
|
}
|
|
|
|
getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appContext) {
|
|
switch(sectionDTO.type) {
|
|
case SectionType.Map:
|
|
return MapConfig(
|
|
initialValue: sectionDTO.data!,
|
|
onChanged: (String data) {
|
|
//print("Received info in parent");
|
|
//print(data);
|
|
sectionDTO.data = data;
|
|
},
|
|
);
|
|
case SectionType.Slider:
|
|
return Container(
|
|
width: MediaQuery.of(context).size.width * 0.5,
|
|
height: MediaQuery.of(context).size.height * 0.5,
|
|
child: SliderConfig(
|
|
initialValue: sectionDTO.data!,
|
|
onChanged: (String data) {
|
|
//print("Received info in parent");
|
|
//print(data);
|
|
sectionDTO.data = data;
|
|
},
|
|
),
|
|
);
|
|
case SectionType.Video:
|
|
case SectionType.Web:
|
|
return WebOrVideoConfig(
|
|
label: sectionDTO.type == SectionType.Video ? "Url de la vidéo:": "Url du site web:",
|
|
initialValue: sectionDTO.data!,
|
|
onChanged: (String data) {
|
|
sectionDTO.data = data;
|
|
},
|
|
);
|
|
case SectionType.Menu:
|
|
return MenuConfig(
|
|
initialValue: sectionDTO.data!,
|
|
onChanged: (String data) {
|
|
//print("Received info in parent");
|
|
//print(data);
|
|
sectionDTO.data = data;
|
|
},
|
|
);
|
|
case SectionType.Quizz:
|
|
return QuizzConfig(
|
|
initialValue: sectionDTO.data!,
|
|
onChanged: (String data) {
|
|
//print("Received info in parent");
|
|
//print(data);
|
|
sectionDTO.data = data;
|
|
},
|
|
);
|
|
}
|
|
}
|