diff --git a/lib/features/devices/view/widgets/room_page_switch.dart b/lib/features/devices/view/widgets/room_page_switch.dart index 5d9488c..e5b23e9 100644 --- a/lib/features/devices/view/widgets/room_page_switch.dart +++ b/lib/features/devices/view/widgets/room_page_switch.dart @@ -76,32 +76,45 @@ class RoomPageSwitch extends StatelessWidget { : const SizedBox(), ], ), - Flexible( - child: FittedBox( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - device.name ?? "", - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: context.bodyLarge.copyWith( - fontWeight: FontWeight.bold, - fontSize: 20, - color: Colors.grey, - ), + LayoutBuilder( + builder: (context, constraints) { + final text = device.name ?? ""; + final textPainter = TextPainter( + text: TextSpan( + text: text, + style: context.bodyLarge.copyWith( + fontWeight: FontWeight.bold, + fontSize: 20, + color: Colors.grey, ), - Text( - device.subspace!.subspaceName ?? '', - overflow: TextOverflow.ellipsis, - style: context.bodySmall.copyWith( - fontWeight: FontWeight.w400, - fontSize: 10, - 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( + device.subspace!.subspaceName ?? '', + overflow: TextOverflow.ellipsis, + style: context.bodySmall.copyWith( + fontWeight: FontWeight.w400, + fontSize: 10, + color: Colors.grey, ), ), ], @@ -119,7 +132,6 @@ Future showDeviceInterface( required BuildContext context, required isAllDevices, List? allDevices}) async { - print('object-----${device.uuid} ${device.name}'); final devicesCubit = context.read();