-
Notifications
You must be signed in to change notification settings - Fork 0
refactor/ui-enhancements #130
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fb83f37
feat(headline-details): rework headline metadata layout
fulleni b89f61b
refactor(headlines-feed): remove ads and simplify headline handling
fulleni 2d1024b
refactor(headline-details): improve metadata chips layout and reduce …
fulleni 5927158
fix(feed_core): update export from headline_metadata_row to headline_…
fulleni c34f2f5
feat(ui_kit): add HeadlineSourceRow widget
fulleni 4b0d1d3
feat(feed_core): add source row to headline tile
fulleni 5dfbfae
refactor(widgets): restructure headline tile layout
fulleni a501570
refactor(widgets): update headline tile text-only layout
fulleni aa4e06c
feat(headline-details): update date format in headline details page
fulleni 9f3cc5a
fix(feed_core): display relative dates in the correct language
fulleni d620330
style: format and cleanup
fulleni c19722d
style: format and cleanup
fulleni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'package:core/core.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:flutter_news_app_mobile_client_full_source_code/ads/interstitial_ad_manager.dart'; | ||
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart'; | ||
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:timeago/timeago.dart' as timeago; | ||
import 'package:ui_kit/ui_kit.dart'; | ||
|
||
/// {@template headline_source_row} | ||
/// A widget to display the source and publish date of a headline. | ||
/// {@endtemplate} | ||
class HeadlineSourceRow extends StatelessWidget { | ||
/// {@macro headline_source_row} | ||
const HeadlineSourceRow({required this.headline, super.key}); | ||
|
||
/// The headline data to display. | ||
final Headline headline; | ||
|
||
Future<void> _handleEntityTap(BuildContext context) async { | ||
await context.read<InterstitialAdManager>().onPotentialAdTrigger(); | ||
if (!context.mounted) return; | ||
await context.pushNamed( | ||
Routes.entityDetailsName, | ||
pathParameters: { | ||
'type': ContentType.source.name, | ||
'id': headline.source.id, | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
final textTheme = theme.textTheme; | ||
final colorScheme = theme.colorScheme; | ||
final currentLocale = context.watch<AppBloc>().state.locale; | ||
|
||
final formattedDate = timeago.format( | ||
headline.createdAt, | ||
locale: currentLocale.languageCode, | ||
); | ||
|
||
final sourceTextStyle = textTheme.bodySmall?.copyWith( | ||
color: colorScheme.onSurfaceVariant, | ||
fontWeight: FontWeight.w500, | ||
); | ||
|
||
final dateTextStyle = textTheme.bodySmall?.copyWith( | ||
color: colorScheme.onSurfaceVariant.withOpacity(0.7), | ||
); | ||
|
||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Expanded( | ||
child: InkWell( | ||
onTap: () => _handleEntityTap(context), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Icon( | ||
Icons.source_outlined, | ||
size: AppSpacing.md, | ||
color: colorScheme.onSurfaceVariant, | ||
), | ||
const SizedBox(width: AppSpacing.xs), | ||
Flexible( | ||
child: Text( | ||
headline.source.name, | ||
style: sourceTextStyle, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
], | ||
), | ||
fulleni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
), | ||
if (formattedDate.isNotEmpty) Text(formattedDate, style: dateTextStyle), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a hardcoded value
18.0
forchipAvatarSize
makes the code harder to maintain and less consistent with the app's design system. The previous implementation usedAppSpacing.md
.If
18.0
is a new standard size, consider adding it as a constant to yourAppSpacing
class (e.g.,AppSpacing.mdLg
). If an existing constant fromAppSpacing
is suitable, please use that instead to maintain consistency.