From 4a2242c1078a42d492277976e6b512aa3e8259ec Mon Sep 17 00:00:00 2001 From: 24bartixx Date: Sun, 8 Dec 2024 18:40:53 +0100 Subject: [PATCH] refractor: replace SliverChildListDeletage with SliverChildBuilderDeletage --- .../presentation/digital_guide_view.dart | 96 ++++++++++--------- .../widgets/accessibility_button.dart | 6 +- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart b/lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart index 39f172b2..1e28ec78 100644 --- a/lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart +++ b/lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart @@ -52,6 +52,52 @@ class _DigitalGuideView extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + + final widgets = [ + const SizedBox(height: DigitalGuideConfig.heightSmall), + MyCachedImage( + digitalGuideResponseExtended.imageUrl, + ), + HeadlinesSection( + // There is only Polish language translation in external API + // In the future we must think how to handle multiple translations in UI + // For now it can be temporarily dealt with in the data layer + name: digitalGuideResponseExtended + .translations.plTranslation.name, + description: digitalGuideResponseExtended + .translations.plTranslation.extendedName, + ), + ContactSection( + list: IList([ + ContactIconsModel( + text: digitalGuideResponseExtended + .translations.plTranslation.address + .replaceAll("ulica", "ul."), + icon: Assets.svg.contactIcons.compass, + ), + ContactIconsModel( + text: digitalGuideResponseExtended.telephoneNumber, + icon: Assets.svg.contactIcons.phone, + // TODO(Bartosh): url not working, nothing happens + url: + "tel:+48${digitalGuideResponseExtended.telephoneNumber.replaceAll("

", "").replaceAll("

", "")}", + ), + ContactIconsModel( + text: context.localize + .storeys(digitalGuideResponseExtended.numberOfStoreys), + icon: Assets.svg.digitalGuide.storey, + ), + ]), + ), + DigitalGuideFeaturesSection( + digitalGuideResponseExtended: digitalGuideResponseExtended, + ), + const SizedBox(height: DigitalGuideConfig.heightMedium), + DigitalGuideDataSourceLink(), + ReportChangeButton(), + const SizedBox(height: DigitalGuideConfig.heightHuge), + ]; + return Scaffold( appBar: DetailViewAppBar( title: context.localize.map, @@ -63,50 +109,12 @@ class _DigitalGuideView extends ConsumerWidget { slivers: [ SliverList( // TODO(Bartosh): replace with SilverChildBuilderDelegate - delegate: SliverChildListDelegate([ - const SizedBox(height: DigitalGuideConfig.heightSmall), - MyCachedImage( - digitalGuideResponseExtended.imageUrl, - ), - HeadlinesSection( - // There is only Polish language translation in external API - // In the future we must think how to handle multiple translations in UI - // For now it can be temporarily dealt with in the data layer - name: digitalGuideResponseExtended - .translations.plTranslation.name, - description: digitalGuideResponseExtended - .translations.plTranslation.extendedName, - ), - ContactSection( - list: IList([ - ContactIconsModel( - text: digitalGuideResponseExtended - .translations.plTranslation.address - .replaceAll("ulica", "ul."), - icon: Assets.svg.contactIcons.compass, - ), - ContactIconsModel( - text: digitalGuideResponseExtended.telephoneNumber, - icon: Assets.svg.contactIcons.phone, - // TODO(Bartosh): url not working, nothing happens - url: - "tel:+48${digitalGuideResponseExtended.telephoneNumber.replaceAll("

", "").replaceAll("

", "")}", - ), - ContactIconsModel( - text: context.localize - .storeys(digitalGuideResponseExtended.numberOfStoreys), - icon: Assets.svg.digitalGuide.storey, - ), - ]), - ), - DigitalGuideFeaturesSection( - digitalGuideResponseExtended: digitalGuideResponseExtended, - ), - const SizedBox(height: DigitalGuideConfig.heightMedium), - DigitalGuideDataSourceLink(), - ReportChangeButton(), - const SizedBox(height: DigitalGuideConfig.heightHuge), - ]), + delegate: SliverChildBuilderDelegate( + (context, index) { + return widgets[index]; + }, + childCount: widgets.length, + ), ), ], ), diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart b/lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart index 1a7f85c3..8951fa11 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart +++ b/lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart @@ -15,10 +15,12 @@ class AccessibilityButton extends StatelessWidget { borderRadius: BorderRadius.circular( DigitalGuideConfig.borderRadiusMedium, ), - side: BorderSide(color: context.colorTheme.greyPigeon,), + side: BorderSide( + color: context.colorTheme.greyPigeon, + ), ), backgroundColor: context.colorTheme.greyLight, - minimumSize: const Size(56,32), + minimumSize: const Size(56, 32), ), child: const Icon( Icons.accessible,