Skip to content

Commit

Permalink
GS-9252 fix username view in posts (#2175)
Browse files Browse the repository at this point in the history
  • Loading branch information
canergulayy authored and github-actions[bot] committed Jun 30, 2023
1 parent fd6553c commit 98b557c
Show file tree
Hide file tree
Showing 88 changed files with 118 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/core/utils/string_overflower.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
String customOverflover(String text, int length) {
return text.length > length ? '${text.substring(0, length)}...' : text;
}
2 changes: 1 addition & 1 deletion lib/features/posts/widgets/post_summary_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PostSummaryBar extends StatelessWidget {
final circleEmoji = circle.emoji;
final circleImage = circle.imageFile;
final deferredLink = DeferredPointerHandlerLink();
final postTimeCreationDate = post.createdAt?.timeElapsed();
final postTimeCreationDate = post.createdAt?.timeElapsedWithoutAgo();

return Padding(
padding: padding,
Expand Down
44 changes: 43 additions & 1 deletion lib/localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1485,5 +1485,47 @@
"interestsSelected": {},
"interestsMinimum": {}
}
},
"secondsTime": "{seconds}s",
"@secondsTime": {
"placeholders": {
"seconds": {}
}
},
"minutesTime": "{minutes}m",
"@minutesTime": {
"placeholders": {
"minutes": {}
}
},
"hoursTime": "{hours}h",
"@hoursTime": {
"placeholders": {
"hours": {}
}
},
"daysTime": "{days}d",
"@daysTime": {
"placeholders": {
"days": {}
}
},
"weeksTime": "{weeks}d",
"@weeksTime": {
"placeholders": {
"weeks": {}
}
},
"monthsTime": "{months}d",
"@monthsTime": {
"placeholders": {
"months": {}
}
},
"yearsTime": "{years}d",
"@yearsTime": {
"placeholders": {
"years": {}
}
}
}
}
42 changes: 34 additions & 8 deletions lib/ui/widgets/picnic_dynamic_author.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:picnic_app/core/utils/stat_extensions.dart';
import 'package:picnic_app/core/utils/string_overflower.dart';
import 'package:picnic_app/features/posts/post_overlay/post_overlay_page.dart';
import 'package:picnic_app/localization/app_localizations_utils.dart';
import 'package:picnic_app/resources/assets.gen.dart';
import 'package:picnic_app/utils/extensions/color_extensions.dart';
import 'package:picnic_app/utils/number_formatter.dart';
import 'package:picnic_ui_components/ui/theme/picnic_theme.dart';
import 'package:picnic_ui_components/ui/widgets/picnic_button.dart';

