Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small improvement of subspace ui #323

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commet/lib/ui/atoms/room_text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class _RoomTextButtonState extends State<RoomTextButton> {
icon: icon,
iconColor: color,
textColor: color,
softwrap: false,
onTap: () => widget.onTap?.call(widget.room),
footer: widget.room.displayHighlightedNotificationCount > 0
? NotificationBadge(
Expand Down
17 changes: 7 additions & 10 deletions commet/lib/ui/atoms/space_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class _SpaceListState extends State<SpaceList> {
itemBuilder: (context, data) {
return tiamat.TextButtonExpander(data.displayName,
initiallyExpanded: true,
childrenPadding: const EdgeInsets.fromLTRB(2, 0, 0, 0),
iconColor: Theme.of(context).colorScheme.secondary,
textColor: Theme.of(context).colorScheme.secondary,
children: [
Expand All @@ -118,16 +119,12 @@ class _SpaceListState extends State<SpaceList> {

Widget roomsList() {
if (widget.isTopLevel) {
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: tiamat.Text(
labelRoomsList,
color: Theme.of(context).colorScheme.secondary,
),
),
buildRoomsList()
]);
return tiamat.TextButtonExpander(labelRoomsList,
childrenPadding: const EdgeInsets.fromLTRB(2, 0, 0, 0),
initiallyExpanded: true,
iconColor: Theme.of(context).colorScheme.secondary,
textColor: Theme.of(context).colorScheme.secondary,
children: [buildRoomsList()]);
} else {
return buildRoomsList();
}
Expand Down
75 changes: 57 additions & 18 deletions tiamat/lib/atoms/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class Text extends StatelessWidget {
this.type = TextType.label,
this.overflow,
this.color,
this.softwrap,
this.autoAdjustBrightness,
this.maxLines});
final String text;
Expand All @@ -122,56 +123,93 @@ class Text extends StatelessWidget {
final TextOverflow? overflow;
final int? maxLines;
final bool? autoAdjustBrightness;
final bool? softwrap;

const Text.label(
this.text, {
Key? key,
this.overflow,
this.maxLines,
this.softwrap,
}) : type = TextType.label,
color = null,
autoAdjustBrightness = false,
super(key: key);

const Text.labelEmphasised(this.text,
{Key? key, this.overflow, this.color, this.maxLines})
: type = TextType.labelEmphasised,
const Text.labelEmphasised(
this.text, {
Key? key,
this.overflow,
this.color,
this.maxLines,
this.softwrap,
}) : type = TextType.labelEmphasised,
autoAdjustBrightness = false,
super(key: key);

const Text.error(this.text, {Key? key, this.overflow, this.maxLines})
: type = TextType.error,
const Text.error(
this.text, {
Key? key,
this.overflow,
this.maxLines,
this.softwrap,
}) : type = TextType.error,
color = null,
autoAdjustBrightness = false,
super(key: key);

const Text.tiny(this.text,
{Key? key, this.overflow, this.maxLines, this.color})
: type = TextType.tiny,
const Text.tiny(
this.text, {
Key? key,
this.overflow,
this.maxLines,
this.color,
this.softwrap,
}) : type = TextType.tiny,
autoAdjustBrightness = false,
super(key: key);

const Text.body(this.text, {Key? key, this.overflow, this.maxLines})
: type = TextType.body,
const Text.body(
this.text, {
Key? key,
this.overflow,
this.maxLines,
this.softwrap,
}) : type = TextType.body,
color = null,
autoAdjustBrightness = false,
super(key: key);

const Text.largeTitle(this.text, {Key? key, this.overflow, this.maxLines})
: type = TextType.largeTitle,
const Text.largeTitle(
this.text, {
Key? key,
this.overflow,
this.maxLines,
this.softwrap,
}) : type = TextType.largeTitle,
color = null,
autoAdjustBrightness = false,
super(key: key);

const Text.name(this.text,
{Key? key, this.color, this.overflow, this.maxLines})
: type = TextType.name,
const Text.name(
this.text, {
Key? key,
this.color,
this.overflow,
this.maxLines,
this.softwrap,
}) : type = TextType.name,
autoAdjustBrightness = true,
super(key: key);

const Text.labelLow(this.text,
{Key? key, this.color, this.overflow, this.maxLines})
: type = TextType.labelLow,
const Text.labelLow(
this.text, {
Key? key,
this.color,
this.overflow,
this.maxLines,
this.softwrap,
}) : type = TextType.labelLow,
autoAdjustBrightness = false,
super(key: key);

Expand Down Expand Up @@ -246,6 +284,7 @@ class Text extends StatelessWidget {
return material.Text(
text,
style: style,
softWrap: softwrap,
overflow: overflow,
maxLines: maxLines,
);
Expand Down
32 changes: 20 additions & 12 deletions tiamat/lib/atoms/text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class TextButton extends StatelessWidget {
this.avatarRadius = 12,
this.avatarPlaceholderColor,
this.avatarPlaceholderText,
this.softwrap,
this.footer});
final String text;

Expand All @@ -179,6 +180,7 @@ class TextButton extends StatelessWidget {
final Widget? footer;
final Color? textColor;
final Color? iconColor;
final bool? softwrap;

bool get useAvatar => avatar != null || avatarPlaceholderText != null;

Expand All @@ -193,7 +195,8 @@ class TextButton extends StatelessWidget {
),
child: material
.Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Row(
Flexible(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -226,19 +229,24 @@ class TextButton extends StatelessWidget {
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 0, 0),
child: Align(
alignment: Alignment.centerLeft,
child: tiamat.Text.labelEmphasised(
text,
color: highlighted
? Theme.of(context).colorScheme.onSecondaryContainer
: textColor,
)),
Flexible(
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 0, 0),
child: Align(
alignment: Alignment.centerLeft,
child: tiamat.Text.labelEmphasised(
text,
maxLines: 1,
softwrap: softwrap,
overflow: TextOverflow.fade,
color: highlighted
? Theme.of(context).colorScheme.onSecondaryContainer
: textColor,
)),
),
),
],
),
)),
if (footer != null) footer!,
]),
onPressed: () => onTap?.call());
Expand Down
2 changes: 1 addition & 1 deletion tiamat/lib/config/style/theme_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ThemeBase {
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
listTileTheme: ListTileThemeData(
dense: true,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
contentPadding: EdgeInsets.fromLTRB(8, 2, 8, 0),
),
canvasColor: scheme.surface,
iconTheme: IconThemeData(color: scheme.secondary),
Expand Down
Loading