From bae237cdf7ab1e88a5dda21322f087f69d572440 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 2 Mar 2023 00:09:59 +0200 Subject: [PATCH] Make history timeago text wrappable --- lib/ui/app/history_drawer.dart | 31 +++++++++++++++++++++++-------- lib/ui/app/live_text.dart | 10 ++++++++-- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lib/ui/app/history_drawer.dart b/lib/ui/app/history_drawer.dart index 5d85daede..4d1a2706b 100644 --- a/lib/ui/app/history_drawer.dart +++ b/lib/ui/app/history_drawer.dart @@ -145,7 +145,10 @@ class _HistoryListTileState extends State { clientId: clientId) : entity.listDisplayName); - subtitle = Text(localization.lookup('${history.entityType}')); + subtitle = Text( + localization.lookup('${history.entityType}'), + style: Theme.of(context).textTheme.bodySmall, + ); } return Container( @@ -154,13 +157,25 @@ class _HistoryListTileState extends State { child: ListTile( key: ValueKey('__${history.id}_${history.entityType}__'), leading: Icon(getEntityIcon(history.entityType)), - title: title, - subtitle: subtitle, - // TODO this needs to be localized - trailing: LiveText( - () => timeago.format(history.dateTime, - locale: localeSelector(state, twoLetter: true) + '_short'), - duration: Duration(minutes: 1), + title: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title, + subtitle, + ], + )), + Flexible( + child: LiveText( + () => timeago.format(history.dateTime, + locale: localeSelector(state, twoLetter: true) + '_short'), + duration: Duration(minutes: 1), + maxLines: 2, + )) + ], ), /* trailing: _isHovered diff --git a/lib/ui/app/live_text.dart b/lib/ui/app/live_text.dart index ba67f6e79..f7f0536e5 100644 --- a/lib/ui/app/live_text.dart +++ b/lib/ui/app/live_text.dart @@ -5,11 +5,17 @@ import 'dart:async'; import 'package:flutter/widgets.dart'; class LiveText extends StatefulWidget { - const LiveText(this.value, {this.style, this.duration}); + const LiveText( + this.value, { + this.style, + this.duration, + this.maxLines = 1, + }); final Duration duration; final Function value; final TextStyle style; + final int maxLines; @override _LiveTextState createState() => _LiveTextState(); @@ -45,7 +51,7 @@ class _LiveTextState extends State { return Text( value, style: widget.style, - maxLines: 1, + maxLines: widget.maxLines, overflow: TextOverflow.ellipsis, ); }