mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
finlizing
This commit is contained in:
@ -88,32 +88,31 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
);
|
||||
}),
|
||||
rightBody: const NavigateHomeGridView(),
|
||||
scaffoldBody: CreateNewRoutineView(),
|
||||
// BlocBuilder<SwitchTabsBloc, SwitchTabsState>(
|
||||
// builder: (context, state) {
|
||||
// if (state is SelectedTabState && state.selectedTab) {
|
||||
// return const RoutinesView();
|
||||
// }
|
||||
// if (state is ShowCreateRoutineState && state.showCreateRoutine) {
|
||||
// return const CreateNewRoutineView();
|
||||
// }
|
||||
scaffoldBody: BlocBuilder<SwitchTabsBloc, SwitchTabsState>(
|
||||
builder: (context, state) {
|
||||
if (state is SelectedTabState && state.selectedTab) {
|
||||
return const RoutinesView();
|
||||
}
|
||||
if (state is ShowCreateRoutineState && state.showCreateRoutine) {
|
||||
return const CreateNewRoutineView();
|
||||
}
|
||||
|
||||
// return BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
||||
// builder: (context, deviceState) {
|
||||
// if (deviceState is DeviceManagementLoading) {
|
||||
// return const Center(child: CircularProgressIndicator());
|
||||
// } else if (deviceState is DeviceManagementLoaded ||
|
||||
// deviceState is DeviceManagementFiltered) {
|
||||
// final devices = (deviceState as dynamic).devices ??
|
||||
// (deviceState as DeviceManagementFiltered).filteredDevices;
|
||||
return BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
||||
builder: (context, deviceState) {
|
||||
if (deviceState is DeviceManagementLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (deviceState is DeviceManagementLoaded ||
|
||||
deviceState is DeviceManagementFiltered) {
|
||||
final devices = (deviceState as dynamic).devices ??
|
||||
(deviceState as DeviceManagementFiltered).filteredDevices;
|
||||
|
||||
// return DeviceManagementBody(devices: devices);
|
||||
// } else {
|
||||
// return const Center(child: Text('Error fetching Devices'));
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// }),
|
||||
return DeviceManagementBody(devices: devices);
|
||||
} else {
|
||||
return const Center(child: Text('Error fetching Devices'));
|
||||
}
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent);
|
||||
on<CreateAutomationEvent>(_onCreateAutomation);
|
||||
on<SetRoutineName>(_onSetRoutineName);
|
||||
on<ResetRoutineState>(_onResetRoutineState);
|
||||
// on<RemoveFunction>(_onRemoveFunction);
|
||||
// on<ClearFunctions>(_onClearFunctions);
|
||||
}
|
||||
@ -370,4 +371,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
routineName: null,
|
||||
);
|
||||
}
|
||||
|
||||
FutureOr<void> _onResetRoutineState(
|
||||
ResetRoutineState event, Emitter<RoutineState> emit) {
|
||||
emit(_resetState());
|
||||
}
|
||||
}
|
||||
|
@ -121,4 +121,7 @@ class SetRoutineName extends RoutineEvent {
|
||||
@override
|
||||
List<Object> get props => [name];
|
||||
}
|
||||
|
||||
class ResetRoutineState 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/routiens/bloc/routine_bloc/routine_bloc.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/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
@ -96,7 +97,9 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
DiscardDialog.show(context);
|
||||
},
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
borderColor: ColorsManager.greyColor,
|
||||
@ -148,7 +151,16 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: () {},
|
||||
onPressed: () async {
|
||||
final result = await SettingHelper.showSettingDialog(
|
||||
context: context,
|
||||
);
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddSelectedIcon(result));
|
||||
}
|
||||
},
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
borderColor: ColorsManager.greyColor,
|
||||
@ -192,7 +204,9 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: DefaultButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||
},
|
||||
borderRadius: 15,
|
||||
elevation: 0,
|
||||
backgroundColor: ColorsManager.primaryColor,
|
||||
|
@ -23,6 +23,11 @@ extension BuildContextExt on BuildContext {
|
||||
VoidCallback? onDismiss,
|
||||
bool? hideConfirmButton,
|
||||
final double? dialogWidth,
|
||||
TextStyle? titleStyle,
|
||||
String? onDismissText,
|
||||
String? onConfirmText,
|
||||
Color? onDismissColor,
|
||||
Color? onConfirmColor,
|
||||
}) {
|
||||
showDialog(
|
||||
context: this,
|
||||
@ -42,10 +47,11 @@ extension BuildContextExt on BuildContext {
|
||||
/// header widget
|
||||
Text(
|
||||
title,
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
style: titleStyle ??
|
||||
context.textTheme.bodyMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
@ -79,9 +85,10 @@ extension BuildContextExt on BuildContext {
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(color: ColorsManager.greyColor),
|
||||
onDismissText ?? 'Cancel',
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
color: onDismissColor ??
|
||||
ColorsManager.greyColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -94,9 +101,9 @@ extension BuildContextExt on BuildContext {
|
||||
onTap: onConfirm,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
onConfirmText ?? 'Confirm',
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
color:
|
||||
color: onConfirmColor ??
|
||||
ColorsManager.primaryColorWithOpacity),
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user