mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
curtain wizard
This commit is contained in:
5
assets/icons/1gang_touch.svg
Normal file
5
assets/icons/1gang_touch.svg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
||||||
|
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
||||||
|
<path opacity="0.6" d="M20.875 19.2411V20.7304C20.875 20.9746 20.7996 21.1767 20.7014 21.3067C20.6035 21.4364 20.5053 21.4715 20.4375 21.4715H16.3125C16.2447 21.4715 16.1465 21.4364 16.0486 21.3067C15.9504 21.1767 15.875 20.9746 15.875 20.7304V19.2411C15.875 18.9969 15.9504 18.7949 16.0486 18.6649C16.1465 18.5352 16.2447 18.5 16.3125 18.5H20.4375C20.5053 18.5 20.6035 18.5352 20.7014 18.6649C20.7996 18.7949 20.875 18.9969 20.875 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
6
assets/icons/2gang_touch.svg
Normal file
6
assets/icons/2gang_touch.svg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
||||||
|
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
||||||
|
<path opacity="0.6" d="M16.5 19.2411V20.7304C16.5 20.9746 16.4246 21.1767 16.3264 21.3067C16.2285 21.4364 16.1303 21.4715 16.0625 21.4715H11.9375C11.8697 21.4715 11.7715 21.4364 11.6736 21.3067C11.5754 21.1767 11.5 20.9746 11.5 20.7304V19.2411C11.5 18.9969 11.5754 18.7949 11.6736 18.6649C11.7715 18.5352 11.8697 18.5 11.9375 18.5H16.0625C16.1303 18.5 16.2285 18.5352 16.3264 18.6649C16.4246 18.7949 16.5 18.9969 16.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||||
|
<path opacity="0.6" d="M26.5 19.2411V20.7304C26.5 20.9746 26.4246 21.1767 26.3264 21.3067C26.2285 21.4364 26.1303 21.4715 26.0625 21.4715H21.9375C21.8697 21.4715 21.7715 21.4364 21.6736 21.3067C21.5754 21.1767 21.5 20.9746 21.5 20.7304V19.2411C21.5 18.9969 21.5754 18.7949 21.6736 18.6649C21.7715 18.5352 21.8697 18.5 21.9375 18.5H26.0625C26.1303 18.5 26.2285 18.5352 26.3264 18.6649C26.4246 18.7949 26.5 18.9969 26.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
7
assets/icons/3gang_touch.svg
Normal file
7
assets/icons/3gang_touch.svg
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
||||||
|
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
||||||
|
<path opacity="0.6" d="M10.5 19.2411V20.7304C10.5 20.9746 10.4246 21.1767 10.3264 21.3067C10.2285 21.4364 10.1303 21.4715 10.0625 21.4715H5.9375C5.86973 21.4715 5.77153 21.4364 5.67355 21.3067C5.57536 21.1767 5.5 20.9746 5.5 20.7304V19.2411C5.5 18.9969 5.57536 18.7949 5.67355 18.6649C5.77153 18.5352 5.86973 18.5 5.9375 18.5H10.0625C10.1303 18.5 10.2285 18.5352 10.3264 18.6649C10.4246 18.7949 10.5 18.9969 10.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||||
|
<path opacity="0.6" d="M20.5 19.2411V20.7304C20.5 20.9746 20.4246 21.1767 20.3264 21.3067C20.2285 21.4364 20.1303 21.4715 20.0625 21.4715H15.9375C15.8697 21.4715 15.7715 21.4364 15.6736 21.3067C15.5754 21.1767 15.5 20.9746 15.5 20.7304V19.2411C15.5 18.9969 15.5754 18.7949 15.6736 18.6649C15.7715 18.5352 15.8697 18.5 15.9375 18.5H20.0625C20.1303 18.5 20.2285 18.5352 20.3264 18.6649C20.4246 18.7949 20.5 18.9969 20.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||||
|
<path opacity="0.6" d="M30.5 19.2411V20.7304C30.5 20.9746 30.4246 21.1767 30.3264 21.3067C30.2285 21.4364 30.1303 21.4715 30.0625 21.4715H25.9375C25.8697 21.4715 25.7715 21.4364 25.6736 21.3067C25.5754 21.1767 25.5 20.9746 25.5 20.7304V19.2411C25.5 18.9969 25.5754 18.7949 25.6736 18.6649C25.7715 18.5352 25.8697 18.5 25.9375 18.5H30.0625C30.1303 18.5 30.2285 18.5352 30.3264 18.6649C30.4246 18.7949 30.5 18.9969 30.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
@ -1,7 +1,11 @@
|
|||||||
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/devices/bloc/curtain_bloc/curtain_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||||
import 'package:syncrow_app/services/api/devices_api.dart';
|
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -22,9 +26,14 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
on<OpenCurtain>(_onOpenCurtain);
|
on<OpenCurtain>(_onOpenCurtain);
|
||||||
on<CloseCurtain>(_onCloseCurtain);
|
on<CloseCurtain>(_onCloseCurtain);
|
||||||
on<PauseCurtain>(_onPauseCurtain);
|
on<PauseCurtain>(_onPauseCurtain);
|
||||||
|
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
||||||
|
on<InitialWizardEvent>(_fetchOneTouchWizardStatus);
|
||||||
|
on<GroupAllOffEvent>(_groupAllOff);
|
||||||
|
on<GroupAllOnEvent>(_groupAllOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onOpenCurtain(OpenCurtain event, Emitter<CurtainState> emit) async {
|
Future<void> _onOpenCurtain(
|
||||||
|
OpenCurtain event, Emitter<CurtainState> emit) async {
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
while (openPercentage < 100.0) {
|
while (openPercentage < 100.0) {
|
||||||
if (state is CurtainsClosing) {
|
if (state is CurtainsClosing) {
|
||||||
@ -71,7 +80,8 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onCloseCurtain(CloseCurtain event, Emitter<CurtainState> emit) async {
|
Future<void> _onCloseCurtain(
|
||||||
|
CloseCurtain event, Emitter<CurtainState> emit) async {
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
while (openPercentage > 0.0) {
|
while (openPercentage > 0.0) {
|
||||||
if (state is CurtainsOpening) {
|
if (state is CurtainsOpening) {
|
||||||
@ -118,7 +128,8 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onPauseCurtain(PauseCurtain event, Emitter<CurtainState> emit) async {
|
Future<void> _onPauseCurtain(
|
||||||
|
PauseCurtain event, Emitter<CurtainState> emit) async {
|
||||||
_pauseCurtain(emit);
|
_pauseCurtain(emit);
|
||||||
await DevicesAPI.controlDevice(
|
await DevicesAPI.controlDevice(
|
||||||
DeviceControlModel(
|
DeviceControlModel(
|
||||||
@ -172,4 +183,157 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<GroupCurtainModel> groupList = [];
|
||||||
|
bool allSwitchesOn = true;
|
||||||
|
List<DeviceModel> devicesList = [];
|
||||||
|
CurtainModel deviceStatus = CurtainModel(
|
||||||
|
control: 'stop',
|
||||||
|
);
|
||||||
|
void _fetchOneTouchWizardStatus(
|
||||||
|
InitialWizardEvent event, Emitter<CurtainState> emit) async {
|
||||||
|
emit(CurtainLoadingState());
|
||||||
|
try {
|
||||||
|
devicesList = [];
|
||||||
|
groupList = [];
|
||||||
|
allSwitchesOn = true;
|
||||||
|
devicesList = await DevicesAPI.getDeviceByGroupName(
|
||||||
|
HomeCubit.getInstance().selectedSpace?.id ?? '', 'CUR');
|
||||||
|
|
||||||
|
for (int i = 0; i < devicesList.length; i++) {
|
||||||
|
var response =
|
||||||
|
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||||
|
List<StatusModel> statusModelList = [];
|
||||||
|
for (var status in response['status']) {
|
||||||
|
statusModelList.add(StatusModel.fromJson(status));
|
||||||
|
}
|
||||||
|
deviceStatus = CurtainModel.fromJson(statusModelList);
|
||||||
|
groupList.add(GroupCurtainModel(
|
||||||
|
deviceId: devicesList[i].uuid ?? '',
|
||||||
|
deviceName: devicesList[i].name ?? '',
|
||||||
|
firstSwitch: deviceStatus.control,
|
||||||
|
percentControl: 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupList.isNotEmpty) {
|
||||||
|
groupList.firstWhere((element) {
|
||||||
|
print('object=====${element.firstSwitch}');
|
||||||
|
if (element.firstSwitch == 'close') {
|
||||||
|
allSwitchesOn = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
emit(
|
||||||
|
UpdateGroupState(curtainList: groupList, allSwitches: allSwitchesOn));
|
||||||
|
} catch (e) {
|
||||||
|
emit(FailedState());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||||
|
Emitter<CurtainState> emit) async {
|
||||||
|
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||||
|
try {
|
||||||
|
bool allSwitchesValue = true;
|
||||||
|
|
||||||
|
// Update the firstSwitch value in the groupList based on the deviceId
|
||||||
|
groupList.forEach((element) {
|
||||||
|
if (element.deviceId == event.deviceId) {
|
||||||
|
element.firstSwitch = event.value; // Set the new value from the event
|
||||||
|
}
|
||||||
|
if (element.firstSwitch != 'open') {
|
||||||
|
allSwitchesValue = false; // Check if any switch is not 'open'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final response = await DevicesAPI.deviceBatchController(
|
||||||
|
code: 'control',
|
||||||
|
devicesUuid: [event.deviceId],
|
||||||
|
value: event.value, // Use the value from the event
|
||||||
|
);
|
||||||
|
|
||||||
|
emit(UpdateGroupState(
|
||||||
|
curtainList: groupList, allSwitches: allSwitchesValue));
|
||||||
|
|
||||||
|
if (response['success']) {
|
||||||
|
// Optionally add an initial event if needed.
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// Handle the error if needed.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _groupAllOn(GroupAllOnEvent event, Emitter<CurtainState> emit) async {
|
||||||
|
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||||
|
try {
|
||||||
|
// Set all devices to 'open'
|
||||||
|
for (int i = 0; i < groupList.length; i++) {
|
||||||
|
groupList[i].firstSwitch = 'open';
|
||||||
|
}
|
||||||
|
|
||||||
|
emit(UpdateGroupState(curtainList: groupList, allSwitches: true));
|
||||||
|
|
||||||
|
List<String> allDeviceIds =
|
||||||
|
groupList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
|
final response1 = await DevicesAPI.deviceBatchController(
|
||||||
|
code: 'control',
|
||||||
|
devicesUuid: allDeviceIds,
|
||||||
|
value: 'open', // Set the devices to 'open'
|
||||||
|
);
|
||||||
|
|
||||||
|
final response2 = await DevicesAPI.deviceBatchController(
|
||||||
|
code: 'control',
|
||||||
|
devicesUuid: allDeviceIds,
|
||||||
|
value: 'open',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response1['failedResults'].toString() != '[]') {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
// Handle retry or error if needed.
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
emit(FailedState());
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
// Optionally add an initial event if needed.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _groupAllOff(GroupAllOffEvent event, Emitter<CurtainState> emit) async {
|
||||||
|
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||||
|
try {
|
||||||
|
// Set all devices to 'close'
|
||||||
|
for (int i = 0; i < groupList.length; i++) {
|
||||||
|
groupList[i].firstSwitch = 'close';
|
||||||
|
}
|
||||||
|
|
||||||
|
emit(UpdateGroupState(curtainList: groupList, allSwitches: false));
|
||||||
|
|
||||||
|
List<String> allDeviceIds =
|
||||||
|
groupList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
|
final response1 = await DevicesAPI.deviceBatchController(
|
||||||
|
code: 'control',
|
||||||
|
devicesUuid: allDeviceIds,
|
||||||
|
value: 'close', // Set the devices to 'close'
|
||||||
|
);
|
||||||
|
|
||||||
|
final response2 = await DevicesAPI.deviceBatchController(
|
||||||
|
code: 'control',
|
||||||
|
devicesUuid: allDeviceIds,
|
||||||
|
value: 'close',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response1['failedResults'].toString() != '[]') {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
// Handle retry or error if needed.
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
emit(FailedState());
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
// Optionally add an initial event if needed.
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,21 @@ class CloseCurtain extends CurtainEvent {
|
|||||||
|
|
||||||
class InitCurtain extends CurtainEvent {}
|
class InitCurtain extends CurtainEvent {}
|
||||||
class PauseCurtain extends CurtainEvent {}
|
class PauseCurtain extends CurtainEvent {}
|
||||||
class useCurtainEvent extends CurtainEvent {}
|
class useCurtainEvent extends CurtainEvent {}
|
||||||
|
class InitialWizardEvent extends CurtainEvent {}
|
||||||
|
|
||||||
|
|
||||||
|
class ChangeFirstWizardSwitchStatusEvent extends CurtainEvent {
|
||||||
|
final String value;
|
||||||
|
final String deviceId;
|
||||||
|
const ChangeFirstWizardSwitchStatusEvent(
|
||||||
|
{required this.value, this.deviceId = ''});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [value, deviceId];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GroupAllOnEvent extends CurtainEvent {}
|
||||||
|
|
||||||
|
class GroupAllOffEvent extends CurtainEvent {}
|
@ -1,5 +1,7 @@
|
|||||||
// curtain_state.dart
|
// curtain_state.dart
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||||
|
|
||||||
abstract class CurtainState extends Equatable {
|
abstract class CurtainState extends Equatable {
|
||||||
const CurtainState();
|
const CurtainState();
|
||||||
@ -10,8 +12,9 @@ abstract class CurtainState extends Equatable {
|
|||||||
|
|
||||||
class CurtainInitial extends CurtainState {}
|
class CurtainInitial extends CurtainState {}
|
||||||
|
|
||||||
class UpdateCurtain extends CurtainState {
|
class LoadingInitialState extends CurtainState {}
|
||||||
|
|
||||||
|
class UpdateCurtain extends CurtainState {
|
||||||
final double curtainWidth;
|
final double curtainWidth;
|
||||||
final double blindHeight;
|
final double blindHeight;
|
||||||
final double openPercentage;
|
final double openPercentage;
|
||||||
@ -73,4 +76,23 @@ class CurtainsPaused extends CurtainState {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [curtainWidth, blindHeight, openPercentage];
|
List<Object?> get props => [curtainWidth, blindHeight, openPercentage];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UpdateGroupState extends CurtainState {
|
||||||
|
final List<GroupCurtainModel> curtainList;
|
||||||
|
final bool allSwitches;
|
||||||
|
|
||||||
|
const UpdateGroupState(
|
||||||
|
{required this.curtainList, required this.allSwitches});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [curtainList, allSwitches];
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoadingNewSate extends CurtainState {
|
||||||
|
final CurtainModel curtainModel;
|
||||||
|
const LoadingNewSate({required this.curtainModel});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [curtainModel];
|
||||||
|
}
|
||||||
|
22
lib/features/devices/model/curtain_model.dart
Normal file
22
lib/features/devices/model/curtain_model.dart
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||||
|
|
||||||
|
class CurtainModel {
|
||||||
|
String control;
|
||||||
|
|
||||||
|
CurtainModel({
|
||||||
|
required this.control,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CurtainModel.fromJson(List<StatusModel> jsonList) {
|
||||||
|
late String _control;
|
||||||
|
|
||||||
|
for (int i = 0; i < jsonList.length; i++) {
|
||||||
|
if (jsonList[i].code == 'control') {
|
||||||
|
_control = jsonList[i].value ?? false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CurtainModel(
|
||||||
|
control: _control,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -42,7 +42,9 @@ class DevicesCategoryModel {
|
|||||||
: name = json['groupName'],
|
: name = json['groupName'],
|
||||||
// id = json['groupId'],
|
// id = json['groupId'],
|
||||||
type = devicesTypesMap[json['groupName']] ?? DeviceType.Other,
|
type = devicesTypesMap[json['groupName']] ?? DeviceType.Other,
|
||||||
icon = deviceTypeIconMap[devicesTypesMap[json['groupName']] ?? DeviceType.Other] ?? '',
|
icon = deviceTypeIconMap[
|
||||||
|
devicesTypesMap[json['groupName']] ?? DeviceType.Other] ??
|
||||||
|
'',
|
||||||
devices = [],
|
devices = [],
|
||||||
isSelected = false;
|
isSelected = false;
|
||||||
|
|
||||||
@ -65,8 +67,8 @@ Map<DeviceType, String> deviceTypeIconMap = {
|
|||||||
DeviceType.WH: Assets.waterHeaterIcon,
|
DeviceType.WH: Assets.waterHeaterIcon,
|
||||||
DeviceType.DS: Assets.doorSensorIcon,
|
DeviceType.DS: Assets.doorSensorIcon,
|
||||||
DeviceType.Other: Assets.assetsIconsAC,
|
DeviceType.Other: Assets.assetsIconsAC,
|
||||||
DeviceType.OneTouch: Assets.oneGang,
|
DeviceType.OneTouch: Assets.gang1touch,
|
||||||
DeviceType.TowTouch: Assets.twoGang,
|
DeviceType.TowTouch: Assets.gang2touch,
|
||||||
DeviceType.ThreeTouch: Assets.assetsIconsGang,
|
DeviceType.ThreeTouch: Assets.gang3touch,
|
||||||
DeviceType.GarageDoor: Assets.garageIcon
|
DeviceType.GarageDoor: Assets.garageIcon
|
||||||
};
|
};
|
||||||
|
@ -67,13 +67,13 @@ class DeviceModel {
|
|||||||
} else if (type == DeviceType.DS) {
|
} else if (type == DeviceType.DS) {
|
||||||
tempIcon = Assets.doorSensorIcon;
|
tempIcon = Assets.doorSensorIcon;
|
||||||
} else if (type == DeviceType.OneTouch) {
|
} else if (type == DeviceType.OneTouch) {
|
||||||
tempIcon = Assets.oneGang;
|
tempIcon = Assets.gang1touch;
|
||||||
} else if (type == DeviceType.TowTouch) {
|
} else if (type == DeviceType.TowTouch) {
|
||||||
tempIcon = Assets.twoGang;
|
tempIcon = Assets.gang2touch;
|
||||||
} else if (type == DeviceType.GarageDoor) {
|
} else if (type == DeviceType.GarageDoor) {
|
||||||
tempIcon = Assets.garageIcon;
|
tempIcon = Assets.garageIcon;
|
||||||
} else if (type == DeviceType.ThreeTouch) {
|
} else if (type == DeviceType.ThreeTouch) {
|
||||||
tempIcon = Assets.assetsIcons3GangSwitch;
|
tempIcon = Assets.gang3touch;
|
||||||
} else if (type == DeviceType.WaterLeak) {
|
} else if (type == DeviceType.WaterLeak) {
|
||||||
tempIcon = Assets.waterLeakIcon;
|
tempIcon = Assets.waterLeakIcon;
|
||||||
} else {
|
} else {
|
||||||
|
13
lib/features/devices/model/group_curtain_model.dart
Normal file
13
lib/features/devices/model/group_curtain_model.dart
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class GroupCurtainModel {
|
||||||
|
final String deviceId;
|
||||||
|
final String deviceName;
|
||||||
|
String firstSwitch;
|
||||||
|
int percentControl;
|
||||||
|
|
||||||
|
GroupCurtainModel({
|
||||||
|
required this.deviceId,
|
||||||
|
required this.deviceName,
|
||||||
|
required this.firstSwitch,
|
||||||
|
required this.percentControl,
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
||||||
|
|
||||||
|
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||||
|
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
|
class CurtainsList extends StatelessWidget {
|
||||||
|
const CurtainsList(
|
||||||
|
{super.key, required this.curtainsList, required this.allSwitches});
|
||||||
|
|
||||||
|
final List<GroupCurtainModel> curtainsList;
|
||||||
|
final bool allSwitches;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<CurtainBloc, CurtainState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const BodySmall(text: 'All Curtains'),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
DevicesDefaultSwitch(
|
||||||
|
switchValue: allSwitches,
|
||||||
|
action: () {
|
||||||
|
BlocProvider.of<CurtainBloc>(context).add(GroupAllOnEvent());
|
||||||
|
},
|
||||||
|
secondAction: () {
|
||||||
|
BlocProvider.of<CurtainBloc>(context).add(GroupAllOffEvent());
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
itemCount: curtainsList.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
BodySmall(text: curtainsList[index].deviceName),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
DevicesDefaultSwitch(
|
||||||
|
switchValue: curtainsList[index].firstSwitch == 'open',
|
||||||
|
action: () {
|
||||||
|
// Toggle between 'open' and 'close' based on current value
|
||||||
|
final newValue =
|
||||||
|
curtainsList[index].firstSwitch == 'open'
|
||||||
|
? 'close'
|
||||||
|
: 'open';
|
||||||
|
BlocProvider.of<CurtainBloc>(context).add(
|
||||||
|
ChangeFirstWizardSwitchStatusEvent(
|
||||||
|
value: newValue,
|
||||||
|
deviceId: curtainsList[index].deviceId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
||||||
|
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtains_list.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
|
|
||||||
|
class CurtainsWizard extends StatelessWidget {
|
||||||
|
const CurtainsWizard({super.key, this.device});
|
||||||
|
|
||||||
|
final DeviceModel? device;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<GroupCurtainModel> groupOneTouchModel = [];
|
||||||
|
|
||||||
|
return DefaultScaffold(
|
||||||
|
title: 'Curtain',
|
||||||
|
child: BlocProvider(
|
||||||
|
create: (context) =>
|
||||||
|
CurtainBloc(device?.uuid ?? '')..add(InitialWizardEvent()),
|
||||||
|
child: BlocBuilder<CurtainBloc, CurtainState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
bool allSwitchesOn = false;
|
||||||
|
if (state is UpdateGroupState) {
|
||||||
|
groupOneTouchModel = state.curtainList;
|
||||||
|
allSwitchesOn = state.allSwitches;
|
||||||
|
}
|
||||||
|
return state is LoadingInitialState
|
||||||
|
? const Center(
|
||||||
|
child: DefaultContainer(
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: CircularProgressIndicator()),
|
||||||
|
)
|
||||||
|
: CurtainsList(
|
||||||
|
curtainsList: groupOneTouchModel,
|
||||||
|
allSwitches: allSwitchesOn,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtains_wizard.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/garage_door/garage_wizard.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/garage_door/garage_wizard.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_wizard.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_wizard.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/one_touch/one_touch_wizard.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/one_touch/one_touch_wizard.dart';
|
||||||
@ -100,6 +101,13 @@ class WizardPage extends StatelessWidget {
|
|||||||
pageBuilder: (context, animation1, animation2) =>
|
pageBuilder: (context, animation1, animation2) =>
|
||||||
const GarageWizard()));
|
const GarageWizard()));
|
||||||
}
|
}
|
||||||
|
if (groupsList[index].name == 'CUR') {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
PageRouteBuilder(
|
||||||
|
pageBuilder: (context, animation1, animation2) =>
|
||||||
|
const CurtainsWizard()));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
padding: const EdgeInsets.all(15),
|
padding: const EdgeInsets.all(15),
|
||||||
|
@ -1078,5 +1078,8 @@ class Assets {
|
|||||||
static const String waterLeakIcon = "assets/icons/waterleak_icon.svg";
|
static const String waterLeakIcon = "assets/icons/waterleak_icon.svg";
|
||||||
static const String leakDetectedIcon = "assets/icons/leak_detected.svg";
|
static const String leakDetectedIcon = "assets/icons/leak_detected.svg";
|
||||||
static const String leakNormalIcon = "assets/icons/leak_normal_icon.svg";
|
static const String leakNormalIcon = "assets/icons/leak_normal_icon.svg";
|
||||||
|
static const String gang1touch = "assets/icons/1gang_touch.svg";
|
||||||
|
static const String gang2touch = "assets/icons/2gang_touch.svg";
|
||||||
|
static const String gang3touch = "assets/icons/3gang_touch.svg";
|
||||||
//leakNormalIcon
|
//leakNormalIcon
|
||||||
}
|
}
|
||||||
|
@ -384,13 +384,15 @@ class DevicesAPI {
|
|||||||
static Future deviceBatchController({
|
static Future deviceBatchController({
|
||||||
List<String>? devicesUuid,
|
List<String>? devicesUuid,
|
||||||
String? code,
|
String? code,
|
||||||
bool? value,
|
var value,
|
||||||
}) async {
|
}) async {
|
||||||
|
print({"devicesUuid": devicesUuid, "code": code, "value": value});
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.controlBatch,
|
path: ApiEndpoints.controlBatch,
|
||||||
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
|
print('json-=-=-=-=-=-${json}');
|
||||||
return json;
|
return json;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,7 @@ description: This is the mobile application project, developed with Flutter for
|
|||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 1.0.4+26
|
version: 1.0.4+27
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.6 <4.0.0"
|
sdk: ">=3.0.6 <4.0.0"
|
||||||
|
Reference in New Issue
Block a user