This commit is contained in:
Faris Armoush
2025-04-23 15:43:55 +03:00
parent e7efd2b3a1
commit 1f1a8a7208
8 changed files with 228 additions and 11 deletions

View File

@ -0,0 +1,15 @@
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5419 20.2424C11.1182 19.3486 10.0545 18.9678 9.16647 19.3935L1.38334 23.1268C0.591819 23.3098 0 24.0197 0 24.8727V33.8466C0 34.8381 0.797668 35.6413 1.78229 35.6413C2.76668 35.6413 3.56412 34.8381 3.56412 33.8466V27.6644L9.16647 30.3516C9.41376 30.4704 9.67449 30.5264 9.93112 30.5264C10.5974 30.5264 11.2359 30.1484 11.5419 29.5025C11.9643 28.6076 11.5875 27.5367 10.699 27.1103L6.03295 24.8725L10.699 22.6346C11.5877 22.2085 11.9643 21.1376 11.5419 20.2424Z" fill="#D5D5D5"/>
<path d="M20.6084 17.6894C20.8655 17.6894 21.1257 17.6334 21.3737 17.5146L32.0481 12.3951C32.9366 11.9685 33.3141 10.8974 32.891 10.0024C32.4682 9.10864 31.4052 8.72813 30.5156 9.15359L19.8408 14.2736C18.9522 14.6999 18.5754 15.7706 18.998 16.6658C19.3038 17.3112 19.9423 17.6894 20.6084 17.6894Z" fill="#D5D5D5"/>
<path d="M42.7227 7.27445L48.1841 4.65449V10.9114C48.1841 11.9027 48.9818 12.7061 49.9659 12.7061C50.9503 12.7061 51.7478 11.9027 51.7478 10.9114V4.62192L57.2779 7.27445C57.5259 7.39303 57.7862 7.44922 58.0433 7.44922C58.7091 7.44922 59.3478 7.07124 59.6534 6.42537C60.0763 5.53041 59.6994 4.45953 58.8106 4.03316L50.7663 0.174427C50.2813 -0.0581424 49.7189 -0.0581424 49.2338 0.174427L41.19 4.03316C40.3015 4.45953 39.9244 5.53018 40.3472 6.42537C40.771 7.32101 41.8362 7.70198 42.7227 7.27445Z" fill="#D5D5D5"/>
<path d="M67.9533 12.3944L78.6281 17.5146C78.875 17.6334 79.1361 17.6894 79.3932 17.6894C80.059 17.6894 80.6978 17.3114 81.0034 16.6655C81.426 15.7706 81.0494 14.6997 80.1606 14.2733L69.4856 9.1529C68.5982 8.72721 67.5345 9.10726 67.1105 10.0018C66.6875 10.8967 67.0645 11.9676 67.9533 12.3944Z" fill="#D5D5D5"/>
<path d="M81.539 34.8099C82.4275 34.3837 82.8046 33.3128 82.3815 32.4177C81.9587 31.5232 80.8946 31.1424 80.0065 31.5695L73.167 34.8509L51.7477 24.577V16.5765C51.7477 15.5846 50.9503 14.7818 49.9659 14.7818C48.9817 14.7818 48.1841 15.5848 48.1841 16.5765V24.6096L26.8346 34.85L20.6999 31.9073C19.8093 31.481 18.7482 31.8612 18.3244 32.7564C17.9016 33.6514 18.2787 34.7225 19.1672 35.1489L25.8031 38.3319V61.6684L19.0593 64.9031C18.1707 65.3295 17.7939 66.4001 18.2165 67.2955C18.5221 67.9412 19.1606 68.3192 19.8266 68.3192C20.0837 68.3192 20.3447 68.2632 20.5917 68.1444L26.8349 65.1499L48.1841 75.3903V81.5075C48.1841 82.4993 48.9817 83.3022 49.9659 83.3022C50.9503 83.3022 51.7477 82.499 51.7477 81.5075V75.4233L73.1657 65.1501L79.6524 68.2616C79.9002 68.3802 80.1607 68.4364 80.4175 68.4364C81.0834 68.4364 81.7221 68.0584 82.0277 67.4125C82.4508 66.5175 82.0735 65.4467 81.1849 65.0201L74.1977 61.6687V38.3319L81.539 34.8099ZM70.634 62.3879L51.7479 71.4467V49.0994L70.634 40.0402V62.3879ZM29.4788 61.8939C29.4472 61.8269 29.4053 61.7691 29.3668 61.7081V40.0404L48.1841 49.0663V71.4141L29.6409 62.5198C29.6239 62.3086 29.5745 62.0964 29.4788 61.8939ZM50.0003 27.7151L69.0207 36.8383L50.0003 45.9611L30.9799 36.8383L50.0003 27.7151Z" fill="#D5D5D5"/>
<path d="M78.6271 82.486L67.9525 87.6062C67.0639 88.0328 66.6864 89.1036 67.1095 89.9979C67.4153 90.644 68.054 91.0215 68.7199 91.0215C68.9767 91.0215 69.2379 90.9656 69.485 90.8477L80.1598 85.7273C81.0483 85.3009 81.4252 84.2295 81.0025 83.3346C80.579 82.4401 79.5149 82.0616 78.6271 82.486Z" fill="#D5D5D5"/>
<path d="M57.2782 92.7266L51.748 95.3793V88.227C51.748 87.2357 50.9506 86.4323 49.9662 86.4323C48.982 86.4323 48.1844 87.2357 48.1844 88.227V95.3468L42.723 92.7266C41.8335 92.3023 40.7713 92.6807 40.3475 93.5759C39.9246 94.4709 40.3015 95.5413 41.1903 95.9676L49.2346 99.8259C49.4769 99.9417 49.7387 100 50.0008 100C50.2629 100 50.5248 99.9417 50.7671 99.8259L58.8114 95.9676C59.6999 95.5413 60.077 94.4709 59.6541 93.5759C59.2304 92.6807 58.166 92.3032 57.2782 92.7266Z" fill="#D5D5D5"/>
<path d="M32.0476 87.6061L21.3728 82.4859C20.4863 82.0605 19.4217 82.4394 18.9975 83.3343C18.5749 84.2293 18.9517 85.3006 19.8403 85.727L30.5153 90.8474C30.7622 90.9653 31.0233 91.0213 31.2802 91.0213C31.946 91.0213 32.5847 90.6438 32.8903 89.9977C33.3132 89.1036 32.9361 88.0328 32.0476 87.6061Z" fill="#D5D5D5"/>
<path d="M11.5419 70.4974C11.1182 69.6029 10.0545 69.224 9.16647 69.6488L3.56412 72.3355V65.6178C3.56412 64.6265 2.76668 63.823 1.78229 63.823C0.797668 63.823 0 64.6265 0 65.6178V74.5919C0 74.8162 0.0457694 75.0284 0.120686 75.2263C0.156892 75.8784 0.53193 76.4651 1.12215 76.7486L9.16647 80.6073C9.41376 80.7254 9.67449 80.7818 9.93112 80.7818C10.5974 80.7818 11.2359 80.4038 11.5419 79.7582C11.9643 78.8632 11.5875 77.7924 10.699 77.3655L6.03295 75.1281L10.699 72.8903C11.5877 72.4637 11.9643 71.3923 11.5419 70.4974Z" fill="#D5D5D5"/>
<path d="M1.78229 56.8226C2.76668 56.8226 3.56412 56.0193 3.56412 55.0274V44.4374C3.56412 43.4461 2.76668 42.6427 1.78229 42.6427C0.797668 42.6427 0 43.4461 0 44.4374V55.0274C0.00022771 56.0193 0.797896 56.8226 1.78229 56.8226Z" fill="#D5D5D5"/>
<path d="M98.6173 23.1268L90.8342 19.3935C89.9443 18.9667 88.8825 19.3479 88.4589 20.2424C88.0363 21.1378 88.4132 22.2084 89.3017 22.6351L93.9677 24.8729L89.3017 27.1108C88.4132 27.5371 88.0363 28.6078 88.4589 29.503C88.7645 30.1488 89.4032 30.5268 90.0691 30.5268C90.3262 30.5268 90.5873 30.4709 90.8342 30.3521L96.4365 27.6649V33.847C96.4365 34.8385 97.234 35.6418 98.2184 35.6418C99.2027 35.6418 100 34.8385 100 33.847V24.8731C100 24.0197 99.4088 23.3098 98.6173 23.1268Z" fill="#D5D5D5"/>
<path d="M98.2184 42.642C97.2337 42.642 96.4365 43.4455 96.4365 44.4367V55.0267C96.4365 56.0187 97.234 56.8214 98.2184 56.8214C99.2027 56.8214 100 56.0184 100 55.0267V44.4367C100 43.4455 99.203 42.642 98.2184 42.642Z" fill="#D5D5D5"/>
<path d="M98.2184 63.8228C97.2337 63.8228 96.4365 64.6263 96.4365 65.6175V72.3352L90.8342 69.6485C89.9443 69.2231 88.8825 69.6022 88.4589 70.4971C88.0363 71.3921 88.4132 72.4634 89.3017 72.8898L93.9677 75.1277L89.3017 77.3651C88.4132 77.7919 88.0363 78.8628 88.4589 79.7577C88.7645 80.4034 89.4032 80.7814 90.0691 80.7814C90.3262 80.7814 90.5873 80.7249 90.8342 80.6068L98.8785 76.7481C99.4687 76.4646 99.8438 75.8779 99.88 75.2258C99.9546 75.0279 100 74.8157 100 74.5914V65.6173C100 64.6263 99.203 63.8228 98.2184 63.8228Z" fill="#D5D5D5"/>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -22,7 +22,7 @@ import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_e
import 'package:syncrow_app/features/scene/bloc/smart_scene/smart_scene_select_dart_bloc.dart';
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
import 'package:syncrow_app/features/scene/view/scene_view.dart';
import 'package:syncrow_app/features/scene/view/routines_view.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/navigation/navigation_service.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
@ -580,7 +580,7 @@ class HomeCubit extends Cubit<HomeState> {
create: (context) => DevicesCubit.getInstance(),
child: const DevicesViewBody(),
),
const SceneView(),
const RoutinesView(),
const MenuView(),
];

