-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat(digital-guide)/add-micronavigation-info' of https:…
…//github.com/Solvro/mobile-topwr into feat(digital-guide)/add-micronavigation-info
- Loading branch information
Showing
9 changed files
with
276 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
lib/features/digital_guide_view/tabs/rooms/data/models/digital_guide_room.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import "package:freezed_annotation/freezed_annotation.dart"; | ||
|
||
part "digital_guide_room.freezed.dart"; | ||
|
||
part "digital_guide_room.g.dart"; | ||
|
||
@freezed | ||
class DigitalGuideRoom with _$DigitalGuideRoom { | ||
const factory DigitalGuideRoom({ | ||
required int id, | ||
required DigitalGuideTranslationsRoom translations, | ||
@JsonKey(name: "images") required List<int>? imagesIds, | ||
}) = _DigitalGuideRoom; | ||
|
||
factory DigitalGuideRoom.fromJson(Map<String, dynamic> json) => | ||
_$DigitalGuideRoomFromJson(json); | ||
} | ||
|
||
@freezed | ||
class DigitalGuideTranslationsRoom with _$DigitalGuideTranslationsRoom { | ||
const factory DigitalGuideTranslationsRoom({ | ||
required DigitalGuideTranslationRoom pl, | ||
}) = _DigitalGuideTranslationsRoom; | ||
|
||
factory DigitalGuideTranslationsRoom.fromJson(Map<String, dynamic> json) => | ||
_$DigitalGuideTranslationsRoomFromJson(json); | ||
} | ||
|
||
@freezed | ||
class DigitalGuideTranslationRoom with _$DigitalGuideTranslationRoom { | ||
@JsonSerializable(fieldRename: FieldRename.snake) | ||
const factory DigitalGuideTranslationRoom({ | ||
required String name, | ||
required String roomPurpose, | ||
required String location, | ||
required String workingDaysAndHours, | ||
required String areEntrancesComment, | ||
required String isOneLevelFloorComment, | ||
required String arePlacesForWheelchairsComment, | ||
required String comment, | ||
}) = _DigitalGuideTranslationRoom; | ||
|
||
factory DigitalGuideTranslationRoom.fromJson(Map<String, dynamic> json) => | ||
_$DigitalGuideTranslationRoomFromJson(json); | ||
} |
26 changes: 26 additions & 0 deletions
26
lib/features/digital_guide_view/tabs/rooms/data/repository/rooms_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import "package:fast_immutable_collections/fast_immutable_collections.dart"; | ||
import "package:flutter_riverpod/flutter_riverpod.dart"; | ||
import "package:riverpod_annotation/riverpod_annotation.dart"; | ||
|
||
import "../../../../data/api/digital_guide_get_and_cache.dart"; | ||
import "../../../../data/models/digital_guide_response.dart"; | ||
import "../models/digital_guide_room.dart"; | ||
|
||
part "rooms_repository.g.dart"; | ||
|
||
@riverpod | ||
Future<IList<DigitalGuideRoom>> roomsRepository( | ||
Ref ref, | ||
DigitalGuideResponse building, | ||
) async { | ||
final String endpoint = "rooms/?building=${building.id}"; | ||
|
||
return ref.getAndCacheDataFromDigitalGuide( | ||
endpoint, | ||
(List<dynamic> json) => json | ||
.whereType<Map<String, dynamic>>() | ||
.map(DigitalGuideRoom.fromJson) | ||
.toIList(), | ||
onRetry: () => ref.invalidateSelf(), | ||
); | ||
} |
109 changes: 109 additions & 0 deletions
109
lib/features/digital_guide_view/tabs/rooms/presentation/digital_guide_room_detail_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import "package:auto_route/annotations.dart"; | ||
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 "../../../../../theme/app_theme.dart"; | ||
import "../../../../../utils/context_extensions.dart"; | ||
import "../../../../../utils/ilist_nonempty.dart"; | ||
import "../../../../../widgets/detail_views/detail_view_app_bar.dart"; | ||
import "../../../presentation/widgets/accessibility_button.dart"; | ||
import "../../../presentation/widgets/bullet_list.dart"; | ||
import "../../../presentation/widgets/digital_guide_nav_link.dart"; | ||
import "../../../presentation/widgets/digital_guide_photo_row.dart"; | ||
import "../data/models/digital_guide_room.dart"; | ||
|
||
@RoutePage() | ||
class DigitalGuideRoomDetailView extends ConsumerWidget { | ||
const DigitalGuideRoomDetailView({required this.room}); | ||
|
||
final DigitalGuideRoom room; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final roomInformation = room.translations.pl; | ||
final widgets = [ | ||
Text( | ||
roomInformation.name, | ||
style: context.textTheme.headline.copyWith(fontSize: 18), | ||
), | ||
const SizedBox(height: DigitalGuideConfig.heightTiny), | ||
Text( | ||
roomInformation.roomPurpose, | ||
style: context.textTheme.headline | ||
.copyWith(fontSize: 12, fontWeight: FontWeight.normal), | ||
), | ||
if (roomInformation.workingDaysAndHours.isNotEmpty) | ||
const SizedBox(height: DigitalGuideConfig.heightMedium), | ||
if (roomInformation.workingDaysAndHours.isNotEmpty) | ||
Text( | ||
"${context.localize.working_hours}:", | ||
style: context.textTheme.headline, | ||
), | ||
if (roomInformation.workingDaysAndHours.isNotEmpty) | ||
const SizedBox(height: DigitalGuideConfig.heightSmall), | ||
Text( | ||
roomInformation.workingDaysAndHours, | ||
style: context.textTheme.body.copyWith(fontSize: 16), | ||
), | ||
if (roomInformation.workingDaysAndHours.isNotEmpty) | ||
const SizedBox(height: DigitalGuideConfig.heightMedium), | ||
Text( | ||
context.localize.key_information, | ||
style: context.textTheme.headline, | ||
), | ||
const SizedBox(height: DigitalGuideConfig.heightSmall), | ||
BulletList( | ||
items: [ | ||
roomInformation.location, | ||
roomInformation.comment, | ||
roomInformation.areEntrancesComment, | ||
roomInformation.isOneLevelFloorComment, | ||
roomInformation.arePlacesForWheelchairsComment, | ||
roomInformation.isOneLevelFloorComment, | ||
].toIList(), | ||
), | ||
if (room.imagesIds != null && room.imagesIds!.isNotEmpty) | ||
const SizedBox( | ||
height: DigitalGuideConfig.heightMedium, | ||
), | ||
DigitalGuidePhotoRow(imagesIDs: room.imagesIds.toIList()), | ||
const SizedBox( | ||
height: DigitalGuideConfig.heightMedium, | ||
), | ||
DigitalGuideNavLink( | ||
onTap: () {}, | ||
text: context.localize.doors, | ||
), | ||
const SizedBox( | ||
height: DigitalGuideConfig.heightMedium, | ||
), | ||
DigitalGuideNavLink( | ||
onTap: () {}, | ||
text: context.localize.platforms, | ||
), | ||
const SizedBox( | ||
height: DigitalGuideConfig.heightMedium, | ||
), | ||
DigitalGuideNavLink( | ||
onTap: () {}, | ||
text: context.localize.stairs, | ||
), | ||
]; | ||
return Scaffold( | ||
appBar: DetailViewAppBar( | ||
actions: [AccessibilityButton()], | ||
), | ||
body: Padding( | ||
padding: const EdgeInsets.all(DigitalGuideConfig.paddingMedium), | ||
child: ListView.builder( | ||
physics: const NeverScrollableScrollPhysics(), | ||
itemCount: widgets.length, | ||
shrinkWrap: true, | ||
itemBuilder: (context, index) => widgets[index], | ||
), | ||
), | ||
); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...igital_guide_view/tabs/rooms/presentation/digital_guide_rooms_expansion_tile_content.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
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 "../../../../../widgets/my_error_widget.dart"; | ||
import "../../../../navigator/utils/navigation_commands.dart"; | ||
import "../../../data/models/digital_guide_response.dart"; | ||
import "../../../presentation/widgets/digital_guide_nav_link.dart"; | ||
import "../data/models/digital_guide_room.dart"; | ||
import "../data/repository/rooms_repository.dart"; | ||
|
||
class DigitalGuideRoomExpansionTileContent extends ConsumerWidget { | ||
const DigitalGuideRoomExpansionTileContent({ | ||
required this.digitalGuideResponse, | ||
}); | ||
|
||
final DigitalGuideResponse digitalGuideResponse; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final roomsInBuilding = | ||
ref.watch(roomsRepositoryProvider(digitalGuideResponse)); | ||
return roomsInBuilding.when( | ||
data: (data) => _DigitalGuideRoomExpansionTileContent(rooms: data), | ||
error: (error, _) => MyErrorWidget(error), | ||
loading: () => const Center( | ||
child: CircularProgressIndicator(), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _DigitalGuideRoomExpansionTileContent extends ConsumerWidget { | ||
const _DigitalGuideRoomExpansionTileContent({required this.rooms}); | ||
|
||
final IList<DigitalGuideRoom> rooms; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: DigitalGuideConfig.paddingMedium, | ||
vertical: DigitalGuideConfig.paddingMedium, | ||
), | ||
child: ListView.separated( | ||
physics: const NeverScrollableScrollPhysics(), | ||
separatorBuilder: (context, index) => const SizedBox( | ||
height: DigitalGuideConfig.heightMedium, | ||
), | ||
itemCount: rooms.length, | ||
shrinkWrap: true, | ||
itemBuilder: (context, index) => DigitalGuideNavLink( | ||
onTap: () async { | ||
await ref.navigateRoomDetails( | ||
rooms[index], | ||
); | ||
}, | ||
text: rooms[index].translations.pl.name, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters