mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 06:17:55 +00:00
change string value to enum
This commit is contained in:
@@ -3,8 +3,9 @@ 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/scene/enum/effective_period_options.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/effect_period_helper.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
@@ -22,15 +23,17 @@ class PeriodOptions extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildRadioOption(context, 'All Day', '24 Hours'),
|
||||
_buildRadioOption(context, 'Daytime', 'Sunrise to Sunset'),
|
||||
_buildRadioOption(context, 'Night', 'Sunset to Sunrise'),
|
||||
_buildRadioOption(
|
||||
context, EnumEffectivePeriodOptions.allDay, '24 Hours'),
|
||||
_buildRadioOption(context, EnumEffectivePeriodOptions.daytime,
|
||||
'Sunrise to Sunset'),
|
||||
_buildRadioOption(
|
||||
context, EnumEffectivePeriodOptions.night, 'Sunset to Sunrise'),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => showCustomTimePicker(context),
|
||||
title: BodyMedium(
|
||||
title: const BodyMedium(
|
||||
text: 'Custom',
|
||||
fontColor: ColorsManager.primaryColorWithOpacity,
|
||||
),
|
||||
subtitle:
|
||||
state.customStartTime != null && state.customEndTime != null
|
||||
@@ -43,10 +46,14 @@ class PeriodOptions extends StatelessWidget {
|
||||
text: '00:00 AM - 11:59 PM',
|
||||
style: context.bodySmall.copyWith(fontSize: 10),
|
||||
),
|
||||
trailing: Radio<String>(
|
||||
value: 'Custom',
|
||||
trailing: Radio<EnumEffectivePeriodOptions>(
|
||||
value: EnumEffectivePeriodOptions.custom,
|
||||
groupValue: state.selectedPeriod,
|
||||
onChanged: (value) async {},
|
||||
onChanged: (value) async {
|
||||
if (value != null) {
|
||||
context.read<EffectPeriodBloc>().add(SetPeriod(value));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -56,7 +63,7 @@ class PeriodOptions extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildRadioOption(
|
||||
BuildContext context, String value, String subtitle) {
|
||||
BuildContext context, EnumEffectivePeriodOptions value, String subtitle) {
|
||||
return BlocBuilder<EffectPeriodBloc, EffectPeriodState>(
|
||||
builder: (context, state) {
|
||||
return ListTile(
|
||||
@@ -64,12 +71,12 @@ class PeriodOptions extends StatelessWidget {
|
||||
onTap: () {
|
||||
context.read<EffectPeriodBloc>().add(SetPeriod(value));
|
||||
},
|
||||
title: BodyMedium(text: value),
|
||||
title: BodyMedium(text: EffectPeriodHelper.formatEnumValue(value)),
|
||||
subtitle: BodySmall(
|
||||
text: subtitle,
|
||||
style: context.bodySmall.copyWith(fontSize: 10),
|
||||
),
|
||||
trailing: Radio<String>(
|
||||
trailing: Radio<EnumEffectivePeriodOptions>(
|
||||
value: value,
|
||||
groupValue: state.selectedPeriod,
|
||||
onChanged: (value) {
|
||||
|
||||
Reference in New Issue
Block a user