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:flutter/material.dart";
|
||||||
|
import "package:nexus/widgets/divider_widget.dart";
|
||||||
|
|
||||||
class DividerText extends StatelessWidget {
|
class DividerText extends StatelessWidget {
|
||||||
final String text;
|
final String text;
|
||||||
|
|
@ -6,24 +7,6 @@ class DividerText extends StatelessWidget {
|
||||||
const DividerText(this.text, {super.key});
|
const DividerText(this.text, {super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => LayoutBuilder(
|
Widget build(BuildContext context) =>
|
||||||
builder: (context, constraints) => Row(
|
DividerWidget(Text(text, style: Theme.of(context).textTheme.labelLarge));
|
||||||
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),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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/controllers/spaces_controller.dart";
|
||||||
import "package:nexus/models/room.dart";
|
import "package:nexus/models/room.dart";
|
||||||
import "package:nexus/widgets/avatar_or_hash.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/join_dialog.dart";
|
||||||
import "package:nexus/widgets/room_menu.dart";
|
import "package:nexus/widgets/room_menu.dart";
|
||||||
|
|
||||||
|
|
@ -214,26 +215,35 @@ class Sidebar extends HookConsumerWidget {
|
||||||
selectedIndex: selectedRoomIndex ?? 0,
|
selectedIndex: selectedRoomIndex ?? 0,
|
||||||
sections: [
|
sections: [
|
||||||
.new(
|
.new(
|
||||||
header: selectedSpace.room == null ? null : Text("Rooms"),
|
header: selectedSpace.room == null
|
||||||
|
? null
|
||||||
|
: DividerWidget(Text("Rooms")),
|
||||||
destinations: roomsToDestinations(selectedSpace.children),
|
destinations: roomsToDestinations(selectedSpace.children),
|
||||||
),
|
),
|
||||||
for (final subSpace in selectedSpace.subSpaces)
|
for (final subSpace in selectedSpace.subSpaces)
|
||||||
.new(
|
.new(
|
||||||
header: Row(
|
header: DividerWidget(
|
||||||
spacing: 8,
|
Row(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
SizedBox(width: 16, child: Divider()),
|
spacing: 8,
|
||||||
if (subSpace.room.metadata?.avatar != null)
|
children: [
|
||||||
AvatarOrHash(
|
if (subSpace.room.metadata?.avatar != null)
|
||||||
subSpace.room.metadata?.avatar,
|
AvatarOrHash(
|
||||||
subSpace.room.metadata?.name ?? "Unnamed Room",
|
subSpace.room.metadata?.avatar,
|
||||||
height: 16,
|
subSpace.room.metadata?.name ??
|
||||||
|
"Unnamed Room",
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
subSpace.room.metadata?.name ??
|
||||||
|
"Unnamed Space",
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Text(
|
],
|
||||||
subSpace.room.metadata?.name ?? "Unnamed Space",
|
),
|
||||||
),
|
|
||||||
Expanded(child: Divider()),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
destinations: roomsToDestinations(subSpace.children),
|
destinations: roomsToDestinations(subSpace.children),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue