Skip to content

Commit

Permalink
refractor: replace SliverChildListDeletage with SliverChildBuilderDel…
Browse files Browse the repository at this point in the history
…etage
  • Loading branch information
24bartixx committed Dec 8, 2024
1 parent 31c2b50 commit 4a2242c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>([
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("<p>", "").replaceAll("</p>", "")}",
),
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,
Expand All @@ -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>([
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("<p>", "").replaceAll("</p>", "")}",
),
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,
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4a2242c

Please sign in to comment.