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