diff --git a/lib/model/ff_exhibition.dart b/lib/model/ff_exhibition.dart index 8735c27bb..6bdf8d767 100644 --- a/lib/model/ff_exhibition.dart +++ b/lib/model/ff_exhibition.dart @@ -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; @@ -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?) diff --git a/lib/screen/dailies_work/dailies_work_page.dart b/lib/screen/dailies_work/dailies_work_page.dart index 93d6a8719..2b74feed0 100644 --- a/lib/screen/dailies_work/dailies_work_page.dart +++ b/lib/screen/dailies_work/dailies_work_page.dart @@ -752,23 +752,25 @@ class DailyWorkPageState extends State 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, + ), + ), + ], ], ); } diff --git a/lib/screen/exhibition_details/exhibition_detail_page.dart b/lib/screen/exhibition_details/exhibition_detail_page.dart index 17f2efc68..51cc2856a 100644 --- a/lib/screen/exhibition_details/exhibition_detail_page.dart +++ b/lib/screen/exhibition_details/exhibition_detail_page.dart @@ -79,9 +79,12 @@ class _ExhibitionDetailPageState extends State 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( @@ -113,25 +116,15 @@ class _ExhibitionDetailPageState extends State 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); + 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); } }, ), @@ -141,6 +134,24 @@ class _ExhibitionDetailPageState extends State ); } + 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) { @@ -154,8 +165,8 @@ class _ExhibitionDetailPageState extends State if (request.catalog == ExhibitionCatalog.artwork) MetricParameter.tokenId: request.catalogId, }; - injector() - .addEvent(MetricEventName.exhibitionView, data: data); + unawaited(injector() + .addEvent(MetricEventName.exhibitionView, data: data)); } void _stream(Exhibition exhibition) { @@ -265,22 +276,30 @@ class _ExhibitionDetailPageState extends State 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); + 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); } diff --git a/lib/util/exhibition_ext.dart b/lib/util/exhibition_ext.dart index c21cc10d6..a2edcfd73 100644 --- a/lib/util/exhibition_ext.dart +++ b/lib/util/exhibition_ext.dart @@ -139,6 +139,9 @@ extension ExhibitionExt on Exhibition { } return resources; } + + bool get shouldShowCuratorNotePage => + note?.isNotEmpty == true || allResources.isNotEmpty; } extension ListExhibitionDetailExt on List { diff --git a/lib/view/note_view.dart b/lib/view/note_view.dart index f759b8801..41b7e846b 100644 --- a/lib/view/note_view.dart +++ b/lib/view/note_view.dart @@ -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() - .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) ...[ + const SizedBox(height: 20), + GestureDetector( + onTap: () async { + await injector() + .openFeralFileExhibitionNotePage(exhibition.slug); + }, + child: Text( + 'read_more'.tr(), + style: theme.textTheme.ppMori400White14.copyWith( + decoration: TextDecoration.underline, + decorationColor: AppColor.white, + ), + ), + ), + ] + ], ], ), ),