mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
61 lines
2.2 KiB
Dart
61 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/switch_tabs/switch_tabs_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),
|
||
);
|
||
});
|
||
}
|
||
}
|