this repo has no description

feat: improve relative time formatting and enhance actor display in timeline item widget

+41 -31
+8 -4
lib/utils.dart
··· 3 3 if (date == null) return ''; 4 4 final now = DateTime.now(); 5 5 final diff = now.difference(date); 6 - if (diff.inSeconds < 60) return '${diff.inSeconds}s ago'; 7 - if (diff.inMinutes < 60) return '${diff.inMinutes}m ago'; 8 - if (diff.inHours < 24) return '${diff.inHours}h ago'; 9 - return '${diff.inDays}d ago'; 6 + final weeks = diff.inDays ~/ 7; 7 + if (weeks > 0) return '${weeks}w'; 8 + final days = diff.inDays; 9 + if (days > 0) return '${days}d'; 10 + final hours = diff.inHours; 11 + if (hours > 0) return '${hours}h'; 12 + final minutes = diff.inMinutes; 13 + return '${minutes < 1 ? 1 : minutes}m'; 10 14 }
+33 -27
lib/widgets/timeline_item.dart
··· 68 68 const SizedBox(width: 10), 69 69 Expanded( 70 70 child: Row( 71 + crossAxisAlignment: CrossAxisAlignment.center, 72 + mainAxisAlignment: MainAxisAlignment.spaceBetween, 71 73 children: [ 72 74 Flexible( 73 - child: Text( 74 - actor != null && (actor.displayName?.isNotEmpty ?? false) 75 - ? actor.displayName ?? '' 76 - : (actor != null ? '@${actor.handle}' : ''), 77 - style: theme.textTheme.titleMedium?.copyWith( 78 - fontWeight: FontWeight.w600, 79 - fontSize: 16, 75 + child: Text.rich( 76 + TextSpan( 77 + children: [ 78 + if (actor != null && (actor.displayName?.isNotEmpty ?? false)) 79 + TextSpan( 80 + text: actor.displayName, 81 + style: theme.textTheme.titleMedium?.copyWith( 82 + fontWeight: FontWeight.w600, 83 + fontSize: 16, 84 + ), 85 + ), 86 + if (actor != null && actor.handle.isNotEmpty) 87 + TextSpan( 88 + text: (actor.displayName?.isNotEmpty ?? false) 89 + ? ' @${actor.handle}' 90 + : '@${actor.handle}', 91 + style: theme.textTheme.bodySmall?.copyWith( 92 + fontSize: 14, 93 + color: theme.colorScheme.onSurfaceVariant, 94 + fontWeight: FontWeight.normal, 95 + ), 96 + ), 97 + ], 80 98 ), 81 99 overflow: TextOverflow.ellipsis, 100 + maxLines: 1, 82 101 ), 83 102 ), 84 - if (actor != null && actor.handle.isNotEmpty) 85 - Padding( 86 - padding: const EdgeInsets.only(left: 6), 87 - child: Text( 88 - '@${actor.handle}', 89 - style: theme.textTheme.bodySmall?.copyWith( 90 - fontSize: 14, 91 - color: theme.colorScheme.onSurfaceVariant, 92 - fontWeight: FontWeight.normal, 93 - ), 94 - overflow: TextOverflow.ellipsis, 95 - maxLines: 1, 96 - ), 103 + Text( 104 + formatRelativeTime(createdAt ?? ''), 105 + style: theme.textTheme.bodySmall?.copyWith( 106 + fontSize: 14, 107 + color: theme.colorScheme.onSurfaceVariant, 97 108 ), 109 + textAlign: TextAlign.right, 110 + ), 98 111 ], 99 - ), 100 - ), 101 - Text( 102 - formatRelativeTime(createdAt ?? ''), 103 - style: theme.textTheme.bodySmall?.copyWith( 104 - fontSize: 12, 105 - color: theme.colorScheme.onSurfaceVariant, 106 112 ), 107 113 ), 108 114 ],