-
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.
feat(digital-guide): add support for levels in rooms section (#534)
* feat(digital-guide): add support for levels * feat(digital-guide): fix linter complaints * feat(digital-guide): fix linter complaints * feat(digital-guide): rebase * feat(digital-guide): decrease padding
- Loading branch information
1 parent
a8e4fbb
commit d34401b
Showing
5 changed files
with
126 additions
and
36 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
37 changes: 37 additions & 0 deletions
37
lib/features/digital_guide_view/tabs/rooms/domain/digital_guide_rooms_use_cases.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,37 @@ | ||
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/models/digital_guide_response.dart"; | ||
import "../../../data/models/level.dart"; | ||
import "../../../data/repository/levels_repository.dart"; | ||
import "../data/models/digital_guide_room.dart"; | ||
import "../data/repository/rooms_repository.dart"; | ||
|
||
part "digital_guide_rooms_use_cases.g.dart"; | ||
|
||
typedef LevelWithRooms = ({ | ||
Level level, | ||
IList<DigitalGuideRoom> rooms, | ||
}); | ||
|
||
@riverpod | ||
Future<IList<LevelWithRooms>> getLevelsWithRoomsUseCase( | ||
Ref ref, | ||
DigitalGuideResponse digitalGuideData, | ||
) async { | ||
final levels = await ref | ||
.watch(levelsWithRegionsRepositoryProvider(digitalGuideData).future); | ||
|
||
final levelsWithRoomsData = await Future.wait( | ||
levels.map((level) async { | ||
final rooms = await ref.watch(roomsRepositoryProvider(level).future); | ||
return (level: level.level, rooms: rooms); | ||
}), | ||
); | ||
return levelsWithRoomsData | ||
.where( | ||
(levelsWithRooms) => levelsWithRooms.rooms.isNotEmpty, | ||
) | ||
.toIList(); | ||
} |
56 changes: 56 additions & 0 deletions
56
lib/features/digital_guide_view/tabs/rooms/presentation/digital_guide_room_level.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,56 @@ | ||
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 "../../../../navigator/utils/navigation_commands.dart"; | ||
import "../../../data/models/level.dart"; | ||
import "../../../presentation/widgets/digital_guide_nav_link.dart"; | ||
import "../data/models/digital_guide_room.dart"; | ||
|
||
class DigitalGuideRoomLevel extends ConsumerWidget { | ||
const DigitalGuideRoomLevel({ | ||
super.key, | ||
required this.level, | ||
required this.rooms, | ||
}); | ||
|
||
final Level level; | ||
final IList<DigitalGuideRoom> rooms; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
level.translations.plTranslation.name, | ||
style: context.textTheme.lightTitle, | ||
), | ||
const SizedBox(height: 10), | ||
ListView.separated( | ||
physics: const NeverScrollableScrollPhysics(), | ||
itemBuilder: (context, index) => DigitalGuideNavLink( | ||
onTap: () async { | ||
await ref.navigateRoomDetails( | ||
rooms[index], | ||
); | ||
}, | ||
text: rooms[index].translations.pl.name, | ||
), | ||
separatorBuilder: (context, index) => SizedBox( | ||
height: index == rooms.length - 1 | ||
? DigitalGuideConfig.heightSmall | ||
: DigitalGuideConfig.heightMedium, | ||
), | ||
itemCount: rooms.length, | ||
shrinkWrap: true, | ||
), | ||
const SizedBox( | ||
height: DigitalGuideConfig.heightMedium, | ||
), | ||
], | ||
); | ||
} | ||
} |
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