mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 04:29:40 +00:00
scene and automation has been updated
This commit is contained in:
@ -260,7 +260,6 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
try {
|
||||
spaces = await SpacesAPI.getSpacesByUserId();
|
||||
} catch (failure) {
|
||||
print(failure);
|
||||
emitSafe(GetSpacesError("No units found"));
|
||||
return;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ class ACsView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("ACsView deviceModel UUID: ${deviceModel?.uuid}");
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => ACsBloc(acId: deviceModel?.uuid ?? '')
|
||||
..add(AcsInitial(allAcs: deviceModel != null ? false : true)),
|
||||
@ -66,12 +68,14 @@ class ACsView extends StatelessWidget {
|
||||
child: state is AcsLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<ACsBloc>(context)
|
||||
.add(AcsInitial(allAcs: deviceModel != null ? false : true));
|
||||
BlocProvider.of<ACsBloc>(context).add(AcsInitial(
|
||||
allAcs: deviceModel != null ? false : true));
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 40),
|
||||
|
@ -69,6 +69,7 @@ class DevicesViewBody extends StatelessWidget {
|
||||
|
||||
Expanded(
|
||||
child: PageView(
|
||||
|
||||
controller: HomeCubit.getInstance().devicesPageController,
|
||||
onPageChanged: (index) {
|
||||
HomeCubit.getInstance().devicesPageChanged(index);
|
||||
|
@ -86,6 +86,7 @@ class RoomPageSwitch extends StatelessWidget {
|
||||
///
|
||||
/// The [device] parameter represents the device model.
|
||||
void showDeviceInterface(DeviceModel device, BuildContext context) {
|
||||
|
||||
switch (device.productType) {
|
||||
case DeviceType.AC:
|
||||
Navigator.push(
|
||||
|
@ -22,7 +22,6 @@ class RoomsSlider extends StatelessWidget {
|
||||
onPageChanged: (index) {
|
||||
HomeCubit.getInstance().roomSliderPageChanged(index);
|
||||
},
|
||||
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
@ -45,15 +44,20 @@ class RoomsSlider extends StatelessWidget {
|
||||
(room) => InkWell(
|
||||
onTap: () {
|
||||
HomeCubit.getInstance().roomSliderPageChanged(
|
||||
HomeCubit.getInstance().selectedSpace!.subspaces!.indexOf(room));
|
||||
HomeCubit.getInstance()
|
||||
.selectedSpace!
|
||||
.subspaces!
|
||||
.indexOf(room));
|
||||
},
|
||||
child: TitleMedium(
|
||||
text: room.name!,
|
||||
style: context.titleMedium.copyWith(
|
||||
fontSize: 25,
|
||||
color: HomeCubit.getInstance().selectedRoom == room
|
||||
? ColorsManager.textPrimaryColor
|
||||
: ColorsManager.textPrimaryColor.withOpacity(.2),
|
||||
color:
|
||||
HomeCubit.getInstance().selectedRoom == room
|
||||
? ColorsManager.textPrimaryColor
|
||||
: ColorsManager.textPrimaryColor
|
||||
.withOpacity(.2),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -124,7 +124,7 @@ mixin SceneLogicHelper {
|
||||
));
|
||||
} else {
|
||||
final createSceneModel = CreateSceneModel(
|
||||
unitUuid: HomeCubit.getInstance().selectedSpace!.id ?? '',
|
||||
spaceUuid: HomeCubit.getInstance().selectedSpace!.id ?? '',
|
||||
sceneName: sceneName.text,
|
||||
decisionExpr: 'and',
|
||||
actions: [
|
||||
|
@ -1,50 +1,57 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class CreateSceneModel {
|
||||
String unitUuid;
|
||||
String spaceUuid;
|
||||
String sceneName;
|
||||
String decisionExpr;
|
||||
List<CreateSceneAction> actions;
|
||||
bool showInHomePage;
|
||||
|
||||
CreateSceneModel({
|
||||
required this.unitUuid,
|
||||
required this.spaceUuid,
|
||||
required this.sceneName,
|
||||
required this.decisionExpr,
|
||||
required this.actions,
|
||||
this.showInHomePage = false,
|
||||
});
|
||||
|
||||
CreateSceneModel copyWith({
|
||||
String? unitUuid,
|
||||
String? spaceUuid,
|
||||
String? sceneName,
|
||||
String? decisionExpr,
|
||||
List<CreateSceneAction>? actions,
|
||||
bool? showInHomePage,
|
||||
}) {
|
||||
return CreateSceneModel(
|
||||
unitUuid: unitUuid ?? this.unitUuid,
|
||||
spaceUuid: spaceUuid ?? this.spaceUuid,
|
||||
sceneName: sceneName ?? this.sceneName,
|
||||
decisionExpr: decisionExpr ?? this.decisionExpr,
|
||||
actions: actions ?? this.actions,
|
||||
showInHomePage: showInHomePage ?? this.showInHomePage,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap([String? sceneId]) {
|
||||
return {
|
||||
if (sceneId == null) 'unitUuid': unitUuid,
|
||||
if (sceneId == null) 'spaceUuid': spaceUuid,
|
||||
'sceneName': sceneName,
|
||||
'decisionExpr': decisionExpr,
|
||||
'actions': actions.map((x) => x.toMap()).toList(),
|
||||
'showInHomePage': showInHomePage,
|
||||
};
|
||||
}
|
||||
|
||||
factory CreateSceneModel.fromMap(Map<String, dynamic> map) {
|
||||
return CreateSceneModel(
|
||||
unitUuid: map['unitUuid'] ?? '',
|
||||
spaceUuid: map['spaceUuid'] ?? '',
|
||||
sceneName: map['sceneName'] ?? '',
|
||||
decisionExpr: map['decisionExpr'] ?? '',
|
||||
actions: List<CreateSceneAction>.from(
|
||||
map['actions']?.map((x) => CreateSceneAction.fromMap(x))),
|
||||
showInHomePage: map['showInHomePage'] ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
@ -55,7 +62,7 @@ class CreateSceneModel {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CreateSceneModel(unitUuid: $unitUuid, sceneName: $sceneName, decisionExpr: $decisionExpr, actions: $actions)';
|
||||
return 'CreateSceneModel(unitUuid: $spaceUuid, sceneName: $sceneName, decisionExpr: $decisionExpr, actions: $actions)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -63,18 +70,20 @@ class CreateSceneModel {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is CreateSceneModel &&
|
||||
other.unitUuid == unitUuid &&
|
||||
other.spaceUuid == spaceUuid &&
|
||||
other.sceneName == sceneName &&
|
||||
other.decisionExpr == decisionExpr &&
|
||||
listEquals(other.actions, actions);
|
||||
listEquals(other.actions, actions) &&
|
||||
other.showInHomePage == showInHomePage;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return unitUuid.hashCode ^
|
||||
return spaceUuid.hashCode ^
|
||||
sceneName.hashCode ^
|
||||
decisionExpr.hashCode ^
|
||||
actions.hashCode;
|
||||
actions.hashCode ^
|
||||
showInHomePage.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class ScenesModel {
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||
id: json["id"],
|
||||
id: json["uuid"],
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
|
@ -3,7 +3,7 @@ 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/devices/bloc/devices_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_event.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_devices/scene_devices_body.dart';
|
||||
@ -27,7 +27,7 @@ class _SceneRoomsTabBarDevicesViewState
|
||||
extends State<SceneRoomsTabBarDevicesView>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final TabController _tabController;
|
||||
List<RoomModel>? rooms = [];
|
||||
List<SubSpaceModel>? rooms = [];
|
||||
late final SpaceModel selectedSpace;
|
||||
|
||||
@override
|
||||
@ -38,11 +38,10 @@ class _SceneRoomsTabBarDevicesViewState
|
||||
if (rooms![0].id != '-1') {
|
||||
rooms?.insert(
|
||||
0,
|
||||
RoomModel(
|
||||
SubSpaceModel(
|
||||
name: 'All Devices',
|
||||
devices: DevicesCubit.getInstance().allDevices,
|
||||
id: '-1',
|
||||
type: SpaceType.Room,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
@ -24,7 +25,7 @@ class SceneDevicesBody extends StatelessWidget {
|
||||
}) : _tabController = tabController;
|
||||
|
||||
final TabController _tabController;
|
||||
final List<RoomModel>? rooms;
|
||||
final List<SubSpaceModel>? rooms;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -76,7 +77,7 @@ class SceneDevicesBody extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildRoomTab(
|
||||
RoomModel room, BuildContext context, bool isAutomationDeviceStatus) {
|
||||
SubSpaceModel room, BuildContext context, bool isAutomationDeviceStatus) {
|
||||
return BlocBuilder<DeviceManagerBloc, DeviceManagerState>(
|
||||
builder: (context, state) {
|
||||
if (state.loading && state.devices == null) {
|
||||
|
@ -64,6 +64,7 @@ class DevicesAPI {
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json),
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user