mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
finlizing
This commit is contained in:
@ -88,32 +88,31 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
rightBody: const NavigateHomeGridView(),
|
rightBody: const NavigateHomeGridView(),
|
||||||
scaffoldBody: CreateNewRoutineView(),
|
scaffoldBody: BlocBuilder<SwitchTabsBloc, SwitchTabsState>(
|
||||||
// BlocBuilder<SwitchTabsBloc, SwitchTabsState>(
|
builder: (context, state) {
|
||||||
// builder: (context, state) {
|
if (state is SelectedTabState && state.selectedTab) {
|
||||||
// if (state is SelectedTabState && state.selectedTab) {
|
return const RoutinesView();
|
||||||
// return const RoutinesView();
|
}
|
||||||
// }
|
if (state is ShowCreateRoutineState && state.showCreateRoutine) {
|
||||||
// if (state is ShowCreateRoutineState && state.showCreateRoutine) {
|
return const CreateNewRoutineView();
|
||||||
// return const CreateNewRoutineView();
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// return BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
return BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
||||||
// builder: (context, deviceState) {
|
builder: (context, deviceState) {
|
||||||
// if (deviceState is DeviceManagementLoading) {
|
if (deviceState is DeviceManagementLoading) {
|
||||||
// return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
// } else if (deviceState is DeviceManagementLoaded ||
|
} else if (deviceState is DeviceManagementLoaded ||
|
||||||
// deviceState is DeviceManagementFiltered) {
|
deviceState is DeviceManagementFiltered) {
|
||||||
// final devices = (deviceState as dynamic).devices ??
|
final devices = (deviceState as dynamic).devices ??
|
||||||
// (deviceState as DeviceManagementFiltered).filteredDevices;
|
(deviceState as DeviceManagementFiltered).filteredDevices;
|
||||||
|
|
||||||
// return DeviceManagementBody(devices: devices);
|
return DeviceManagementBody(devices: devices);
|
||||||
// } else {
|
} else {
|
||||||
// return const Center(child: Text('Error fetching Devices'));
|
return const Center(child: Text('Error fetching Devices'));
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// );
|
);
|
||||||
// }),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent);
|
on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent);
|
||||||
on<CreateAutomationEvent>(_onCreateAutomation);
|
on<CreateAutomationEvent>(_onCreateAutomation);
|
||||||
on<SetRoutineName>(_onSetRoutineName);
|
on<SetRoutineName>(_onSetRoutineName);
|
||||||
|
on<ResetRoutineState>(_onResetRoutineState);
|
||||||
// on<RemoveFunction>(_onRemoveFunction);
|
// on<RemoveFunction>(_onRemoveFunction);
|
||||||
// on<ClearFunctions>(_onClearFunctions);
|
// on<ClearFunctions>(_onClearFunctions);
|
||||||
}
|
}
|
||||||
@ -370,4 +371,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
routineName: null,
|
routineName: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _onResetRoutineState(
|
||||||
|
ResetRoutineState event, Emitter<RoutineState> emit) {
|
||||||
|
emit(_resetState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,4 +121,7 @@ class SetRoutineName extends RoutineEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [name];
|
List<Object> get props => [name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ResetRoutineState extends RoutineEvent {}
|
||||||
|
|
||||||
class ClearFunctions extends RoutineEvent {}
|
class ClearFunctions extends RoutineEvent {}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/common/custom_table.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/switch_tabs/switch_tabs_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
|
class DiscardDialog {
|
||||||
|
static void show(BuildContext context) {
|
||||||
|
context.customAlertDialog(
|
||||||
|
alertBody: Container(
|
||||||
|
height: 150,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'If you close, you will lose all the changes you have made.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: context.textTheme.bodyMedium!.copyWith(
|
||||||
|
color: ColorsManager.red,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Are you sure you wish to close?',
|
||||||
|
style: context.textTheme.bodyMedium!.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
title: 'Discard',
|
||||||
|
titleStyle: context.textTheme.titleLarge!.copyWith(
|
||||||
|
color: ColorsManager.red,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
onDismissText: "Don’t Close",
|
||||||
|
onConfirmText: "Close",
|
||||||
|
onDismissColor: ColorsManager.grayColor,
|
||||||
|
onConfirmColor: ColorsManager.red.withOpacity(0.8),
|
||||||
|
onDismiss: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
onConfirm: () {
|
||||||
|
context.read<RoutineBloc>().add(ResetRoutineState());
|
||||||
|
Navigator.pop(context);
|
||||||
|
BlocProvider.of<SwitchTabsBloc>(context).add(
|
||||||
|
const CreateNewRoutineViewEvent(false),
|
||||||
|
);
|
||||||
|
BlocProvider.of<SwitchTabsBloc>(context).add(
|
||||||
|
const TriggerSwitchTabsEvent(true),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
|||||||
import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/helper/save_routine_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/save_routine_helper.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/discard_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/setting_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/setting_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
@ -96,7 +97,9 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
|||||||
width: 200,
|
width: 200,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
DiscardDialog.show(context);
|
||||||
|
},
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
borderColor: ColorsManager.greyColor,
|
borderColor: ColorsManager.greyColor,
|
||||||
@ -148,7 +151,16 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
|||||||
width: 200,
|
width: 200,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {},
|
onPressed: () async {
|
||||||
|
final result = await SettingHelper.showSettingDialog(
|
||||||
|
context: context,
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(AddSelectedIcon(result));
|
||||||
|
}
|
||||||
|
},
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
borderColor: ColorsManager.greyColor,
|
borderColor: ColorsManager.greyColor,
|
||||||
@ -192,7 +204,9 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
|||||||
width: 200,
|
width: 200,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||||
|
},
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
backgroundColor: ColorsManager.primaryColor,
|
backgroundColor: ColorsManager.primaryColor,
|
||||||
|
@ -23,6 +23,11 @@ extension BuildContextExt on BuildContext {
|
|||||||
VoidCallback? onDismiss,
|
VoidCallback? onDismiss,
|
||||||
bool? hideConfirmButton,
|
bool? hideConfirmButton,
|
||||||
final double? dialogWidth,
|
final double? dialogWidth,
|
||||||
|
TextStyle? titleStyle,
|
||||||
|
String? onDismissText,
|
||||||
|
String? onConfirmText,
|
||||||
|
Color? onDismissColor,
|
||||||
|
Color? onConfirmColor,
|
||||||
}) {
|
}) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: this,
|
context: this,
|
||||||
@ -42,10 +47,11 @@ extension BuildContextExt on BuildContext {
|
|||||||
/// header widget
|
/// header widget
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
style: context.textTheme.bodyMedium!.copyWith(
|
style: titleStyle ??
|
||||||
color: ColorsManager.primaryColorWithOpacity,
|
context.textTheme.bodyMedium!.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@ -79,9 +85,10 @@ extension BuildContextExt on BuildContext {
|
|||||||
},
|
},
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Cancel',
|
onDismissText ?? 'Cancel',
|
||||||
style: context.textTheme.bodyMedium!
|
style: context.textTheme.bodyMedium!.copyWith(
|
||||||
.copyWith(color: ColorsManager.greyColor),
|
color: onDismissColor ??
|
||||||
|
ColorsManager.greyColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -94,9 +101,9 @@ extension BuildContextExt on BuildContext {
|
|||||||
onTap: onConfirm,
|
onTap: onConfirm,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Confirm',
|
onConfirmText ?? 'Confirm',
|
||||||
style: context.textTheme.bodyMedium!.copyWith(
|
style: context.textTheme.bodyMedium!.copyWith(
|
||||||
color:
|
color: onConfirmColor ??
|
||||||
ColorsManager.primaryColorWithOpacity),
|
ColorsManager.primaryColorWithOpacity),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user