Change reorder section size + add search

This commit is contained in:
Fransolet Thomas 2022-06-30 21:08:58 +02:00
parent 98e066c712
commit e3beb6c7f8
4 changed files with 73 additions and 33 deletions

View File

@ -10,6 +10,7 @@ class RoundedInputField extends StatelessWidget {
final Color color, textColor, iconColor;
final int maxLength;
final bool isEmail;
final double fontSize;
const RoundedInputField({
Key key,
this.hintText,
@ -20,7 +21,8 @@ class RoundedInputField extends StatelessWidget {
this.iconColor = kPrimaryColor,
this.onChanged,
this.maxLength, // 50
this.isEmail = false
this.isEmail = false,
this.fontSize = 20,
}) : super(key: key);
@override
@ -33,14 +35,14 @@ class RoundedInputField extends StatelessWidget {
cursorColor: textColor,
maxLength: maxLength,
keyboardType: isEmail ? TextInputType.emailAddress : TextInputType.text,
style: TextStyle(fontSize: 20, color: textColor),
style: TextStyle(fontSize: fontSize, color: textColor),
decoration: InputDecoration(
icon: icon != null ? Icon(
icon,
color: iconColor,
): null,
hintText: hintText,
hintStyle: TextStyle(fontSize: 20.0, color: textColor),
hintStyle: TextStyle(fontSize: fontSize, color: textColor),
border: InputBorder.none,
)
),

View File

@ -10,6 +10,8 @@ class StringInputContainer extends StatelessWidget {
final bool isUrl;
final bool isSmall;
final int maxLength;
final double fontSize;
final double fontSizeText;
const StringInputContainer({
Key key,
this.color = kSecond,
@ -19,6 +21,8 @@ class StringInputContainer extends StatelessWidget {
this.isUrl = false,
this.isSmall = false,
this.maxLength = 50,
this.fontSize = 25,
this.fontSizeText = 20,
}) : super(key: key);
@override
@ -29,7 +33,7 @@ class StringInputContainer extends StatelessWidget {
children: [
Align(
alignment: AlignmentDirectional.centerStart,
child: Text(label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
child: Text(label, style: TextStyle(fontSize: fontSize, fontWeight: FontWeight.w300))
),
Padding(
padding: const EdgeInsets.all(10.0),
@ -38,6 +42,7 @@ class StringInputContainer extends StatelessWidget {
child: RoundedInputField(
color: color,
textColor: kBlack,
fontSize: fontSizeText,
initialValue: initialValue,
onChanged: onChanged,
maxLength: maxLength,

View File

@ -33,34 +33,25 @@ class _ListViewCardSectionsState extends State<ListViewCardSections> {
Size size = MediaQuery.of(context).size;
return Card(
margin: EdgeInsets.all(4),
child: Center(
child: Stack(
children: [
InkWell(
child: InkWell(
onTap: () {
widget.onSelect(widget.sections[widget.index]);
},
child: Container(
width: 250,
height: 200,
child: Padding(
padding: const EdgeInsets.only(right: 30.0),
child: Center(
//padding: const EdgeInsets.only(right: 30.0),
child: getElement(widget.index, widget.sections[widget.index], size, appContext)
),
),
),
],
),
),
);
}
getElement(int index, SectionDTO sectionDTO, Size size, AppContext appContext) {
return Container(
width: 150,
height: 150,
decoration: boxDecoration(sectionDTO, appContext),
padding: const EdgeInsets.all(15),
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
padding: const EdgeInsets.all(5),
//margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
child: Align(
alignment: Alignment.center,
child: getDetails(sectionDTO, size),

View File

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Screens/Configurations/listView_card_section.dart';
import 'package:manager_app/Screens/Configurations/new_section_popup.dart';
@ -25,6 +26,7 @@ class SectionReorderList extends StatefulWidget {
class _SectionReorderListState extends State<SectionReorderList> {
List<SectionDTO> sections;
String filterSearch = '';
@override
void initState() {
@ -55,17 +57,36 @@ class _SectionReorderListState extends State<SectionReorderList> {
@override
Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
//Size size = MediaQuery.of(context).size;
Size size = MediaQuery.of(context).size;
return Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0, top: 15.0),
child: ReorderableListView(
child: Container(
height: size.height*0.3,
child: ReorderableListView.builder(
itemCount: sections.length,
onReorder: _onReorder,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(vertical: 20.0),
children: List.generate(
itemBuilder: (context, index) {
//final String productName = _products[index];
return ListViewCardSections(
sections,
index,
Key('$index'),
appContext,
(section) {
setState(() {
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedSection = section;
appContext.setContext(managerAppContext);
});
}
);
},
/*children: List.generate(
sections.length,
(index) {
return ListViewCardSections(
@ -82,6 +103,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
}
);
},
),*/
),
),
),
@ -93,6 +115,22 @@ class _SectionReorderListState extends State<SectionReorderList> {
style: TextStyle(fontSize: 15),
),
),
Positioned(
bottom: -20,
left: 10,
child: StringInputContainer(
label: "Recherche:",
isSmall: true,
fontSize: 15,
fontSizeText: 15,
onChanged: (String value) {
setState(() {
filterSearch = value;
filterResource();
});
},
),
),
Positioned(
bottom: 10,
right: 10,
@ -127,4 +165,8 @@ class _SectionReorderListState extends State<SectionReorderList> {
],
);
}
void filterResource() {
sections = filterSearch.isEmpty ? widget.sectionsIn: widget.sectionsIn.where((SectionDTO section) => section.label.toUpperCase().contains(filterSearch.toUpperCase())).toList();
}
}