mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
144 lines
5.1 KiB
Dart
144 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
|
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
|
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
|
|
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
|
|
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
|
|
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
|
import 'package:syncrow_app/generated/assets.dart';
|
|
import 'package:syncrow_app/utils/context_extension.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
|
|
|
class SceneTasksView extends StatelessWidget {
|
|
const SceneTasksView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
|
as SceneSettingsRouteArguments;
|
|
return DefaultScaffold(
|
|
title: sceneSettings.sceneName.isNotEmpty
|
|
? sceneSettings.sceneName
|
|
: StringsManager.createScene,
|
|
padding: EdgeInsets.zero,
|
|
actions: [
|
|
SizedBox(
|
|
width: 40,
|
|
child: GestureDetector(
|
|
onTap: sceneSettings.sceneName.isEmpty
|
|
? null
|
|
: () {
|
|
context.customBottomSheet(
|
|
child: DeleteBottomSheetContent(
|
|
sceneId: sceneSettings.sceneId),
|
|
);
|
|
},
|
|
child: SvgPicture.asset(
|
|
Assets.assetsIconsSettings,
|
|
colorFilter: const ColorFilter.mode(
|
|
ColorsManager.textPrimaryColor,
|
|
BlendMode.srcIn,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
child: Stack(
|
|
children: [
|
|
SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(
|
|
height: 24,
|
|
),
|
|
// IF
|
|
const IFDefaultContainer(),
|
|
const SizedBox(
|
|
height: 8,
|
|
),
|
|
// THEN
|
|
ThenDefaultContainer(sceneId: sceneSettings.sceneId),
|
|
const SizedBox(
|
|
height: 100,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 16,
|
|
right: 40,
|
|
left: 40,
|
|
child: SizedBox(
|
|
width: context.width * 0.8,
|
|
child: CreateSceneSaveButton(
|
|
sceneName: sceneSettings.sceneName,
|
|
sceneId: sceneSettings.sceneId,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class DeleteBottomSheetContent extends StatelessWidget {
|
|
const DeleteBottomSheetContent({super.key, required this.sceneId});
|
|
|
|
final String sceneId;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DefaultContainer(
|
|
height: context.height * 0.2,
|
|
child: ListView(
|
|
shrinkWrap: true,
|
|
children: [
|
|
BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
|
listener: (context, state) {
|
|
if (state is DeleteSceneSuccess) {
|
|
if (state.success) {
|
|
Navigator.pop(context);
|
|
Navigator.pop(context);
|
|
BlocProvider.of<SceneBloc>(context).add(
|
|
LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
|
}
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
return DefaultContainer(
|
|
onTap: () {
|
|
context.read<CreateSceneBloc>().add(DeleteSceneEvent(
|
|
sceneId: sceneId,
|
|
unitUuid:
|
|
HomeCubit.getInstance().selectedSpace!.id!,
|
|
));
|
|
},
|
|
child: SceneListTile(
|
|
titleString: StringsManager.deleteScene,
|
|
leadingWidget: (state is DeleteSceneLoading)
|
|
? const SizedBox(
|
|
height: 24,
|
|
width: 24,
|
|
child: CircularProgressIndicator())
|
|
: SvgPicture.asset(
|
|
Assets.assetsDeleteIcon,
|
|
color: ColorsManager.red,
|
|
),
|
|
));
|
|
},
|
|
),
|
|
],
|
|
));
|
|
}
|
|
}
|