Changed the action executor of the tab to run scenes and changed the order of the effective days

This commit is contained in:
Abdullah Alassaf
2024-08-07 15:52:27 +03:00
parent afe37dd68a
commit a32d885e50
4 changed files with 38 additions and 58 deletions

View File

@ -13,16 +13,7 @@ class RepeatDays extends StatelessWidget {
@override
Widget build(BuildContext context) {
final daysMap = {
'Mon': 'M',
'Tue': 'T',
'Wed': 'W',
'Thu': 'T',
'Fri': 'F',
'Sat': 'S',
'Sun': 'S',
};
final effectiveBloc = context.read<EffectPeriodBloc>();
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@ -37,25 +28,22 @@ class RepeatDays extends StatelessWidget {
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: daysMap.entries.map((entry) {
children: effectiveBloc.daysMap.entries.map((entry) {
final day = entry.key;
final abbreviation = entry.value;
final dayIndex = _getDayIndex(day);
final isSelected =
state.selectedDaysBinary[dayIndex] == '1';
final dayIndex = effectiveBloc.getDayIndex(day);
final isSelected = state.selectedDaysBinary[dayIndex] == '1';
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 3.0),
child: GestureDetector(
onTap: () {
context.read<EffectPeriodBloc>().add(ToggleDay(day));
effectiveBloc.add(ToggleDay(day));
},
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: isSelected
? Colors.grey
: Colors.grey.shade300,
color: isSelected ? Colors.grey : Colors.grey.shade300,
width: 1,
),
),
@ -66,9 +54,7 @@ class RepeatDays extends StatelessWidget {
abbreviation,
style: TextStyle(
fontSize: 16,
color: isSelected
? Colors.grey
: Colors.grey.shade300,
color: isSelected ? Colors.grey : Colors.grey.shade300,
),
),
),
@ -83,8 +69,7 @@ class RepeatDays extends StatelessWidget {
if (state.selectedDaysBinary == '0000000')
BodySmall(
text: 'At least one day must be selected',
style:
context.bodyMedium.copyWith(color: ColorsManager.red),
style: context.bodyMedium.copyWith(color: ColorsManager.red),
),
],
);
@ -93,9 +78,4 @@ class RepeatDays extends StatelessWidget {
],
);
}
int _getDayIndex(String day) {
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
return days.indexOf(day);
}
}