View File

@ -0,0 +1,117 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.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/bloc/smart_scene/smart_scene_select_dart_bloc.dart';
import 'package:syncrow_app/features/scene/helper/scene_bloc_factory.dart';
import 'package:syncrow_app/features/scene/widgets/empty_routines_widget.dart';
import 'package:syncrow_app/features/scene/widgets/routines_expansion_tile.dart';
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_header.dart';
import 'package:syncrow_app/features/shared_widgets/app_loading_indicator.dart';
import 'package:syncrow_app/utils/context_extension.dart';
class RoutinesView extends StatelessWidget {
const RoutinesView({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => SceneBlocFactory.create(
pageType: false,
homeCubit: HomeCubit.getInstance(),
),
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
builder: (context, state) {
final selectedSpace = HomeCubit.getInstance().selectedSpace;
if (state is DeleteSceneSuccess) {
if (state.success) _loadScenesAndAutomations(context, selectedSpace);
}
if (state is CreateSceneWithTasks) {
if (state.success) {
_loadScenesAndAutomations(context, selectedSpace);
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
}
}
return BlocListener<SceneBloc, SceneState>(
listener: (context, state) {
if (state is SceneTriggerSuccess) {
context.showCustomSnackbar(
message: 'Scene ${state.sceneName} triggered successfully!',
);
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SceneHeader(),
const SizedBox(height: 8),
Expanded(
child: BlocBuilder<SceneBloc, SceneState>(
builder: (context, state) {
if (state is SceneLoading) {
return const AppLoadingIndicator();
}
if (state is SceneError) {
return Center(
child: Text(state.message),
);
}
if (state is SceneLoaded) {
final scenes = state.scenes;
final automationList = state.automationList;
final routinesIsEmpty =
scenes.isEmpty && automationList.isEmpty;
if (routinesIsEmpty) return const EmptyRoutinesWidget();
return Theme(
data: Theme.of(context).copyWith(
dividerColor: Colors.transparent,
),
child: Expanded(
child: ListView(
children: [
RoutinesExpansionTile(
title: 'Tap to run routines',
emptyRoutinesMessage:
'No scenes have been added yet',
routines: state.scenes,
loadingStates: state.loadingStates,
loadingSceneId: state.loadingSceneId,
),
RoutinesExpansionTile(
title: 'Automation',
emptyRoutinesMessage:
'No automations have been added yet',
routines: state.automationList,
loadingStates: state.loadingStates,
loadingSceneId: state.loadingSceneId,
),
const SizedBox(height: 15),
],
),
),
);
}
return const SizedBox.shrink();
},
),
),
],
),
);
},
),
);
}
void _loadScenesAndAutomations(BuildContext context, SpaceModel? selectedSpace) {
context.read<SceneBloc>()
..add(LoadScenes(selectedSpace!.id, selectedSpace, showInDevice: false))
..add(LoadAutomation(selectedSpace.id, selectedSpace.community.uuid));
}
}

