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

@ -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(
border: TableBorder.all(
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: [
TableRow(
@ -50,17 +51,21 @@ class ScheduleGarageTableWidget extends StatelessWidget {
BlocBuilder<GarageDoorBloc, GarageDoorState>(
builder: (context, state) {
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);
} else if (state is GarageDoorLoadedState) {
return Container(
height: 200,
decoration: BoxDecoration(
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: _buildTableBody(state, context));
}
@ -78,7 +83,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
height: 200,
decoration: BoxDecoration(
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: Column(
@ -112,7 +118,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
children: [
if (state.status.schedules != null)
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(
children: [
Center(
@ -152,7 +160,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
width: 24,
height: 24,
child: schedule.enable
? const Icon(Icons.radio_button_checked, color: ColorsManager.blueColor)
? const Icon(Icons.radio_button_checked,
color: ColorsManager.blueColor)
: const Icon(
Icons.radio_button_unchecked,
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(schedule.function.value ? 'On' : 'Off')),
Center(
@ -170,18 +181,24 @@ class ScheduleGarageTableWidget extends StatelessWidget {
TextButton(
style: TextButton.styleFrom(padding: EdgeInsets.zero),
onPressed: () {
ScheduleGarageDoorDialogHelper.showAddGarageDoorScheduleDialog(context,
schedule: schedule, index: index, isEdit: true);
GarageDoorDialogHelper.showAddGarageDoorScheduleDialog(
context,
schedule: schedule,
index: index,
isEdit: true);
},
child: Text(
'Edit',
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blueColor),
style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blueColor),
),
),
TextButton(
style: TextButton.styleFrom(padding: EdgeInsets.zero),
onPressed: () {
context.read<GarageDoorBloc>().add(DeleteGarageDoorScheduleEvent(
context
.read<GarageDoorBloc>()
.add(DeleteGarageDoorScheduleEvent(
index: index,
scheduleId: schedule.scheduleId,
deviceId: state.status.uuid,
@ -189,7 +206,8 @@ class ScheduleGarageTableWidget extends StatelessWidget {
},
child: Text(
'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,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 40.0, vertical: 20),
padding:
const EdgeInsets.symmetric(horizontal: 40.0, vertical: 20),
child: BlocBuilder<GarageDoorBloc, GarageDoorState>(
builder: (context, state) {
if (state is GarageDoorLoadedState) {
@ -46,8 +47,9 @@ class _BuildScheduleViewState extends State<BuildGarageDoorScheduleView> {
ScheduleGarageManagementUI(
state: state,
onAddSchedule: () {
ScheduleGarageDoorDialogHelper.showAddGarageDoorScheduleDialog(context,
schedule: null, index: null, isEdit: false);
GarageDoorDialogHelper
.showAddGarageDoorScheduleDialog(context,
schedule: null, index: null, isEdit: false);
},
),
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'),
);
}
}