mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
80 lines
2.7 KiB
Dart
80 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_event.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_state.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
|
|
|
class RepeatDays extends StatelessWidget {
|
|
const RepeatDays({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final daysMap = {
|
|
'Mon': 'M',
|
|
'Tue': 'T',
|
|
'Wed': 'W',
|
|
'Thu': 'T',
|
|
'Fri': 'F',
|
|
'Sat': 'S',
|
|
'Sun': 'S',
|
|
};
|
|
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
const BodyMedium(text: 'Repeat'),
|
|
const SizedBox(width: 8),
|
|
BlocBuilder<EffectPeriodBloc, EffectPeriodState>(
|
|
builder: (context, state) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: daysMap.entries.map((entry) {
|
|
final day = entry.key;
|
|
final abbreviation = entry.value;
|
|
final dayIndex = _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));
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
border: Border.all(
|
|
color:
|
|
isSelected ? Colors.grey : Colors.grey.shade300,
|
|
width: 1,
|
|
),
|
|
),
|
|
child: CircleAvatar(
|
|
radius: 15,
|
|
backgroundColor: Colors.white,
|
|
child: Text(
|
|
abbreviation,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color:
|
|
isSelected ? Colors.grey : Colors.grey.shade300,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
int _getDayIndex(String day) {
|
|
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
return days.indexOf(day);
|
|
}
|
|
}
|