From 1834c67c56aef5882f8ab5f97e5cb832a8412877 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 12:46:39 +0100 Subject: [PATCH 01/14] feat: evacuation screen and small refactor of file structure in digital guide --- lib/config/ui_config.dart | 4 ++ .../data/models/digital_guide_response.dart | 3 + .../digital_guide_response_extended.dart | 14 ++++ .../repository/digital_guide_repository.dart | 10 ++- .../presentation/digital_guide_view.dart | 16 ++--- .../widgets/accessibility_button.dart | 4 +- .../digital_guide_data_source_link.dart | 8 +-- .../digital_guide_features_section.dart | 16 +++-- .../widgets/digital_guide_go_to_button.dart | 46 +++++++++++++ .../widgets/headlines_section.dart | 2 +- .../widgets/report_change_button.dart | 8 +-- .../amenities_expansion_tile_content.dart | 10 +-- .../data/models/digital_guide_entrace.dart | 36 ++++++++++ .../data/repository/entraces_repository.dart | 31 +++++++++ .../tabs/evacuation/evacuation_widget.dart | 66 +++++++++++++++++++ .../tabs/models/digital_guide_entrace.dart | 36 ++++++++++ .../data/models/surrounding_response.dart | 0 .../repository/surrounding_repository.dart | 4 +- .../surroundings_expansion_tile_content.dart | 6 +- lib/features/navigator/app_router.dart | 2 +- lib/l10n/app_pl.arb | 3 +- 21 files changed, 286 insertions(+), 39 deletions(-) rename lib/features/digital_guide_view/{general_info => }/data/models/digital_guide_response.dart (94%) rename lib/features/digital_guide_view/{general_info => }/data/models/digital_guide_response_extended.dart (79%) rename lib/features/digital_guide_view/{general_info => }/data/repository/digital_guide_repository.dart (80%) rename lib/features/digital_guide_view/{general_info => }/presentation/digital_guide_view.dart (90%) rename lib/features/digital_guide_view/{general_info => }/presentation/widgets/accessibility_button.dart (89%) rename lib/features/digital_guide_view/{general_info => }/presentation/widgets/digital_guide_data_source_link.dart (87%) rename lib/features/digital_guide_view/{general_info => }/presentation/widgets/digital_guide_features_section.dart (81%) create mode 100644 lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart rename lib/features/digital_guide_view/{general_info => }/presentation/widgets/headlines_section.dart (93%) rename lib/features/digital_guide_view/{general_info => }/presentation/widgets/report_change_button.dart (86%) rename lib/features/digital_guide_view/{ => tabs}/amenities/presentation/amenities_expansion_tile_content.dart (88%) create mode 100644 lib/features/digital_guide_view/tabs/entraces/data/models/digital_guide_entrace.dart create mode 100644 lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart create mode 100644 lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart create mode 100644 lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart rename lib/features/digital_guide_view/{ => tabs}/surrounding/data/models/surrounding_response.dart (100%) rename lib/features/digital_guide_view/{ => tabs}/surrounding/data/repository/surrounding_repository.dart (85%) rename lib/features/digital_guide_view/{ => tabs}/surrounding/presentation/surroundings_expansion_tile_content.dart (88%) diff --git a/lib/config/ui_config.dart b/lib/config/ui_config.dart index 434d1c1c..c04e37bc 100644 --- a/lib/config/ui_config.dart +++ b/lib/config/ui_config.dart @@ -213,9 +213,13 @@ abstract class DigitalGuideConfig { EdgeInsets.symmetric(vertical: 24, horizontal: 24); static const borderRadiusMedium = 8.0; static const heightSmall = 8.0; + static const heightMedium = 16.0; static const heightBig = 24.0; static const heightHuge = 48.0; + static const mediumButtonPadding = + EdgeInsets.symmetric(vertical: 8, horizontal: 14); static const paddingMedium = 16.0; + static const borderColor = Color(0x8077859D); } abstract class AlertDialogConfig { diff --git a/lib/features/digital_guide_view/general_info/data/models/digital_guide_response.dart b/lib/features/digital_guide_view/data/models/digital_guide_response.dart similarity index 94% rename from lib/features/digital_guide_view/general_info/data/models/digital_guide_response.dart rename to lib/features/digital_guide_view/data/models/digital_guide_response.dart index 09766d6b..7d43ec0c 100644 --- a/lib/features/digital_guide_view/general_info/data/models/digital_guide_response.dart +++ b/lib/features/digital_guide_view/data/models/digital_guide_response.dart @@ -55,6 +55,7 @@ class DigitalGuideResponse with _$DigitalGuideResponse { required List phoneNumbers, @JsonKey(name: "surrounding") required int surroundingId, required List images, + @JsonKey(name: "evacuation_map") required int evacuationMapId, String? imageUrl, }) = _DigitalGuideResponse; @@ -78,6 +79,8 @@ class DigitalGuideTranslation with _$DigitalGuideTranslation { required String name, @JsonKey(name: "extended_name") required String extendedName, required String address, + @JsonKey(name: "evacuation_description") + required String evacuationDescription, }) = _DigitalGuideTranslation; factory DigitalGuideTranslation.fromJson(Map json) => diff --git a/lib/features/digital_guide_view/general_info/data/models/digital_guide_response_extended.dart b/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart similarity index 79% rename from lib/features/digital_guide_view/general_info/data/models/digital_guide_response_extended.dart rename to lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart index 4ede202f..6f29eb0b 100644 --- a/lib/features/digital_guide_view/general_info/data/models/digital_guide_response_extended.dart +++ b/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart @@ -1,5 +1,8 @@ import "dart:core"; +import "package:fast_immutable_collections/fast_immutable_collections.dart"; + +import "../../tabs/entraces/data/models/digital_guide_entrace.dart"; import "digital_guide_response.dart"; class DigitalGuideResponseExtended { @@ -19,6 +22,9 @@ class DigitalGuideResponseExtended { required this.surroundingId, required this.images, required this.imageUrl, + required this.evacuationMapId, + required this.evacuationMapUrl, + required this.entraces, }); final int id; @@ -36,10 +42,15 @@ class DigitalGuideResponseExtended { final int surroundingId; final List images; final String? imageUrl; + final int evacuationMapId; + final String? evacuationMapUrl; + final IList entraces; factory DigitalGuideResponseExtended.fromDigitalGuideResponse({ required DigitalGuideResponse digitalGuideResponse, required String? imageUrl, + required String? evacuationMapUrl, + required IList entraces, }) { return DigitalGuideResponseExtended( id: digitalGuideResponse.id, @@ -57,6 +68,9 @@ class DigitalGuideResponseExtended { surroundingId: digitalGuideResponse.surroundingId, images: digitalGuideResponse.images, imageUrl: imageUrl, + evacuationMapId: digitalGuideResponse.evacuationMapId, + evacuationMapUrl: evacuationMapUrl, + entraces: entraces, ); } } diff --git a/lib/features/digital_guide_view/general_info/data/repository/digital_guide_repository.dart b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart similarity index 80% rename from lib/features/digital_guide_view/general_info/data/repository/digital_guide_repository.dart rename to lib/features/digital_guide_view/data/repository/digital_guide_repository.dart index ebe4a17f..ff828074 100644 --- a/lib/features/digital_guide_view/general_info/data/repository/digital_guide_repository.dart +++ b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart @@ -2,8 +2,9 @@ import "package:flutter/foundation.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; -import "../../../../../api_base_rest/client/dio_client.dart"; -import "../../../../../config/env.dart"; +import "../../../../api_base_rest/client/dio_client.dart"; +import "../../../../config/env.dart"; +import "../../tabs/entraces/data/repository/entraces_repository.dart"; import "../models/digital_guide_response.dart"; import "../models/digital_guide_response_extended.dart"; @@ -22,9 +23,14 @@ Future getDigitalGuideData( final digitalGuideResponse = DigitalGuideResponse.fromJson(response.data as Map); final imageUrl = await getImageUrl(ref, digitalGuideResponse.images[0]); + final evacuationMapUrl = + await getImageUrl(ref, digitalGuideResponse.evacuationMapId); + final entraces = await getDigitalGuideEntraces(ref, digitalGuideResponse.id); return DigitalGuideResponseExtended.fromDigitalGuideResponse( digitalGuideResponse: digitalGuideResponse, imageUrl: imageUrl, + evacuationMapUrl: evacuationMapUrl, + entraces: entraces, ); } diff --git a/lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart b/lib/features/digital_guide_view/presentation/digital_guide_view.dart similarity index 90% rename from lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart rename to lib/features/digital_guide_view/presentation/digital_guide_view.dart index 38da56b8..d27fdaf7 100644 --- a/lib/features/digital_guide_view/general_info/presentation/digital_guide_view.dart +++ b/lib/features/digital_guide_view/presentation/digital_guide_view.dart @@ -3,14 +3,14 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:flutter/material.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; -import "../../../../config/ui_config.dart"; -import "../../../../gen/assets.gen.dart"; -import "../../../../utils/context_extensions.dart"; -import "../../../../utils/determine_contact_icon.dart"; -import "../../../../widgets/detail_views/contact_section.dart"; -import "../../../../widgets/detail_views/detail_view_app_bar.dart"; -import "../../../../widgets/my_cached_image.dart"; -import "../../../../widgets/my_error_widget.dart"; +import "../../../config/ui_config.dart"; +import "../../../gen/assets.gen.dart"; +import "../../../utils/context_extensions.dart"; +import "../../../utils/determine_contact_icon.dart"; +import "../../../widgets/detail_views/contact_section.dart"; +import "../../../widgets/detail_views/detail_view_app_bar.dart"; +import "../../../widgets/my_cached_image.dart"; +import "../../../widgets/my_error_widget.dart"; import "../data/models/digital_guide_response_extended.dart"; import "../data/repository/digital_guide_repository.dart"; import "widgets/accessibility_button.dart"; diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart b/lib/features/digital_guide_view/presentation/widgets/accessibility_button.dart similarity index 89% rename from lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart rename to lib/features/digital_guide_view/presentation/widgets/accessibility_button.dart index 85fbe089..047be8dc 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/accessibility_button.dart +++ b/lib/features/digital_guide_view/presentation/widgets/accessibility_button.dart @@ -1,7 +1,7 @@ import "package:flutter/material.dart"; -import "../../../../../config/ui_config.dart"; -import "../../../../../theme/app_theme.dart"; +import "../../../../config/ui_config.dart"; +import "../../../../theme/app_theme.dart"; class AccessibilityButton extends StatelessWidget { @override diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_data_source_link.dart similarity index 87% rename from lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart rename to lib/features/digital_guide_view/presentation/widgets/digital_guide_data_source_link.dart index e91e8da9..13a7162d 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_data_source_link.dart +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_data_source_link.dart @@ -2,10 +2,10 @@ import "package:flutter/gestures.dart"; import "package:flutter/widgets.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; -import "../../../../../config/ui_config.dart"; -import "../../../../../theme/app_theme.dart"; -import "../../../../../utils/context_extensions.dart"; -import "../../../../../utils/launch_url_util.dart"; +import "../../../../config/ui_config.dart"; +import "../../../../theme/app_theme.dart"; +import "../../../../utils/context_extensions.dart"; +import "../../../../utils/launch_url_util.dart"; class DigitalGuideDataSourceLink extends ConsumerWidget { @override diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_features_section.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart similarity index 81% rename from lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_features_section.dart rename to lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart index 704a7bf5..3d1c33c8 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/digital_guide_features_section.dart +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart @@ -1,12 +1,13 @@ import "package:flutter/material.dart"; import "package:flutter/widgets.dart"; -import "../../../../../utils/context_extensions.dart"; -import "../../../../../widgets/my_expansion_tile.dart"; -import "../../../amenities/presentation/amenities_expansion_tile_content.dart"; -import "../../../localization/presentation/localization_expansion_tile_content.dart"; -import "../../../surrounding/presentation/surroundings_expansion_tile_content.dart"; +import "../../../../utils/context_extensions.dart"; +import "../../../../widgets/my_expansion_tile.dart"; import "../../data/models/digital_guide_response_extended.dart"; +import "../../localization/presentation/localization_expansion_tile_content.dart"; +import "../../tabs/amenities/presentation/amenities_expansion_tile_content.dart"; +import "../../tabs/evacuation/evacuation_widget.dart"; +import "../../tabs/surrounding/presentation/surroundings_expansion_tile_content.dart"; typedef TileContent = ({String title, List content}); @@ -70,7 +71,10 @@ class DigitalGuideFeaturesSection extends StatelessWidget { ), ( title: context.localize.evacuation, - content: [LocalizationExpansionTileContent()], + content: [ + EvacuationWidget( + digitalGuideResponseExtended: digitalGuideResponseExtended) + ], ), ]; diff --git a/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart new file mode 100644 index 00000000..6b7d95b7 --- /dev/null +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart @@ -0,0 +1,46 @@ +import "package:flutter/material.dart"; + +import "../../../../config/ui_config.dart"; +import "../../../../theme/app_theme.dart"; +import "../../tabs/entraces/data/models/digital_guide_entrace.dart"; + +class DigitalGuideGoToButton extends StatelessWidget { + const DigitalGuideGoToButton({ + super.key, + required this.onTap, + required this.entrace, + }); + + final VoidCallback onTap; + final DigitalGuideEntrace entrace; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: DigitalGuideConfig.mediumButtonPadding, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(DigitalGuideConfig.borderRadiusMedium), + border: Border.all( + color: DigitalGuideConfig.borderColor, + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + entrace.translations.pl.name, + style: context.textTheme.title, + ), + Icon( + Icons.arrow_forward_ios, + color: context.colorTheme.blueAzure, + ), + ], + ), + ), + ); + } +} diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/headlines_section.dart b/lib/features/digital_guide_view/presentation/widgets/headlines_section.dart similarity index 93% rename from lib/features/digital_guide_view/general_info/presentation/widgets/headlines_section.dart rename to lib/features/digital_guide_view/presentation/widgets/headlines_section.dart index 0c60e01c..7bc76e69 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/headlines_section.dart +++ b/lib/features/digital_guide_view/presentation/widgets/headlines_section.dart @@ -1,6 +1,6 @@ import "package:flutter/widgets.dart"; -import "../../../../../config/ui_config.dart"; +import "../../../../config/ui_config.dart"; class HeadlinesSection extends StatelessWidget { const HeadlinesSection({ diff --git a/lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart b/lib/features/digital_guide_view/presentation/widgets/report_change_button.dart similarity index 86% rename from lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart rename to lib/features/digital_guide_view/presentation/widgets/report_change_button.dart index 00bed0a4..39d9a656 100644 --- a/lib/features/digital_guide_view/general_info/presentation/widgets/report_change_button.dart +++ b/lib/features/digital_guide_view/presentation/widgets/report_change_button.dart @@ -3,10 +3,10 @@ import "dart:async"; import "package:flutter/material.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; -import "../../../../../config/ui_config.dart"; -import "../../../../../theme/app_theme.dart"; -import "../../../../../utils/context_extensions.dart"; -import "../../../../../utils/launch_url_util.dart"; +import "../../../../config/ui_config.dart"; +import "../../../../theme/app_theme.dart"; +import "../../../../utils/context_extensions.dart"; +import "../../../../utils/launch_url_util.dart"; class ReportChangeButton extends ConsumerWidget { @override diff --git a/lib/features/digital_guide_view/amenities/presentation/amenities_expansion_tile_content.dart b/lib/features/digital_guide_view/tabs/amenities/presentation/amenities_expansion_tile_content.dart similarity index 88% rename from lib/features/digital_guide_view/amenities/presentation/amenities_expansion_tile_content.dart rename to lib/features/digital_guide_view/tabs/amenities/presentation/amenities_expansion_tile_content.dart index dc3ca6ab..46fa1470 100644 --- a/lib/features/digital_guide_view/amenities/presentation/amenities_expansion_tile_content.dart +++ b/lib/features/digital_guide_view/tabs/amenities/presentation/amenities_expansion_tile_content.dart @@ -1,11 +1,11 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:flutter/widgets.dart"; -import "../../../../gen/assets.gen.dart"; -import "../../../../utils/context_extensions.dart"; -import "../../../../utils/determine_contact_icon.dart"; -import "../../../../widgets/detail_views/contact_section.dart"; -import "../../general_info/data/models/digital_guide_response_extended.dart"; +import "../../../../../gen/assets.gen.dart"; +import "../../../../../utils/context_extensions.dart"; +import "../../../../../utils/determine_contact_icon.dart"; +import "../../../../../widgets/detail_views/contact_section.dart"; +import "../../../data/models/digital_guide_response_extended.dart"; class AmenitiesExpansionTileContent extends StatelessWidget { const AmenitiesExpansionTileContent({ diff --git a/lib/features/digital_guide_view/tabs/entraces/data/models/digital_guide_entrace.dart b/lib/features/digital_guide_view/tabs/entraces/data/models/digital_guide_entrace.dart new file mode 100644 index 00000000..063bfaf0 --- /dev/null +++ b/lib/features/digital_guide_view/tabs/entraces/data/models/digital_guide_entrace.dart @@ -0,0 +1,36 @@ +import "package:freezed_annotation/freezed_annotation.dart"; + +part "digital_guide_entrace.freezed.dart"; +part "digital_guide_entrace.g.dart"; + +@freezed +class DigitalGuideEntrace with _$DigitalGuideEntrace { + const factory DigitalGuideEntrace({ + required int id, + required DigitalGuideTranslationsEntrace translations, + }) = _DigitalGuideEntrace; + + factory DigitalGuideEntrace.fromJson(Map json) => + _$DigitalGuideEntraceFromJson(json); +} + +@freezed +class DigitalGuideTranslationsEntrace with _$DigitalGuideTranslationsEntrace { + const factory DigitalGuideTranslationsEntrace({ + required DigitalGuideTranslationEntrace pl, + }) = _DigitalGuideTranslationsEntrace; + + factory DigitalGuideTranslationsEntrace.fromJson(Map json) => + _$DigitalGuideTranslationsEntraceFromJson(json); +} + +@freezed +class DigitalGuideTranslationEntrace with _$DigitalGuideTranslationEntrace { + const factory DigitalGuideTranslationEntrace({ + required String name, + required String location, + }) = _DigitalGuideTranslationEntrace; + + factory DigitalGuideTranslationEntrace.fromJson(Map json) => + _$DigitalGuideTranslationEntraceFromJson(json); +} diff --git a/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart b/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart new file mode 100644 index 00000000..e7520b87 --- /dev/null +++ b/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart @@ -0,0 +1,31 @@ +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:riverpod_annotation/riverpod_annotation.dart"; + +import "../../../../../../../api_base_rest/client/dio_client.dart"; +import "../../../../../../../config/env.dart"; + +import "../models/digital_guide_entrace.dart"; + +part "entraces_repository.g.dart"; + +@riverpod +Future> getDigitalGuideEntraces( + Ref ref, + int buildingId, +) async { + final digitalGuideEntranceUrl = + "${Env.digitalGuideUrl}/entrances/?building=$buildingId"; + final dio = ref.read(restClientProvider); + dio.options.headers["Authorization"] = + "Token ${Env.digitalGuideAuthorizationToken}"; + + final response = await dio.get(digitalGuideEntranceUrl); + final data = response.data as List; + final entrances = data + .map((json) => DigitalGuideEntrace.fromJson(json as Map)) + .toIList(); + + print(entrances); + return entrances; +} diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart new file mode 100644 index 00000000..b2ceaafa --- /dev/null +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -0,0 +1,66 @@ +import "package:flutter/material.dart"; +import "../../../../config/ui_config.dart"; +import "../../../../theme/app_theme.dart"; +import "../../../../utils/context_extensions.dart"; +import "../../../../widgets/my_cached_image.dart"; +import "../../../../widgets/my_html_widget.dart"; +import "../../data/models/digital_guide_response_extended.dart"; +import "../../presentation/widgets/digital_guide_go_to_button.dart"; + +class EvacuationWidget extends StatelessWidget { + const EvacuationWidget({ + super.key, + required this.digitalGuideResponseExtended, + }); + + final DigitalGuideResponseExtended digitalGuideResponseExtended; + + @override + Widget build(BuildContext context) { + final widgets = [ + const SizedBox( + height: DigitalGuideConfig.heightSmall, + ), + MyHtmlWidget( + digitalGuideResponseExtended + .translations.plTranslation.evacuationDescription, + textStyle: context.textTheme.boldBody), + const SizedBox( + height: DigitalGuideConfig.heightMedium, + ), + Text( + context.localize.evacuation_text, + style: context.textTheme.boldBody, + ), + const SizedBox( + height: DigitalGuideConfig.heightMedium, + ), + MyCachedImage(digitalGuideResponseExtended.evacuationMapUrl), + const SizedBox( + height: DigitalGuideConfig.heightMedium, + ), + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) => DigitalGuideGoToButton( + onTap: () {}, + entrace: digitalGuideResponseExtended.entraces[index], + ), + separatorBuilder: (context, index) => const SizedBox( + height: 15, + ), + itemCount: digitalGuideResponseExtended.entraces.length, + shrinkWrap: true, + ), + ]; + + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: ListView.builder( + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) => widgets[index], + itemCount: widgets.length, + shrinkWrap: true, + ), + ); + } +} diff --git a/lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart b/lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart new file mode 100644 index 00000000..063bfaf0 --- /dev/null +++ b/lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart @@ -0,0 +1,36 @@ +import "package:freezed_annotation/freezed_annotation.dart"; + +part "digital_guide_entrace.freezed.dart"; +part "digital_guide_entrace.g.dart"; + +@freezed +class DigitalGuideEntrace with _$DigitalGuideEntrace { + const factory DigitalGuideEntrace({ + required int id, + required DigitalGuideTranslationsEntrace translations, + }) = _DigitalGuideEntrace; + + factory DigitalGuideEntrace.fromJson(Map json) => + _$DigitalGuideEntraceFromJson(json); +} + +@freezed +class DigitalGuideTranslationsEntrace with _$DigitalGuideTranslationsEntrace { + const factory DigitalGuideTranslationsEntrace({ + required DigitalGuideTranslationEntrace pl, + }) = _DigitalGuideTranslationsEntrace; + + factory DigitalGuideTranslationsEntrace.fromJson(Map json) => + _$DigitalGuideTranslationsEntraceFromJson(json); +} + +@freezed +class DigitalGuideTranslationEntrace with _$DigitalGuideTranslationEntrace { + const factory DigitalGuideTranslationEntrace({ + required String name, + required String location, + }) = _DigitalGuideTranslationEntrace; + + factory DigitalGuideTranslationEntrace.fromJson(Map json) => + _$DigitalGuideTranslationEntraceFromJson(json); +} diff --git a/lib/features/digital_guide_view/surrounding/data/models/surrounding_response.dart b/lib/features/digital_guide_view/tabs/surrounding/data/models/surrounding_response.dart similarity index 100% rename from lib/features/digital_guide_view/surrounding/data/models/surrounding_response.dart rename to lib/features/digital_guide_view/tabs/surrounding/data/models/surrounding_response.dart diff --git a/lib/features/digital_guide_view/surrounding/data/repository/surrounding_repository.dart b/lib/features/digital_guide_view/tabs/surrounding/data/repository/surrounding_repository.dart similarity index 85% rename from lib/features/digital_guide_view/surrounding/data/repository/surrounding_repository.dart rename to lib/features/digital_guide_view/tabs/surrounding/data/repository/surrounding_repository.dart index 3b57dd78..ef3f5623 100644 --- a/lib/features/digital_guide_view/surrounding/data/repository/surrounding_repository.dart +++ b/lib/features/digital_guide_view/tabs/surrounding/data/repository/surrounding_repository.dart @@ -1,8 +1,8 @@ import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:riverpod_annotation/riverpod_annotation.dart"; -import "../../../../../api_base_rest/client/dio_client.dart"; -import "../../../../../config/env.dart"; +import "../../../../../../api_base_rest/client/dio_client.dart"; +import "../../../../../../config/env.dart"; import "../models/surrounding_response.dart"; part "surrounding_repository.g.dart"; diff --git a/lib/features/digital_guide_view/surrounding/presentation/surroundings_expansion_tile_content.dart b/lib/features/digital_guide_view/tabs/surrounding/presentation/surroundings_expansion_tile_content.dart similarity index 88% rename from lib/features/digital_guide_view/surrounding/presentation/surroundings_expansion_tile_content.dart rename to lib/features/digital_guide_view/tabs/surrounding/presentation/surroundings_expansion_tile_content.dart index 7bc4e436..965dfe85 100644 --- a/lib/features/digital_guide_view/surrounding/presentation/surroundings_expansion_tile_content.dart +++ b/lib/features/digital_guide_view/tabs/surrounding/presentation/surroundings_expansion_tile_content.dart @@ -1,9 +1,9 @@ import "package:flutter/material.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; -import "../../../../utils/context_extensions.dart"; -import "../../../../widgets/my_error_widget.dart"; -import "../../general_info/data/models/digital_guide_response_extended.dart"; +import "../../../../../utils/context_extensions.dart"; +import "../../../../../widgets/my_error_widget.dart"; +import "../../../data/models/digital_guide_response_extended.dart"; import "../data/models/surrounding_response.dart"; import "../data/repository/surrounding_repository.dart"; diff --git a/lib/features/navigator/app_router.dart b/lib/features/navigator/app_router.dart index ab86a511..63753be6 100644 --- a/lib/features/navigator/app_router.dart +++ b/lib/features/navigator/app_router.dart @@ -7,7 +7,7 @@ import "../about_us_view/about_us_view.dart"; import "../buildings_view/buildings_view.dart"; import "../department_detail_view/department_detail_view.dart"; import "../departments_view/departments_view.dart"; -import "../digital_guide_view/general_info/presentation/digital_guide_view.dart"; +import "../digital_guide_view/presentation/digital_guide_view.dart"; import "../guide_detail_view/guide_detail_view.dart"; import "../guide_view/guide_view.dart"; import "../home_view/home_view.dart"; diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index ad1155df..f03d3165 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -204,5 +204,6 @@ "example": "wydziałów" } } - } + }, + "evacuation_text": "Ewakuacja i pierwsza pomoc" } From 6bdaa052171cf864c8ef792daee85cdbd1f61894 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 12:56:07 +0100 Subject: [PATCH 02/14] fix: padding --- .../tabs/evacuation/evacuation_widget.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart index b2ceaafa..97766a03 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -46,7 +46,7 @@ class EvacuationWidget extends StatelessWidget { entrace: digitalGuideResponseExtended.entraces[index], ), separatorBuilder: (context, index) => const SizedBox( - height: 15, + height: DigitalGuideConfig.heightMedium, ), itemCount: digitalGuideResponseExtended.entraces.length, shrinkWrap: true, @@ -54,7 +54,9 @@ class EvacuationWidget extends StatelessWidget { ]; return Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), + padding: const EdgeInsets.symmetric( + horizontal: DigitalGuideConfig.heightMedium, + ), child: ListView.builder( physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) => widgets[index], From d005d11c339eef3f87a8b582e61aefa3f1ae9809 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 13:00:26 +0100 Subject: [PATCH 03/14] chore: fix linter complaints --- .../tabs/evacuation/evacuation_widget.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart index 97766a03..7717b910 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -22,9 +22,10 @@ class EvacuationWidget extends StatelessWidget { height: DigitalGuideConfig.heightSmall, ), MyHtmlWidget( - digitalGuideResponseExtended - .translations.plTranslation.evacuationDescription, - textStyle: context.textTheme.boldBody), + digitalGuideResponseExtended + .translations.plTranslation.evacuationDescription, + textStyle: context.textTheme.boldBody, + ), const SizedBox( height: DigitalGuideConfig.heightMedium, ), From fcbad0cd6afd9f9e73ff0a6f0d54d058f41a2b1a Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 13:01:45 +0100 Subject: [PATCH 04/14] chore: fix linter complaints --- .../presentation/widgets/digital_guide_features_section.dart | 3 ++- .../tabs/entraces/data/repository/entraces_repository.dart | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart index 3d1c33c8..225acdcd 100644 --- a/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart @@ -73,7 +73,8 @@ class DigitalGuideFeaturesSection extends StatelessWidget { title: context.localize.evacuation, content: [ EvacuationWidget( - digitalGuideResponseExtended: digitalGuideResponseExtended) + digitalGuideResponseExtended: digitalGuideResponseExtended, + ), ], ), ]; diff --git a/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart b/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart index e7520b87..845dacd8 100644 --- a/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart +++ b/lib/features/digital_guide_view/tabs/entraces/data/repository/entraces_repository.dart @@ -26,6 +26,5 @@ Future> getDigitalGuideEntraces( .map((json) => DigitalGuideEntrace.fromJson(json as Map)) .toIList(); - print(entrances); return entrances; } From ceda67e067c7e228627dcd745440f34a0f227265 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 22:09:09 +0100 Subject: [PATCH 05/14] refactor/use providers --- .../repository/digital_guide_repository.dart | 6 ++-- .../tabs/models/digital_guide_entrace.dart | 36 ------------------- 2 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart diff --git a/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart index ff828074..de6a9411 100644 --- a/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart +++ b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart @@ -22,10 +22,10 @@ Future getDigitalGuideData( final response = await dio.get(digitalGuideUrl); final digitalGuideResponse = DigitalGuideResponse.fromJson(response.data as Map); - final imageUrl = await getImageUrl(ref, digitalGuideResponse.images[0]); + final imageUrl = await ref.watch(getImageUrlProvider(digitalGuideResponse.images[0]).future); final evacuationMapUrl = - await getImageUrl(ref, digitalGuideResponse.evacuationMapId); - final entraces = await getDigitalGuideEntraces(ref, digitalGuideResponse.id); + await ref.watch(getImageUrlProvider( digitalGuideResponse.evacuationMapId).future); + final entraces = await ref.watch(getDigitalGuideEntracesProvider(digitalGuideResponse.id).future); return DigitalGuideResponseExtended.fromDigitalGuideResponse( digitalGuideResponse: digitalGuideResponse, imageUrl: imageUrl, diff --git a/lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart b/lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart deleted file mode 100644 index 063bfaf0..00000000 --- a/lib/features/digital_guide_view/tabs/models/digital_guide_entrace.dart +++ /dev/null @@ -1,36 +0,0 @@ -import "package:freezed_annotation/freezed_annotation.dart"; - -part "digital_guide_entrace.freezed.dart"; -part "digital_guide_entrace.g.dart"; - -@freezed -class DigitalGuideEntrace with _$DigitalGuideEntrace { - const factory DigitalGuideEntrace({ - required int id, - required DigitalGuideTranslationsEntrace translations, - }) = _DigitalGuideEntrace; - - factory DigitalGuideEntrace.fromJson(Map json) => - _$DigitalGuideEntraceFromJson(json); -} - -@freezed -class DigitalGuideTranslationsEntrace with _$DigitalGuideTranslationsEntrace { - const factory DigitalGuideTranslationsEntrace({ - required DigitalGuideTranslationEntrace pl, - }) = _DigitalGuideTranslationsEntrace; - - factory DigitalGuideTranslationsEntrace.fromJson(Map json) => - _$DigitalGuideTranslationsEntraceFromJson(json); -} - -@freezed -class DigitalGuideTranslationEntrace with _$DigitalGuideTranslationEntrace { - const factory DigitalGuideTranslationEntrace({ - required String name, - required String location, - }) = _DigitalGuideTranslationEntrace; - - factory DigitalGuideTranslationEntrace.fromJson(Map json) => - _$DigitalGuideTranslationEntraceFromJson(json); -} From 893fc13d7a3432f2b1c8b73ff6f7171580aba8fb Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 22:11:40 +0100 Subject: [PATCH 06/14] chore: fix linter complaints --- .../data/repository/digital_guide_repository.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart index de6a9411..a6614630 100644 --- a/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart +++ b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart @@ -22,10 +22,12 @@ Future getDigitalGuideData( final response = await dio.get(digitalGuideUrl); final digitalGuideResponse = DigitalGuideResponse.fromJson(response.data as Map); - final imageUrl = await ref.watch(getImageUrlProvider(digitalGuideResponse.images[0]).future); - final evacuationMapUrl = - await ref.watch(getImageUrlProvider( digitalGuideResponse.evacuationMapId).future); - final entraces = await ref.watch(getDigitalGuideEntracesProvider(digitalGuideResponse.id).future); + final imageUrl = await ref + .watch(getImageUrlProvider(digitalGuideResponse.images[0]).future); + final evacuationMapUrl = await ref + .watch(getImageUrlProvider(digitalGuideResponse.evacuationMapId).future); + final entraces = await ref + .watch(getDigitalGuideEntracesProvider(digitalGuideResponse.id).future); return DigitalGuideResponseExtended.fromDigitalGuideResponse( digitalGuideResponse: digitalGuideResponse, imageUrl: imageUrl, From 7b82d578058e0bd53693b0d5e3fa5d0ae700950f Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 22:22:52 +0100 Subject: [PATCH 07/14] feat/generalize parameters --- .../widgets/digital_guide_go_to_button.dart | 10 +++++----- .../tabs/evacuation/evacuation_widget.dart | 4 ++-- lib/widgets/my_error_widget.dart | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart index 6b7d95b7..349497cf 100644 --- a/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart @@ -4,15 +4,15 @@ import "../../../../config/ui_config.dart"; import "../../../../theme/app_theme.dart"; import "../../tabs/entraces/data/models/digital_guide_entrace.dart"; -class DigitalGuideGoToButton extends StatelessWidget { - const DigitalGuideGoToButton({ +class DigitalGuideNavLink extends StatelessWidget { + const DigitalGuideNavLink({ super.key, required this.onTap, - required this.entrace, + required this.text, }); final VoidCallback onTap; - final DigitalGuideEntrace entrace; + final String text; @override Widget build(BuildContext context) { @@ -31,7 +31,7 @@ class DigitalGuideGoToButton extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - entrace.translations.pl.name, + text, style: context.textTheme.title, ), Icon( diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart index 7717b910..508357ca 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -42,9 +42,9 @@ class EvacuationWidget extends StatelessWidget { ), ListView.separated( physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) => DigitalGuideGoToButton( + itemBuilder: (context, index) => DigitalGuideNavLink( onTap: () {}, - entrace: digitalGuideResponseExtended.entraces[index], + text: digitalGuideResponseExtended.entraces[index].translations.pl.name, ), separatorBuilder: (context, index) => const SizedBox( height: DigitalGuideConfig.heightMedium, diff --git a/lib/widgets/my_error_widget.dart b/lib/widgets/my_error_widget.dart index 0ee7a628..741f932a 100644 --- a/lib/widgets/my_error_widget.dart +++ b/lib/widgets/my_error_widget.dart @@ -14,6 +14,8 @@ import "../features/parkings_view/widgets/offline_parkings_view.dart"; import "../gen/assets.gen.dart"; import "../theme/app_theme.dart"; +// MEGA TEST NICE // TODO(simon-the-shark): delete this comment + class MyErrorWidget extends HookWidget { const MyErrorWidget(this.error, {super.key}); From 11c77a3806513e305211c938a302aa98b24a755d Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 22:25:22 +0100 Subject: [PATCH 08/14] chore: fix linter complaints --- .../digital_guide_view/tabs/evacuation/evacuation_widget.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart index 508357ca..0fd6e241 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -44,7 +44,8 @@ class EvacuationWidget extends StatelessWidget { physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) => DigitalGuideNavLink( onTap: () {}, - text: digitalGuideResponseExtended.entraces[index].translations.pl.name, + text: + digitalGuideResponseExtended.entraces[index].translations.pl.name, ), separatorBuilder: (context, index) => const SizedBox( height: DigitalGuideConfig.heightMedium, From 7ee00e5b858cfb924f73e0072a716857585176a9 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 22:33:30 +0100 Subject: [PATCH 09/14] chore: fix linter complaints --- ...ital_guide_go_to_button.dart => digital_guide_nav_link.dart} | 1 - .../digital_guide_view/tabs/evacuation/evacuation_widget.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) rename lib/features/digital_guide_view/presentation/widgets/{digital_guide_go_to_button.dart => digital_guide_nav_link.dart} (94%) diff --git a/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_nav_link.dart similarity index 94% rename from lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart rename to lib/features/digital_guide_view/presentation/widgets/digital_guide_nav_link.dart index 349497cf..75a58dd6 100644 --- a/lib/features/digital_guide_view/presentation/widgets/digital_guide_go_to_button.dart +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_nav_link.dart @@ -2,7 +2,6 @@ import "package:flutter/material.dart"; import "../../../../config/ui_config.dart"; import "../../../../theme/app_theme.dart"; -import "../../tabs/entraces/data/models/digital_guide_entrace.dart"; class DigitalGuideNavLink extends StatelessWidget { const DigitalGuideNavLink({ diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart index 0fd6e241..9b9aab15 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -5,7 +5,7 @@ import "../../../../utils/context_extensions.dart"; import "../../../../widgets/my_cached_image.dart"; import "../../../../widgets/my_html_widget.dart"; import "../../data/models/digital_guide_response_extended.dart"; -import "../../presentation/widgets/digital_guide_go_to_button.dart"; +import "../../presentation/widgets/digital_guide_nav_link.dart"; class EvacuationWidget extends StatelessWidget { const EvacuationWidget({ From 227c894a2c31ec0a0aad7e8c0166749f6dafe045 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 23:32:53 +0100 Subject: [PATCH 10/14] refactor: add evacuation repo --- .../digital_guide_response_extended.dart | 14 ++++----- .../repository/digital_guide_repository.dart | 31 +++++++++++++------ .../presentation/digital_guide_view.dart | 3 +- .../data/models/digital_guide_evacuation.dart | 15 +++++++++ .../repository/evacuation_repository.dart | 24 ++++++++++++++ .../tabs/evacuation/evacuation_widget.dart | 5 ++- 6 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 lib/features/digital_guide_view/tabs/evacuation/data/models/digital_guide_evacuation.dart create mode 100644 lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart diff --git a/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart b/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart index 6f29eb0b..728d066c 100644 --- a/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart +++ b/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart @@ -3,6 +3,7 @@ import "dart:core"; import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "../../tabs/entraces/data/models/digital_guide_entrace.dart"; +import "../../tabs/evacuation/data/models/digital_guide_evacuation.dart"; import "digital_guide_response.dart"; class DigitalGuideResponseExtended { @@ -22,9 +23,8 @@ class DigitalGuideResponseExtended { required this.surroundingId, required this.images, required this.imageUrl, - required this.evacuationMapId, - required this.evacuationMapUrl, required this.entraces, + required this.evacuation, }); final int id; @@ -42,14 +42,13 @@ class DigitalGuideResponseExtended { final int surroundingId; final List images; final String? imageUrl; - final int evacuationMapId; - final String? evacuationMapUrl; + final DigitalGuideEvacuation evacuation; final IList entraces; factory DigitalGuideResponseExtended.fromDigitalGuideResponse({ required DigitalGuideResponse digitalGuideResponse, required String? imageUrl, - required String? evacuationMapUrl, + required DigitalGuideEvacuation evacuation, required IList entraces, }) { return DigitalGuideResponseExtended( @@ -64,13 +63,12 @@ class DigitalGuideResponseExtended { areLargeFontBoards: digitalGuideResponse.areLargeFontBoards, isSignLanguageInterpreter: digitalGuideResponse.isSignLanguageInterpreter, areEmergencyChairs: digitalGuideResponse.areEmergencyChairs, - phoneNumbers: digitalGuideResponse.phoneNumbers, + telephoneNumber: digitalGuideResponse.telephoneNumber, surroundingId: digitalGuideResponse.surroundingId, images: digitalGuideResponse.images, imageUrl: imageUrl, - evacuationMapId: digitalGuideResponse.evacuationMapId, - evacuationMapUrl: evacuationMapUrl, entraces: entraces, + evacuation: evacuation, ); } } diff --git a/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart index a6614630..270606cb 100644 --- a/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart +++ b/lib/features/digital_guide_view/data/repository/digital_guide_repository.dart @@ -5,33 +5,29 @@ import "package:riverpod_annotation/riverpod_annotation.dart"; import "../../../../api_base_rest/client/dio_client.dart"; import "../../../../config/env.dart"; import "../../tabs/entraces/data/repository/entraces_repository.dart"; +import "../../tabs/evacuation/data/repository/evacuation_repository.dart"; import "../models/digital_guide_response.dart"; import "../models/digital_guide_response_extended.dart"; part "digital_guide_repository.g.dart"; @riverpod -Future getDigitalGuideData( +Future getDigitalGuideDataExtended( Ref ref, int id, ) async { - final digitalGuideUrl = "${Env.digitalGuideUrl}/buildings/$id"; - final dio = ref.read(restClientProvider); - dio.options.headers["Authorization"] = - "Token ${Env.digitalGuideAuthorizationToken}"; - final response = await dio.get(digitalGuideUrl); final digitalGuideResponse = - DigitalGuideResponse.fromJson(response.data as Map); + await ref.watch(getDigitalGuideBuildingDataProvider(id).future); final imageUrl = await ref .watch(getImageUrlProvider(digitalGuideResponse.images[0]).future); - final evacuationMapUrl = await ref - .watch(getImageUrlProvider(digitalGuideResponse.evacuationMapId).future); + final evacuation = + await ref.watch(getDigitalGuideEvacuationProvider(id).future); final entraces = await ref .watch(getDigitalGuideEntracesProvider(digitalGuideResponse.id).future); return DigitalGuideResponseExtended.fromDigitalGuideResponse( digitalGuideResponse: digitalGuideResponse, imageUrl: imageUrl, - evacuationMapUrl: evacuationMapUrl, + evacuation: evacuation, entraces: entraces, ); } @@ -57,3 +53,18 @@ Future getImageUrl(Ref ref, int id) async { return imageUrl; } + +@riverpod +Future getDigitalGuideBuildingData( + Ref ref, + int id, +) async { + final digitalGuideUrl = "${Env.digitalGuideUrl}/buildings/$id"; + final dio = ref.read(restClientProvider); + dio.options.headers["Authorization"] = + "Token ${Env.digitalGuideAuthorizationToken}"; + final response = await dio.get(digitalGuideUrl); + final digitalGuideResponse = + DigitalGuideResponse.fromJson(response.data as Map); + return digitalGuideResponse; +} diff --git a/lib/features/digital_guide_view/presentation/digital_guide_view.dart b/lib/features/digital_guide_view/presentation/digital_guide_view.dart index d27fdaf7..8441b778 100644 --- a/lib/features/digital_guide_view/presentation/digital_guide_view.dart +++ b/lib/features/digital_guide_view/presentation/digital_guide_view.dart @@ -29,7 +29,8 @@ class DigitalGuideView extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final asyncDigitalGuideData = ref.watch(getDigitalGuideDataProvider(id)); + final asyncDigitalGuideData = + ref.watch(getDigitalGuideDataExtendedProvider(id)); // question: Should the app bar appear during loading or when there's an error? // Now it doesn't, neither does it appear on SKS menu screen return asyncDigitalGuideData.when( diff --git a/lib/features/digital_guide_view/tabs/evacuation/data/models/digital_guide_evacuation.dart b/lib/features/digital_guide_view/tabs/evacuation/data/models/digital_guide_evacuation.dart new file mode 100644 index 00000000..7fdf6be0 --- /dev/null +++ b/lib/features/digital_guide_view/tabs/evacuation/data/models/digital_guide_evacuation.dart @@ -0,0 +1,15 @@ +import "package:freezed_annotation/freezed_annotation.dart"; + +part "digital_guide_evacuation.freezed.dart"; +part "digital_guide_evacuation.g.dart"; + +@freezed +class DigitalGuideEvacuation with _$DigitalGuideEvacuation { + const factory DigitalGuideEvacuation({ + required String evacuationDescription, + required String? evacuationMapUrl, + }) = _DigitalGuideEvacuation; + + factory DigitalGuideEvacuation.fromJson(Map json) => + _$DigitalGuideEvacuationFromJson(json); +} diff --git a/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart b/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart new file mode 100644 index 00000000..6de4e70f --- /dev/null +++ b/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart @@ -0,0 +1,24 @@ +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:riverpod_annotation/riverpod_annotation.dart"; + +import "../../../../data/repository/digital_guide_repository.dart"; +import "../models/digital_guide_evacuation.dart"; + +part "evacuation_repository.g.dart"; + +@riverpod +Future getDigitalGuideEvacuation( + Ref ref, + int buildingId, +) async { + final building = + await ref.watch(getDigitalGuideBuildingDataProvider(buildingId).future); + final evacuationMapUrl = + await ref.watch(getImageUrlProvider(building.evacuationMapId).future); + + return DigitalGuideEvacuation( + evacuationDescription: + building.translations.plTranslation.evacuationDescription, + evacuationMapUrl: evacuationMapUrl, + ); +} diff --git a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart index 9b9aab15..69aa8a02 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/evacuation_widget.dart @@ -22,8 +22,7 @@ class EvacuationWidget extends StatelessWidget { height: DigitalGuideConfig.heightSmall, ), MyHtmlWidget( - digitalGuideResponseExtended - .translations.plTranslation.evacuationDescription, + digitalGuideResponseExtended.evacuation.evacuationDescription, textStyle: context.textTheme.boldBody, ), const SizedBox( @@ -36,7 +35,7 @@ class EvacuationWidget extends StatelessWidget { const SizedBox( height: DigitalGuideConfig.heightMedium, ), - MyCachedImage(digitalGuideResponseExtended.evacuationMapUrl), + MyCachedImage(digitalGuideResponseExtended.evacuation.evacuationMapUrl), const SizedBox( height: DigitalGuideConfig.heightMedium, ), From 0dd6eb90ac11ed65408cf5c69b1d8e92a92296dc Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 14 Dec 2024 23:33:39 +0100 Subject: [PATCH 11/14] chore: fix linter complaints --- .../evacuation/data/repository/evacuation_repository.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart b/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart index 6de4e70f..cca04e3b 100644 --- a/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart +++ b/lib/features/digital_guide_view/tabs/evacuation/data/repository/evacuation_repository.dart @@ -17,8 +17,8 @@ Future getDigitalGuideEvacuation( await ref.watch(getImageUrlProvider(building.evacuationMapId).future); return DigitalGuideEvacuation( - evacuationDescription: - building.translations.plTranslation.evacuationDescription, - evacuationMapUrl: evacuationMapUrl, - ); + evacuationDescription: + building.translations.plTranslation.evacuationDescription, + evacuationMapUrl: evacuationMapUrl, + ); } From dcb328929472fad2a8aec0af641c2035744ce936 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Tue, 17 Dec 2024 21:59:00 +0100 Subject: [PATCH 12/14] fix: rebase mistakes --- .../data/models/digital_guide_response_extended.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart b/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart index 728d066c..ea3d82f3 100644 --- a/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart +++ b/lib/features/digital_guide_view/data/models/digital_guide_response_extended.dart @@ -63,7 +63,7 @@ class DigitalGuideResponseExtended { areLargeFontBoards: digitalGuideResponse.areLargeFontBoards, isSignLanguageInterpreter: digitalGuideResponse.isSignLanguageInterpreter, areEmergencyChairs: digitalGuideResponse.areEmergencyChairs, - telephoneNumber: digitalGuideResponse.telephoneNumber, + phoneNumbers: digitalGuideResponse.phoneNumbers, surroundingId: digitalGuideResponse.surroundingId, images: digitalGuideResponse.images, imageUrl: imageUrl, From 1a7bf95e6bad1dce56acce3d370ed2dd6e0e6cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Kowali=C5=84ski?= Date: Wed, 18 Dec 2024 19:04:05 +0100 Subject: [PATCH 13/14] refactor(digital-guide): move localizations to tabs subfolder --- .../presentation/widgets/digital_guide_features_section.dart | 2 +- .../presentation/localization_expansion_tile_content.dart | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/features/digital_guide_view/{ => tabs}/localization/presentation/localization_expansion_tile_content.dart (100%) diff --git a/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart b/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart index 225acdcd..6fa5817f 100644 --- a/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart +++ b/lib/features/digital_guide_view/presentation/widgets/digital_guide_features_section.dart @@ -4,9 +4,9 @@ import "package:flutter/widgets.dart"; import "../../../../utils/context_extensions.dart"; import "../../../../widgets/my_expansion_tile.dart"; import "../../data/models/digital_guide_response_extended.dart"; -import "../../localization/presentation/localization_expansion_tile_content.dart"; import "../../tabs/amenities/presentation/amenities_expansion_tile_content.dart"; import "../../tabs/evacuation/evacuation_widget.dart"; +import "../../tabs/localization/presentation/localization_expansion_tile_content.dart"; import "../../tabs/surrounding/presentation/surroundings_expansion_tile_content.dart"; typedef TileContent = ({String title, List content}); diff --git a/lib/features/digital_guide_view/localization/presentation/localization_expansion_tile_content.dart b/lib/features/digital_guide_view/tabs/localization/presentation/localization_expansion_tile_content.dart similarity index 100% rename from lib/features/digital_guide_view/localization/presentation/localization_expansion_tile_content.dart rename to lib/features/digital_guide_view/tabs/localization/presentation/localization_expansion_tile_content.dart From 9373e9d0bc7d700ebaf029671d86f66afb633d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Kowali=C5=84ski?= Date: Wed, 18 Dec 2024 19:06:12 +0100 Subject: [PATCH 14/14] refactor(digital-guide): remove useless comment --- lib/widgets/my_error_widget.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/widgets/my_error_widget.dart b/lib/widgets/my_error_widget.dart index 741f932a..0ee7a628 100644 --- a/lib/widgets/my_error_widget.dart +++ b/lib/widgets/my_error_widget.dart @@ -14,8 +14,6 @@ import "../features/parkings_view/widgets/offline_parkings_view.dart"; import "../gen/assets.gen.dart"; import "../theme/app_theme.dart"; -// MEGA TEST NICE // TODO(simon-the-shark): delete this comment - class MyErrorWidget extends HookWidget { const MyErrorWidget(this.error, {super.key});