Service generation update + select languages + add new config popup + add new section popup
This commit is contained in:
parent
6aca22b758
commit
6fb7dbdad7
89
lib/Components/multi_select_container.dart
Normal file
89
lib/Components/multi_select_container.dart
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
|
||||||
|
class MultiSelectContainer extends StatelessWidget {
|
||||||
|
final Color color;
|
||||||
|
final String label;
|
||||||
|
final List<String> values;
|
||||||
|
final List<String> initialValue;
|
||||||
|
final ValueChanged<List<dynamic>> onChanged;
|
||||||
|
const MultiSelectContainer({
|
||||||
|
Key key,
|
||||||
|
this.color = kSecond,
|
||||||
|
this.label,
|
||||||
|
this.values,
|
||||||
|
this.initialValue,
|
||||||
|
this.onChanged,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
return Container(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
child: Text(label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Container(
|
||||||
|
width: size.width *0.2,
|
||||||
|
child: MultiSelectChip(
|
||||||
|
values,
|
||||||
|
initialValue,
|
||||||
|
onSelectionChanged: (selectedList) {
|
||||||
|
onChanged(selectedList);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MultiSelectChip extends StatefulWidget {
|
||||||
|
final List<String> values;
|
||||||
|
final List<String> selectedValues;
|
||||||
|
final Function(List<String>) onSelectionChanged; // +added
|
||||||
|
MultiSelectChip(
|
||||||
|
this.values,
|
||||||
|
this.selectedValues,
|
||||||
|
{this.onSelectionChanged} // +added
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
_MultiSelectChipState createState() => _MultiSelectChipState();
|
||||||
|
}
|
||||||
|
class _MultiSelectChipState extends State<MultiSelectChip> {
|
||||||
|
_buildChoiceList() {
|
||||||
|
List<Widget> choices = List();
|
||||||
|
widget.values.forEach((item) {
|
||||||
|
choices.add(Container(
|
||||||
|
padding: const EdgeInsets.all(2.0),
|
||||||
|
child: ChoiceChip(
|
||||||
|
label: Text(item, style: TextStyle(color: kBlack)),
|
||||||
|
selected: widget.selectedValues.contains(item),
|
||||||
|
selectedColor: kPrimaryColor,
|
||||||
|
onSelected: (selected) {
|
||||||
|
setState(() {
|
||||||
|
widget.selectedValues.contains(item)
|
||||||
|
? widget.selectedValues.remove(item)
|
||||||
|
: widget.selectedValues.add(item);
|
||||||
|
widget.onSelectionChanged(widget.selectedValues); // +added
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
return choices;
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Wrap(
|
||||||
|
children: _buildChoiceList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,15 +2,13 @@ import 'package:auto_size_text/auto_size_text.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/painting.dart';
|
import 'package:flutter/painting.dart';
|
||||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
|
||||||
import 'package:manager_app/Components/color_picker.dart';
|
|
||||||
import 'package:manager_app/Components/color_picker_input_container.dart';
|
import 'package:manager_app/Components/color_picker_input_container.dart';
|
||||||
import 'package:manager_app/Components/confirmation_dialog.dart';
|
import 'package:manager_app/Components/confirmation_dialog.dart';
|
||||||
import 'package:manager_app/Components/message_notification.dart';
|
import 'package:manager_app/Components/multi_select_container.dart';
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
import 'package:manager_app/Components/rounded_input_field.dart';
|
|
||||||
import 'package:manager_app/Components/string_input_container.dart';
|
import 'package:manager_app/Components/string_input_container.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
|
import 'package:manager_app/Screens/Configurations/new_section_popup.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
import 'package:manager_app/client.dart';
|
import 'package:manager_app/client.dart';
|
||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
@ -30,15 +28,14 @@ class ConfigurationDetailScreen extends StatefulWidget {
|
|||||||
class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||||
ConfigurationDTO configurationDTO;
|
ConfigurationDTO configurationDTO;
|
||||||
SectionDTO selectedSection;
|
SectionDTO selectedSection;
|
||||||
|
List<String> languages = ["FR", "NL", "EN", "DE"];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appContext = Provider.of<AppContext>(context);
|
final appContext = Provider.of<AppContext>(context);
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
return Container(
|
return Container(
|
||||||
child: Column(
|
child: FutureBuilder(
|
||||||
children: [
|
|
||||||
FutureBuilder(
|
|
||||||
future: getConfiguration(this.widget, appContext.getContext().clientAPI),
|
future: getConfiguration(this.widget, appContext.getContext().clientAPI),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
@ -51,20 +48,14 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
]
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget bodyConfiguration(ConfigurationDTO configurationDTO, Size size, AppContext appContext, BuildContext context) {
|
Widget bodyConfiguration(ConfigurationDTO configurationDTO, Size size, AppContext appContext, BuildContext context) {
|
||||||
|
return Column(
|
||||||
return Container(
|
|
||||||
height: size.height*0.96,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: size.width*0.9,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -107,51 +98,39 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
), // TITLE
|
), // TITLE
|
||||||
Padding(
|
Container(
|
||||||
padding: const EdgeInsets.all(15.0),
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
//color: Colors.yellowAccent,
|
|
||||||
height: size.height*0.65,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Container(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
StringContainer(
|
StringContainer(
|
||||||
label: "Label :",
|
label: "Nom :",
|
||||||
initialValue: configurationDTO.label,
|
initialValue: configurationDTO.label,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
configurationDTO.label = value;
|
configurationDTO.label = value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Row(
|
MultiSelectContainer(
|
||||||
children: [
|
label: "Langues :",
|
||||||
Align(
|
initialValue: configurationDTO.languages != null ? configurationDTO.languages: [],
|
||||||
alignment: AlignmentDirectional.centerStart,
|
values: languages,
|
||||||
child: Text("Languages :", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: Container(
|
|
||||||
width: size.width *0.2,
|
|
||||||
child: RoundedInputField(
|
|
||||||
color: kSecond,
|
|
||||||
textColor: kBlack,
|
|
||||||
initialValue: configurationDTO.label,
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
configurationDTO.label = value;
|
var tempOutput = new List<String>.from(value);
|
||||||
|
configurationDTO.languages = tempOutput;
|
||||||
|
print(configurationDTO.languages);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
@ -159,14 +138,14 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ColorPickerInputContainer(
|
ColorPickerInputContainer(
|
||||||
label: "Primary color :",
|
label: "Couleur principal :",
|
||||||
color: configurationDTO.primaryColor,
|
color: configurationDTO.primaryColor,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
configurationDTO.primaryColor = value;
|
configurationDTO.primaryColor = value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ColorPickerInputContainer(
|
ColorPickerInputContainer(
|
||||||
label: "Secondary color :",
|
label: "Couleur secondaire :",
|
||||||
color: appContext.getContext().selectedConfiguration.secondaryColor,
|
color: appContext.getContext().selectedConfiguration.secondaryColor,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
configurationDTO.secondaryColor = value;
|
configurationDTO.secondaryColor = value;
|
||||||
@ -176,18 +155,22 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Align(
|
|
||||||
alignment: AlignmentDirectional.centerStart,
|
|
||||||
child: Text("Sections :", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
|
||||||
),
|
),
|
||||||
FutureBuilder(
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
border: Border.all(width: 0.5, color: kSecond)
|
||||||
|
),
|
||||||
|
child: FutureBuilder(
|
||||||
future: getSections(configurationDTO, appContext.getContext().clientAPI),
|
future: getSections(configurationDTO, appContext.getContext().clientAPI),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
var tempOutput = new List<SectionDTO>.from(snapshot.data);
|
var tempOutput = new List<SectionDTO>.from(snapshot.data);
|
||||||
print(tempOutput);
|
|
||||||
tempOutput.add(SectionDTO(id: null));
|
tempOutput.add(SectionDTO(id: null));
|
||||||
return bodyGrid(tempOutput, size, appContext);
|
return bodyGrid(configurationDTO, tempOutput, size, appContext);
|
||||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
return Text("No data");
|
return Text("No data");
|
||||||
} else {
|
} else {
|
||||||
@ -195,11 +178,58 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),// FIELDS SECTION
|
),// FIELDS SECTION
|
||||||
|
getButtons(configurationDTO, appContext),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getElement(dynamic element, Size size) {
|
||||||
|
if (element.id != null) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
Align(
|
Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: AutoSizeText(
|
||||||
|
element.label,
|
||||||
|
style: new TextStyle(fontSize: 25),
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.add,
|
||||||
|
color: kTextLightColor,
|
||||||
|
size: 40.0,
|
||||||
|
),
|
||||||
|
AutoSizeText(
|
||||||
|
"Nouvelle section",
|
||||||
|
maxLines: 2,
|
||||||
|
style: new TextStyle(color: kWhite, fontWeight: FontWeight.w400),
|
||||||
|
minFontSize: 0,
|
||||||
|
maxFontSize: 40,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getButtons(ConfigurationDTO configurationDTO, AppContext appContext) {
|
||||||
|
return Align(
|
||||||
alignment: AlignmentDirectional.bottomCenter,
|
alignment: AlignmentDirectional.bottomCenter,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@ -248,46 +278,10 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),// BUTTONS
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getElement(dynamic element, Size size) {
|
Widget bodyGrid(ConfigurationDTO configurationDTO, data, Size size, AppContext appContext) {
|
||||||
if (element.id != null) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: AutoSizeText(
|
|
||||||
element.label,
|
|
||||||
style: new TextStyle(fontSize: 25),
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: AutoSizeText(
|
|
||||||
DateFormat('dd/MM/yyyy').format(element.dateCreation),
|
|
||||||
style: new TextStyle(fontSize: 18, fontFamily: ""),
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: kTextLightColor,
|
|
||||||
size: 50.0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget bodyGrid(data, Size size, AppContext appContext) {
|
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
|
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
|
||||||
@ -297,7 +291,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (data[index].id == null) {
|
if (data[index].id == null) {
|
||||||
print("open modal to create new section !");
|
showNewSection(configurationDTO, appContext, context);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
@ -342,7 +336,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
() {},
|
() {},
|
||||||
() async {
|
() async {
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
ConfigurationDTO configuration = await appContext.getContext().clientAPI.configurationApi.configurationDelete(configurationDTO.id);
|
await appContext.getContext().clientAPI.configurationApi.configurationDelete(configurationDTO.id);
|
||||||
managerAppContext.selectedConfiguration = null;
|
managerAppContext.selectedConfiguration = null;
|
||||||
appContext.setContext(managerAppContext);
|
appContext.setContext(managerAppContext);
|
||||||
},
|
},
|
||||||
@ -358,7 +352,6 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<ConfigurationDTO> getConfiguration(ConfigurationDetailScreen widget, Client client) async {
|
Future<ConfigurationDTO> getConfiguration(ConfigurationDetailScreen widget, Client client) async {
|
||||||
print(widget.id);
|
|
||||||
ConfigurationDTO configuration = await client.configurationApi.configurationGetDetail(widget.id);
|
ConfigurationDTO configuration = await client.configurationApi.configurationGetDetail(widget.id);
|
||||||
print(configuration);
|
print(configuration);
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'package:auto_size_text/auto_size_text.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/configuration_detail_screen.dart';
|
import 'package:manager_app/Screens/Configurations/configuration_detail_screen.dart';
|
||||||
|
import 'package:manager_app/Screens/Configurations/new_configuration_popup.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:managerapi/api.dart';
|
import 'package:managerapi/api.dart';
|
||||||
@ -61,7 +62,7 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (data[index].id == null) {
|
if (data[index].id == null) {
|
||||||
print("open modal to create new config !");
|
showNewConfiguration(appContext, context);
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
|||||||
89
lib/Screens/Configurations/new_configuration_popup.dart
Normal file
89
lib/Screens/Configurations/new_configuration_popup.dart
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/rounded_button.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:managerapi/api.dart';
|
||||||
|
import 'package:overlay_support/overlay_support.dart';
|
||||||
|
|
||||||
|
void showNewConfiguration(AppContext appContext, BuildContext context) {
|
||||||
|
ConfigurationDTO configurationDTO = new ConfigurationDTO();
|
||||||
|
showDialog(
|
||||||
|
builder: (BuildContext context) => AlertDialog(
|
||||||
|
content: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
StringContainer(
|
||||||
|
label: "Nom :",
|
||||||
|
initialValue: configurationDTO.label,
|
||||||
|
onChanged: (value) {
|
||||||
|
configurationDTO.label = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: 150,
|
||||||
|
height: 70,
|
||||||
|
child: RoundedButton(
|
||||||
|
text: "Créer",
|
||||||
|
icon: Icons.check,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
textColor: kWhite,
|
||||||
|
press: () {
|
||||||
|
//onYes();
|
||||||
|
create(configurationDTO, appContext, context);
|
||||||
|
},
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
), context: context
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void create(ConfigurationDTO configurationDTO, AppContext appContext, context) async {
|
||||||
|
if (configurationDTO.label != null) {
|
||||||
|
ConfigurationDTO newConfiguration = await appContext.getContext().clientAPI.configurationApi.configurationCreate(configurationDTO);
|
||||||
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
managerAppContext.selectedConfiguration = null;
|
||||||
|
appContext.setContext(managerAppContext);
|
||||||
|
|
||||||
|
// popup a toast.
|
||||||
|
toast('La configuration a été créée avec succès');
|
||||||
|
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
93
lib/Screens/Configurations/new_section_popup.dart
Normal file
93
lib/Screens/Configurations/new_section_popup.dart
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/rounded_button.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:managerapi/api.dart';
|
||||||
|
import 'package:overlay_support/overlay_support.dart';
|
||||||
|
|
||||||
|
void showNewSection(ConfigurationDTO configurationDTO, AppContext appContext, BuildContext context) {
|
||||||
|
SectionDTO sectionDTO = new SectionDTO();
|
||||||
|
sectionDTO.configurationId = configurationDTO.id;
|
||||||
|
showDialog(
|
||||||
|
builder: (BuildContext context) => AlertDialog(
|
||||||
|
content: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text("Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
StringContainer(
|
||||||
|
label: "Nom :",
|
||||||
|
initialValue: sectionDTO.label,
|
||||||
|
onChanged: (value) {
|
||||||
|
sectionDTO.label = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: 150,
|
||||||
|
height: 70,
|
||||||
|
child: RoundedButton(
|
||||||
|
text: "Créer",
|
||||||
|
icon: Icons.check,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
textColor: kWhite,
|
||||||
|
press: () {
|
||||||
|
//onYes();
|
||||||
|
create(sectionDTO, appContext, context);
|
||||||
|
},
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
), context: context
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context) async {
|
||||||
|
if (sectionDTO.label != null) {
|
||||||
|
SectionDTO newSection = await appContext.getContext().clientAPI.sectionApi.sectionCreate(sectionDTO);
|
||||||
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
if (managerAppContext.selectedConfiguration.sectionIds == null) {
|
||||||
|
managerAppContext.selectedConfiguration.sectionIds = new List<String>();
|
||||||
|
}
|
||||||
|
managerAppContext.selectedConfiguration.sectionIds.add(newSection.id);
|
||||||
|
appContext.setContext(managerAppContext);
|
||||||
|
|
||||||
|
// popup a toast.
|
||||||
|
toast('La section a été créée avec succès');
|
||||||
|
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,7 +17,7 @@ Method | HTTP request | Description
|
|||||||
|
|
||||||
|
|
||||||
# **configurationCreate**
|
# **configurationCreate**
|
||||||
> RessourceDetailDTO configurationCreate(configurationDTO)
|
> ConfigurationDTO configurationCreate(configurationDTO)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
[**RessourceDetailDTO**](RessourceDetailDTO.md)
|
[**ConfigurationDTO**](ConfigurationDTO.md)
|
||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class ConfigurationApi {
|
|||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
/// * [ConfigurationDTO] configurationDTO (required):
|
/// * [ConfigurationDTO] configurationDTO (required):
|
||||||
Future<RessourceDetailDTO> configurationCreate(ConfigurationDTO configurationDTO) async {
|
Future<ConfigurationDTO> configurationCreate(ConfigurationDTO configurationDTO) async {
|
||||||
final response = await configurationCreateWithHttpInfo(configurationDTO);
|
final response = await configurationCreateWithHttpInfo(configurationDTO);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||||
@ -73,9 +73,9 @@ class ConfigurationApi {
|
|||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'RessourceDetailDTO') as RessourceDetailDTO;
|
return apiClient.deserialize(_decodeBodyBytes(response), 'ConfigurationDTO') as ConfigurationDTO;
|
||||||
}
|
}
|
||||||
return Future<RessourceDetailDTO>.value(null);
|
return Future<ConfigurationDTO>.value(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs an HTTP 'DELETE /api/Configuration/{id}' operation and returns the [Response].
|
/// Performs an HTTP 'DELETE /api/Configuration/{id}' operation and returns the [Response].
|
||||||
|
|||||||
@ -47,7 +47,7 @@ paths:
|
|||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/RessourceDetailDTO'
|
$ref: '#/components/schemas/ConfigurationDTO'
|
||||||
'400':
|
'400':
|
||||||
description: ''
|
description: ''
|
||||||
content:
|
content:
|
||||||
@ -901,6 +901,31 @@ components:
|
|||||||
dateCreation:
|
dateCreation:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
RessourceDTO:
|
||||||
|
type: object
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
type:
|
||||||
|
$ref: '#/components/schemas/RessourceType'
|
||||||
|
label:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
RessourceType:
|
||||||
|
type: string
|
||||||
|
description: ''
|
||||||
|
x-enumNames:
|
||||||
|
- Image
|
||||||
|
- Video
|
||||||
|
- ImageUrl
|
||||||
|
- VideoUrl
|
||||||
|
enum:
|
||||||
|
- Image
|
||||||
|
- Video
|
||||||
|
- ImageUrl
|
||||||
|
- VideoUrl
|
||||||
RessourceDetailDTO:
|
RessourceDetailDTO:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
@ -919,31 +944,6 @@ components:
|
|||||||
data:
|
data:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
RessourceType:
|
|
||||||
type: string
|
|
||||||
description: ''
|
|
||||||
x-enumNames:
|
|
||||||
- Image
|
|
||||||
- Video
|
|
||||||
- ImageUrl
|
|
||||||
- VideoUrl
|
|
||||||
enum:
|
|
||||||
- Image
|
|
||||||
- Video
|
|
||||||
- ImageUrl
|
|
||||||
- VideoUrl
|
|
||||||
RessourceDTO:
|
|
||||||
type: object
|
|
||||||
additionalProperties: false
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
nullable: true
|
|
||||||
type:
|
|
||||||
$ref: '#/components/schemas/RessourceType'
|
|
||||||
label:
|
|
||||||
type: string
|
|
||||||
nullable: true
|
|
||||||
SectionDTO:
|
SectionDTO:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
|||||||
@ -123,6 +123,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
multiselect_formfield:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: multiselect_formfield
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.6"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -29,6 +29,7 @@ dependencies:
|
|||||||
overlay_support: 1.0.5-hotfix1
|
overlay_support: 1.0.5-hotfix1
|
||||||
auto_size_text: ^2.1.0
|
auto_size_text: ^2.1.0
|
||||||
flutter_colorpicker: ^0.4.0
|
flutter_colorpicker: ^0.4.0
|
||||||
|
multiselect_formfield: ^0.1.6
|
||||||
managerapi:
|
managerapi:
|
||||||
path: manager_api
|
path: manager_api
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user