Skip to content

Commit e2cb28e

Browse files
committed
feat(example): add UI to display related publications
- Export RelatedPublication entity in SDK main library - Create RelatedPublicationsWidget to display list of related publications - Create RelatedPublicationItem widget for individual publication items - Update PublicationDetailContent to show related publications section - Display related publications with cover image, title, and release date - Add navigation placeholder for related publication items
1 parent 54552a4 commit e2cb28e

File tree

3 files changed

+172
-1
lines changed

3 files changed

+172
-1
lines changed

app/example/lib/features/publications/presentation/widgets/publication_detail_content.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:gap/gap.dart';
33
import 'package:stadata_example/core/constants/app_sizes.dart';
44
import 'package:stadata_example/core/generated/strings.g.dart';
5+
import 'package:stadata_example/features/publications/presentation/widgets/related_publications_widget.dart';
56
import 'package:stadata_flutter_sdk/stadata_flutter_sdk.dart';
67

78
class PublicationDetailContent extends StatelessWidget {
@@ -33,7 +34,17 @@ class PublicationDetailContent extends StatelessWidget {
3334
if (publication.abstract != null && publication.abstract!.isNotEmpty)
3435
_buildAbstractSection(context, theme, t),
3536

36-
const Gap(AppSizes.spaceLg),
37+
if (publication.abstract != null && publication.abstract!.isNotEmpty)
38+
const Gap(AppSizes.spaceLg),
39+
40+
// Related publications section
41+
if (publication.relatedPublications.isNotEmpty)
42+
RelatedPublicationsWidget(
43+
relatedPublications: publication.relatedPublications,
44+
),
45+
46+
if (publication.relatedPublications.isNotEmpty)
47+
const Gap(AppSizes.spaceLg),
3748

3849
// Action buttons
3950
_buildActionButtons(context, theme, t),
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:gap/gap.dart';
3+
import 'package:stadata_example/core/constants/app_sizes.dart';
4+
import 'package:stadata_flutter_sdk/stadata_flutter_sdk.dart';
5+
6+
class RelatedPublicationsWidget extends StatelessWidget {
7+
const RelatedPublicationsWidget({
8+
required this.relatedPublications,
9+
super.key,
10+
});
11+
12+
final List<RelatedPublication> relatedPublications;
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
final theme = Theme.of(context);
17+
18+
return Card(
19+
child: Padding(
20+
padding: const EdgeInsets.all(AppSizes.spaceMd),
21+
child: Column(
22+
crossAxisAlignment: CrossAxisAlignment.start,
23+
children: [
24+
Text(
25+
'Related Publications',
26+
style: theme.textTheme.titleMedium?.copyWith(
27+
fontWeight: FontWeight.w600,
28+
),
29+
),
30+
const Gap(AppSizes.spaceMd),
31+
ListView.separated(
32+
shrinkWrap: true,
33+
physics: const NeverScrollableScrollPhysics(),
34+
itemCount: relatedPublications.length,
35+
separatorBuilder:
36+
(context, index) => const Divider(
37+
height: AppSizes.spaceMd,
38+
),
39+
itemBuilder: (context, index) {
40+
final related = relatedPublications[index];
41+
return RelatedPublicationItem(publication: related);
42+
},
43+
),
44+
],
45+
),
46+
),
47+
);
48+
}
49+
}
50+
51+
class RelatedPublicationItem extends StatelessWidget {
52+
const RelatedPublicationItem({
53+
required this.publication,
54+
super.key,
55+
});
56+
57+
final RelatedPublication publication;
58+
59+
@override
60+
Widget build(BuildContext context) {
61+
final theme = Theme.of(context);
62+
63+
return InkWell(
64+
onTap: () {
65+
// Navigate to the related publication
66+
// This could be implemented to open the publication detail
67+
},
68+
borderRadius: BorderRadius.circular(8),
69+
child: Padding(
70+
padding: const EdgeInsets.all(AppSizes.spaceXs),
71+
child: Row(
72+
crossAxisAlignment: CrossAxisAlignment.start,
73+
children: [
74+
// Cover image
75+
ClipRRect(
76+
borderRadius: BorderRadius.circular(4),
77+
child: SizedBox(
78+
width: 60,
79+
height: 80,
80+
child: Image.network(
81+
publication.cover,
82+
fit: BoxFit.cover,
83+
errorBuilder:
84+
(context, error, stackTrace) => ColoredBox(
85+
color: theme.colorScheme.surfaceContainerLowest,
86+
child: Icon(
87+
Icons.book,
88+
size: 24,
89+
color: theme.colorScheme.onSurfaceVariant,
90+
),
91+
),
92+
loadingBuilder: (context, child, loadingProgress) {
93+
if (loadingProgress == null) return child;
94+
return ColoredBox(
95+
color: theme.colorScheme.surfaceContainerLowest,
96+
child: Center(
97+
child: SizedBox(
98+
width: 16,
99+
height: 16,
100+
child: CircularProgressIndicator(
101+
strokeWidth: 2,
102+
value:
103+
loadingProgress.expectedTotalBytes != null
104+
? loadingProgress.cumulativeBytesLoaded /
105+
loadingProgress.expectedTotalBytes!
106+
: null,
107+
),
108+
),
109+
),
110+
);
111+
},
112+
),
113+
),
114+
),
115+
116+
const Gap(AppSizes.spaceSm),
117+
118+
// Publication info
119+
Expanded(
120+
child: Column(
121+
crossAxisAlignment: CrossAxisAlignment.start,
122+
children: [
123+
Text(
124+
publication.title,
125+
style: theme.textTheme.bodyMedium?.copyWith(
126+
fontWeight: FontWeight.w500,
127+
),
128+
maxLines: 2,
129+
overflow: TextOverflow.ellipsis,
130+
),
131+
const Gap(AppSizes.spaceXs),
132+
Text(
133+
_formatDate(publication.releaseDate),
134+
style: theme.textTheme.bodySmall?.copyWith(
135+
color: theme.colorScheme.onSurfaceVariant,
136+
),
137+
),
138+
],
139+
),
140+
),
141+
142+
// Arrow icon
143+
Icon(
144+
Icons.arrow_forward_ios,
145+
size: 16,
146+
color: theme.colorScheme.onSurfaceVariant,
147+
),
148+
],
149+
),
150+
),
151+
);
152+
}
153+
154+
String _formatDate(DateTime date) {
155+
return '${date.day.toString().padLeft(2, '0')}/'
156+
'${date.month.toString().padLeft(2, '0')}/'
157+
'${date.year}';
158+
}
159+
}

packages/stadata_flutter_sdk/lib/stadata_flutter_sdk.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export 'src/features/features.dart'
4646
NewsCategory,
4747
PressRelease,
4848
Publication,
49+
RelatedPublication,
4950
StaticTable,
5051
StatisticClassification,
5152
StrategicIndicator,

0 commit comments

Comments
 (0)