Merge pull request #87 from SyncrowIOT/FE-Complete-the-Device-Name-as

Refactor device name display in RoomPageSwitch widget
This commit is contained in:
mohammadnemer1
2025-04-21 10:43:22 +03:00
committed by GitHub
@@ -76,21 +76,38 @@ 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 ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: context.bodyLarge.copyWith( style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 20, fontSize: 20,
color: Colors.grey, color: Colors.grey,
), ),
), ),
maxLines: 1,
textDirection: TextDirection.ltr,
);
textPainter.layout(maxWidth: constraints.maxWidth);
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( Text(
device.subspace!.subspaceName ?? '', device.subspace!.subspaceName ?? '',
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -103,10 +120,6 @@ class RoomPageSwitch extends StatelessWidget {
], ],
), ),
), ),
),
],
),
),
); );
} }
} }
@@ -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>();