Expand Down Expand Up @@ -67,6 +69,9 @@ class PicnicDynamicAuthor extends StatelessWidget {
static const double _followButtonHeight = 26.0;
static const double _joinButtonRadius = 100.0;

static const double _iconSize = 16.0;
static const int _maxOverflowLength = 20;

@override
Widget build(BuildContext context) {
final theme = PicnicTheme.of(context);
Expand Down Expand Up @@ -165,7 +170,8 @@ class PicnicDynamicAuthor extends StatelessWidget {
onTap: onAuthorUsernameTap,
child: RichText(
text: TextSpan(
text: appLocalizations.byUsername(authorUsername),
text:
customOverflover(appLocalizations.byUsername(authorUsername), _maxOverflowLength),
style: subtitleStyle,
children: [
if (authorVerifiedBadge != null) ...[
Expand Down Expand Up @@ -193,12 +199,32 @@ class PicnicDynamicAuthor extends StatelessWidget {
),
),
),
if (showDateViews)
Text(
' • $dateToDisplay • ${appLocalizations.viewsCount(formatNumber(viewsCount))}',
style: subtitleStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
if (showDateViews && dateToDisplay.isNotEmpty)
Row(
children: [
Text(
' • $dateToDisplay •',
style: subtitleStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
children: [
Image.asset(
Assets.images.play.path,
height: _iconSize,
width: _iconSize,
),
const Gap(2),
Text(
viewsCount.formattingToStat(),
style: subtitleStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
],
),
Expand Down
35 changes: 35 additions & 0 deletions lib/utils/extensions/time_ago_formatting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,38 @@ extension TimeAgoFormatting on DateTime {
return result;
}
}

extension TimeFormatting on DateTime {
String timeElapsedWithoutAgo() {
final currentTimeProvider = getIt<CurrentTimeProvider>();
var elapsed = currentTimeProvider.currentTime.millisecondsSinceEpoch - millisecondsSinceEpoch;
final seconds = elapsed / 1000;
final minutes = seconds / 60;
final hours = minutes / 60;
final days = hours / 24;
final weeks = days / 7;
final months = days / 30;
final years = days / 365;

String result;
if (seconds <= 0) {
result = appLocalizations.secondsTime(0);
} else if (seconds < 60) {
result = appLocalizations.secondsTime(seconds.floor());
} else if (minutes < 60) {
result = appLocalizations.minutesTime(minutes.floor());
} else if (hours < 24) {
result = appLocalizations.hoursTime(hours.floor());
} else if (days < 7) {
result = appLocalizations.daysTime(days.floor());
} else if (weeks < 4) {
result = appLocalizations.weeksTime(weeks.floor());
} else if (months <= 12) {
result = appLocalizations.monthsTime(months.floor());
} else {
result = appLocalizations.yearsTime(years.floor());
}

return result;
}
}
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import recaptcha_verification
import share_plus_macos
import shared_preferences_foundation
import sign_in_with_apple
import smart_auth
import sqflite
import url_launcher_macos
import wakelock_macos
Expand All @@ -51,6 +52,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
SmartAuthPlugin.register(with: registry.registrar(forPlugin: "SmartAuthPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/features/posts/pages/goldens/ci/comment_chat_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/features/posts/pages/goldens/ci/image_post_page.png
Binary file modified test/features/posts/pages/goldens/ci/link_post_page.png
Binary file modified test/features/posts/pages/goldens/ci/poll_post_page.png
Binary file modified test/features/posts/pages/goldens/ci/post_details_page.png
Binary file modified test/features/posts/pages/goldens/ci/posts_list_page_list.png
Binary file modified test/features/posts/pages/goldens/ci/single_feed_page.png
Binary file modified test/features/posts/pages/goldens/ci/text_post_page.png
Binary file modified test/features/posts/pages/goldens/ci/text_post_page_0_comments.png
Binary file modified test/features/posts/pages/goldens/ci/text_post_page_6_comments.png
Binary file modified test/features/posts/pages/goldens/ci/text_post_page_green.png
Binary file modified test/features/posts/pages/goldens/ci/text_post_page_red.png
Binary file modified test/features/posts/pages/goldens/ci/video_post_page.png
Binary file modified test/features/posts/pages/goldens/macos/comment_chat_page.png
Binary file modified test/features/posts/pages/goldens/macos/image_post_page.png
Binary file modified test/features/posts/pages/goldens/macos/link_post_page.png
Binary file modified test/features/posts/pages/goldens/macos/poll_post_page.png
Binary file modified test/features/posts/pages/goldens/macos/post_details_page.png
Binary file modified test/features/posts/pages/goldens/macos/posts_list_page_list.png
Binary file modified test/features/posts/pages/goldens/macos/single_feed_page.png
Binary file modified test/features/posts/pages/goldens/macos/text_post_page.png
Binary file modified test/features/posts/pages/goldens/macos/text_post_page_red.png
Binary file modified test/features/posts/pages/goldens/macos/video_post_page.png
Binary file modified test/widgets/goldens/ci/picnic_post.png
Binary file modified test/widgets/goldens/macos/picnic_post.png

0 comments on commit 98b557c

Please sign in to comment.