working on preferences

This commit is contained in:
ashrafzarkanisala
2024-10-07 07:43:07 +03:00
parent 00277742d0
commit ebde81b64d
8 changed files with 330 additions and 49 deletions

View File

@ -4,11 +4,15 @@ import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_bloc.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_bloc.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_event.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_event.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_state.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_state.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/widgets/opening_clsoing_time_dialog_body.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/widgets/time_out_alarm_dialog_body.dart';
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_display_data.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_model.dart'; import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_model.dart';
import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart'; import 'package:syncrow_web/utils/extension/build_context_x.dart';
class ScheduleGarageDoorDialogHelper { class GarageDoorDialogHelper {
static void showAddGarageDoorScheduleDialog(BuildContext context, static void showAddGarageDoorScheduleDialog(BuildContext context,
{ScheduleModel? schedule, int? index, bool? isEdit}) { {ScheduleModel? schedule, int? index, bool? isEdit}) {
final bloc = context.read<GarageDoorBloc>(); final bloc = context.read<GarageDoorBloc>();
@ -77,7 +81,8 @@ class ScheduleGarageDoorDialogHelper {
: () async { : () async {
TimeOfDay? time = await showTimePicker( TimeOfDay? time = await showTimePicker(
context: context, context: context,
initialTime: state.selectedTime ?? TimeOfDay.now(), initialTime:
state.selectedTime ?? TimeOfDay.now(),
builder: (context, child) { builder: (context, child) {
return Theme( return Theme(
data: Theme.of(context).copyWith( data: Theme.of(context).copyWith(
@ -97,7 +102,9 @@ class ScheduleGarageDoorDialogHelper {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
state.selectedTime == null ? 'Time' : state.selectedTime!.format(context), state.selectedTime == null
? 'Time'
: state.selectedTime!.format(context),
style: context.textTheme.bodySmall!.copyWith( style: context.textTheme.bodySmall!.copyWith(
color: ColorsManager.grayColor, color: ColorsManager.grayColor,
), ),
@ -112,7 +119,8 @@ class ScheduleGarageDoorDialogHelper {
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
_buildDayCheckboxes(context, state.selectedDays, isEdit: isEdit), _buildDayCheckboxes(context, state.selectedDays,
isEdit: isEdit),
const SizedBox(height: 16), const SizedBox(height: 16),
_buildFunctionSwitch(context, state.functionOn, isEdit), _buildFunctionSwitch(context, state.functionOn, isEdit),
], ],
@ -191,7 +199,9 @@ class ScheduleGarageDoorDialogHelper {
return daysBoolean; return daysBoolean;
} }
static Widget _buildDayCheckboxes(BuildContext context, List<bool> selectedDays, {bool? isEdit}) { static Widget _buildDayCheckboxes(
BuildContext context, List<bool> selectedDays,
{bool? isEdit}) {
final dayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; final dayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
return Row( return Row(
@ -203,7 +213,9 @@ class ScheduleGarageDoorDialogHelper {
onChanged: isEdit == true onChanged: isEdit == true
? null ? null
: (bool? value) { : (bool? value) {
context.read<GarageDoorBloc>().add(UpdateSelectedDayEvent(index, value!)); context
.read<GarageDoorBloc>()
.add(UpdateSelectedDayEvent(index, value!));
}, },
), ),
Text(dayLabels[index]), Text(dayLabels[index]),
@ -213,12 +225,14 @@ class ScheduleGarageDoorDialogHelper {
); );
} }
static Widget _buildFunctionSwitch(BuildContext context, bool isOn, bool? isEdit) { static Widget _buildFunctionSwitch(
BuildContext context, bool isOn, bool? isEdit) {
return Row( return Row(
children: [ children: [
Text( Text(
'Function:', 'Function:',
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.grayColor), style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.grayColor),
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
Radio<bool>( Radio<bool>(
@ -228,7 +242,9 @@ class ScheduleGarageDoorDialogHelper {
if (isEdit == true) { if (isEdit == true) {
return; return;
} else { } else {
context.read<GarageDoorBloc>().add(const UpdateFunctionOnEvent(functionOn: true)); context
.read<GarageDoorBloc>()
.add(const UpdateFunctionOnEvent(functionOn: true));
} }
}, },
), ),
@ -241,7 +257,9 @@ class ScheduleGarageDoorDialogHelper {
if (isEdit == true) { if (isEdit == true) {
return; return;
} else { } else {
context.read<GarageDoorBloc>().add(const UpdateFunctionOnEvent(functionOn: false)); context
.read<GarageDoorBloc>()
.add(const UpdateFunctionOnEvent(functionOn: false));
} }
}, },
), ),
@ -249,4 +267,95 @@ class ScheduleGarageDoorDialogHelper {
], ],
); );
} }
static void showPreferencesDialog(BuildContext context) {
final bloc = context.read<GarageDoorBloc>();
showDialog(
context: context,
builder: (ctx) {
return BlocProvider.value(
value: bloc,
child: BlocBuilder<GarageDoorBloc, GarageDoorState>(
builder: (context, state) {
if (state is GarageDoorLoadedState) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(),
Text(
'Preferences',
style: context.textTheme.titleLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
const SizedBox(),
],
),
const SizedBox(height: 24),
Row(
children: [
const SizedBox(width: 24),
SizedBox(
width: 190,
height: 150,
child: GestureDetector(
onTap: () {
context.customAlertDialog(
alertBody: TimeOutAlarmDialogBody(),
title: 'Time Out Alarm',
onConfirm: () {});
},
child: ToggleWidget(
icon: "-1",
value: bloc.deviceStatus.countdownAlarm > 0,
code: 'countdown_alarm',
deviceId: bloc.deviceId,
label: 'Alarm when door is open',
onChange: (value) {}),
),
),
const SizedBox(
width: 20,
),
SizedBox(
width: 190,
height: 150,
child: GestureDetector(
onTap: () {
context.customAlertDialog(
alertBody: OpeningClosingTimeDialogBody(),
title: 'Opening and Closing Time',
onConfirm: () {});
},
child: PresenceDisplayValue(
value: bloc.deviceStatus.trTimeCon.toString(),
postfix: 'sec',
description: 'Opening & Closing Time',
),
),
),
const SizedBox(width: 24),
],
)
],
),
);
}
return const SizedBox();
},
),
);
},
);
}
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_bloc.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_bloc.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_event.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_event.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_state.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_state.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/widgets/schedule_garage_view.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/widgets/schedule_garage_view.dart';
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart'; import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
@ -14,7 +15,8 @@ import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_la
import '../../main_door_sensor/view/main_door_control_view.dart'; import '../../main_door_sensor/view/main_door_control_view.dart';
class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout { class GarageDoorControlView extends StatelessWidget
with HelperResponsiveLayout {
final String deviceId; final String deviceId;
const GarageDoorControlView({required this.deviceId, super.key}); const GarageDoorControlView({required this.deviceId, super.key});
@ -22,7 +24,8 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => GarageDoorBloc(deviceId: deviceId)..add(GarageDoorInitialEvent(deviceId)), create: (context) => GarageDoorBloc(deviceId: deviceId)
..add(GarageDoorInitialEvent(deviceId)),
child: BlocBuilder<GarageDoorBloc, GarageDoorState>( child: BlocBuilder<GarageDoorBloc, GarageDoorState>(
builder: (context, state) { builder: (context, state) {
if (state is GarageDoorLoadingState) { if (state is GarageDoorLoadingState) {
@ -34,7 +37,9 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
garageDoorSensor: true, garageDoorSensor: true,
onRowTap: (index) {}, onRowTap: (index) {},
onClose: () { onClose: () {
context.read<GarageDoorBloc>().add(BackToGarageDoorGridViewEvent()); context
.read<GarageDoorBloc>()
.add(BackToGarageDoorGridViewEvent());
}, },
); );
} else if (state is GarageDoorLoadedState) { } else if (state is GarageDoorLoadedState) {
@ -64,7 +69,7 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
? 2 ? 2
: 1, : 1,
childAspectRatio: 1.5, childAspectRatio: 1.5,
mainAxisExtent: 170, mainAxisExtent: 140,
crossAxisSpacing: 12, crossAxisSpacing: 12,
mainAxisSpacing: 12, mainAxisSpacing: 12,
), ),
@ -75,17 +80,20 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
icon: status.switch1 ? Assets.openedDoor : Assets.closedDoor, icon: status.switch1 ? Assets.openedDoor : Assets.closedDoor,
onTap: () { onTap: () {
context.read<GarageDoorBloc>().add( context.read<GarageDoorBloc>().add(
GarageDoorControlEvent(deviceId: status.uuid, value: !status.switch1, code: 'switch_1'), GarageDoorControlEvent(
deviceId: status.uuid,
value: !status.switch1,
code: 'switch_1'),
); );
}, },
status: status.switch1, status: status.switch1,
textColor: ColorsManager.blackColor, textColor: ColorsManager.blackColor,
//paddingAmount: 6,
), ),
IconNameStatusContainer( IconNameStatusContainer(
onTap: () { onTap: () {
context.read<GarageDoorBloc>().add( context.read<GarageDoorBloc>().add(
FetchGarageDoorSchedulesEvent(deviceId: deviceId, category: 'switch_1'), FetchGarageDoorSchedulesEvent(
deviceId: deviceId, category: 'switch_1'),
); );
showDialog( showDialog(
context: context, context: context,
@ -99,7 +107,6 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
status: false, status: false,
textColor: ColorsManager.blackColor, textColor: ColorsManager.blackColor,
isFullIcon: false, isFullIcon: false,
//paddingAmount: 15,
), ),
ToggleWidget( ToggleWidget(
label: '', label: '',
@ -109,9 +116,9 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
children: [ children: [
IconButton( IconButton(
onPressed: () { onPressed: () {
// if (status.countdown1 != 0) { context
context.read<GarageDoorBloc>().add(DecreaseGarageDoorDelayEvent(deviceId: status.uuid)); .read<GarageDoorBloc>()
// } .add(DecreaseGarageDoorDelayEvent(deviceId: status.uuid));
}, },
icon: const Icon( icon: const Icon(
Icons.remove, Icons.remove,
@ -129,7 +136,8 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
), ),
Text( Text(
'h', 'h',
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor), style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blackColor),
), ),
Text( Text(
(status.delay.inMinutes % 60).toString().padLeft(2, '0'), (status.delay.inMinutes % 60).toString().padLeft(2, '0'),
@ -140,13 +148,14 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
), ),
Text( Text(
'm', 'm',
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor), style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blackColor),
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
// if (status.countdown1 != 0) { context
context.read<GarageDoorBloc>().add(IncreaseGarageDoorDelayEvent(deviceId: status.uuid)); .read<GarageDoorBloc>()
// } .add(IncreaseGarageDoorDelayEvent(deviceId: status.uuid));
}, },
icon: const Icon( icon: const Icon(
Icons.add, Icons.add,
@ -164,7 +173,9 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
onChange: (value) { onChange: (value) {
context.read<GarageDoorBloc>().add( context.read<GarageDoorBloc>().add(
GarageDoorControlEvent( GarageDoorControlEvent(
deviceId: status.uuid, value: value ? status.delay.inSeconds : 0, code: 'countdown_1'), deviceId: status.uuid,
value: value ? status.delay.inSeconds : 0,
code: 'countdown_1'),
); );
}, },
), ),
@ -173,20 +184,21 @@ class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout
name: 'Records', name: 'Records',
icon: Assets.records, icon: Assets.records,
onTap: () { onTap: () {
context.read<GarageDoorBloc>().add(FetchGarageDoorRecordsEvent(code: 'switch_1', deviceId: status.uuid)); context.read<GarageDoorBloc>().add(FetchGarageDoorRecordsEvent(
code: 'switch_1', deviceId: status.uuid));
}, },
status: false, status: false,
textColor: ColorsManager.blackColor, textColor: ColorsManager.blackColor,
//paddingAmount: 6,
), ),
IconNameStatusContainer( IconNameStatusContainer(
isFullIcon: false, isFullIcon: false,
name: 'Preferences', name: 'Preferences',
icon: Assets.preferences, icon: Assets.preferences,
onTap: () {}, onTap: () {
GarageDoorDialogHelper.showPreferencesDialog(context);
},
status: false, status: false,
textColor: ColorsManager.blackColor, textColor: ColorsManager.blackColor,
// paddingAmount: 6,
), ),
], ],
); );

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
class OpeningClosingTimeDialogBody extends StatelessWidget {
const OpeningClosingTimeDialogBody({super.key});
@override
Widget build(BuildContext context) {
return Container(
width: 350,
child: Text('asdasd'),
);
}
}

View File

@ -26,7 +26,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
Table( Table(
border: TableBorder.all( border: TableBorder.all(
color: ColorsManager.graysColor, color: ColorsManager.graysColor,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)), borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20), topRight: Radius.circular(20)),
), ),
children: [ children: [
TableRow( TableRow(
@ -50,17 +51,21 @@ class ScheduleGarageTableWidget extends StatelessWidget {
BlocBuilder<GarageDoorBloc, GarageDoorState>( BlocBuilder<GarageDoorBloc, GarageDoorState>(
builder: (context, state) { builder: (context, state) {
if (state is ScheduleGarageLoadingState) { if (state is ScheduleGarageLoadingState) {
return const SizedBox(height: 200, child: Center(child: CircularProgressIndicator())); return const SizedBox(
height: 200,
child: Center(child: CircularProgressIndicator()));
} }
if (state is GarageDoorLoadedState && state.status.schedules == null) { if (state is GarageDoorLoadedState &&
state.status.schedules == null) {
return _buildEmptyState(context); return _buildEmptyState(context);
} else if (state is GarageDoorLoadedState) { } else if (state is GarageDoorLoadedState) {
return Container( return Container(
height: 200, height: 200,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: ColorsManager.graysColor), border: Border.all(color: ColorsManager.graysColor),
borderRadius: borderRadius: const BorderRadius.only(
const BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)), bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20)),
), ),
child: _buildTableBody(state, context)); child: _buildTableBody(state, context));
} }
@ -78,7 +83,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
height: 200, height: 200,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: ColorsManager.graysColor), border: Border.all(color: ColorsManager.graysColor),
borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)), borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)),
), ),
child: Center( child: Center(
child: Column( child: Column(
@ -112,7 +118,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
children: [ children: [
if (state.status.schedules != null) if (state.status.schedules != null)
for (int i = 0; i < state.status.schedules!.length; i++) for (int i = 0; i < state.status.schedules!.length; i++)
_buildScheduleRow(state.status.schedules![i], i, context, state), _buildScheduleRow(
state.status.schedules![i], i, context, state),
], ],
), ),
), ),
@ -134,7 +141,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
); );
} }
TableRow _buildScheduleRow(ScheduleModel schedule, int index, BuildContext context, GarageDoorLoadedState state) { TableRow _buildScheduleRow(ScheduleModel schedule, int index,
BuildContext context, GarageDoorLoadedState state) {
return TableRow( return TableRow(
children: [ children: [
Center( Center(
@ -152,7 +160,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
width: 24, width: 24,
height: 24, height: 24,
child: schedule.enable child: schedule.enable
? const Icon(Icons.radio_button_checked, color: ColorsManager.blueColor) ? const Icon(Icons.radio_button_checked,
color: ColorsManager.blueColor)
: const Icon( : const Icon(
Icons.radio_button_unchecked, Icons.radio_button_unchecked,
color: ColorsManager.grayColor, color: ColorsManager.grayColor,
@ -160,7 +169,9 @@ class ScheduleGarageTableWidget extends StatelessWidget {
), ),
), ),
), ),
Center(child: Text(_getSelectedDays(ScheduleModel.parseSelectedDays(schedule.days)))), Center(
child: Text(_getSelectedDays(
ScheduleModel.parseSelectedDays(schedule.days)))),
Center(child: Text(formatIsoStringToTime(schedule.time, context))), Center(child: Text(formatIsoStringToTime(schedule.time, context))),
Center(child: Text(schedule.function.value ? 'On' : 'Off')), Center(child: Text(schedule.function.value ? 'On' : 'Off')),
Center( Center(
@ -170,18 +181,24 @@ class ScheduleGarageTableWidget extends StatelessWidget {
TextButton( TextButton(
style: TextButton.styleFrom(padding: EdgeInsets.zero), style: TextButton.styleFrom(padding: EdgeInsets.zero),
onPressed: () { onPressed: () {
ScheduleGarageDoorDialogHelper.showAddGarageDoorScheduleDialog(context, GarageDoorDialogHelper.showAddGarageDoorScheduleDialog(
schedule: schedule, index: index, isEdit: true); context,
schedule: schedule,
index: index,
isEdit: true);
}, },
child: Text( child: Text(
'Edit', 'Edit',
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blueColor), style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blueColor),
), ),
), ),
TextButton( TextButton(
style: TextButton.styleFrom(padding: EdgeInsets.zero), style: TextButton.styleFrom(padding: EdgeInsets.zero),
onPressed: () { onPressed: () {
context.read<GarageDoorBloc>().add(DeleteGarageDoorScheduleEvent( context
.read<GarageDoorBloc>()
.add(DeleteGarageDoorScheduleEvent(
index: index, index: index,
scheduleId: schedule.scheduleId, scheduleId: schedule.scheduleId,
deviceId: state.status.uuid, deviceId: state.status.uuid,
@ -189,7 +206,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
}, },
child: Text( child: Text(
'Delete', 'Delete',
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blueColor), style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blueColor),
), ),
), ),
], ],

View File

@ -34,7 +34,8 @@ class _BuildScheduleViewState extends State<BuildGarageDoorScheduleView> {
width: 700, width: 700,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 40.0, vertical: 20), padding:
const EdgeInsets.symmetric(horizontal: 40.0, vertical: 20),
child: BlocBuilder<GarageDoorBloc, GarageDoorState>( child: BlocBuilder<GarageDoorBloc, GarageDoorState>(
builder: (context, state) { builder: (context, state) {
if (state is GarageDoorLoadedState) { if (state is GarageDoorLoadedState) {
@ -46,8 +47,9 @@ class _BuildScheduleViewState extends State<BuildGarageDoorScheduleView> {
ScheduleGarageManagementUI( ScheduleGarageManagementUI(
state: state, state: state,
onAddSchedule: () { onAddSchedule: () {
ScheduleGarageDoorDialogHelper.showAddGarageDoorScheduleDialog(context, GarageDoorDialogHelper
schedule: null, index: null, isEdit: false); .showAddGarageDoorScheduleDialog(context,
schedule: null, index: null, isEdit: false);
}, },
), ),
const SizedBox(height: 20), const SizedBox(height: 20),

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
class TimeOutAlarmDialogBody extends StatelessWidget {
const TimeOutAlarmDialogBody({super.key});
@override
Widget build(BuildContext context) {
return Container(
width: 350,
child: Text('asdasd'),
);
}
}

View File

@ -13,6 +13,7 @@ class ToggleWidget extends StatelessWidget {
final Widget? labelWidget; final Widget? labelWidget;
final Function(dynamic value) onChange; final Function(dynamic value) onChange;
final bool showToggle; final bool showToggle;
final bool showIcon;
const ToggleWidget({ const ToggleWidget({
super.key, super.key,
@ -24,6 +25,7 @@ class ToggleWidget extends StatelessWidget {
this.icon, this.icon,
this.labelWidget, this.labelWidget,
this.showToggle = true, this.showToggle = true,
this.showIcon = true,
}); });
@override @override

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
extension BuildContextExt on BuildContext { extension BuildContextExt on BuildContext {
ThemeData get theme => Theme.of(this); ThemeData get theme => Theme.of(this);
@ -14,4 +15,115 @@ extension BuildContextExt on BuildContext {
double get screenHeight => MediaQuery.of(this).size.height; double get screenHeight => MediaQuery.of(this).size.height;
double get textScale => MediaQuery.textScalerOf(this).scale(1); double get textScale => MediaQuery.textScalerOf(this).scale(1);
void customAlertDialog({
required Widget alertBody,
required String title,
required VoidCallback onConfirm,
VoidCallback? onDismiss,
bool? hideConfirmButton,
final double? dialogWidth,
}) {
showDialog(
context: this,
builder: (BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Container(
width: dialogWidth ?? 360,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.only(top: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
/// header widget
Text(
title,
style: context.textTheme.bodyMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 15,
horizontal: 50,
),
child: Container(
height: 1,
width: double.infinity,
color: ColorsManager.greyColor,
),
),
/// custom body content
Flexible(child: SingleChildScrollView(child: alertBody)),
/// Footer buttons
Container(
height: 1,
width: double.infinity,
color: ColorsManager.greyColor,
),
hideConfirmButton != true
? Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: onDismiss ??
() {
Navigator.pop(context);
},
child: Center(
child: Text(
'Cancel',
style: context.textTheme.bodyMedium!
.copyWith(color: ColorsManager.greyColor),
),
),
),
Container(
height: 50,
width: 1,
color: ColorsManager.greyColor,
),
GestureDetector(
onTap: onConfirm,
child: Center(
child: Text(
'Confirm',
style: context.textTheme.bodyMedium!.copyWith(
color:
ColorsManager.primaryColorWithOpacity),
),
),
),
],
)
: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: GestureDetector(
onTap: onDismiss ??
() {
Navigator.pop(context);
},
child: Center(
child: Text(
'Cancel',
style: context.textTheme.bodyMedium!
.copyWith(color: ColorsManager.greyColor),
),
),
),
),
],
),
),
);
},
);
}
} }