mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-10 20:21:44 +00:00
Refactor device name display in RoomPageSwitch widget
This commit is contained in:
@ -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<void> showDeviceInterface(
|
||||
required BuildContext context,
|
||||
required isAllDevices,
|
||||
List<DeviceModel>? allDevices}) async {
|
||||
print('object-----${device.uuid} ${device.name}');
|
||||
|
||||
final devicesCubit = context.read<DevicesCubit>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user