6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit c25dc07a
Changed files
.../hotel_information/models/call_to_action.g.dart | 20 ++++++++++ .../hotel_information/models/facilities.g.dart | 13 ------ .../hotel_information/hotel_information_page.dart | 46 ++++++++++++++-------- .../hotel_information/models/call_to_action.dart | 20 ++++++++++ .../lib/hotel_information/models/facilities.dart | 15 +------ .../lib/hotel_information/models/parking_info.dart | 2 +- .../lib/hotel_information/models/restaurant.dart | 2 +- .../lib/hotel_information/models/spa.dart | 2 +- .../lib/hotel_information/pages/facility_page.dart | 40 +++++++++++++++++++ .../pages/hotel_information_menu.dart | 4 +- .../pages/restaurant_facility_page.dart | 36 ----------------- comwell_key_app/lib/routing/app_router.dart | 41 ++++--------------- comwell_key_app/lib/routing/app_routes.dart | 4 +- 13 files changed, 125 insertions(+), 120 deletions(-)
Diff
diff --git a/comwell_key_app/lib/.generated/hotel_information/models/call_to_action.g.dart b/comwell_key_app/lib/.generated/hotel_information/models/call_to_action.g.dart
new file mode 100644
index 00000000..9bc35220
--- /dev/null
+++ b/comwell_key_app/lib/.generated/hotel_information/models/call_to_action.g.dart
@@ -0,0 +1,20 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of '../../../hotel_information/models/call_to_action.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+CallToAction _$CallToActionFromJson(Map json) => CallToAction(
+ name: json['name'] as String,
+ url: json['url'] as String,
+ target: json['target'] as String?,
+ );
+
+Map<String, dynamic> _$CallToActionToJson(CallToAction instance) =>
+ <String, dynamic>{
+ 'name': instance.name,
+ 'url': instance.url,
+ 'target': instance.target,
+ };
diff --git a/comwell_key_app/lib/.generated/hotel_information/models/facilities.g.dart b/comwell_key_app/lib/.generated/hotel_information/models/facilities.g.dart
index 0dfcabe9..644206f0 100644
--- a/comwell_key_app/lib/.generated/hotel_information/models/facilities.g.dart
+++ b/comwell_key_app/lib/.generated/hotel_information/models/facilities.g.dart
@@ -25,16 +25,3 @@ Map<String, dynamic> _$FacilityToJson(Facility instance) => <String, dynamic>{
'structuredText': instance.structuredText.map((e) => e.toJson()).toList(),
'callToAction': instance.callToAction?.toJson(),
};
-
-CallToAction _$CallToActionFromJson(Map json) => CallToAction(
- name: json['name'] as String,
- url: json['url'] as String,
- target: json['target'] as String?,
- );
-
-Map<String, dynamic> _$CallToActionToJson(CallToAction instance) =>
- <String, dynamic>{
- 'name': instance.name,
- 'url': instance.url,
- 'target': instance.target,
- };
diff --git a/comwell_key_app/lib/hotel_information/hotel_information_page.dart b/comwell_key_app/lib/hotel_information/hotel_information_page.dart
index 84844af6..583fcdbb 100644
--- a/comwell_key_app/lib/hotel_information/hotel_information_page.dart
+++ b/comwell_key_app/lib/hotel_information/hotel_information_page.dart
@@ -1,8 +1,12 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
+import 'package:comwell_key_app/hotel_information/repository/hotel_information_repository.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
-
+import 'package:go_router/go_router.dart';
class HotelInformationPage extends StatelessWidget {
final Widget child;
@@ -10,21 +14,31 @@ class HotelInformationPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return BlocBuilder<HotelInformationCubit, HotelInformationState>(
+ // Get the booking from GoRouter's extra parameter
+ final booking = GoRouterState.of(context).extra as Booking;
+
+ return BlocProvider<HotelInformationCubit>(
+ create: (_) => HotelInformationCubit(
+ hotelInformationRepository: locator<HotelInformationRepository>(),
+ booking: booking,
+ culture: context.locale, // Now it's safe!
+ )..init(),
+ child: BlocBuilder<HotelInformationCubit, HotelInformationState>(
builder: (context, state) {
-
- return Scaffold(
- extendBodyBehindAppBar: true,
- appBar: const ComwellAppBar(),
- backgroundColor: Colors.white,
- body: Builder(builder: (context) {
- return switch (state.hotelState) {
- HotelState.loading => const Center(child: CircularProgressIndicator()),
- HotelState.error => const Center(child: Text("Error")),
- HotelState.success => child,
- };
- }),
- );
- });
+ return Scaffold(
+ extendBodyBehindAppBar: true,
+ appBar: const ComwellAppBar(),
+ backgroundColor: Colors.white,
+ body: Builder(builder: (context) {
+ return switch (state.hotelState) {
+ HotelState.loading => const Center(child: CircularProgressIndicator()),
+ HotelState.error => const Center(child: Text("Error")),
+ HotelState.success => child,
+ };
+ }),
+ );
+ }
+ ),
+ );
}
}
diff --git a/comwell_key_app/lib/hotel_information/models/call_to_action.dart b/comwell_key_app/lib/hotel_information/models/call_to_action.dart
new file mode 100644
index 00000000..e93cb99a
--- /dev/null
+++ b/comwell_key_app/lib/hotel_information/models/call_to_action.dart
@@ -0,0 +1,20 @@
+import 'package:comwell_key_app/utils/json.dart';
+import 'package:json_annotation/json_annotation.dart';
+
+part '../../.generated/hotel_information/models/call_to_action.g.dart';
+
+@JsonSerializable()
+class CallToAction {
+ final String name;
+ final String url;
+ final String? target;
+
+ CallToAction({
+ required this.name,
+ required this.url,
+ this.target,
+ });
+
+ factory CallToAction.fromJson(Json json) => _$CallToActionFromJson(json);
+ Json toJson() => _$CallToActionToJson(this);
+}
\ No newline at end of file
diff --git a/comwell_key_app/lib/hotel_information/models/facilities.dart b/comwell_key_app/lib/hotel_information/models/facilities.dart
index eee9a700..735810d5 100644
--- a/comwell_key_app/lib/hotel_information/models/facilities.dart
+++ b/comwell_key_app/lib/hotel_information/models/facilities.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/hotel_information/models/call_to_action.dart';
import 'package:comwell_key_app/hotel_information/models/structured_text.dart';
import 'package:comwell_key_app/utils/json.dart';
import 'package:json_annotation/json_annotation.dart';
@@ -22,20 +23,6 @@ class Facility {
Json toJson() => _$FacilityToJson(this);
}
-@JsonSerializable()
-class CallToAction {
- final String name;
- final String url;
- final String? target;
-
- CallToAction({
- required this.name,
- required this.url,
- this.target,
- });
- factory CallToAction.fromJson(Json json) => _$CallToActionFromJson(json);
- Json toJson() => _$CallToActionToJson(this);
-}
diff --git a/comwell_key_app/lib/hotel_information/models/parking_info.dart b/comwell_key_app/lib/hotel_information/models/parking_info.dart
index ba6650e4..b7dd48de 100644
--- a/comwell_key_app/lib/hotel_information/models/parking_info.dart
+++ b/comwell_key_app/lib/hotel_information/models/parking_info.dart
@@ -1,5 +1,5 @@
+import 'package:comwell_key_app/hotel_information/models/call_to_action.dart';
import 'package:comwell_key_app/hotel_information/models/structured_text.dart';
-import 'package:comwell_key_app/hotel_information/models/facilities.dart';
import 'package:comwell_key_app/utils/json.dart';
import 'package:json_annotation/json_annotation.dart';
diff --git a/comwell_key_app/lib/hotel_information/models/restaurant.dart b/comwell_key_app/lib/hotel_information/models/restaurant.dart
index c2f6c15d..bdc622dc 100644
--- a/comwell_key_app/lib/hotel_information/models/restaurant.dart
+++ b/comwell_key_app/lib/hotel_information/models/restaurant.dart
@@ -1,5 +1,5 @@
+import 'package:comwell_key_app/hotel_information/models/call_to_action.dart';
import 'package:comwell_key_app/hotel_information/models/structured_text.dart';
-import 'package:comwell_key_app/hotel_information/models/facilities.dart';
import 'package:comwell_key_app/utils/json.dart';
import 'package:json_annotation/json_annotation.dart';
diff --git a/comwell_key_app/lib/hotel_information/models/spa.dart b/comwell_key_app/lib/hotel_information/models/spa.dart
index a8f3a7d1..6b14f511 100644
--- a/comwell_key_app/lib/hotel_information/models/spa.dart
+++ b/comwell_key_app/lib/hotel_information/models/spa.dart
@@ -1,5 +1,5 @@
+import 'package:comwell_key_app/hotel_information/models/call_to_action.dart';
import 'package:comwell_key_app/hotel_information/models/structured_text.dart';
-import 'package:comwell_key_app/hotel_information/models/facilities.dart';
import 'package:comwell_key_app/utils/json.dart';
import 'package:json_annotation/json_annotation.dart';
diff --git a/comwell_key_app/lib/hotel_information/pages/facility_page.dart b/comwell_key_app/lib/hotel_information/pages/facility_page.dart
new file mode 100644
index 00000000..a6956dc6
--- /dev/null
+++ b/comwell_key_app/lib/hotel_information/pages/facility_page.dart
@@ -0,0 +1,40 @@
+import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
+import 'package:comwell_key_app/hotel_information/components/structured_text.dart';
+import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
+import 'package:comwell_key_app/hotel_information/models/facilities.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+class FacilityPage extends StatelessWidget {
+ final Facility facility;
+
+ const FacilityPage({super.key, required this.facility});
+
+ @override
+ Widget build(BuildContext context) {
+ final cubit = context.read<HotelInformationCubit>();
+
+ return Scaffold(
+ backgroundColor: Colors.white,
+ body: Column(
+ children: [
+ ImageWidget(image: facility.headerImage ?? ""),
+ Expanded(
+ child: SingleChildScrollView(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 26),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ StructuredText(blocks: facility.structuredText),
+ const SizedBox(height: 100),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/hotel_information/pages/hotel_information_menu.dart b/comwell_key_app/lib/hotel_information/pages/hotel_information_menu.dart
index aba0bbda..b257a5f8 100644
--- a/comwell_key_app/lib/hotel_information/pages/hotel_information_menu.dart
+++ b/comwell_key_app/lib/hotel_information/pages/hotel_information_menu.dart
@@ -16,6 +16,8 @@ class HotelInformationMenu extends StatelessWidget {
final cubit = context.read<HotelInformationCubit>();
final hotel = cubit.hotel;
+ print(hotel.facilities);
+
return Column(
children: [
ImageWidget(image: hotel.image),
@@ -37,7 +39,7 @@ class HotelInformationMenu extends StatelessWidget {
title: facility.title,
onClick: () {
context.pushNamed(
- "${AppRoutes.hotelInformation.name}/${facility.title.toLowerCase()}",
+ "${AppRoutes.hotelInformation.name}/${AppRoutes.facility.name}",
extra: facility);
},
),
diff --git a/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart b/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart
deleted file mode 100644
index 1e0c670f..00000000
--- a/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
-import 'package:comwell_key_app/hotel_information/components/structured_text.dart';
-import 'package:comwell_key_app/hotel_information/models/facilities.dart';
-import 'package:flutter/material.dart';
-
-class RestaurantFacilityPage extends StatelessWidget {
- final Facility restaurant;
-
- const RestaurantFacilityPage({super.key, required this.restaurant});
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.white,
- body: Column(
- children: [
- ImageWidget(image: restaurant.headerImage ?? ""),
- Expanded(
- child: SingleChildScrollView(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 26),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- StructuredText(blocks: restaurant.structuredText),
- const SizedBox(height: 100),
- ],
- ),
- ),
- ),
- ),
- ],
- ),
- );
- }
-}
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 11673a49..850bbac7 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -12,9 +12,9 @@ import 'package:comwell_key_app/contact/repository/contact_repository.dart';
import 'package:comwell_key_app/find_booking/find_booking_page.dart';
import 'package:comwell_key_app/find_booking/loading_page.dart';
import 'package:comwell_key_app/hotel_information/models/facilities.dart';
+import 'package:comwell_key_app/hotel_information/pages/facility_page.dart';
import 'package:comwell_key_app/hotel_information/pages/hotel_information_menu.dart';
import 'package:comwell_key_app/hotel_information/pages/parking_facility_page.dart';
-import 'package:comwell_key_app/hotel_information/pages/restaurant_facility_page.dart';
import 'package:comwell_key_app/hotel_information/pages/spa_facility_page.dart';
import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
import 'package:comwell_key_app/hotel_information/hotel_information_page.dart';
@@ -115,19 +115,7 @@ GoRouter goRouter() {
parentNavigatorKey: _rootNavigatorKey,
pageBuilder: (context, state, child) {
return NoTransitionPage(
- child: BlocProvider<HotelInformationCubit>(
- create: (BuildContext context) => HotelInformationCubit(
- hotelInformationRepository:
- locator<HotelInformationRepository>(),
- booking: state.extra as Booking,
- culture: context.locale)
- ..init(),
- child:
- BlocBuilder<HotelInformationCubit, HotelInformationState>(
- builder: (context, state) {
- return HotelInformationPage(child: child);
- }),
- ),
+ child: HotelInformationPage(child: child),
);
},
routes: [
@@ -137,30 +125,15 @@ GoRouter goRouter() {
builder: (context, state) {
return const HotelInformationMenu();
}),
+
GoRoute(
path:
- "/${AppRoutes.hotelInformation.name}/${AppRoutes.spa.name}",
- name:
- "${AppRoutes.hotelInformation.name}/${AppRoutes.spa.name}",
- builder: (context, state) {
- final spa = state.extra as Facility;
- return SpaFacilityPage(spa: spa);
- }),
- GoRoute(
- path:
- "/${AppRoutes.hotelInformation.name}/${AppRoutes.restaurant.name}",
+ "/${AppRoutes.hotelInformation.name}/${AppRoutes.facility.name}",
name:
- "${AppRoutes.hotelInformation.name}/${AppRoutes.restaurant.name}",
- builder: (context, state) {
- final restaurant = state.extra as Facility;
- return RestaurantFacilityPage(restaurant: restaurant);
- }),
- GoRoute(
- path: "/${AppRoutes.hotelInformation.name}/parking",
- name: "${AppRoutes.hotelInformation.name}/parking",
+ "${AppRoutes.hotelInformation.name}/${AppRoutes.facility.name}",
builder: (context, state) {
- final parking = state.extra as ParkingInfo;
- return ParkingFacilityPage(parkingInfo: parking);
+ final facility = state.extra as Facility;
+ return FacilityPage(facility: facility);
}),
]),
GoRoute(
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index 1eef87ac..0e3e2d81 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -19,9 +19,7 @@ enum AppRoutes {
contact,
preregistration,
hotelInformation,
- restaurant,
- spa,
- parking,
+ facility,
houseKeeping,
checkOut,
paymentCards,