Compare commits

..

5 Commits

Author SHA1 Message Date
3f49a18130 remove unused code 2025-04-21 15:19:14 +03:00
a51c4d9679 Refactor device name display in RoomPageSwitch widget 2025-04-21 15:00:31 +03:00
caeed8e73f Merge pull request #87 from SyncrowIOT/FE-Complete-the-Device-Name-as
Refactor device name display in RoomPageSwitch widget
2025-04-21 10:43:22 +03:00
dc5ac9be5b Refactor device name display in RoomPageSwitch widget 2025-04-21 10:36:43 +03:00
5c9b30895f Merge pull request #86 from SyncrowIOT/SP-1286-FE-Add-Device-to-Routine-2-Gang
add tow gang and change gang device ui
2025-04-17 16:29:24 +03:00
3 changed files with 61 additions and 32 deletions

View File

@ -76,32 +76,45 @@ class RoomPageSwitch extends StatelessWidget {
: const SizedBox(), : const SizedBox(),
], ],
), ),
Flexible( LayoutBuilder(
child: FittedBox( builder: (context, constraints) {
child: Column( final text = device.name ?? "";
crossAxisAlignment: CrossAxisAlignment.start, final textPainter = TextPainter(
children: [ text: TextSpan(
Text( text: text,
device.name ?? "", style: context.bodyLarge.copyWith(
overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold,
maxLines: 2, fontSize: 20,
style: context.bodyLarge.copyWith( color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.grey,
),
), ),
Text( ),
device.subspace!.subspaceName ?? '', maxLines: 1,
overflow: TextOverflow.ellipsis, textDirection: TextDirection.ltr,
style: context.bodySmall.copyWith( );
fontWeight: FontWeight.w400,
fontSize: 10, textPainter.layout(maxWidth: constraints.maxWidth);
color: Colors.grey,
), final exceeded = textPainter.didExceedMaxLines;
),
], return Text(
), exceeded ? '${text.substring(0, 10)}...' : text,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.grey,
),
overflow: TextOverflow.clip,
maxLines: 1,
);
},
),
Text(
device.subspace!.subspaceName ?? '',
overflow: TextOverflow.ellipsis,
style: context.bodySmall.copyWith(
fontWeight: FontWeight.w400,
fontSize: 10,
color: Colors.grey,
), ),
), ),
], ],
@ -119,7 +132,6 @@ Future<void> showDeviceInterface(
required BuildContext context, required BuildContext context,
required isAllDevices, required isAllDevices,
List<DeviceModel>? allDevices}) async { List<DeviceModel>? allDevices}) async {
print('object-----${device.uuid} ${device.name}');
final devicesCubit = context.read<DevicesCubit>(); final devicesCubit = context.read<DevicesCubit>();

View File

@ -259,6 +259,7 @@ mixin SceneOperationsDataHelper {
for (var condition in conditions) { for (var condition in conditions) {
// Create a dummy Action from Condition to reuse _mapExecutorPropertyToSceneFunction // Create a dummy Action from Condition to reuse _mapExecutorPropertyToSceneFunction
Action dummyAction = Action( Action dummyAction = Action(
productType: condition.productType,
actionExecutor: 'device_report', actionExecutor: 'device_report',
entityId: condition.entityId, entityId: condition.entityId,
executorProperty: ExecutorProperty( executorProperty: ExecutorProperty(
@ -858,12 +859,24 @@ mixin SceneOperationsDataHelper {
comparator, comparator,
uniqueCustomId, uniqueCustomId,
); );
default: case "1G":
return _createSceneFunction( return _createSceneFunction(
action, action,
'1 Gang Button Switch L-L', '1 Gang Button Switch L-L',
Assets.oneGang, Assets.oneGang,
'Light Switch', 'Light 1 Switch',
OperationDialogType.onOff,
_createOnOffOptions(),
isAutomation,
comparator,
uniqueCustomId,
);
default:
return _createSceneFunction(
action,
'None',
Assets.assetsRemoteUnlockReq,
'None',
OperationDialogType.onOff, OperationDialogType.onOff,
_createOnOffOptions(), _createOnOffOptions(),
isAutomation, isAutomation,
@ -1434,6 +1447,7 @@ mixin SceneOperationsDataHelper {
return [ return [
_mapExecutorPropertyToSceneFunction( _mapExecutorPropertyToSceneFunction(
Action( Action(
productType: '',
entityId: deviceId, entityId: deviceId,
executorProperty: ExecutorProperty( executorProperty: ExecutorProperty(
functionCode: taskItem.code, functionCode: taskItem.code,

View File

@ -74,7 +74,7 @@ class Action {
ExecutorProperty? executorProperty; ExecutorProperty? executorProperty;
String? name; String? name;
String? type; String? type;
String? productType; final String productType;
Action({ Action({
required this.actionExecutor, required this.actionExecutor,
@ -82,7 +82,7 @@ class Action {
this.executorProperty, this.executorProperty,
this.name, this.name,
this.type, this.type,
this.productType, required this.productType,
}); });
String toRawJson() => json.encode(toJson()); String toRawJson() => json.encode(toJson());
@ -94,7 +94,7 @@ class Action {
entityId: json["entityId"] as String, entityId: json["entityId"] as String,
name: json['name'] as String?, name: json['name'] as String?,
type: json['type'] as String?, type: json['type'] as String?,
productType: json['productType'] as String?, productType: json['productType'] as String,
); );
} }
if (json["executorProperty"] == null) { if (json["executorProperty"] == null) {
@ -105,7 +105,7 @@ class Action {
actionExecutor: json["actionExecutor"] as String, actionExecutor: json["actionExecutor"] as String,
entityId: json["entityId"] as String, entityId: json["entityId"] as String,
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]), executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
productType: json['productType'] as String?, productType: json['productType'] as String,
); );
} }
@ -146,12 +146,14 @@ class Condition {
final String entityId; final String entityId;
final String entityType; final String entityType;
final Expr expr; final Expr expr;
final String productType;
Condition({ Condition({
required this.code, required this.code,
required this.entityId, required this.entityId,
required this.entityType, required this.entityType,
required this.expr, required this.expr,
required this.productType,
}); });
factory Condition.fromRawJson(String str) => factory Condition.fromRawJson(String str) =>
@ -164,6 +166,7 @@ class Condition {
entityId: json["entityId"], entityId: json["entityId"],
entityType: json["entityType"], entityType: json["entityType"],
expr: Expr.fromJson(json["expr"]), expr: Expr.fromJson(json["expr"]),
productType: json['productType'] as String,
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {