Skip to content

Commit

Permalink
init: structure tab
Browse files Browse the repository at this point in the history
  • Loading branch information
24bartixx committed Jan 18, 2025
1 parent 47102e2 commit d9b3d4c
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 107 deletions.
1 change: 1 addition & 0 deletions lib/config/nav_bar_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extension IsRouteATabViewX on PageRouteInfo<dynamic> {
ScienceClubDetailRoute.name => context.localize.scientific_cirlces,
GuideDetailRoute.name => context.localize.guide,
DigitalGuideRoute.name => context.localize.digital_guide,
LevelRoute.name => context.localize.level,
_ => null,
};
}
Expand Down
1 change: 1 addition & 0 deletions lib/features/digital_guide_view/data/models/level.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class LevelTranslations with _$LevelTranslations {
class LevelTranslation with _$LevelTranslation {
const factory LevelTranslation({
required String name,
@JsonKey(name: "room_numbers_range") required String roomNumbersRange,
}) = _LevelTranslation;

factory LevelTranslation.fromJson(Map<String, dynamic> json) =>
Expand Down
17 changes: 10 additions & 7 deletions lib/features/digital_guide_view/data/models/region.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ class Region with _$Region {
@freezed
class RegionTranslations with _$RegionTranslations {
const factory RegionTranslations({
@JsonKey(name: "pl") required RegionTranslations plTranslation,
@JsonKey(name: "pl") required RegionTranslation plTranslation,
}) = _RegionTranslations;

factory RegionTranslations.fromJson(Map<String, dynamic> json) => _$RegionTranslationsFromJson(json);

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

@freezed
class RegionTraslation with _$RegionTraslation {
const factory RegionTraslation({
class RegionTranslation with _$RegionTranslation {
const factory RegionTranslation({
required String name,
}) = _RegionTraslation;
required String location,
}) = _RegionTranslation;

factory RegionTraslation.fromJson(Map<String, dynamic> json) => _$RegionTraslationFromJson(json);
factory RegionTranslation.fromJson(Map<String, dynamic> json) =>
_$RegionTranslationFromJson(json);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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/rooms/presentation/digital_guide_rooms_expansion_tile_content.dart";
import "../../tabs/structure/presentation/structure_expansion_tile_content.dart";
import "../../tabs/surrounding/presentation/surroundings_expansion_tile_content.dart";

typedef TileContent = ({String title, List<Widget> content});
Expand Down Expand Up @@ -79,7 +80,9 @@ class DigitalGuideFeaturesSection extends ConsumerWidget {
),
(
title: context.localize.building_structure,
content: [LocalizationExpansionTileContent()],
content: [
StructureExpansionTileContent(digitalGuideData: digitalGuideData)
],
),
(
title: context.localize.room_information,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ 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 "../../../data/models/level.dart";
import "../../../data/models/level_with_regions.dart";
import "../../../data/repository/levels_repository.dart";
import "../../../presentation/widgets/digital_guide_nav_link.dart";

Expand All @@ -18,31 +19,28 @@ class StructureExpansionTileContent extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {

final levelDataAsync = ref.watch(rawLevelsRepositoryProvider(digitalGuideData));
final levelDataAsync =
ref.watch(levelsWithRegionsRepositoryProvider(digitalGuideData));

return levelDataAsync.when(
data: (data) => _StructureExpansionTileContent(
digitalGuideResponse: digitalGuideData,
digitalGuideResponse: digitalGuideData,
levels: data,
),
loading: () => const Center(
child: CircularProgressIndicator(),
),
error: (error, _) => MyErrorWidget(error),
);

}
}

class _StructureExpansionTileContent extends ConsumerWidget {
const _StructureExpansionTileContent({
required this.digitalGuideResponse,
required this.levels
});
const _StructureExpansionTileContent(
{required this.digitalGuideResponse, required this.levels});

final DigitalGuideResponse digitalGuideResponse;
final IList<Level> levels;
final IList<LevelWithRegions> levels;

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -52,16 +50,22 @@ class _StructureExpansionTileContent extends ConsumerWidget {
left: DigitalGuideConfig.heightMedium,
right: DigitalGuideConfig.heightMedium,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: levels.map((level) {
return DigitalGuideNavLink(
onTap: () {},
text: level.translations.plTranslation.name,
);
}).toList(),
child: ListView.separated(
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => DigitalGuideNavLink(
onTap: () async {
await ref.navigateDigitalGuideLevel(
levels[index],
);
},
text: levels[index].level.translations.plTranslation.name,
),
separatorBuilder: (context, index) => const SizedBox(
height: DigitalGuideConfig.heightMedium,
),
itemCount: levels.length,
shrinkWrap: true,
),
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import "package:auto_route/auto_route.dart";
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";

import "../../../../../../config/nav_bar_config.dart";
import "../../../../../../config/ui_config.dart";
import "../../../../../../theme/app_theme.dart";
import "../../../../../../utils/context_extensions.dart";
import "../../../../../../widgets/detail_views/detail_view_app_bar.dart";
import "../../../../../../widgets/my_error_widget.dart";
import "../../../../../navigation_tab_view/navigation_tab_view.dart";
import "../../../../../navigator/utils/navigation_commands.dart";
import "../../../../data/models/level_with_regions.dart";
import "../../../../presentation/widgets/accessibility_button.dart";
import "../../../../presentation/widgets/digital_guide_nav_link.dart";

@RoutePage()
class LevelView extends ConsumerWidget {
const LevelView({
required this.levelInfo,
});
final LevelWithRegions levelInfo;

@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: DetailViewAppBar(),
body: Padding(
padding: const EdgeInsets.symmetric(
horizontal: DigitalGuideConfig.heightBig,
),
child: CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildListDelegate([
Text(levelInfo.level.translations.plTranslation.name,
style: context.textTheme.headline.copyWith(fontSize: 22),),
const SizedBox(
height: DigitalGuideConfig.heightSmall,
),
Text(context.localize.rooms_distribution,
style: context.textTheme.boldBody.copyWith(fontSize: 16),),
const SizedBox(
height: DigitalGuideConfig.heightSmall,
),
Text(
levelInfo.level.translations.plTranslation.roomNumbersRange,
style: context.textTheme.body.copyWith(fontSize: 16),),
const SizedBox(
height: DigitalGuideConfig.heightMedium,
),
]),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => Column(
children: [
DigitalGuideNavLink(
onTap: () async {
await ref.navigateDigitalGuideRegion(
levelInfo.regions[index]);
},
text: levelInfo
.regions[index].translations.plTranslation.name,
),
const SizedBox(
height: DigitalGuideConfig.heightMedium,
),
],
),
childCount: levelInfo.regions.length,
),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import "package:auto_route/auto_route.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 "../../../../../../widgets/detail_views/detail_view_app_bar.dart";
import "../../../../data/models/region.dart";
import "../../../../presentation/widgets/digital_guide_nav_link.dart";

@RoutePage()
class RegionView extends ConsumerWidget {
const RegionView({
required this.region,
});

final Region region;

@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: DetailViewAppBar(),
body: Padding(
padding: const EdgeInsets.symmetric(
horizontal: DigitalGuideConfig.heightBig,
),
child: CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildListDelegate([
Text(region.translations.plTranslation.name,
style: context.textTheme.headline.copyWith(fontSize: 22),),
const SizedBox(
height: DigitalGuideConfig.heightSmall,
),
Text(context.localize.region_location,
style: context.textTheme.boldBody.copyWith(fontSize: 16),),
const SizedBox(
height: DigitalGuideConfig.heightSmall,
),
Text(
region.translations.plTranslation.location,
style: context.textTheme.body.copyWith(fontSize: 16),),
const SizedBox(
height: DigitalGuideConfig.heightMedium,
),
// corridors
// DigitalGuideNavLink(
// onTap: onTap,
// text: text
// )
]),
),
],
)
),
);
}
}

This file was deleted.

Loading

0 comments on commit d9b3d4c

Please sign in to comment.