forked from eatvio/eatvio_app
Merge pull request 'main' (#9) from eatvio/eatvio_app:main into main
Reviewed-on: mso7nueh/eatvio_app#9
This commit is contained in:
@@ -2,11 +2,27 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChoiceChipWidget extends StatelessWidget {
|
||||
const ChoiceChipWidget({super.key, required this.chipsLabelList, required this.index, required this.selectedChipIndex, required this.onSelected});
|
||||
const ChoiceChipWidget({
|
||||
super.key,
|
||||
required this.chipsLabelList,
|
||||
required this.index,
|
||||
required this.selectedChipIndex,
|
||||
required this.onSelected,
|
||||
this.padding,
|
||||
this.fontSize,
|
||||
this.activeColor,
|
||||
this.inactiveColor,
|
||||
this.fontWeight,
|
||||
});
|
||||
final List<String> chipsLabelList;
|
||||
final int index;
|
||||
final int selectedChipIndex;
|
||||
final double? fontSize;
|
||||
final Color? activeColor;
|
||||
final Color? inactiveColor;
|
||||
final FontWeight? fontWeight;
|
||||
final void Function(bool) onSelected;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChoiceChip(
|
||||
@@ -17,12 +33,12 @@ class ChoiceChipWidget extends StatelessWidget {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
label: Text(chipsLabelList[index]),
|
||||
labelStyle: TextStyle(
|
||||
color: index == selectedChipIndex ? Colors.white : appTheme.gray600,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12,
|
||||
color: index == selectedChipIndex ? activeColor ?? Colors.white : inactiveColor ?? appTheme.gray600,
|
||||
fontWeight: fontWeight ?? FontWeight.w500,
|
||||
fontSize: fontSize ?? 12,
|
||||
),
|
||||
selected: selectedChipIndex == index,
|
||||
backgroundColor: appTheme.gray100,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/duration_choice_filter_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/sorting_drop_down_filter.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/type_choice_filter_widget.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
@@ -8,8 +10,8 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DietFilterBottomSheet extends StatelessWidget {
|
||||
const DietFilterBottomSheet({super.key});
|
||||
|
||||
const DietFilterBottomSheet({super.key, required this.dietsCubit});
|
||||
final DietsCubit dietsCubit;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
@@ -29,7 +31,7 @@ class DietFilterBottomSheet extends StatelessWidget {
|
||||
style: TextStyles.textMSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
SortingDropDownFilter(),
|
||||
SortingDropDownFilter(cubit: dietsCubit,),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
@@ -44,7 +46,7 @@ class DietFilterBottomSheet extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
TypeChoiceFilterWidget(),
|
||||
TypeChoiceFilterWidget(cubit: dietsCubit,),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
@@ -59,7 +61,7 @@ class DietFilterBottomSheet extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
TypeChoiceFilterWidget(),
|
||||
DurationChoiceFilterWidget(cubit: dietsCubit,),
|
||||
SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
|
||||
@@ -1,84 +1,85 @@
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/utils/localization_utils.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_state.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/choice_chip_widget.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class DurationChoiceFilterWidget extends StatefulWidget {
|
||||
const DurationChoiceFilterWidget({super.key});
|
||||
|
||||
const DurationChoiceFilterWidget({super.key, required this.cubit});
|
||||
final DietsCubit cubit;
|
||||
@override
|
||||
State<DurationChoiceFilterWidget> createState() => _DurationChoiceFilterWidgetState();
|
||||
}
|
||||
|
||||
class _DurationChoiceFilterWidgetState extends State<DurationChoiceFilterWidget> {
|
||||
final List<String> chipsLabelList = [];
|
||||
int selectedChipIndex = 0;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
final s = S.of(context);
|
||||
super.didChangeDependencies();
|
||||
if (chipsLabelList.isEmpty) {
|
||||
chipsLabelList.add(s.all);
|
||||
chipsLabelList.add('7 ${getDayForm(7, s)}');
|
||||
chipsLabelList.add('14 ${getDayForm(14, s)}');
|
||||
chipsLabelList.add('21 ${getDayForm(21, s)}');
|
||||
durationValues.forEach((element) {
|
||||
chipsLabelList.add('${element} ${getDayForm(element, s)}');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
children: [
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 0,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 0;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 1,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 2,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 2;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 3,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 3;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
return BlocBuilder<DietsCubit, DietsState>(
|
||||
bloc: widget.cubit,
|
||||
builder: (context, state) {
|
||||
return Wrap(
|
||||
children: [
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 0,
|
||||
selectedChipIndex: state.filterState.durationIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeDurationFilter(0);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 1,
|
||||
selectedChipIndex: state.filterState.durationIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeDurationFilter(1);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 2,
|
||||
selectedChipIndex: state.filterState.durationIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeDurationFilter(2);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 3,
|
||||
selectedChipIndex: state.filterState.durationIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeDurationFilter(3);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_state.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class SortingDropDownFilter extends StatefulWidget {
|
||||
const SortingDropDownFilter({super.key});
|
||||
|
||||
const SortingDropDownFilter({super.key, required this.cubit});
|
||||
final DietsCubit cubit;
|
||||
@override
|
||||
State<SortingDropDownFilter> createState() => _SortingDropDownFilterState();
|
||||
}
|
||||
|
||||
class _SortingDropDownFilterState extends State<SortingDropDownFilter> {
|
||||
final List<String> sortingTypes = [];
|
||||
int selectedIndex = 0;
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
@@ -24,46 +26,35 @@ class _SortingDropDownFilterState extends State<SortingDropDownFilter> {
|
||||
sortingTypes.add(s.popular);
|
||||
sortingTypes.add(s.most_new);
|
||||
sortingTypes.add(s.most_old);
|
||||
sortingTypes.add(s.most_liked);
|
||||
sortingTypes.add(s.from_a_to_z);
|
||||
sortingTypes.add(s.from_z_to_a);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DropdownButtonFormField(
|
||||
icon: SvgPicture.asset(
|
||||
'assets/icons/arrow_down2.svg',
|
||||
width: 12,
|
||||
height: 8,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
dropdownColor: appTheme.lightGray0,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
fillColor: appTheme.lightGray0,
|
||||
filled: true,
|
||||
),
|
||||
value: sortingTypes[selectedIndex],
|
||||
items: sortingTypes
|
||||
.mapIndexed(
|
||||
(index, value) => DropdownMenuItem(
|
||||
child: Text(
|
||||
sortingTypes[index],
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
value: sortingTypes[index],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
selectedIndex = sortingTypes.indexOf(value);
|
||||
});
|
||||
}
|
||||
return BlocBuilder<DietsCubit, DietsState>(
|
||||
bloc: widget.cubit,
|
||||
builder: (context, state) {
|
||||
return CustomDropDownButton(
|
||||
items: sortingTypes
|
||||
.mapIndexed(
|
||||
(index, value) => DropdownMenuItem(
|
||||
child: Text(
|
||||
sortingTypes[index],
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
value: sortingTypes[index],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
value: sortingTypes[state.filterState.sortingIndex],
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
widget.cubit.changeSortingType(sortingTypes.indexOf(value));
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_state.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/choice_chip_widget.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class TypeChoiceFilterWidget extends StatefulWidget {
|
||||
const TypeChoiceFilterWidget({super.key});
|
||||
|
||||
const TypeChoiceFilterWidget({super.key, required this.cubit});
|
||||
final DietsCubit cubit;
|
||||
@override
|
||||
State<TypeChoiceFilterWidget> createState() => _TypeChoiceFilterWidgetState();
|
||||
}
|
||||
|
||||
class _TypeChoiceFilterWidgetState extends State<TypeChoiceFilterWidget> {
|
||||
final List<String> chipsLabelList = [];
|
||||
int selectedChipIndex = 0;
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
final s = S.of(context);
|
||||
@@ -19,79 +21,74 @@ class _TypeChoiceFilterWidgetState extends State<TypeChoiceFilterWidget> {
|
||||
if (chipsLabelList.isEmpty) {
|
||||
chipsLabelList.add(s.all);
|
||||
chipsLabelList.add(s.vegan_type);
|
||||
chipsLabelList.add(s.alko_type);
|
||||
chipsLabelList.add(s.corb_type);
|
||||
chipsLabelList.add(s.light_type);
|
||||
chipsLabelList.add(s.carb_type);
|
||||
chipsLabelList.add(s.meat_type);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
children: [
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 0,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 0;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 1,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 2,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 2;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 3,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 3;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 4,
|
||||
selectedChipIndex: selectedChipIndex,
|
||||
onSelected: (selectedValue) {
|
||||
setState(() {
|
||||
selectedChipIndex = 4;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
return BlocBuilder<DietsCubit, DietsState>(
|
||||
bloc: widget.cubit,
|
||||
builder: (context, state) {
|
||||
return Wrap(
|
||||
children: [
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 0,
|
||||
selectedChipIndex: state.filterState.typeIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeTypeFilter(0);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 1,
|
||||
selectedChipIndex: state.filterState.typeIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeTypeFilter(1);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 2,
|
||||
selectedChipIndex: state.filterState.typeIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeTypeFilter(2);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 3,
|
||||
selectedChipIndex: state.filterState.typeIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeTypeFilter(3);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
ChoiceChipWidget(
|
||||
chipsLabelList: chipsLabelList,
|
||||
index: 4,
|
||||
selectedChipIndex: state.filterState.typeIndex,
|
||||
onSelected: (selectedValue) {
|
||||
widget.cubit.changeTypeFilter(4);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user