Skip to content
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

fix: make curator note nullable #2342

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/model/ff_exhibition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class Exhibition {
final DateTime exhibitionStartAt;
final int? previewDuration;

final String noteTitle;
final String noteBrief;
final String note;
final String? noteTitle;
final String? noteBrief;
final String? note;

final String coverURI;
final String? coverDisplay;
Expand Down Expand Up @@ -60,9 +60,9 @@ class Exhibition {
slug: json['slug'] as String,
exhibitionStartAt: DateTime.parse(json['exhibitionStartAt'] as String),
previewDuration: json['previewDuration'] as int?,
noteTitle: json['noteTitle'] as String,
noteBrief: json['noteBrief'] as String,
note: json['note'] as String,
noteTitle: json['noteTitle'] as String?,
noteBrief: json['noteBrief'] as String?,
note: json['note'] as String?,
coverURI: json['coverURI'] as String,
coverDisplay: json['coverDisplay'] as String?,
curatorsAlumni: (json['curatorsAlumni'] as List<dynamic>?)
Expand Down
34 changes: 18 additions & 16 deletions lib/screen/dailies_work/dailies_work_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -752,23 +752,25 @@ class DailyWorkPageState extends State<DailyWorkPage>
horizontalMargin: 16,
),
const SizedBox(height: 48),
HtmlWidget(
exhibition.noteBrief,
customStylesBuilder: auHtmlStyle,
textStyle: theme.textTheme.ppMori400White14,
onTapUrl: (url) async {
await launchUrl(Uri.parse(url),
mode: LaunchMode.externalApplication);
return true;
},
),
const SizedBox(height: 16),
Text(
'read_more'.tr(),
style: theme.textTheme.ppMori400White14.copyWith(
decoration: TextDecoration.underline,
if (exhibition.noteBrief?.isNotEmpty == true) ...[
HtmlWidget(
exhibition.noteBrief!,
customStylesBuilder: auHtmlStyle,
textStyle: theme.textTheme.ppMori400White14,
onTapUrl: (url) async {
await launchUrl(Uri.parse(url),
mode: LaunchMode.externalApplication);
return true;
},
),
),
const SizedBox(height: 16),
Text(
'read_more'.tr(),
style: theme.textTheme.ppMori400White14.copyWith(
decoration: TextDecoration.underline,
),
),
],
],
);
}
Expand Down
77 changes: 48 additions & 29 deletions lib/screen/exhibition_details/exhibition_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ class _ExhibitionDetailPageState extends State<ExhibitionDetailPage>
return const LoadingWidget();
}

final shouldShowNotePage = exhibition.shouldShowCuratorNotePage;
// if exhibition is not minted, show only preview page
final itemCount =
!exhibition.isMinted ? 3 : ((exhibition.displayableSeries.length) + 3);
final exhibitionInfoCount = shouldShowNotePage ? 2 : 3;
final itemCount = !exhibition.isMinted
? exhibitionInfoCount
: ((exhibition.displayableSeries.length) + exhibitionInfoCount);
return Column(
children: [
Expanded(
Expand Down Expand Up @@ -113,25 +116,15 @@ class _ExhibitionDetailPageState extends State<ExhibitionDetailPage>
case 0:
return _getPreviewPage(exhibition);
case 1:
return _notePage(exhibition);
default:
final seriesIndex = index - 2;
final series =
exhibition.displayableSeries.sorted[seriesIndex];
final artwork = series.artwork;
if (artwork == null) {
return const SizedBox();
if (shouldShowNotePage) {
return _notePage(exhibition);
} else {
final seriesIndex = index - (exhibitionInfoCount - 1);
Copy link
Contributor

@hoangbtmrk hoangbtmrk Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

series index is definitely 0 in this case

return _getSeriesPreviewPage(seriesIndex, exhibition);
}
return Padding(
padding: const EdgeInsets.only(bottom: 40),
child: FeralFileArtworkPreview(
key: Key('feral_file_artwork_preview_${artwork.id}'),
payload: FeralFileArtworkPreviewPayload(
artwork: artwork.copyWith(
series: series.copyWith(exhibition: exhibition)),
),
),
);
default:
final seriesIndex = index - (exhibitionInfoCount - 1);
return _getSeriesPreviewPage(seriesIndex, exhibition);
}
},
),
Expand All @@ -141,6 +134,24 @@ class _ExhibitionDetailPageState extends State<ExhibitionDetailPage>
);
}

Widget _getSeriesPreviewPage(int seriesIndex, Exhibition exhibition) {
final series = exhibition.displayableSeries.sorted[seriesIndex];
final artwork = series.artwork;
if (artwork == null) {
return const SizedBox();
}
return Padding(
padding: const EdgeInsets.only(bottom: 40),
child: FeralFileArtworkPreview(
key: Key('feral_file_artwork_preview_${artwork.id}'),
payload: FeralFileArtworkPreviewPayload(
artwork:
artwork.copyWith(series: series.copyWith(exhibition: exhibition)),
),
),
);
}

