Layout menu (translation as horizontal list) + add filter in resource screen (name)
This commit is contained in:
parent
171fce5e24
commit
ab833808a4
@ -48,7 +48,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: size.width *0.10,
|
width: size.width *0.08,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showSelectResourceModal(
|
showSelectResourceModal(
|
||||||
|
|||||||
@ -7,6 +7,7 @@ class TextFormInputContainer extends StatelessWidget {
|
|||||||
final String label;
|
final String label;
|
||||||
final String initialValue;
|
final String initialValue;
|
||||||
final bool isTitle;
|
final bool isTitle;
|
||||||
|
final int maxLines;
|
||||||
final ValueChanged<String> onChanged;
|
final ValueChanged<String> onChanged;
|
||||||
const TextFormInputContainer({
|
const TextFormInputContainer({
|
||||||
Key key,
|
Key key,
|
||||||
@ -14,6 +15,7 @@ class TextFormInputContainer extends StatelessWidget {
|
|||||||
this.label,
|
this.label,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
this.isTitle,
|
this.isTitle,
|
||||||
|
this.maxLines = 5,
|
||||||
this.onChanged
|
this.onChanged
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ class TextFormInputContainer extends StatelessWidget {
|
|||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
textInputAction: TextInputAction.newline,
|
textInputAction: TextInputAction.newline,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
maxLines: 5,
|
maxLines: maxLines,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
maxLength: isTitle ? 50 : 2000,
|
maxLength: isTitle ? 50 : 2000,
|
||||||
|
|||||||
@ -29,6 +29,7 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
|||||||
children: [
|
children: [
|
||||||
Text("Modifier sous section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
Text("Modifier sous section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
Column(
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
@ -48,34 +49,14 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
|||||||
subSectionDTO.imageId = resource.id;
|
subSectionDTO.imageId = resource.id;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
/*Column(
|
|
||||||
children: [
|
|
||||||
StringInputContainer(
|
|
||||||
label: "Latitude :",
|
|
||||||
initialValue: geoPointDTO.latitude,
|
|
||||||
onChanged: (value) {
|
|
||||||
geoPointDTO.latitude = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
StringInputContainer(
|
|
||||||
label: "Longitude :",
|
|
||||||
initialValue: geoPointDTO.longitude,
|
|
||||||
onChanged: (value) {
|
|
||||||
geoPointDTO.longitude = value;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)*/
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
height: size.height * 0.33,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
color: Colors.lightBlue,
|
child: ListView(
|
||||||
child: SingleChildScrollView(
|
scrollDirection: Axis.horizontal,
|
||||||
child: Row(
|
children: getTranslations(context, appContext, subSectionDTO),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: getTranslations(context, appContext, subSectionDTO),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@ -190,51 +171,54 @@ getTranslations(BuildContext context, AppContext appContext, SectionDTO subSecti
|
|||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
for(var language in managerAppContext.selectedConfiguration.languages) {
|
for(var language in managerAppContext.selectedConfiguration.languages) {
|
||||||
translations.add(
|
translations.add(
|
||||||
Padding(
|
SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(8.0),
|
child: Padding(
|
||||||
child: Row(
|
padding: const EdgeInsets.all(8.0),
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
child: Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
Container(
|
children: [
|
||||||
width: MediaQuery.of(context).size.width *0.05,
|
Container(
|
||||||
height: MediaQuery.of(context).size.height *0.2,
|
width: MediaQuery.of(context).size.width *0.05,
|
||||||
decoration: BoxDecoration(
|
height: MediaQuery.of(context).size.height *0.2,
|
||||||
border: Border(
|
decoration: BoxDecoration(
|
||||||
right: BorderSide(width: 1.5, color: kSecond),
|
border: Border(
|
||||||
|
right: BorderSide(width: 1.5, color: kSecond),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Center(child: AutoSizeText(language.toUpperCase()))
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: Container(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
TextFormInputContainer(
|
||||||
|
label: "Titre:",
|
||||||
|
color: kWhite,
|
||||||
|
isTitle: true,
|
||||||
|
maxLines: 1,
|
||||||
|
initialValue: subSectionDTO.title.where((element) => element.language == language).first.value,
|
||||||
|
onChanged: (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,
|
||||||
|
onChanged: (value) {
|
||||||
|
subSectionDTO.description.where((element) => element.language == language).first.value = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Center(child: AutoSizeText(language.toUpperCase()))
|
)
|
||||||
),
|
],
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: Container(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
TextFormInputContainer(
|
|
||||||
label: "Titre:",
|
|
||||||
color: kWhite,
|
|
||||||
isTitle: true,
|
|
||||||
initialValue: subSectionDTO.title.where((element) => element.language == language).first.value,
|
|
||||||
onChanged: (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,
|
|
||||||
onChanged: (value) {
|
|
||||||
subSectionDTO.description.where((element) => element.language == language).first.value = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -36,19 +36,17 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
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 SingleChildScrollView(
|
return FutureBuilder(
|
||||||
child: FutureBuilder(
|
future: getSection(widget.id, appContext.getContext().clientAPI),
|
||||||
future: getSection(widget.id, appContext.getContext().clientAPI),
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
return bodySection(snapshot.data, size, appContext, context);
|
||||||
return bodySection(snapshot.data, size, appContext, context);
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
return Text("No data");
|
||||||
return Text("No data");
|
} else {
|
||||||
} else {
|
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
||||||
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
),
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +187,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
),
|
),
|
||||||
),// FIELDS SECTION
|
),// FIELDS SECTION
|
||||||
Container(
|
Container(
|
||||||
height: size.height * 0.45,
|
height: size.height * 0.39,
|
||||||
width: size.width * 0.8,
|
width: size.width * 0.8,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
|||||||
@ -34,19 +34,17 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
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 FutureBuilder(
|
||||||
child: 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) {
|
return bodyConfiguration(snapshot.data, size, appContext, context);
|
||||||
return bodyConfiguration(snapshot.data, size, appContext, context);
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
return Text("No data");
|
||||||
return Text("No data");
|
} else {
|
||||||
} else {
|
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
||||||
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
),
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,137 +53,148 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
child: Row(
|
//height: size.height *0.12,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
child: SingleChildScrollView(
|
||||||
children: [
|
child: Row(
|
||||||
Align(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
alignment: AlignmentDirectional.bottomStart,
|
children: [
|
||||||
child: Padding(
|
Align(
|
||||||
padding: const EdgeInsets.all(10.0),
|
alignment: AlignmentDirectional.bottomStart,
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.all(10.0),
|
||||||
children: [
|
child: Column(
|
||||||
Text(configurationDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Padding(
|
children: [
|
||||||
padding: const EdgeInsets.all(5.0),
|
Text(configurationDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)),
|
||||||
child: Text(DateFormat('dd/MM/yyyy').format(configurationDTO.dateCreation), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
|
Padding(
|
||||||
),
|
padding: const EdgeInsets.all(5.0),
|
||||||
],
|
child: Text(DateFormat('dd/MM/yyyy').format(configurationDTO.dateCreation), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)),
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
),
|
),
|
||||||
Padding(
|
)
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
|
||||||
managerAppContext.selectedConfiguration = null;
|
|
||||||
appContext.setContext(managerAppContext);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
child: Icon(
|
|
||||||
Icons.arrow_back,
|
|
||||||
color: kPrimaryColor,
|
|
||||||
size: 50.0,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
Padding(
|
||||||
],
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
managerAppContext.selectedConfiguration = null;
|
||||||
|
appContext.setContext(managerAppContext);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
child: Icon(
|
||||||
|
Icons.arrow_back,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
size: 50.0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
), // TITLE
|
), // TITLE
|
||||||
Container(
|
Container(
|
||||||
child: Padding(
|
//height: size.height *0.76,
|
||||||
padding: const EdgeInsets.all(10.0),
|
child: SingleChildScrollView(
|
||||||
child: Container(
|
child: Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.all(10.0),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
child: Container(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
Container(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
Container(
|
||||||
children: [
|
child: Row(
|
||||||
Column(
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Column(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
StringInputContainer(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
label: "Nom :",
|
children: [
|
||||||
initialValue: configurationDTO.label,
|
StringInputContainer(
|
||||||
onChanged: (value) {
|
label: "Nom :",
|
||||||
configurationDTO.label = value;
|
initialValue: configurationDTO.label,
|
||||||
},
|
onChanged: (value) {
|
||||||
),
|
configurationDTO.label = value;
|
||||||
MultiSelectContainer(
|
},
|
||||||
label: "Langues :",
|
),
|
||||||
initialValue: configurationDTO.languages != null ? configurationDTO.languages: [],
|
MultiSelectContainer(
|
||||||
values: languages,
|
label: "Langues :",
|
||||||
isMultiple: true,
|
initialValue: configurationDTO.languages != null ? configurationDTO.languages: [],
|
||||||
onChanged: (value) {
|
values: languages,
|
||||||
var tempOutput = new List<String>.from(value);
|
isMultiple: true,
|
||||||
configurationDTO.languages = tempOutput;
|
onChanged: (value) {
|
||||||
print(configurationDTO.languages);
|
var tempOutput = new List<String>.from(value);
|
||||||
},
|
configurationDTO.languages = tempOutput;
|
||||||
),
|
print(configurationDTO.languages);
|
||||||
],
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ColorPickerInputContainer(
|
||||||
|
label: "Couleur principal :",
|
||||||
|
color: configurationDTO.primaryColor,
|
||||||
|
onChanged: (value) {
|
||||||
|
configurationDTO.primaryColor = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ColorPickerInputContainer(
|
||||||
|
label: "Couleur secondaire :",
|
||||||
|
color: configurationDTO.secondaryColor,
|
||||||
|
onChanged: (value) {
|
||||||
|
configurationDTO.secondaryColor = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
border: Border.all(width: 0.5, color: kSecond)
|
||||||
),
|
),
|
||||||
Column(
|
child: FutureBuilder(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
future: getSections(configurationDTO, appContext.getContext().clientAPI),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
children: [
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
ColorPickerInputContainer(
|
var tempOutput = new List<SectionDTO>.from(snapshot.data).where((section) => !section.isSubSection).toList();
|
||||||
label: "Couleur principal :",
|
tempOutput.add(SectionDTO(id: null));
|
||||||
color: configurationDTO.primaryColor,
|
return bodyGrid(configurationDTO, tempOutput, size, appContext);
|
||||||
onChanged: (value) {
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
configurationDTO.primaryColor = value;
|
return Text("No data");
|
||||||
},
|
} else {
|
||||||
),
|
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
||||||
ColorPickerInputContainer(
|
}
|
||||||
label: "Couleur secondaire :",
|
|
||||||
color: configurationDTO.secondaryColor,
|
|
||||||
onChanged: (value) {
|
|
||||||
configurationDTO.secondaryColor = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(20.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),
|
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
var tempOutput = new List<SectionDTO>.from(snapshot.data).where((section) => !section.isSubSection).toList();
|
|
||||||
tempOutput.add(SectionDTO(id: null));
|
|
||||||
return bodyGrid(configurationDTO, tempOutput, size, appContext);
|
|
||||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
|
||||||
return Text("No data");
|
|
||||||
} else {
|
|
||||||
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
|
||||||
}
|
}
|
||||||
}
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),// FIELDS SECTION
|
),// FIELDS SECTION
|
||||||
getButtons(configurationDTO, appContext),
|
Container(
|
||||||
|
//height: size.height *0.09,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: getButtons(configurationDTO, appContext)
|
||||||
|
)
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,8 @@ class _ConfigurationsScreenState extends State<ConfigurationsScreen> {
|
|||||||
if (managerAppContext.selectedConfiguration != null) {
|
if (managerAppContext.selectedConfiguration != null) {
|
||||||
return ConfigurationDetailScreen(id: managerAppContext.selectedConfiguration.id);
|
return ConfigurationDetailScreen(id: managerAppContext.selectedConfiguration.id);
|
||||||
} else {
|
} else {
|
||||||
return Container(
|
return Align(
|
||||||
|
alignment: AlignmentDirectional.topCenter,
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: getConfigurations(appContext),
|
future: getConfigurations(appContext),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
|||||||
189
lib/Screens/Resources/resource_body_grid.dart
Normal file
189
lib/Screens/Resources/resource_body_grid.dart
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/fetch_resource_icon.dart';
|
||||||
|
import 'package:manager_app/Components/string_input_container.dart';
|
||||||
|
import 'package:manager_app/Screens/Resources/new_resource_popup.dart';
|
||||||
|
import 'package:manager_app/Screens/Resources/show_resource_popup.dart';
|
||||||
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ResourceBodyGrid extends StatefulWidget {
|
||||||
|
final List<ResourceDTO> resources; //return ResourceDTO
|
||||||
|
final Function onSelect;
|
||||||
|
const ResourceBodyGrid({
|
||||||
|
Key key,
|
||||||
|
this.resources,
|
||||||
|
this.onSelect,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ResourceBodyGridState createState() => _ResourceBodyGridState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ResourceBodyGridState extends State<ResourceBodyGrid> {
|
||||||
|
String filter;
|
||||||
|
List<ResourceDTO> resourcesToShow;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
resourcesToShow = widget.resources;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
return bodyGrid(resourcesToShow, size, appContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget bodyGrid(data, Size size, AppContext appContext) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: StringInputContainer(
|
||||||
|
label: "Recherche:",
|
||||||
|
onChanged: (String value) {
|
||||||
|
setState(() {
|
||||||
|
resourcesToShow = value.isEmpty ? widget.resources: widget.resources.where((ResourceDTO resource) => resource.label.toUpperCase().contains(value.toUpperCase())).toList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
widget.onSelect(ResourceDTO(id: null));
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: size.height *0.08,
|
||||||
|
width: size.height *0.08,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.lightGreen,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kSecond,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: LayoutBuilder(builder: (context, constraint) {
|
||||||
|
return new Icon(Icons.add, size: constraint.biggest.height, color: kTextLightColor);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: size.height *0.85,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: GridView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6),
|
||||||
|
itemCount: data.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
widget.onSelect(resourcesToShow[index]);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: boxDecoration(data[index], appContext),
|
||||||
|
padding: const EdgeInsets.all(15),
|
||||||
|
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: getElement(data[index], size, appContext)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getElement(ResourceDTO resource, Size size, AppContext appContext) {
|
||||||
|
if (resource.id != null) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: size.width *0.01,
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: AutoSizeText(
|
||||||
|
resource.label == null ? "" : resource.label,
|
||||||
|
style: new TextStyle(fontSize: 20),
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
|
child: Icon(
|
||||||
|
getResourceIcon(resource.type),
|
||||||
|
color: kPrimaryColor,
|
||||||
|
size: 25,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Icon(
|
||||||
|
Icons.add,
|
||||||
|
color: kTextLightColor,
|
||||||
|
size: 80.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boxDecoration(dynamic resourceDetailDTO, appContext) {
|
||||||
|
return BoxDecoration(
|
||||||
|
color: resourceDetailDTO.id == null ? Colors.lightGreen : kBackgroundColor,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(30.0),
|
||||||
|
image: resourceDetailDTO.id != null && resourceDetailDTO.type != ResourceType.videoUrl ? new DecorationImage(
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
) : null,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kSecond,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<ResourceDTO>> getResources(Function onGetResult, bool isImage, dynamic appContext) async {
|
||||||
|
List<ResourceDTO> resources = await appContext.getContext().clientAPI.resourceApi.resourceGet();
|
||||||
|
if (onGetResult != null && isImage) {
|
||||||
|
resources = resources.where((element) => element.type == ResourceType.image || element.type == ResourceType.imageUrl).toList();
|
||||||
|
}
|
||||||
|
return resources;
|
||||||
|
}
|
||||||
@ -1,7 +1,9 @@
|
|||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_app/Components/fetch_resource_icon.dart';
|
import 'package:manager_app/Components/fetch_resource_icon.dart';
|
||||||
|
import 'package:manager_app/Components/string_input_container.dart';
|
||||||
import 'package:manager_app/Screens/Resources/new_resource_popup.dart';
|
import 'package:manager_app/Screens/Resources/new_resource_popup.dart';
|
||||||
|
import 'package:manager_app/Screens/Resources/resource_body_grid.dart';
|
||||||
import 'package:manager_app/Screens/Resources/show_resource_popup.dart';
|
import 'package:manager_app/Screens/Resources/show_resource_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';
|
||||||
@ -22,6 +24,7 @@ class ResourcesScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ResourcesScreenState extends State<ResourcesScreen> {
|
class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||||
|
String filter;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -34,8 +37,26 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
|||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
var tempOutput = new List<ResourceDTO>.from(snapshot.data);
|
var tempOutput = new List<ResourceDTO>.from(snapshot.data);
|
||||||
tempOutput.add(ResourceDTO(id: null));
|
// tempOutput.add(ResourceDTO(id: null));
|
||||||
return bodyGrid(tempOutput, size, appContext);
|
return ResourceBodyGrid(resources: tempOutput, onSelect: (value) {
|
||||||
|
print("result parent");
|
||||||
|
print(value);
|
||||||
|
if (widget.onGetResult == null) {
|
||||||
|
// Main screen
|
||||||
|
if (value.id == null) {
|
||||||
|
showNewResource(appContext, context);
|
||||||
|
} else {
|
||||||
|
showResource(value, appContext, context, size);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value.id == null) {
|
||||||
|
showNewResource(appContext, context);
|
||||||
|
} else {
|
||||||
|
// Result for select modal
|
||||||
|
widget.onGetResult(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},);//bodyGrid(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 {
|
||||||
@ -45,108 +66,8 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget bodyGrid(data, Size size, AppContext appContext) {
|
|
||||||
return GridView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6),
|
|
||||||
itemCount: data.length,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
if (widget.onGetResult == null) {
|
|
||||||
// Main screen
|
|
||||||
if (data[index].id == null) {
|
|
||||||
showNewResource(appContext, context);
|
|
||||||
} else {
|
|
||||||
showResource(data[index], appContext, context, size);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (data[index].id == null) {
|
|
||||||
showNewResource(appContext, context);
|
|
||||||
} else {
|
|
||||||
// Result for select modal
|
|
||||||
widget.onGetResult(data[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: boxDecoration(data[index], appContext),
|
|
||||||
padding: const EdgeInsets.all(15),
|
|
||||||
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: getElement(data[index], size, appContext)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getElement(ResourceDTO resource, Size size, AppContext appContext) {
|
|
||||||
if (resource.id != null) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: size.width *0.01,
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: AutoSizeText(
|
|
||||||
resource.label == null ? "" : resource.label,
|
|
||||||
style: new TextStyle(fontSize: 20),
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: Icon(
|
|
||||||
getResourceIcon(resource.type),
|
|
||||||
color: kPrimaryColor,
|
|
||||||
size: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Icon(
|
|
||||||
Icons.add,
|
|
||||||
color: kTextLightColor,
|
|
||||||
size: 80.0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boxDecoration(dynamic resourceDetailDTO, appContext) {
|
|
||||||
return BoxDecoration(
|
|
||||||
color: resourceDetailDTO.id == null ? Colors.lightGreen : kBackgroundColor,
|
|
||||||
shape: BoxShape.rectangle,
|
|
||||||
borderRadius: BorderRadius.circular(30.0),
|
|
||||||
image: resourceDetailDTO.id != null && resourceDetailDTO.type != ResourceType.videoUrl ? new DecorationImage(
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
) : null,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: kSecond,
|
|
||||||
spreadRadius: 0.5,
|
|
||||||
blurRadius: 5,
|
|
||||||
offset: Offset(0, 1.5), // changes position of shadow
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Future<List<ResourceDTO>> getResources(Function onGetResult, bool isImage, dynamic appContext) async {
|
Future<List<ResourceDTO>> getResources(Function onGetResult, bool isImage, dynamic appContext) async {
|
||||||
List<ResourceDTO> resources = await appContext.getContext().clientAPI.resourceApi.resourceGet();
|
List<ResourceDTO> resources = await appContext.getContext().clientAPI.resourceApi.resourceGet();
|
||||||
if (onGetResult != null && isImage) {
|
if (onGetResult != null && isImage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user