Skip to content

Commit 2b82999

Browse files
committed
profile: Show date joined on profile page
1 parent 8dab005 commit 2b82999

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

lib/widgets/profile.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,30 @@ class _ProfileDataTable extends StatelessWidget {
413413
@override
414414
Widget build(BuildContext context) {
415415
final store = PerAccountStoreWidget.of(context);
416+
final zulipLocalizations = ZulipLocalizations.of(context);
416417

417418
List<Widget> items = [];
418419

420+
final date = DateTime.tryParse(user.dateJoined);
421+
if (date != null) {
422+
final localDate = date.toLocal();
423+
final formattedDate = DateFormat.yMMMd().format(localDate);
424+
final label = user.isImportedStub
425+
? zulipLocalizations.profileDateImportedLabel
426+
: zulipLocalizations.profileDateJoinedLabel;
427+
items.add(Row(
428+
crossAxisAlignment: CrossAxisAlignment.baseline,
429+
textBaseline: localizedTextBaseline(context),
430+
children: [
431+
SizedBox(width: 100,
432+
child: Text(style: _TextStyles.customProfileFieldLabel(context),
433+
label)),
434+
const SizedBox(width: 8),
435+
Flexible(child: _TextWidget(text: formattedDate)),
436+
]));
437+
items.add(const SizedBox(height: 8));
438+
}
439+
419440
final profileData = user.profileData;
420441
for (final realmField in store.customProfileFields) {
421442
final profileField = profileData?[realmField.id];
@@ -436,8 +457,6 @@ class _ProfileDataTable extends StatelessWidget {
436457
items.add(const SizedBox(height: 8));
437458
}
438459

439-
if (items.isEmpty) return const SizedBox.shrink();
440-
441460
return Column(children: [
442461
const SizedBox(height: 16),
443462
...items

test/widgets/profile_test.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,28 @@ void main() {
201201
});
202202
});
203203

204+
group('date joined in profile data table', () {
205+
// The date is formatted in the user's local timezone, which we can't
206+
// control in tests; accept outputs for any possible timezone.
207+
// See comments in "show dates" test in message_list_test.dart.
208+
209+
testWidgets('shows date joined label and date', (tester) async {
210+
final user = eg.user(dateJoined: '2024-02-24T11:18:00+00:00');
211+
await setupPage(tester, users: [user], pageUserId: user.userId);
212+
check(find.text('Date joined')).findsOne();
213+
check(find.textContaining(RegExp('Feb 2[34], 2024'))).findsOne();
214+
});
215+
216+
testWidgets('shows imported on label when isImportedStub', (tester) async {
217+
final user = eg.user(
218+
dateJoined: '2024-02-24T11:18:00+00:00',
219+
isImportedStub: true);
220+
await setupPage(tester, users: [user], pageUserId: user.userId);
221+
check(find.text('Imported on')).findsOne();
222+
check(find.textContaining(RegExp('Feb 2[34], 2024'))).findsOne();
223+
});
224+
});
225+
204226
group('custom profile fields', () {
205227
testWidgets('page builds; profile page renders with profileData', (tester) async {
206228
await setupPage(tester,

0 commit comments

Comments
 (0)