File tree Expand file tree Collapse file tree 7 files changed +46
-10
lines changed Expand file tree Collapse file tree 7 files changed +46
-10
lines changed Original file line number Diff line number Diff line change 1
- import 'package:flutter/foundation.dart' show kIsWeb;
2
1
import 'package:flutter/material.dart' ;
3
2
import 'package:flutter_bloc/flutter_bloc.dart' ;
4
3
import 'package:ht_auth_api/ht_auth_api.dart' ;
@@ -16,7 +15,9 @@ import 'package:ht_main/app/config/config.dart' as app_config;
16
15
import 'package:ht_main/app/services/demo_data_migration_service.dart' ;
17
16
import 'package:ht_main/bloc_observer.dart' ;
18
17
import 'package:ht_shared/ht_shared.dart' ;
18
+ import 'package:ht_ui_kit/ht_ui_kit.dart' ;
19
19
import 'package:logging/logging.dart' ;
20
+ import 'package:timeago/timeago.dart' as timeago;
20
21
21
22
Future <Widget > bootstrap (
22
23
app_config.AppConfig appConfig,
@@ -25,6 +26,9 @@ Future<Widget> bootstrap(
25
26
WidgetsFlutterBinding .ensureInitialized ();
26
27
Bloc .observer = const AppBlocObserver ();
27
28
29
+ timeago.setLocaleMessages ('en' , EnTimeagoMessages ());
30
+ timeago.setLocaleMessages ('ar' , ArTimeagoMessages ());
31
+
28
32
final logger = Logger ('bootstrap' );
29
33
30
34
final kvStorage = await HtKvStorageSharedPreferences .getInstance ();
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import 'package:ht_main/app/bloc/app_bloc.dart';
9
9
import 'package:ht_main/headlines-search/bloc/headlines_search_bloc.dart' ;
10
10
// import 'package:ht_main/headlines-search/widgets/country_item_widget.dart';
11
11
import 'package:ht_main/headlines-search/widgets/source_item_widget.dart' ;
12
+ import 'package:ht_main/headlines-search/widgets/topic_item_widget.dart' ;
12
13
import 'package:ht_main/l10n/l10n.dart' ;
13
14
import 'package:ht_main/router/routes.dart' ;
14
15
import 'package:ht_main/shared/extensions/content_type_extensions.dart' ;
@@ -332,8 +333,7 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
332
333
}
333
334
return tile;
334
335
} else if (feedItem is Topic ) {
335
- // TODO(user): Create a TopicItemWidget similar to CategoryItemWidget
336
- return ListTile (title: Text (feedItem.name));
336
+ return TopicItemWidget (topic: feedItem);
337
337
} else if (feedItem is Source ) {
338
338
return SourceItemWidget (source: feedItem);
339
339
} else if (feedItem is Ad ) {
Original file line number Diff line number Diff line change
1
+ import 'package:flutter/material.dart' ;
2
+ import 'package:go_router/go_router.dart' ;
3
+ import 'package:ht_main/entity_details/view/entity_details_page.dart' ;
4
+ import 'package:ht_main/router/routes.dart' ;
5
+ import 'package:ht_shared/ht_shared.dart' ;
6
+
7
+ /// A simple widget to display a Topic search result.
8
+ class TopicItemWidget extends StatelessWidget {
9
+ const TopicItemWidget ({required this .topic, super .key});
10
+
11
+ final Topic topic;
12
+
13
+ @override
14
+ Widget build (BuildContext context) {
15
+ return ListTile (
16
+ title: Text (topic.name),
17
+ subtitle: topic.description.isNotEmpty
18
+ ? Text (
19
+ topic.description,
20
+ maxLines: 2 ,
21
+ overflow: TextOverflow .ellipsis,
22
+ )
23
+ : null ,
24
+ onTap: () {
25
+ context.push (
26
+ Routes .topicDetails,
27
+ extra: EntityDetailsPageArguments (entity: topic),
28
+ );
29
+ },
30
+ );
31
+ }
32
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import 'package:ht_main/entity_details/view/entity_details_page.dart';
4
4
import 'package:ht_main/router/routes.dart' ;
5
5
import 'package:ht_shared/ht_shared.dart' ;
6
6
import 'package:ht_ui_kit/ht_ui_kit.dart' ;
7
+ import 'package:timeago/timeago.dart' as timeago;
7
8
8
9
/// {@template headline_tile_image_start}
9
10
/// A shared widget to display a headline item with a small image at the start.
@@ -136,8 +137,7 @@ class _HeadlineMetadataRow extends StatelessWidget {
136
137
137
138
@override
138
139
Widget build (BuildContext context) {
139
- // TODO(anyone): Use a proper timeago library.
140
- final formattedDate = headline.createdAt.toString ();
140
+ final formattedDate = timeago.format (headline.createdAt);
141
141
142
142
// Use bodySmall for a reasonable base size, with muted accent color
143
143
final metadataTextStyle = textTheme.bodySmall? .copyWith (
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import 'package:ht_main/entity_details/view/entity_details_page.dart';
4
4
import 'package:ht_main/router/routes.dart' ;
5
5
import 'package:ht_shared/ht_shared.dart' ;
6
6
import 'package:ht_ui_kit/ht_ui_kit.dart' ;
7
+ import 'package:timeago/timeago.dart' as timeago;
7
8
8
9
/// {@template headline_tile_image_top}
9
10
/// A shared widget to display a headline item with a large image at the top.
@@ -147,8 +148,7 @@ class _HeadlineMetadataRow extends StatelessWidget {
147
148
148
149
@override
149
150
Widget build (BuildContext context) {
150
- // TODO(anyone): Use a proper timeago library.
151
- final formattedDate = headline.createdAt.toString ();
151
+ final formattedDate = timeago.format (headline.createdAt);
152
152
153
153
// Use bodySmall for a reasonable base size, with muted accent color
154
154
final metadataTextStyle = textTheme.bodySmall? .copyWith (
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import 'package:ht_main/entity_details/view/entity_details_page.dart';
4
4
import 'package:ht_main/router/routes.dart' ;
5
5
import 'package:ht_shared/ht_shared.dart' ;
6
6
import 'package:ht_ui_kit/ht_ui_kit.dart' ;
7
+ import 'package:timeago/timeago.dart' as timeago;
7
8
8
9
/// {@template headline_tile_text_only}
9
10
/// A widget to display a headline item with text only.
@@ -108,8 +109,7 @@ class _HeadlineMetadataRow extends StatelessWidget {
108
109
109
110
@override
110
111
Widget build (BuildContext context) {
111
- // TODO(anyone): Use a proper timeago library.
112
- final formattedDate = headline.createdAt.toString ();
112
+ final formattedDate = timeago.format (headline.createdAt);
113
113
114
114
// Use bodySmall for a reasonable base size, with muted accent color
115
115
final metadataTextStyle = textTheme.bodySmall? .copyWith (
Original file line number Diff line number Diff line change @@ -416,7 +416,7 @@ packages:
416
416
description:
417
417
path: "."
418
418
ref: HEAD
419
- resolved-ref: abef81e5294d70ace82d3e87f1efc94fca6a8445
419
+ resolved-ref: "7945773edb4251d294071820c4ce1b6332f032ec"
420
420
url: "https://github.com/headlines-toolkit/ht-data-inmemory.git"
421
421
source: git
422
422
version: "0.0.0"
You can’t perform that action at this time.
0 commit comments