View File

@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class EmptyRoutinesWidget extends StatelessWidget {
const EmptyRoutinesWidget({super.key});
@override
Widget build(BuildContext context) {
return Expanded(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
spacing: 16,
children: [
SvgPicture.asset(
'assets/icons/empty_routines.svg',
colorFilter: ColorFilter.mode(
ColorsManager.textGray,
BlendMode.srcIn,
),
),
BodyMedium(
text: 'No Routines yet',
fontColor: ColorsManager.textGray,
),
],
),
),
);
}
}

View File

@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class RoutinesExpansionTile extends StatelessWidget {
const RoutinesExpansionTile({
super.key,
required this.title,
required this.emptyRoutinesMessage,
required this.routines,
required this.loadingStates,
this.loadingSceneId,
});
final String title;
final String emptyRoutinesMessage;
final List<ScenesModel> routines;
final Map<String, bool> loadingStates;
final String? loadingSceneId;
@override
Widget build(BuildContext context) {
return ExpansionTile(
tilePadding: const EdgeInsets.symmetric(
horizontal: 6,
),
initiallyExpanded: true,
iconColor: ColorsManager.grayColor,
title: BodyMedium(
text: title,
),
childrenPadding: EdgeInsetsDirectional.only(bottom: 10),
children: [
Visibility(
visible: routines.isNotEmpty,
replacement: Center(
child: BodyMedium(
text: emptyRoutinesMessage,
textAlign: TextAlign.center,
),
),
child: SceneGrid(
scenes: routines,
loadingSceneId: loadingSceneId,
disablePlayButton: false,
loadingStates: loadingStates,
),
),
],
);
}
}

View File

@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
class SceneHeader extends StatelessWidget {
@ -19,10 +17,6 @@ class SceneHeader extends StatelessWidget {
fontWeight: FontWeight.bold,
),
),
// SizedBox(height: 20),
// BodySmall(
// text: StringsManager.tapToRunRoutine,
// ),
],
);
}

View File

@ -59,13 +59,16 @@ class DefaultScaffold extends StatelessWidget {
height: height ?? MediaQuery.sizeOf(context).height,
padding: padding ??
const EdgeInsets.symmetric(horizontal: Constants.defaultPadding),
decoration: const BoxDecoration(
image: DecorationImage(
decoration: BoxDecoration(
image: const DecorationImage(
colorFilter: ColorFilter.mode(
ColorsManager.backgroundGrey,
BlendMode.srcIn,
),
image: AssetImage(
Assets.assetsImagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: SafeArea(child: child),

View File

@ -35,6 +35,7 @@ abstract class ColorsManager {
static const Color blueColor1 = Color(0xff0A7AFF);
static const Color grayButtonColors = Color(0xffCCCCCC);
static const Color blueButton = Color(0xff85BDFF);
static const Color backgroundGrey = Color(0xFFF3F3F3);
}
//background: #F5F5F5;background: #85BDFF;