Skip to content

Commit

Permalink
feat: evacuation screen and small refactor of file structure in digit…
Browse files Browse the repository at this point in the history
…al guide
  • Loading branch information
Tomasz Trela authored and Tomasz Trela committed Dec 14, 2024
1 parent 90f9e89 commit 15810d5
Show file tree
Hide file tree
Showing 21 changed files with 286 additions and 39 deletions.
4 changes: 4 additions & 0 deletions lib/config/ui_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class DigitalGuideResponse with _$DigitalGuideResponse {
required String telephoneNumber,
@JsonKey(name: "surrounding") required int surroundingId,
required List<int> images,
@JsonKey(name: "evacuation_map") required int evacuationMapId,
String? imageUrl,
}) = _DigitalGuideResponse;

Expand All @@ -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<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand All @@ -36,10 +42,15 @@ class DigitalGuideResponseExtended {
final int surroundingId;
final List<int> images;
final String? imageUrl;
final int evacuationMapId;
final String? evacuationMapUrl;
final IList<DigitalGuideEntrace> entraces;

factory DigitalGuideResponseExtended.fromDigitalGuideResponse({
required DigitalGuideResponse digitalGuideResponse,
required String? imageUrl,
required String? evacuationMapUrl,
required IList<DigitalGuideEntrace> entraces,
}) {
return DigitalGuideResponseExtended(
id: digitalGuideResponse.id,
Expand All @@ -57,6 +68,9 @@ class DigitalGuideResponseExtended {
surroundingId: digitalGuideResponse.surroundingId,
images: digitalGuideResponse.images,
imageUrl: imageUrl,
evacuationMapId: digitalGuideResponse.evacuationMapId,
evacuationMapUrl: evacuationMapUrl,
entraces: entraces,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -22,9 +23,14 @@ Future<DigitalGuideResponseExtended> getDigitalGuideData(
final digitalGuideResponse =
DigitalGuideResponse.fromJson(response.data as Map<String, dynamic>);
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,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Widget> content});

Expand Down Expand Up @@ -70,7 +71,10 @@ class DigitalGuideFeaturesSection extends StatelessWidget {
),
(
title: context.localize.evacuation,
content: [LocalizationExpansionTileContent()],
content: [
EvacuationWidget(
digitalGuideResponseExtended: digitalGuideResponseExtended)
],
),
];

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, dynamic> json) =>
_$DigitalGuideEntraceFromJson(json);
}

@freezed
class DigitalGuideTranslationsEntrace with _$DigitalGuideTranslationsEntrace {
const factory DigitalGuideTranslationsEntrace({
required DigitalGuideTranslationEntrace pl,
}) = _DigitalGuideTranslationsEntrace;

factory DigitalGuideTranslationsEntrace.fromJson(Map<String, dynamic> json) =>
_$DigitalGuideTranslationsEntraceFromJson(json);
}

@freezed
class DigitalGuideTranslationEntrace with _$DigitalGuideTranslationEntrace {
const factory DigitalGuideTranslationEntrace({
required String name,
required String location,
}) = _DigitalGuideTranslationEntrace;

factory DigitalGuideTranslationEntrace.fromJson(Map<String, dynamic> json) =>
_$DigitalGuideTranslationEntraceFromJson(json);
}
Original file line number Diff line number Diff line change
@@ -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<IList<DigitalGuideEntrace>> 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<dynamic>;
final entrances = data
.map((json) => DigitalGuideEntrace.fromJson(json as Map<String, dynamic>))
.toIList();

print(entrances);
return entrances;
}
Loading

0 comments on commit 15810d5

Please sign in to comment.