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: const EdgeInsets.all(10.0),
|
||||
child: Container(
|
||||
width: size.width *0.10,
|
||||
width: size.width *0.08,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showSelectResourceModal(
|
||||
|
||||
@ -7,6 +7,7 @@ class TextFormInputContainer extends StatelessWidget {
|
||||
final String label;
|
||||
final String initialValue;
|
||||
final bool isTitle;
|
||||
final int maxLines;
|
||||
final ValueChanged<String> onChanged;
|
||||
const TextFormInputContainer({
|
||||
Key key,
|
||||
@ -14,6 +15,7 @@ class TextFormInputContainer extends StatelessWidget {
|
||||
this.label,
|
||||
this.initialValue,
|
||||
this.isTitle,
|
||||
this.maxLines = 5,
|
||||
this.onChanged
|
||||
}) : super(key: key);
|
||||
|
||||
@ -42,7 +44,7 @@ class TextFormInputContainer extends StatelessWidget {
|
||||
keyboardType: TextInputType.multiline,
|
||||
textInputAction: TextInputAction.newline,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
maxLines: maxLines,
|
||||
initialValue: initialValue,
|
||||
onChanged: onChanged,
|
||||
maxLength: isTitle ? 50 : 2000,
|
||||
|
||||
@ -29,6 +29,7 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
||||
children: [
|
||||
Text("Modifier sous section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
@ -48,36 +49,16 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
||||
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(
|
||||
height: size.height * 0.33,
|
||||
width: double.infinity,
|
||||
color: Colors.lightBlue,
|
||||
child: SingleChildScrollView(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: getTranslations(context, appContext, subSectionDTO),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: kWhite,
|
||||
@ -190,7 +171,8 @@ getTranslations(BuildContext context, AppContext appContext, SectionDTO subSecti
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
for(var language in managerAppContext.selectedConfiguration.languages) {
|
||||
translations.add(
|
||||
Padding(
|
||||
SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@ -216,6 +198,7 @@ getTranslations(BuildContext context, AppContext appContext, SectionDTO subSecti
|
||||
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;
|
||||
@ -236,6 +219,7 @@ getTranslations(BuildContext context, AppContext appContext, SectionDTO subSecti
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -36,8 +36,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: FutureBuilder(
|
||||
return FutureBuilder(
|
||||
future: getSection(widget.id, appContext.getContext().clientAPI),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
@ -48,7 +47,6 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||
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
|
||||
Container(
|
||||
height: size.height * 0.45,
|
||||
height: size.height * 0.39,
|
||||
width: size.width * 0.8,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
|
||||
@ -34,8 +34,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return Container(
|
||||
child: FutureBuilder(
|
||||
return FutureBuilder(
|
||||
future: getConfiguration(this.widget, appContext.getContext().clientAPI),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
@ -46,7 +45,6 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
||||
}
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -55,6 +53,8 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
//height: size.height *0.12,
|
||||
child: SingleChildScrollView(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -96,8 +96,11 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
), // TITLE
|
||||
Container(
|
||||
//height: size.height *0.76,
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Container(
|
||||
@ -184,8 +187,14 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),// 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) {
|
||||
return ConfigurationDetailScreen(id: managerAppContext.selectedConfiguration.id);
|
||||
} else {
|
||||
return Container(
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.topCenter,
|
||||
child: FutureBuilder(
|
||||
future: getConfigurations(appContext),
|
||||
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: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/resource_body_grid.dart';
|
||||
import 'package:manager_app/Screens/Resources/show_resource_popup.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
@ -22,6 +24,7 @@ class ResourcesScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||
String filter;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -34,8 +37,26 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
var tempOutput = new List<ResourceDTO>.from(snapshot.data);
|
||||
tempOutput.add(ResourceDTO(id: null));
|
||||
return bodyGrid(tempOutput, size, appContext);
|
||||
// tempOutput.add(ResourceDTO(id: null));
|
||||
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) {
|
||||
return Text("No data");
|
||||
} 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 {
|
||||
List<ResourceDTO> resources = await appContext.getContext().clientAPI.resourceApi.resourceGet();
|
||||
if (onGetResult != null && isImage) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user