void _sendMetricViewExhibition() {
final exhibition = _exBloc.state.exhibition;
if (exhibition == null) {
Expand All @@ -154,8 +165,8 @@ class _ExhibitionDetailPageState extends State<ExhibitionDetailPage>
if (request.catalog == ExhibitionCatalog.artwork)
MetricParameter.tokenId: request.catalogId,
};
injector<MetricClientService>()
.addEvent(MetricEventName.exhibitionView, data: data);
unawaited(injector<MetricClientService>()
.addEvent(MetricEventName.exhibitionView, data: data));
}

void _stream(Exhibition exhibition) {
Expand Down Expand Up @@ -265,22 +276,30 @@ class _ExhibitionDetailPageState extends State<ExhibitionDetailPage>
Exhibition exhibition) {
ExhibitionCatalog? catalog;
String? catalogId;
final shouldShowNotePage = exhibition.shouldShowCuratorNotePage;
final exhibitionInfoCount = shouldShowNotePage ? 2 : 3;
switch (_currentIndex) {
case 0:
catalog = ExhibitionCatalog.home;
case 1:
if (_carouselIndex == 0) {
catalog = ExhibitionCatalog.curatorNote;
if (shouldShowNotePage) {
if (_carouselIndex == 0) {
catalog = ExhibitionCatalog.curatorNote;
} else {
catalog = ExhibitionCatalog.resource;
catalogId = exhibition.allResources[_carouselIndex - 1].id;
}
} else {
catalog = ExhibitionCatalog.resource;
catalogId = exhibition.allResources[_carouselIndex - 1].id;
catalog = ExhibitionCatalog.artwork;
final seriesIndex = _currentIndex - (exhibitionInfoCount - 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with above comment

catalogId =
exhibition.displayableSeries.sorted[seriesIndex].artwork?.id;
}
default:
catalog = ExhibitionCatalog.artwork;
final seriesIndex = _currentIndex - 2;
final currentArtwork =
final seriesIndex = _currentIndex - (exhibitionInfoCount - 1);
catalogId =
exhibition.displayableSeries.sorted[seriesIndex].artwork?.id;
catalogId = currentArtwork;
}
return Pair(catalog, catalogId);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/util/exhibition_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ extension ExhibitionExt on Exhibition {
}
return resources;
}

bool get shouldShowCuratorNotePage =>
note?.isNotEmpty == true || allResources.isNotEmpty;
}

extension ListExhibitionDetailExt on List<ExhibitionDetail> {
Expand Down
64 changes: 34 additions & 30 deletions lib/view/note_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,44 @@ class ExhibitionNoteView extends StatelessWidget {
style: theme.textTheme.ppMori400White12,
),
const SizedBox(height: 30),
Text(
exhibition.noteTitle,
style: theme.textTheme.ppMori700White14,
),
const SizedBox(height: 20),
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 400),
child: HtmlWidget(
customStylesBuilder: auHtmlStyle,
exhibition.noteBrief,
textStyle: theme.textTheme.ppMori400White14,
onTapUrl: (url) async {
await launchUrl(Uri.parse(url),
mode: LaunchMode.externalApplication);
return true;
},
if (exhibition.noteTitle?.isNotEmpty == true) ...[
Text(
exhibition.noteTitle!,
style: theme.textTheme.ppMori700White14,
),
),
if (exhibition.noteBrief != exhibition.note) ...[
const SizedBox(height: 20),
GestureDetector(
onTap: () async {
await injector<NavigationService>()
.openFeralFileExhibitionNotePage(exhibition.slug);
},
child: Text(
'read_more'.tr(),
style: theme.textTheme.ppMori400White14.copyWith(
decoration: TextDecoration.underline,
decorationColor: AppColor.white,
),
],
if (exhibition.noteBrief?.isNotEmpty == true) ...[
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 400),
child: HtmlWidget(
customStylesBuilder: auHtmlStyle,
exhibition.noteBrief!,
textStyle: theme.textTheme.ppMori400White14,
onTapUrl: (url) async {
await launchUrl(Uri.parse(url),
mode: LaunchMode.externalApplication);
return true;
},
),
),
]
if (exhibition.noteBrief != exhibition.note) ...[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about if both are null

const SizedBox(height: 20),
GestureDetector(
onTap: () async {
await injector<NavigationService>()
.openFeralFileExhibitionNotePage(exhibition.slug);
},
child: Text(
'read_more'.tr(),
style: theme.textTheme.ppMori400White14.copyWith(
decoration: TextDecoration.underline,
decorationColor: AppColor.white,
),
),
),
]
],
],
),
),
Expand Down
Loading