mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 10:06:16 +00:00
Merge branch 'dev' of https://github.com/SyncrowIOT/syncrow-app into feat/update-additional-device-endpoints
This commit is contained in:
@ -8,8 +8,7 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
class GarageList extends StatelessWidget {
|
class GarageList extends StatelessWidget {
|
||||||
const GarageList(
|
const GarageList({super.key, required this.garageList, required this.allSwitches});
|
||||||
{super.key, required this.garageList, required this.allSwitches});
|
|
||||||
|
|
||||||
final List<GroupGarageModel> garageList;
|
final List<GroupGarageModel> garageList;
|
||||||
final bool allSwitches;
|
final bool allSwitches;
|
||||||
@ -23,43 +22,42 @@ class GarageList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Garages'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'Close',
|
||||||
on: 'ON',
|
on: 'Open',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () => BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
BlocProvider.of<GarageDoorBloc>(context)
|
GroupAllOnEvent(),
|
||||||
.add(GroupAllOnEvent());
|
),
|
||||||
},
|
secondAction: () => BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
secondAction: () {
|
GroupAllOffEvent(),
|
||||||
BlocProvider.of<GarageDoorBloc>(context)
|
),
|
||||||
.add(GroupAllOffEvent());
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: EdgeInsetsDirectional.zero,
|
||||||
itemCount: garageList.length,
|
itemCount: garageList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
final garageDoor = garageList[index];
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: garageList[index].deviceName),
|
BodySmall(text: garageDoor.deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'Close',
|
||||||
on: 'ON',
|
on: 'Open',
|
||||||
switchValue: garageList[index].firstSwitch,
|
switchValue: garageDoor.firstSwitch,
|
||||||
action: () {
|
action: () => BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
BlocProvider.of<GarageDoorBloc>(context).add(
|
ChangeFirstWizardSwitchStatusEvent(
|
||||||
ChangeFirstWizardSwitchStatusEvent(
|
value: garageDoor.firstSwitch,
|
||||||
value: garageList[index].firstSwitch,
|
deviceId: garageDoor.deviceId,
|
||||||
deviceId: garageList[index].deviceId));
|
),
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -8,7 +8,11 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
class WHList extends StatelessWidget {
|
class WHList extends StatelessWidget {
|
||||||
const WHList({super.key, required this.whList, required this.allSwitches});
|
const WHList({
|
||||||
|
required this.whList,
|
||||||
|
required this.allSwitches,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final List<GroupWHModel> whList;
|
final List<GroupWHModel> whList;
|
||||||
final bool allSwitches;
|
final bool allSwitches;
|
||||||
@ -22,43 +26,42 @@ class WHList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Water Heaters'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'OFF',
|
||||||
on: 'ON',
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () => context.read<WaterHeaterBloc>().add(
|
||||||
BlocProvider.of<WaterHeaterBloc>(context)
|
GroupAllOnEvent(),
|
||||||
.add(GroupAllOnEvent());
|
),
|
||||||
},
|
secondAction: () => context.read<WaterHeaterBloc>().add(
|
||||||
secondAction: () {
|
GroupAllOffEvent(),
|
||||||
BlocProvider.of<WaterHeaterBloc>(context)
|
),
|
||||||
.add(GroupAllOffEvent());
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: EdgeInsetsDirectional.zero,
|
||||||
itemCount: whList.length,
|
itemCount: whList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
final waterHeater = whList[index];
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: whList[index].deviceName),
|
BodySmall(text: waterHeater.deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'OFF',
|
||||||
on: 'ON',
|
on: 'ON',
|
||||||
switchValue: whList[index].firstSwitch,
|
switchValue: waterHeater.firstSwitch,
|
||||||
action: () {
|
action: () => context.read<WaterHeaterBloc>().add(
|
||||||
BlocProvider.of<WaterHeaterBloc>(context).add(
|
|
||||||
ChangeFirstWizardSwitchStatusEvent(
|
ChangeFirstWizardSwitchStatusEvent(
|
||||||
value: whList[index].firstSwitch,
|
value: waterHeater.firstSwitch,
|
||||||
deviceId: whList[index].deviceId));
|
deviceId: waterHeater.deviceId,
|
||||||
},
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
48
lib/features/scene/helper/scene_bloc_factory.dart
Normal file
48
lib/features/scene/helper/scene_bloc_factory.dart
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/model/community_model.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/model/space_model.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';
|
||||||
|
|
||||||
|
abstract final class SceneBlocFactory {
|
||||||
|
static SceneBloc create({
|
||||||
|
required bool pageType,
|
||||||
|
required HomeCubit homeCubit,
|
||||||
|
}) {
|
||||||
|
final selectedSpace = homeCubit.selectedSpace;
|
||||||
|
final defaultSpace = SpaceModel(
|
||||||
|
id: '-1',
|
||||||
|
name: '',
|
||||||
|
community: Community(
|
||||||
|
uuid: '-1',
|
||||||
|
name: '',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final spaceId = selectedSpace?.id ?? defaultSpace.id;
|
||||||
|
final space = selectedSpace ?? defaultSpace;
|
||||||
|
final communityUuid =
|
||||||
|
selectedSpace?.community.uuid ?? defaultSpace.community.uuid;
|
||||||
|
|
||||||
|
final sceneBloc = SceneBloc();
|
||||||
|
|
||||||
|
sceneBloc.add(
|
||||||
|
LoadScenes(
|
||||||
|
spaceId,
|
||||||
|
space,
|
||||||
|
showInDevice: pageType,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!pageType) {
|
||||||
|
sceneBloc.add(
|
||||||
|
LoadAutomation(
|
||||||
|
spaceId,
|
||||||
|
communityUuid,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sceneBloc;
|
||||||
|
}
|
||||||
|
}
|
@ -1,92 +1,54 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/bloc/home_cubit.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/model/community_model.dart';
|
|
||||||
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/scene_listview.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/scene_listview.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.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_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.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/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_devices_widget.dart';
|
import 'package:syncrow_app/features/scene/widgets/empty_devices_widget.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
|
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_header.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/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.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/color_manager.dart';
|
||||||
|
|
||||||
class SceneView extends StatelessWidget {
|
class SceneView extends StatelessWidget {
|
||||||
|
const SceneView({
|
||||||
|
this.pageType = false,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final bool pageType;
|
final bool pageType;
|
||||||
const SceneView({super.key, this.pageType = false});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (BuildContext context) {
|
create: (context) => SceneBlocFactory.create(
|
||||||
if (pageType) {
|
pageType: pageType,
|
||||||
return SceneBloc()
|
homeCubit: HomeCubit.getInstance(),
|
||||||
..add(LoadScenes(
|
),
|
||||||
HomeCubit.getInstance().selectedSpace?.id ?? '',
|
|
||||||
HomeCubit.getInstance().selectedSpace ??
|
|
||||||
SpaceModel(
|
|
||||||
id: '-1',
|
|
||||||
name: '',
|
|
||||||
community: Community(
|
|
||||||
uuid: '-1',
|
|
||||||
name: '',
|
|
||||||
)),
|
|
||||||
showInDevice: pageType));
|
|
||||||
} else {
|
|
||||||
return SceneBloc()
|
|
||||||
..add(LoadScenes(
|
|
||||||
HomeCubit.getInstance().selectedSpace?.id ?? '',
|
|
||||||
HomeCubit.getInstance().selectedSpace ??
|
|
||||||
SpaceModel(
|
|
||||||
id: '-1',
|
|
||||||
name: '',
|
|
||||||
community: Community(
|
|
||||||
uuid: '-1',
|
|
||||||
name: '',
|
|
||||||
)),
|
|
||||||
showInDevice: pageType))
|
|
||||||
..add(LoadAutomation(
|
|
||||||
HomeCubit.getInstance().selectedSpace?.id ?? '',
|
|
||||||
HomeCubit.getInstance().selectedSpace?.community.uuid ?? ''));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
final selectedSpace = HomeCubit.getInstance().selectedSpace;
|
||||||
if (state is DeleteSceneSuccess) {
|
if (state is DeleteSceneSuccess) {
|
||||||
if (state.success) {
|
if (state.success) _loadScenesAndAutomations(context, selectedSpace);
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
|
||||||
HomeCubit.getInstance().selectedSpace!.id,
|
|
||||||
HomeCubit.getInstance().selectedSpace!,
|
|
||||||
showInDevice: pageType));
|
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadAutomation(
|
|
||||||
HomeCubit.getInstance().selectedSpace!.id,
|
|
||||||
HomeCubit.getInstance().selectedSpace!.community.uuid));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (state is CreateSceneWithTasks) {
|
if (state is CreateSceneWithTasks) {
|
||||||
if (state.success == true) {
|
if (state.success) {
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
_loadScenesAndAutomations(context, selectedSpace);
|
||||||
HomeCubit.getInstance().selectedSpace!.id,
|
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||||
HomeCubit.getInstance().selectedSpace!,
|
|
||||||
showInDevice: pageType));
|
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadAutomation(
|
|
||||||
HomeCubit.getInstance().selectedSpace!.id,
|
|
||||||
HomeCubit.getInstance().selectedSpace!.community.uuid));
|
|
||||||
context
|
|
||||||
.read<SmartSceneSelectBloc>()
|
|
||||||
.add(const SmartSceneClearEvent());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BlocListener<SceneBloc, SceneState>(
|
return BlocListener<SceneBloc, SceneState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is SceneTriggerSuccess) {
|
if (state is SceneTriggerSuccess) {
|
||||||
context.showCustomSnackbar(
|
context.showCustomSnackbar(
|
||||||
message:
|
message: 'Scene ${state.sceneName} triggered successfully!',
|
||||||
'Scene ${state.sceneName} triggered successfully!');
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: HomeCubit.getInstance().spaces.isEmpty
|
child: HomeCubit.getInstance().spaces.isEmpty
|
||||||
@ -95,13 +57,14 @@ class SceneView extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
if (pageType == false) const SceneHeader(),
|
if (!pageType) ...[
|
||||||
if (pageType == false) const SizedBox(height: 8),
|
const SceneHeader(),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
BlocBuilder<SceneBloc, SceneState>(
|
BlocBuilder<SceneBloc, SceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is SceneLoading) {
|
if (state is SceneLoading) {
|
||||||
return const Center(
|
return const AppLoadingIndicator();
|
||||||
child: CircularProgressIndicator());
|
|
||||||
}
|
}
|
||||||
if (state is SceneError) {
|
if (state is SceneError) {
|
||||||
return Center(
|
return Center(
|
||||||
@ -111,84 +74,81 @@ class SceneView extends StatelessWidget {
|
|||||||
if (state is SceneLoaded) {
|
if (state is SceneLoaded) {
|
||||||
final scenes = state.scenes;
|
final scenes = state.scenes;
|
||||||
final automationList = state.automationList;
|
final automationList = state.automationList;
|
||||||
|
if (scenes.isEmpty) return const EmptyDevicesWidget();
|
||||||
|
|
||||||
return pageType
|
if (pageType) {
|
||||||
? SizedBox(
|
return SizedBox(
|
||||||
height: context.height * 0.1,
|
height: context.height * 0.1,
|
||||||
child: SceneListview(
|
child: SceneListview(
|
||||||
scenes: scenes,
|
scenes: scenes,
|
||||||
loadingSceneId: state.loadingSceneId,
|
loadingSceneId: state.loadingSceneId,
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
: Expanded(
|
}
|
||||||
child: ListView(
|
|
||||||
|
return Theme(
|
||||||
|
data: Theme.of(context).copyWith(
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
ExpansionTile(
|
||||||
|
tilePadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6,
|
||||||
|
),
|
||||||
|
initiallyExpanded: true,
|
||||||
|
iconColor: ColorsManager.grayColor,
|
||||||
|
title: const BodyMedium(
|
||||||
|
text: 'Tap to run routines',
|
||||||
|
),
|
||||||
children: [
|
children: [
|
||||||
Theme(
|
if (scenes.isNotEmpty)
|
||||||
data: ThemeData().copyWith(
|
SceneGrid(
|
||||||
dividerColor: Colors.transparent),
|
scenes: scenes,
|
||||||
child: ExpansionTile(
|
loadingSceneId: state.loadingSceneId,
|
||||||
tilePadding:
|
disablePlayButton: false,
|
||||||
const EdgeInsets.symmetric(
|
loadingStates: state.loadingStates,
|
||||||
horizontal: 6),
|
)
|
||||||
initiallyExpanded: true,
|
else
|
||||||
iconColor: ColorsManager.grayColor,
|
const Center(
|
||||||
title: const BodyMedium(
|
child: BodyMedium(
|
||||||
text: 'Tap to run routines'),
|
text: 'No scenes have been added yet',
|
||||||
children: [
|
),
|
||||||
scenes.isNotEmpty
|
|
||||||
? SceneGrid(
|
|
||||||
scenes: scenes,
|
|
||||||
loadingSceneId:
|
|
||||||
state.loadingSceneId,
|
|
||||||
disablePlayButton: false,
|
|
||||||
loadingStates: state
|
|
||||||
.loadingStates, // Add this line
|
|
||||||
)
|
|
||||||
: const Center(
|
|
||||||
child: BodyMedium(
|
|
||||||
text:
|
|
||||||
'No scenes have been added yet',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
Theme(
|
|
||||||
data: ThemeData().copyWith(
|
|
||||||
dividerColor: Colors.transparent),
|
|
||||||
child: ExpansionTile(
|
|
||||||
initiallyExpanded: true,
|
|
||||||
iconColor: ColorsManager.grayColor,
|
|
||||||
tilePadding:
|
|
||||||
const EdgeInsets.symmetric(
|
|
||||||
horizontal: 6),
|
|
||||||
title: const BodyMedium(
|
|
||||||
text: 'Automation'),
|
|
||||||
children: [
|
|
||||||
automationList.isNotEmpty
|
|
||||||
? SceneGrid(
|
|
||||||
scenes: automationList,
|
|
||||||
loadingSceneId:
|
|
||||||
state.loadingSceneId,
|
|
||||||
disablePlayButton: true,
|
|
||||||
loadingStates: state
|
|
||||||
.loadingStates, // Add this line
|
|
||||||
)
|
|
||||||
: const Center(
|
|
||||||
child: BodyMedium(
|
|
||||||
text:
|
|
||||||
'No automations have been added yet',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
ExpansionTile(
|
||||||
|
initiallyExpanded: true,
|
||||||
|
iconColor: ColorsManager.grayColor,
|
||||||
|
tilePadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6,
|
||||||
|
),
|
||||||
|
title: const BodyMedium(text: 'Automation'),
|
||||||
|
children: [
|
||||||
|
if (automationList.isNotEmpty)
|
||||||
|
SceneGrid(
|
||||||
|
scenes: automationList,
|
||||||
|
loadingSceneId: state.loadingSceneId,
|
||||||
|
disablePlayButton: true,
|
||||||
|
loadingStates: state.loadingStates,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
const Center(
|
||||||
|
child: BodyMedium(
|
||||||
|
text:
|
||||||
|
'No automations have been added yet',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
},
|
},
|
||||||
@ -200,4 +160,21 @@ class SceneView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _loadScenesAndAutomations(BuildContext context, SpaceModel? selectedSpace) {
|
||||||
|
BlocProvider.of<SceneBloc>(context)
|
||||||
|
..add(
|
||||||
|
LoadScenes(
|
||||||
|
selectedSpace!.id,
|
||||||
|
selectedSpace,
|
||||||
|
showInDevice: pageType,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..add(
|
||||||
|
LoadAutomation(
|
||||||
|
selectedSpace.id,
|
||||||
|
selectedSpace.community.uuid,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
lib/features/shared_widgets/app_loading_indicator.dart
Normal file
12
lib/features/shared_widgets/app_loading_indicator.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppLoadingIndicator extends StatelessWidget {
|
||||||
|
const AppLoadingIndicator({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator.adaptive(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user