Fix text overflows for long subspace names
This commit is contained in:
parent
d513e466fd
commit
8c047827de
3 changed files with 53 additions and 35 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:nexus/widgets/divider_widget.dart";
|
||||
|
||||
class DividerText extends StatelessWidget {
|
||||
final String text;
|
||||
|
|
@ -6,24 +7,6 @@ class DividerText extends StatelessWidget {
|
|||
const DividerText(this.text, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) => Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 16,
|
||||
child: Divider(color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: .new(maxWidth: constraints.maxWidth - 32),
|
||||
child: Padding(
|
||||
padding: const .all(8),
|
||||
child: Text(text, style: Theme.of(context).textTheme.labelLarge),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
Widget build(BuildContext context) =>
|
||||
DividerWidget(Text(text, style: Theme.of(context).textTheme.labelLarge));
|
||||
}
|
||||
|
|
|
|||
25
lib/widgets/divider_widget.dart
Normal file
25
lib/widgets/divider_widget.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import "package:flutter/material.dart";
|
||||
|
||||
class DividerWidget extends StatelessWidget {
|
||||
final Widget widget;
|
||||
const DividerWidget(this.widget, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (_, constraints) => Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 16,
|
||||
child: Divider(color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: .new(maxWidth: constraints.maxWidth - 32),
|
||||
child: Padding(padding: const .all(8), child: widget),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import "package:nexus/controllers/key_controller.dart";
|
|||
import "package:nexus/controllers/spaces_controller.dart";
|
||||
import "package:nexus/models/room.dart";
|
||||
import "package:nexus/widgets/avatar_or_hash.dart";
|
||||
import "package:nexus/widgets/divider_widget.dart";
|
||||
import "package:nexus/widgets/join_dialog.dart";
|
||||
import "package:nexus/widgets/room_menu.dart";
|
||||
|
||||
|
|
@ -214,27 +215,36 @@ class Sidebar extends HookConsumerWidget {
|
|||
selectedIndex: selectedRoomIndex ?? 0,
|
||||
sections: [
|
||||
.new(
|
||||
header: selectedSpace.room == null ? null : Text("Rooms"),
|
||||
header: selectedSpace.room == null
|
||||
? null
|
||||
: DividerWidget(Text("Rooms")),
|
||||
destinations: roomsToDestinations(selectedSpace.children),
|
||||
),
|
||||
for (final subSpace in selectedSpace.subSpaces)
|
||||
.new(
|
||||
header: Row(
|
||||
header: DividerWidget(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8,
|
||||
children: [
|
||||
SizedBox(width: 16, child: Divider()),
|
||||
if (subSpace.room.metadata?.avatar != null)
|
||||
AvatarOrHash(
|
||||
subSpace.room.metadata?.avatar,
|
||||
subSpace.room.metadata?.name ?? "Unnamed Room",
|
||||
subSpace.room.metadata?.name ??
|
||||
"Unnamed Room",
|
||||
height: 16,
|
||||
),
|
||||
Text(
|
||||
subSpace.room.metadata?.name ?? "Unnamed Space",
|
||||
Flexible(
|
||||
child: Text(
|
||||
subSpace.room.metadata?.name ??
|
||||
"Unnamed Space",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Expanded(child: Divider()),
|
||||
],
|
||||
),
|
||||
),
|
||||
destinations: roomsToDestinations(subSpace.children),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue