6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 59fb0742

AuthorMikkel Thygesen<mikkelet@gmail.com>
Date2026-02-15 00:20:42 +0100
2085: updated all routes to use path

Changed files

.../lib/.generated/assets/assets.gen.dart          |  14 +-
 .../check_in/bloc/check_in_state.freezed.dart      | 277 +++++++++++
 .../cubit/choose_share_room_state.freezed.dart     | 154 ++++++
 .../lib/booking_details/booking_details_page.dart  |   2 +-
 .../lib/booking_details/booking_details_route.dart |  38 ++
 .../components/booking_details_bottom_sheet.dart   | 129 +++--
 .../components/check_in_button.dart                |  33 +-
 .../components/check_out_button.dart               |   2 +-
 .../components/get_keys_button.dart                |   2 +-
 .../components/housekeeping_button.dart            |   2 +-
 .../components/preregister_button.dart             |   4 +-
 .../booking_details/components/share_button.dart   |  10 +-
 .../components/unlock_room_button.dart             |   2 +-
 .../lib/check_in/bloc/check_in_cubit.dart          |  68 ++-
 .../lib/check_in/bloc/check_in_state.dart          | 115 +----
 comwell_key_app/lib/check_in/check_in_page.dart    | 301 +++++------
 comwell_key_app/lib/check_in/check_in_route.dart   |  24 +
 .../lib/check_out/bloc/check_out_cubit.dart        |  72 +--
 comwell_key_app/lib/check_out/check_out_flow.dart  |   5 +-
 comwell_key_app/lib/check_out/checkout_routes.dart |  41 ++
 .../lib/check_out/pages/check_out_error_page.dart  |  51 +-
 .../check_out/pages/check_out_processing_page.dart |   4 +-
 .../check_out/pages/check_out_success_page.dart    |  56 +--
 .../choose_share_room/choose_share_room_page.dart  |  43 +-
 .../choose_share_room/choose_share_room_route.dart |  18 +
 .../components/choose_room_widget.dart             | 279 +++++------
 .../cubit/choose_share_room_cubit.dart             |  43 +-
 .../cubit/choose_share_room_state.dart             |  37 +-
 .../choose_share_room/pages/room_info_page.dart    | 264 +++++-----
 .../choose_share_room/pages/share_room_page.dart   |  23 -
 .../lib/common/components/comwell_app_bar.dart     |   2 +-
 comwell_key_app/lib/contact/contact_route.dart     |  24 +
 .../lib/contact/cubit/contact_cubit.dart           |  26 +-
 .../lib/find_booking/find_booking_page.dart        |   2 +-
 .../lib/find_booking/find_booking_route.dart       |  26 +
 .../lib/force_update/force_update_route.dart       |  10 +
 .../cubit/hotel_information_cubit.dart             |  12 +-
 .../hotel_information/hotel_information_route.dart |  45 ++
 .../lib/hotel_information/pages/facility_page.dart |  11 +-
 .../pages/hotel_information_menu.dart              |   2 +-
 .../lib/housekeeping/house_keeping_route.dart      |  12 +
 comwell_key_app/lib/key/key_route.dart             |  12 +
 .../components/balance_bottom_sheet.dart           |   2 +-
 .../lib/my_booking/cubit/my_booking_cubit.dart     |  62 ++-
 .../lib/my_booking/my_booking_page.dart            |   2 +-
 .../lib/my_booking/my_booking_route.dart           |  53 ++
 .../my_booking/pages/my_booking_payment_page.dart  |   2 +-
 .../notifications/cubit/notifications_cubit.dart   | 142 +++---
 .../lib/notifications/notifications_route.dart     |  18 +
 .../components/booking_list_item_view.dart         |  59 ++-
 .../components/current_booking_list_item_view.dart | 154 +++---
 .../overview/components/find_booking_button.dart   |   2 +-
 .../overview/components/room_selection_widget.dart |   2 +-
 comwell_key_app/lib/overview/overview_page.dart    |   4 +-
 comwell_key_app/lib/overview/overview_route.dart   |  52 +-
 .../past_cancelled_booking_detail_page.dart        | 184 -------
 .../pregistration/cubit/preregistration_cubit.dart | 261 +++++-----
 .../lib/pregistration/preregistration_route.dart   |  18 +
 .../past_cancelled_booking_detail_page.dart        | 196 ++++++++
 .../past_cancelled_booking_detail_route.dart       |  15 +
 .../payment_processing_route.dart                  |  32 ++
 .../screens/room_info/room_info_route.dart         |  20 +
 .../screens/share_room/share_room_page.dart        |  23 +
 .../screens/share_room/share_room_route.dart       |  18 +
 .../profile/components/profile_page_widget.dart    |  14 +-
 .../cubit/received_shared_booking_cubit.dart       |  22 +-
 .../received_shared_booking_route.dart             |  23 +
 .../cubit/received_shared_room_cubit.dart          |  21 +-
 .../received_shared_room_route.dart                |  23 +
 .../lib/redeem_debug/bloc/redeem_cubit.dart        |  35 --
 comwell_key_app/lib/redeem_debug/redeem_page.dart  |  80 ---
 comwell_key_app/lib/redeem_debug/redeem_route.dart |   9 -
 .../widgets/invitation_code_formatter.dart         |  40 --
 .../widgets/invitation_code_textfield.dart         |  41 --
 comwell_key_app/lib/routing/app_router.dart        | 552 ++-------------------
 comwell_key_app/lib/routing/app_routes.dart        |  80 ++-
 comwell_key_app/lib/services/api.dart              |  77 ---
 .../lib/share/cubit/share_booking_cubit.dart       |  23 +-
 comwell_key_app/lib/share/share_booking_page.dart  |  54 +-
 comwell_key_app/lib/share/share_booking_route.dart |  18 +
 .../components/catalog/addon_upgrade_catalog.dart  |   4 +-
 .../components/catalog/room_upgrade_catalog.dart   |   6 +-
 .../components/catalog/service_catalog.dart        |   4 +-
 .../components/up_sales_catalog_button.dart        |   2 +-
 .../components/up_sales_continue_button.dart       |   2 +-
 .../lib/up_sales/cubit/up_sales_cubit.dart         |  37 +-
 .../pages/processing/up_sales_error_page.dart      |   2 +-
 .../pages/processing/up_sales_processing_page.dart |  58 +--
 .../lib/up_sales/pages/services_upgrade_page.dart  |  61 +--
 .../up_sales/pages/up_sale_confirmation_page.dart  |   2 +-
 comwell_key_app/lib/up_sales/up_sales_route.dart   | 114 +++++
 91 files changed, 2620 insertions(+), 2402 deletions(-)

Diff

diff --git a/comwell_key_app/lib/.generated/assets/assets.gen.dart b/comwell_key_app/lib/.generated/assets/assets.gen.dart
index baf03c86..6ee77802 100644
--- a/comwell_key_app/lib/.generated/assets/assets.gen.dart
+++ b/comwell_key_app/lib/.generated/assets/assets.gen.dart
@@ -17,17 +17,17 @@ import 'package:vector_graphics/vector_graphics.dart' as _vg;
class $EnvGen {
const $EnvGen();
- /// File path: env/.env.dev
- String get aEnvDev => 'env/.env.dev';
+ /// File path: env/.dev.env
+ String get aDev => 'env/.dev.env';
- /// File path: env/.env.prod
- String get aEnvProd => 'env/.env.prod';
+ /// File path: env/.prod.env
+ String get aProd => 'env/.prod.env';
- /// File path: env/.env.stage
- String get aEnvStage => 'env/.env.stage';
+ /// File path: env/.stage.env
+ String get aStage => 'env/.stage.env';
/// List of all assets
- List<String> get values => [aEnvDev, aEnvProd, aEnvStage];
+ List<String> get values => [aDev, aProd, aStage];
}
class $AssetsAnimationsGen {
diff --git a/comwell_key_app/lib/.generated/check_in/bloc/check_in_state.freezed.dart b/comwell_key_app/lib/.generated/check_in/bloc/check_in_state.freezed.dart
new file mode 100644
index 00000000..208bb28e
--- /dev/null
+++ b/comwell_key_app/lib/.generated/check_in/bloc/check_in_state.freezed.dart
@@ -0,0 +1,277 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// coverage:ignore-file
+// ignore_for_file: type=lint
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
+
+part of '../../../check_in/bloc/check_in_state.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+// dart format off
+T _$identity<T>(T value) => value;
+/// @nodoc
+mixin _$CheckInState {
+
+ bool get isLoading; CheckInStatus get cardState; String get roomNumber;
+/// Create a copy of CheckInState
+/// with the given fields replaced by the non-null parameter values.
+@JsonKey(includeFromJson: false, includeToJson: false)
+@pragma('vm:prefer-inline')
+$CheckInStateCopyWith<CheckInState> get copyWith => _$CheckInStateCopyWithImpl<CheckInState>(this as CheckInState, _$identity);
+
+
+
+@override
+bool operator ==(Object other) {
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is CheckInState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.cardState, cardState) || other.cardState == cardState)&&(identical(other.roomNumber, roomNumber) || other.roomNumber == roomNumber));
+}
+
+
+@override
+int get hashCode => Object.hash(runtimeType,isLoading,cardState,roomNumber);
+
+@override
+String toString() {
+ return 'CheckInState(isLoading: $isLoading, cardState: $cardState, roomNumber: $roomNumber)';
+}
+
+
+}
+
+/// @nodoc
+abstract mixin class $CheckInStateCopyWith<$Res> {
+ factory $CheckInStateCopyWith(CheckInState value, $Res Function(CheckInState) _then) = _$CheckInStateCopyWithImpl;
+@useResult
+$Res call({
+ bool isLoading, CheckInStatus cardState, String roomNumber
+});
+
+
+
+
+}
+/// @nodoc
+class _$CheckInStateCopyWithImpl<$Res>
+ implements $CheckInStateCopyWith<$Res> {
+ _$CheckInStateCopyWithImpl(this._self, this._then);
+
+ final CheckInState _self;
+ final $Res Function(CheckInState) _then;
+
+/// Create a copy of CheckInState
+/// with the given fields replaced by the non-null parameter values.
+@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? cardState = null,Object? roomNumber = null,}) {
+ return _then(_self.copyWith(
+isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
+as bool,cardState: null == cardState ? _self.cardState : cardState // ignore: cast_nullable_to_non_nullable
+as CheckInStatus,roomNumber: null == roomNumber ? _self.roomNumber : roomNumber // ignore: cast_nullable_to_non_nullable
+as String,
+ ));
+}
+
+}
+
+
+/// Adds pattern-matching-related methods to [CheckInState].
+extension CheckInStatePatterns on CheckInState {
+/// A variant of `map` that fallback to returning `orElse`.
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case final Subclass value:
+/// return ...;
+/// case _:
+/// return orElse();
+/// }
+/// ```
+
+@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CheckInState value)? $default,{required TResult orElse(),}){
+final _that = this;
+switch (_that) {
+case _CheckInState() when $default != null:
+return $default(_that);case _:
+ return orElse();
+
+}
+}
+/// A `switch`-like method, using callbacks.
+///
+/// Callbacks receives the raw object, upcasted.
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case final Subclass value:
+/// return ...;
+/// case final Subclass2 value:
+/// return ...;
+/// }
+/// ```
+
+@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CheckInState value) $default,){
+final _that = this;
+switch (_that) {
+case _CheckInState():
+return $default(_that);case _:
+ throw StateError('Unexpected subclass');
+
+}
+}
+/// A variant of `map` that fallback to returning `null`.
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case final Subclass value:
+/// return ...;
+/// case _:
+/// return null;
+/// }
+/// ```
+
+@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CheckInState value)? $default,){
+final _that = this;
+switch (_that) {
+case _CheckInState() when $default != null:
+return $default(_that);case _:
+ return null;
+
+}
+}
+/// A variant of `when` that fallback to an `orElse` callback.
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case Subclass(:final field):
+/// return ...;
+/// case _:
+/// return orElse();
+/// }
+/// ```
+
+@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, CheckInStatus cardState, String roomNumber)? $default,{required TResult orElse(),}) {final _that = this;
+switch (_that) {
+case _CheckInState() when $default != null:
+return $default(_that.isLoading,_that.cardState,_that.roomNumber);case _:
+ return orElse();
+
+}
+}
+/// A `switch`-like method, using callbacks.
+///
+/// As opposed to `map`, this offers destructuring.
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case Subclass(:final field):
+/// return ...;
+/// case Subclass2(:final field2):
+/// return ...;
+/// }
+/// ```
+
+@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, CheckInStatus cardState, String roomNumber) $default,) {final _that = this;
+switch (_that) {
+case _CheckInState():
+return $default(_that.isLoading,_that.cardState,_that.roomNumber);case _:
+ throw StateError('Unexpected subclass');
+
+}
+}
+/// A variant of `when` that fallback to returning `null`
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case Subclass(:final field):
+/// return ...;
+/// case _:
+/// return null;
+/// }
+/// ```
+
+@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, CheckInStatus cardState, String roomNumber)? $default,) {final _that = this;
+switch (_that) {
+case _CheckInState() when $default != null:
+return $default(_that.isLoading,_that.cardState,_that.roomNumber);case _:
+ return null;
+
+}
+}
+
+}
+
+/// @nodoc
+
+
+class _CheckInState extends CheckInState {
+ const _CheckInState({this.isLoading = false, this.cardState = CheckInStatus.loading, this.roomNumber = ""}): super._();
+
+
+@override@JsonKey() final bool isLoading;
+@override@JsonKey() final CheckInStatus cardState;
+@override@JsonKey() final String roomNumber;
+
+/// Create a copy of CheckInState
+/// with the given fields replaced by the non-null parameter values.
+@override @JsonKey(includeFromJson: false, includeToJson: false)
+@pragma('vm:prefer-inline')
+_$CheckInStateCopyWith<_CheckInState> get copyWith => __$CheckInStateCopyWithImpl<_CheckInState>(this, _$identity);
+
+
+
+@override
+bool operator ==(Object other) {
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is _CheckInState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.cardState, cardState) || other.cardState == cardState)&&(identical(other.roomNumber, roomNumber) || other.roomNumber == roomNumber));
+}
+
+
+@override
+int get hashCode => Object.hash(runtimeType,isLoading,cardState,roomNumber);
+
+@override
+String toString() {
+ return 'CheckInState(isLoading: $isLoading, cardState: $cardState, roomNumber: $roomNumber)';
+}
+
+
+}
+
+/// @nodoc
+abstract mixin class _$CheckInStateCopyWith<$Res> implements $CheckInStateCopyWith<$Res> {
+ factory _$CheckInStateCopyWith(_CheckInState value, $Res Function(_CheckInState) _then) = __$CheckInStateCopyWithImpl;
+@override @useResult
+$Res call({
+ bool isLoading, CheckInStatus cardState, String roomNumber
+});
+
+
+
+
+}
+/// @nodoc
+class __$CheckInStateCopyWithImpl<$Res>
+ implements _$CheckInStateCopyWith<$Res> {
+ __$CheckInStateCopyWithImpl(this._self, this._then);
+
+ final _CheckInState _self;
+ final $Res Function(_CheckInState) _then;
+
+/// Create a copy of CheckInState
+/// with the given fields replaced by the non-null parameter values.
+@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? cardState = null,Object? roomNumber = null,}) {
+ return _then(_CheckInState(
+isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
+as bool,cardState: null == cardState ? _self.cardState : cardState // ignore: cast_nullable_to_non_nullable
+as CheckInStatus,roomNumber: null == roomNumber ? _self.roomNumber : roomNumber // ignore: cast_nullable_to_non_nullable
+as String,
+ ));
+}
+
+
+}
+
+// dart format on
diff --git a/comwell_key_app/lib/.generated/choose_share_room/cubit/choose_share_room_state.freezed.dart b/comwell_key_app/lib/.generated/choose_share_room/cubit/choose_share_room_state.freezed.dart
new file mode 100644
index 00000000..320c8ec5
--- /dev/null
+++ b/comwell_key_app/lib/.generated/choose_share_room/cubit/choose_share_room_state.freezed.dart
@@ -0,0 +1,154 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// coverage:ignore-file
+// ignore_for_file: type=lint
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
+
+part of '../../../choose_share_room/cubit/choose_share_room_state.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+// dart format off
+T _$identity<T>(T value) => value;
+/// @nodoc
+mixin _$ChooseShareRoomState {
+
+ bool get isLoading; String get errorMessage; List<Room> get rooms;
+/// Create a copy of ChooseShareRoomState
+/// with the given fields replaced by the non-null parameter values.
+@JsonKey(includeFromJson: false, includeToJson: false)
+@pragma('vm:prefer-inline')
+$ChooseShareRoomStateCopyWith<ChooseShareRoomState> get copyWith => _$ChooseShareRoomStateCopyWithImpl<ChooseShareRoomState>(this as ChooseShareRoomState, _$identity);
+
+
+
+@override
+bool operator ==(Object other) {
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is ChooseShareRoomState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&const DeepCollectionEquality().equals(other.rooms, rooms));
+}
+
+
+@override
+int get hashCode => Object.hash(runtimeType,isLoading,errorMessage,const DeepCollectionEquality().hash(rooms));
+
+@override
+String toString() {
+ return 'ChooseShareRoomState(isLoading: $isLoading, errorMessage: $errorMessage, rooms: $rooms)';
+}
+
+
+}
+
+/// @nodoc
+abstract mixin class $ChooseShareRoomStateCopyWith<$Res> {
+ factory $ChooseShareRoomStateCopyWith(ChooseShareRoomState value, $Res Function(ChooseShareRoomState) _then) = _$ChooseShareRoomStateCopyWithImpl;
+@useResult
+$Res call({
+ bool isLoading, String errorMessage, List<Room> rooms
+});
+
+
+
+
+}
+/// @nodoc
+class _$ChooseShareRoomStateCopyWithImpl<$Res>
+ implements $ChooseShareRoomStateCopyWith<$Res> {
+ _$ChooseShareRoomStateCopyWithImpl(this._self, this._then);
+
+ final ChooseShareRoomState _self;
+ final $Res Function(ChooseShareRoomState) _then;
+
+/// Create a copy of ChooseShareRoomState
+/// with the given fields replaced by the non-null parameter values.
+@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? errorMessage = null,Object? rooms = null,}) {
+ return _then(_self.copyWith(
+isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
+as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
+as String,rooms: null == rooms ? _self.rooms : rooms // ignore: cast_nullable_to_non_nullable
+as List<Room>,
+ ));
+}
+
+}
+
+
+
+/// @nodoc
+
+
+class _ChooseShareRoomState implements ChooseShareRoomState {
+ const _ChooseShareRoomState({this.isLoading = false, this.errorMessage = "", final List<Room> rooms = const []}): _rooms = rooms;
+
+
+@override@JsonKey() final bool isLoading;
+@override@JsonKey() final String errorMessage;
+ final List<Room> _rooms;
+@override@JsonKey() List<Room> get rooms {
+ if (_rooms is EqualUnmodifiableListView) return _rooms;
+ // ignore: implicit_dynamic_type
+ return EqualUnmodifiableListView(_rooms);
+}
+
+
+/// Create a copy of ChooseShareRoomState
+/// with the given fields replaced by the non-null parameter values.
+@override @JsonKey(includeFromJson: false, includeToJson: false)
+@pragma('vm:prefer-inline')
+_$ChooseShareRoomStateCopyWith<_ChooseShareRoomState> get copyWith => __$ChooseShareRoomStateCopyWithImpl<_ChooseShareRoomState>(this, _$identity);
+
+
+
+@override
+bool operator ==(Object other) {
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChooseShareRoomState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&const DeepCollectionEquality().equals(other._rooms, _rooms));
+}
+
+
+@override
+int get hashCode => Object.hash(runtimeType,isLoading,errorMessage,const DeepCollectionEquality().hash(_rooms));
+
+@override
+String toString() {
+ return 'ChooseShareRoomState._(isLoading: $isLoading, errorMessage: $errorMessage, rooms: $rooms)';
+}
+
+
+}
+
+/// @nodoc
+abstract mixin class _$ChooseShareRoomStateCopyWith<$Res> implements $ChooseShareRoomStateCopyWith<$Res> {
+ factory _$ChooseShareRoomStateCopyWith(_ChooseShareRoomState value, $Res Function(_ChooseShareRoomState) _then) = __$ChooseShareRoomStateCopyWithImpl;
+@override @useResult
+$Res call({
+ bool isLoading, String errorMessage, List<Room> rooms
+});
+
+
+
+
+}
+/// @nodoc
+class __$ChooseShareRoomStateCopyWithImpl<$Res>
+ implements _$ChooseShareRoomStateCopyWith<$Res> {
+ __$ChooseShareRoomStateCopyWithImpl(this._self, this._then);
+
+ final _ChooseShareRoomState _self;
+ final $Res Function(_ChooseShareRoomState) _then;
+
+/// Create a copy of ChooseShareRoomState
+/// with the given fields replaced by the non-null parameter values.
+@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? errorMessage = null,Object? rooms = null,}) {
+ return _then(_ChooseShareRoomState(
+isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
+as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
+as String,rooms: null == rooms ? _self._rooms : rooms // ignore: cast_nullable_to_non_nullable
+as List<Room>,
+ ));
+}
+
+
+}
+
+// dart format on
diff --git a/comwell_key_app/lib/booking_details/booking_details_page.dart b/comwell_key_app/lib/booking_details/booking_details_page.dart
index 71bcb4d3..54c306fa 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -110,7 +110,7 @@ class BookingDetailsPage extends StatelessWidget {
BookingDetailsState state, BookingDetailsBloc cubit, ThemeData theme) {
return InkWell(
onTap: () async {
- await context.pushNamed(AppRoutes.myBooking.name, extra: cubit.booking);
+ await context.push(AppRoutes.myBooking, extra: cubit.booking);
cubit.add(const InitialEvent(fetchRemote: true));
},
child: Container(
diff --git a/comwell_key_app/lib/booking_details/booking_details_route.dart b/comwell_key_app/lib/booking_details/booking_details_route.dart
new file mode 100644
index 00000000..65b1f618
--- /dev/null
+++ b/comwell_key_app/lib/booking_details/booking_details_route.dart
@@ -0,0 +1,38 @@
+import 'package:comwell_key_app/booking_details/bloc/booking_details_bloc.dart';
+import 'package:comwell_key_app/booking_details/booking_details_page.dart';
+import 'package:comwell_key_app/find_booking/loading_page.dart';
+import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final bookingDetailsRoute = GoRoute(
+ path: AppRoutes.bookingDetails,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return BlocProvider<BookingDetailsBloc>(
+ create: (BuildContext context) => BookingDetailsBloc(
+ booking: booking,
+ locator(),
+ locator(),
+ locator(),
+ locator(),
+ locator(),
+ locator(),
+ ),
+ child: const BookingDetailsPage(),
+ );
+ },
+);
+
+final bookingDetailsWithIdRoute = GoRoute(
+ path: AppRoutes.bookingDetailsWithId,
+ builder: (context, state) {
+ final bookingId = state.pathParameters['id']!;
+ context.read<OverviewCubit>().findBookingById(bookingId);
+ return const LoadingPage();
+ },
+);
diff --git a/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart b/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart
index da00f389..b5fb2dc8 100644
--- a/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart
+++ b/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart
@@ -17,8 +17,8 @@ class BookingDetailsBottomSheet extends StatelessWidget {
final BookingDetailsBloc cubit;
final BookingDetailsState state;
- const BookingDetailsBottomSheet(
- {super.key, required this.cubit, required this.state});
+ const BookingDetailsBottomSheet({super.key, required this.cubit, required this.state});
+
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
@@ -60,8 +60,9 @@ class BookingDetailsBottomSheet extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: HousekeepingButton(
- key: ValueKey(state.isHouseKeepingOrdered),
- booking: cubit.booking),
+ key: ValueKey(state.isHouseKeepingOrdered),
+ booking: cubit.booking,
+ ),
),
],
),
@@ -70,57 +71,57 @@ class BookingDetailsBottomSheet extends StatelessWidget {
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text("booking_details_page_practical_information".tr(),
- style: theme.textTheme.headlineMedium),
+ child: Text(
+ "booking_details_page_practical_information".tr(),
+ style: theme.textTheme.headlineMedium,
+ ),
),
const SizedBox(height: 20),
- Row(children: [
- Expanded(
- child: AspectRatio(
- aspectRatio: 175 / 220,
- child: Padding(
- padding: const EdgeInsets.only(left: 16),
- child: PracticalInformationButton(
+ Row(
+ children: [
+ Expanded(
+ child: AspectRatio(
+ aspectRatio: 175 / 220,
+ child: Padding(
+ padding: const EdgeInsets.only(left: 16),
+ child: PracticalInformationButton(
iconPath: "assets/icons/ic_bed.svg",
- title:
- "booking_details_page_hotel_information_button_title"
- .tr(),
- subtitle:
- "booking_details_page_hotel_information_button_subtitle"
- .tr(),
+ title: "booking_details_page_hotel_information_button_title".tr(),
+ subtitle: "booking_details_page_hotel_information_button_subtitle".tr(),
onClick: () {
- context.pushNamed(AppRoutes.hotelInformation.name,
- extra: cubit.booking);
- }),
+ context.push(AppRoutes.hotelInformation, extra: cubit.booking);
+ },
+ ),
+ ),
),
),
- ),
- const SizedBox(width: 8),
- Expanded(
- child: AspectRatio(
- aspectRatio: 175 / 220,
- child: Padding(
- padding: const EdgeInsets.only(right: 16),
- child: PracticalInformationButton(
+ const SizedBox(width: 8),
+ Expanded(
+ child: AspectRatio(
+ aspectRatio: 175 / 220,
+ child: Padding(
+ padding: const EdgeInsets.only(right: 16),
+ child: PracticalInformationButton(
iconPath: "assets/icons/ic_telephone.svg",
title: "booking_details_page_contact_button_title".tr(),
- subtitle:
- "booking_details_page_contact_button_subtitle".tr(),
+ subtitle: "booking_details_page_contact_button_subtitle".tr(),
onClick: () {
- context.pushNamed(AppRoutes.contact.name,
- extra: cubit.booking);
- }),
+ context.push(AppRoutes.contact, extra: cubit.booking);
+ },
+ ),
+ ),
),
),
- ),
- ]),
+ ],
+ ),
const SizedBox(height: 16),
if (!isActive && cubit.user != null)
ComwellClubContainer(
- user: cubit.user!,
- onSignupClick: () {
- cubit.add(const InitialEvent(fetchRemote: true));
- }),
+ user: cubit.user!,
+ onSignupClick: () {
+ cubit.add(const InitialEvent(fetchRemote: true));
+ },
+ ),
const SizedBox(height: 16),
const SizedBox(height: 50),
],
@@ -128,8 +129,7 @@ class BookingDetailsBottomSheet extends StatelessWidget {
);
}
- Widget _buildUpSalesCatalogButton(
- ReservationStatus reservationStatus, BuildContext context) {
+ Widget _buildUpSalesCatalogButton(ReservationStatus reservationStatus, BuildContext context) {
switch (reservationStatus) {
case ReservationStatus.checkedin:
return const SizedBox();
@@ -148,10 +148,8 @@ class BookingDetailsBottomSheet extends StatelessWidget {
Widget _buildServices(BuildContext context) {
final theme = Theme.of(context);
- final serviceUpgrades = cubit.state.upSales?.addOnUpgrades
- .where((upgrade) => upgrade.isService)
- .toList() ??
- [];
+ final serviceUpgrades =
+ cubit.state.upSales?.addOnUpgrades.where((upgrade) => upgrade.isService).toList() ?? [];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -161,8 +159,7 @@ class BookingDetailsBottomSheet extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text('services'.tr(),
- style: theme.textTheme.headlineMedium),
+ child: Text('services'.tr(), style: theme.textTheme.headlineMedium),
),
const SizedBox(width: 8),
ComwellErrorWidget(
@@ -178,8 +175,7 @@ class BookingDetailsBottomSheet extends StatelessWidget {
if (state.upSales?.addOnUpgrades.isNotEmpty ?? false) ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text('services'.tr(),
- style: theme.textTheme.headlineMedium),
+ child: Text('services'.tr(), style: theme.textTheme.headlineMedium),
),
const SizedBox(width: 8),
Padding(
@@ -187,8 +183,10 @@ class BookingDetailsBottomSheet extends StatelessWidget {
child: OutlinedPillButton(
text: 'up_sales_see_all'.tr(),
onTap: () async {
- await context.pushNamed(AppRoutes.upSalesCatalog.name,
- extra: [cubit.booking]);
+ await context.push(
+ AppRoutes.upSalesCatalog,
+ extra: [cubit.booking],
+ );
cubit.add(const InitialEvent());
},
),
@@ -200,18 +198,19 @@ class BookingDetailsBottomSheet extends StatelessWidget {
const SizedBox(height: 16),
if (serviceUpgrades.isNotEmpty)
ServiceCatalog(
- bookingDetailsBloc: cubit,
- booking: cubit.booking,
- upSales: serviceUpgrades,
- height: 252,
- showRadioButton: false,
- isSinglePurchase: true,
- onTap: (upgrade) {
- // No OP
- },
- onServiceSelected: (upgrade, isSelected) {
- // No OP
- }),
+ bookingDetailsBloc: cubit,
+ booking: cubit.booking,
+ upSales: serviceUpgrades,
+ height: 252,
+ showRadioButton: false,
+ isSinglePurchase: true,
+ onTap: (upgrade) {
+ // No OP
+ },
+ onServiceSelected: (upgrade, isSelected) {
+ // No OP
+ },
+ ),
],
);
}
diff --git a/comwell_key_app/lib/booking_details/components/check_in_button.dart b/comwell_key_app/lib/booking_details/components/check_in_button.dart
index fe62a22f..0302aa53 100644
--- a/comwell_key_app/lib/booking_details/components/check_in_button.dart
+++ b/comwell_key_app/lib/booking_details/components/check_in_button.dart
@@ -24,8 +24,7 @@ class CheckInButton extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 10),
child: ElevatedButton(
onPressed: () async {
- final (result) = await context
- .pushNamed(AppRoutes.checkIn.name, extra: [bloc.booking, false]);
+ final (result) = await context.push(AppRoutes.checkIn, extra: [bloc.booking, false]);
if (result == true && !bloc.isClosed) {
bloc.add(CheckInEvent());
}
@@ -42,22 +41,20 @@ class CheckInButton extends StatelessWidget {
children: [
Text(
"check_in".tr(),
- style: Theme.of(context)
- .textTheme
- .titleMedium
- ?.copyWith(color: colorBackground),
+ style: Theme.of(
+ context,
+ ).textTheme.titleMedium?.copyWith(color: colorBackground),
),
Text(
"overview_page_check_in_button_subtitle".tr(),
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorBackground),
+ style: Theme.of(
+ context,
+ ).textTheme.bodySmall?.copyWith(color: colorBackground),
softWrap: true,
),
],
),
- )
+ ),
],
),
),
@@ -84,22 +81,18 @@ class CheckInButton extends StatelessWidget {
children: [
Text(
"check_in".tr(),
- style: Theme.of(context)
- .textTheme
- .titleMedium
- ?.copyWith(color: colorBackground),
+ style: Theme.of(
+ context,
+ ).textTheme.titleMedium?.copyWith(color: colorBackground),
),
Text(
"overview_page_check_in_physical_card_subtitle".tr(),
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorBackground),
+ style: Theme.of(context).textTheme.bodySmall?.copyWith(color: colorBackground),
softWrap: true,
),
],
),
- )
+ ),
],
),
),
diff --git a/comwell_key_app/lib/booking_details/components/check_out_button.dart b/comwell_key_app/lib/booking_details/components/check_out_button.dart
index 49563c82..381d51e0 100644
--- a/comwell_key_app/lib/booking_details/components/check_out_button.dart
+++ b/comwell_key_app/lib/booking_details/components/check_out_button.dart
@@ -24,7 +24,7 @@ class CheckOutButton extends StatelessWidget {
child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(15)),
onTap: () async {
- await context.pushNamed(AppRoutes.checkOut.name,
+ await context.push(AppRoutes.checkOut,
extra: cubit.booking);
cubit.add(const InitialEvent());
},
diff --git a/comwell_key_app/lib/booking_details/components/get_keys_button.dart b/comwell_key_app/lib/booking_details/components/get_keys_button.dart
index eddd6d56..1988e354 100644
--- a/comwell_key_app/lib/booking_details/components/get_keys_button.dart
+++ b/comwell_key_app/lib/booking_details/components/get_keys_button.dart
@@ -19,7 +19,7 @@ class GetKeysButton extends StatelessWidget {
child: ElevatedButton(
onPressed: () async {
const bool onlyKeys = true;
- final (result) = await context.pushNamed(AppRoutes.checkIn.name, extra: [bloc.booking, onlyKeys],);
+ final (result) = await context.push(AppRoutes.checkIn, extra: [bloc.booking, onlyKeys],);
if (result == true && !bloc.isClosed) {
bloc.add(CheckInEvent());
}
diff --git a/comwell_key_app/lib/booking_details/components/housekeeping_button.dart b/comwell_key_app/lib/booking_details/components/housekeeping_button.dart
index 899592ee..35a0848d 100644
--- a/comwell_key_app/lib/booking_details/components/housekeeping_button.dart
+++ b/comwell_key_app/lib/booking_details/components/housekeeping_button.dart
@@ -30,7 +30,7 @@ class HousekeepingButton extends StatelessWidget {
onTap: () async {
if (bloc.state.isHouseKeepingOrdered) return;
- final result = await context.pushNamed(AppRoutes.houseKeeping.name,
+ final result = await context.push(AppRoutes.houseKeeping,
extra: booking);
if (result != null && !bloc.isClosed) {
bloc.add(OrderHouseKeepingEvent(result as List<String>));
diff --git a/comwell_key_app/lib/booking_details/components/preregister_button.dart b/comwell_key_app/lib/booking_details/components/preregister_button.dart
index 03237e5b..b4aacfb2 100644
--- a/comwell_key_app/lib/booking_details/components/preregister_button.dart
+++ b/comwell_key_app/lib/booking_details/components/preregister_button.dart
@@ -22,8 +22,8 @@ class PreregisterButton extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 8),
child: ElevatedButton(
onPressed: () async {
- final (result) = await context.pushNamed(
- AppRoutes.preregistration.name,
+ final (result) = await context.push(
+ AppRoutes.preregistration,
extra: [bloc.booking, bloc.state.upSales]);
if (result != null) {
bloc.add(PreregisterEvent());
diff --git a/comwell_key_app/lib/booking_details/components/share_button.dart b/comwell_key_app/lib/booking_details/components/share_button.dart
index 771c08de..2b64cb6e 100644
--- a/comwell_key_app/lib/booking_details/components/share_button.dart
+++ b/comwell_key_app/lib/booking_details/components/share_button.dart
@@ -1,9 +1,11 @@
import 'package:comwell_key_app/booking_details/bloc/booking_details_bloc.dart';
import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/overview/models/guest.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/booking_details/components/guest_list.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:comwell_key_app/utils/locator.dart';
import 'package:comwell_key_app/utils/share_button_utils.dart';
import 'package:comwell_key_app/share/cubit/share_booking_cubit.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -54,7 +56,7 @@ class ShareButton extends StatelessWidget {
height: userButtonSize,
child: ElevatedButton(
onPressed: () {
- context.pushNamed(AppRoutes.shareBooking.name, extra: booking);
+ context.push(AppRoutes.shareBooking, extra: booking);
},
style: ElevatedButton.styleFrom(
backgroundColor: buttonColor ?? sandColor[10],
@@ -88,7 +90,7 @@ class ShareButton extends StatelessWidget {
context,
index,
guests,
- "${booking.firstName} ${booking.lastName}",
+ booking,
);
if (results is List<String>) {
@@ -128,7 +130,7 @@ class ShareButton extends StatelessWidget {
BuildContext context,
int index,
List<Guest> guests,
- String booker,
+ Booking booking,
) async {
final theme = Theme.of(context);
final selectedGuests = guests.map((e) => e.id.toString()).toList();
@@ -138,7 +140,7 @@ class ShareButton extends StatelessWidget {
isScrollControlled: false,
builder: (BuildContext bottomSheetContext) {
return BlocProvider(
- create: (context) => ShareBookingCubit(),
+ create: (context) => ShareBookingCubit(locator(), booking: booking),
child: BlocConsumer<ShareBookingCubit, ShareBookingState>(
listener: (context, state) {},
builder: (context, state) {
diff --git a/comwell_key_app/lib/booking_details/components/unlock_room_button.dart b/comwell_key_app/lib/booking_details/components/unlock_room_button.dart
index da626451..d01e1cfc 100644
--- a/comwell_key_app/lib/booking_details/components/unlock_room_button.dart
+++ b/comwell_key_app/lib/booking_details/components/unlock_room_button.dart
@@ -29,7 +29,7 @@ class UnlockRoomButton extends StatelessWidget {
),
),
action: () async {
- context.pushNamed(AppRoutes.key.name, extra: roomNumber);
+ context.push(AppRoutes.key, extra: roomNumber);
return false;
},
alignLabel: Alignment.center,
diff --git a/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart b/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
index efb88937..45dab4e0 100644
--- a/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
+++ b/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
@@ -1,83 +1,75 @@
-import 'package:bloc/bloc.dart';
+import 'package:comwell_key_app/base/base_cubit.dart';
import 'package:comwell_key_app/check_in/bloc/check_in_state.dart';
import 'package:comwell_key_app/check_in/check_in_repository.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:flutter/foundation.dart';
-class CheckInCubit extends Cubit<CheckInState> {
+class CheckInCubit extends BaseCubit<CheckInState> {
final _checkInRepository = CheckInRepository();
late final Booking booking;
- CheckInCubit(this.booking) : super(CheckInState.initial()) {
+ CheckInCubit(this.booking) : super(const CheckInState()) {
init();
}
- CheckInCubit.initialOnlyKeys(this.booking) : super(CheckInState.initial()) {
+ CheckInCubit.initialOnlyKeys(this.booking) : super(const CheckInState()) {
initOnlyKeys();
}
Future<void> initOnlyKeys() async {
try {
- final bookingDetails = await _checkInRepository.getBookingDetails(booking.id, booking.hotelCode);
- emit(state.checkInStatusRoomFound(roomNumber: bookingDetails.roomNumber));
- debugPrint("bookingDetails ${bookingDetails.roomNumber}");
+ final bookingDetails = await _checkInRepository.getBookingDetails(
+ booking.id,
+ booking.hotelCode,
+ );
+ safeEmit(state.copyWith(roomNumber: bookingDetails.roomNumber));
await _checkInRepository.checkIfSetup();
- debugPrint("checkIfSetup");
await _checkInRepository.provisionKey(booking.id, booking.hotelCode);
await Future<void>.delayed(const Duration(milliseconds: 3000));
- await tryGetKeys();
- emit(state.checkInStatusYourDigitalCard(roomNumber: bookingDetails.roomNumber));
- debugPrint("checkInStatusYourDigitalCard");
+ await _tryGetKeys();
+ safeEmit(state.copyWith(roomNumber: bookingDetails.roomNumber));
} catch (err, st) {
- if (kDebugMode) print("qqq err=$err, $st");
- emit(state.checkInStatusError(Exception(err.toString())));
+ logError(err, st);
+ safeEmit(state.copyWith(cardState: CheckInStatus.error));
}
}
Future<void> init() async {
try {
await Future<void>.delayed(const Duration(milliseconds: 500));
- emit(state.checkInStatusLoading());
+ safeEmit(state.copyWith(isLoading: true));
await _checkInRepository.checkIn(booking.confirmationNumber);
- final bookingDetails = await _checkInRepository.getBookingDetails(booking.id, booking.hotelCode);
- emit(state.checkInStatusRoomFound(roomNumber: bookingDetails.roomNumber));
+ final bookingDetails = await _checkInRepository.getBookingDetails(
+ booking.id,
+ booking.hotelCode,
+ );
+ safeEmit(state.copyWith(cardState: CheckInStatus.roomFound));
await _checkInRepository.checkIfSetup();
await _checkInRepository.provisionKey(booking.id, booking.hotelCode);
await Future<void>.delayed(const Duration(milliseconds: 3000));
- await tryGetKeys();
-
+ await _tryGetKeys();
await Future<void>.delayed(const Duration(milliseconds: 1000));
- emit(state.checkInStatusYourDigitalCard(roomNumber: bookingDetails.roomNumber));
- } catch (err, st) {
- if (kDebugMode) print("qqq err=$err, $st");
- emit(state.setLoading(false));
- emit(state.checkInStatusError(Exception(err.toString())));
- }
- }
-
- Future<void> onDonePressed() async {
- emit(state.checkInStatusLoading());
- try {
- emit(state.checkInStatusDone());
+ safeEmit(state.copyWith(roomNumber: bookingDetails.roomNumber));
} catch (err, st) {
- if (kDebugMode) print("qqq err=$err, $st");
- emit(state.checkInStatusError(Exception(err.toString())));
+ logError(err, st);
+ safeEmit(state.copyWith(cardState: CheckInStatus.error));
+ } finally {
+ safeEmit(state.copyWith(isLoading: false));
}
}
- Future<void> tryGetKeys({int attempt = 0}) async {
+ Future<void> _tryGetKeys({int attempt = 0}) async {
try {
await _checkInRepository.getKeys(booking.id, booking.hotelCode);
} catch (e) {
- if (attempt < getKeysRetryAttempts) {
+ if (attempt < _getKeysRetryAttempts) {
await Future<void>.delayed(const Duration(milliseconds: 500));
- tryGetKeys(attempt: attempt + 1);
+ await _tryGetKeys(attempt: attempt + 1);
} else {
- emit(state.checkInStatusError(Exception(e.toString())));
+ rethrow;
}
}
}
- static const getKeysRetryAttempts = 3;
+ static const _getKeysRetryAttempts = 3;
}
diff --git a/comwell_key_app/lib/check_in/bloc/check_in_state.dart b/comwell_key_app/lib/check_in/bloc/check_in_state.dart
index b5adc533..0a92a430 100644
--- a/comwell_key_app/lib/check_in/bloc/check_in_state.dart
+++ b/comwell_key_app/lib/check_in/bloc/check_in_state.dart
@@ -1,113 +1,44 @@
import 'package:easy_localization/easy_localization.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
-import '../../overview/models/booking.dart';
+part '../../.generated/check_in/bloc/check_in_state.freezed.dart';
-class CheckInState {
- final bool loading;
- final CheckInStatus checkInStatus;
+enum CheckInStatus {
+ loading,
+ roomFound,
+ done,
+ error,
+}
- CheckInState._({
- required this.checkInStatus,
- required this.loading,
- });
+@freezed
+abstract class CheckInState with _$CheckInState {
+ const factory CheckInState({
+ @Default(false) bool isLoading,
+ @Default(CheckInStatus.loading) CheckInStatus cardState,
+ @Default("") String roomNumber,
+ }) = _CheckInState;
- CheckInState.initial()
- : this._(
- checkInStatus: CheckInStatusInitial(),
- loading: true,
- );
+ CheckInState._();
String get titleStringId {
- switch (checkInStatus) {
- case CheckInStatusInitial _:
- return "";
- case CheckInStatusLoading _:
+ switch (cardState) {
+ case CheckInStatus.loading:
return "check_in_loading_title".tr();
- case CheckInStatusRoomFound _:
+ case CheckInStatus.roomFound:
return "check_in_room_found_title".tr();
- case CheckInStatusYourDigitalCard _:
+ case CheckInStatus.done:
return "check_in_your_digital_card_title".tr();
- case CheckInStatusRoomNotFound _:
- return "check_in_room_not_found_title".tr();
- case CheckInStatusError _:
+ case CheckInStatus.error:
return "check_in_error_title".tr();
- case CheckInStatusDone _:
- return "check_in_done_title".tr();
}
}
String get subtitleStringId {
- switch (checkInStatus) {
- case CheckInStatusYourDigitalCard _:
+ switch (cardState) {
+ case CheckInStatus.done:
return "check_in_your_digital_card_subtitle".tr();
default:
return "";
}
}
-
- CheckInState setLoading(bool loading) => _copyWith(loading: loading);
-
- CheckInState checkInStatusInitial() =>
- _copyWith(checkInStatus: CheckInStatusInitial());
-
- CheckInState checkInStatusLoading() =>
- _copyWith(checkInStatus: CheckInStatusLoading());
-
- CheckInState checkInStatusRoomFound({required String roomNumber}) =>
- _copyWith(checkInStatus: CheckInStatusRoomFound(roomNumber: roomNumber));
-
- CheckInState checkInStatusYourDigitalCard({required String roomNumber}) =>
- _copyWith(
- checkInStatus: CheckInStatusYourDigitalCard(roomNumber: roomNumber));
-
- CheckInState checkInStatusRoomNotFound() =>
- _copyWith(checkInStatus: CheckInStatusRoomNotFound());
-
- CheckInState checkInStatusError(Exception exception) =>
- _copyWith(checkInStatus: CheckInStatusError(exception: exception), loading: false);
-
- CheckInState checkInStatusDone() =>
- _copyWith(checkInStatus: CheckInStatusDone());
-
- CheckInState bookingLoaded({required Booking booking}) =>
- _copyWith(booking: booking);
-
- CheckInState _copyWith({
- CheckInStatus? checkInStatus,
- Booking? booking,
- bool? loading,
- }) {
- return CheckInState._(
- checkInStatus: checkInStatus ?? this.checkInStatus,
- loading: loading ?? this.loading,
- );
- }
-}
-
-sealed class CheckInStatus {}
-
-final class CheckInStatusInitial extends CheckInStatus {}
-
-final class CheckInStatusLoading extends CheckInStatus {}
-
-final class CheckInStatusRoomFound extends CheckInStatus {
- final String roomNumber;
-
- CheckInStatusRoomFound({required this.roomNumber});
-}
-
-final class CheckInStatusRoomNotFound extends CheckInStatus {}
-
-final class CheckInStatusYourDigitalCard extends CheckInStatus {
- final String roomNumber;
-
- CheckInStatusYourDigitalCard({required this.roomNumber});
-}
-
-final class CheckInStatusDone extends CheckInStatus {}
-
-final class CheckInStatusError extends CheckInStatus {
- final Exception exception;
-
- CheckInStatusError({required this.exception});
}
diff --git a/comwell_key_app/lib/check_in/check_in_page.dart b/comwell_key_app/lib/check_in/check_in_page.dart
index 6623d078..05ae6a51 100644
--- a/comwell_key_app/lib/check_in/check_in_page.dart
+++ b/comwell_key_app/lib/check_in/check_in_page.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/.generated/assets/assets.gen.dart';
import 'package:comwell_key_app/check_in/bloc/check_in_cubit.dart';
import 'package:comwell_key_app/check_in/bloc/check_in_state.dart';
import 'package:comwell_key_app/common/components/comwell_card_component.dart';
@@ -16,9 +17,7 @@ class CheckInPage extends StatefulWidget {
State<CheckInPage> createState() => _CheckInPageState();
}
-class _CheckInPageState extends State<CheckInPage>
- with SingleTickerProviderStateMixin {
- var animationDone = false;
+class _CheckInPageState extends State<CheckInPage> with SingleTickerProviderStateMixin {
LottieComposition? loadingComposition;
late final AnimationController animationController;
late final Widget loadingAnimation;
@@ -27,7 +26,7 @@ class _CheckInPageState extends State<CheckInPage>
void initState() {
animationController = AnimationController(vsync: this);
loadingAnimation = Lottie.asset(
- 'assets/animations/load_animation.json',
+ Assets.animations.loadAnimation,
controller: animationController,
onLoaded: (composition) {
if (loadingComposition == null) {
@@ -53,8 +52,12 @@ class _CheckInPageState extends State<CheckInPage>
}
void playLoading() {
- loadingComposition?.playBetween(animationController, "spinner",
- markerEnd: "success", repeat: true);
+ loadingComposition?.playBetween(
+ animationController,
+ "spinner",
+ markerEnd: "success",
+ repeat: true,
+ );
}
void playError() {
@@ -62,8 +65,7 @@ class _CheckInPageState extends State<CheckInPage>
}
void playSuccess() {
- loadingComposition?.playBetween(animationController, "success",
- markerEnd: "error");
+ loadingComposition?.playBetween(animationController, "success", markerEnd: "error");
}
double getCardPosition(BuildContext context) {
@@ -73,12 +75,11 @@ class _CheckInPageState extends State<CheckInPage>
final padding = mq.viewPadding;
final height = mq.size.height;
final startPosition = height - padding.bottom - padding.top - 100;
- switch (state.checkInStatus) {
- case CheckInStatusLoading _:
- case CheckInStatusError _:
- case CheckInStatusRoomFound _:
+ switch (state.cardState) {
+ case CheckInStatus.loading:
+ case CheckInStatus.error:
return height / 2 - 100;
- case CheckInStatusYourDigitalCard _:
+ case CheckInStatus.done:
return 100;
case _:
return startPosition;
@@ -87,18 +88,19 @@ class _CheckInPageState extends State<CheckInPage>
Widget getCardContent(BuildContext context) {
final cubit = context.read<CheckInCubit>();
- if (cubit.state.checkInStatus is CheckInStatusYourDigitalCard) {
+ if (cubit.state.cardState == CheckInStatus.done) {
return Container(
decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(30)),
- border: Border.all(color: colorBackground, width: 2)),
+ borderRadius: const BorderRadius.all(Radius.circular(30)),
+ border: Border.all(color: colorBackground, width: 2),
+ ),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"${"check_in_your_digital_card_room_prefix".tr()} ${(cubit.booking.roomNumber)}",
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
- color: colorBackground,
- ),
+ color: colorBackground,
+ ),
),
),
);
@@ -112,147 +114,154 @@ class _CheckInPageState extends State<CheckInPage>
final cubit = context.read<CheckInCubit>();
final theme = Theme.of(context);
- return BlocConsumer<CheckInCubit, CheckInState>(listener: (context, state) {
- switch (state.checkInStatus) {
- case CheckInStatusInitial _:
- playLoading();
- break;
- case CheckInStatusRoomFound _:
- playSuccess();
- break;
- case CheckInStatusError _:
- playError();
- break;
- default:
- break;
- }
- }, builder: (context, state) {
- return Scaffold(
- body: SafeArea(
- child: Builder(builder: (context) {
- final position = getCardPosition(context);
- return Stack(
- fit: StackFit.expand,
- children: [
- AnimatedPositioned(
- duration: const Duration(milliseconds: 200),
- top: position,
- left: 16,
- right: 16,
- curve: Easing.linear,
- onEnd: onAnimationEnd,
- child: ComwellCard(content: getCardContent(context)),
- ),
- if (state.checkInStatus is CheckInStatusError)
- Align(
- alignment: Alignment.bottomCenter,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const SizedBox(height: 15),
- Text("check_in_page_error_title".tr(),
- textAlign: TextAlign.center,
- style: theme.textTheme.headlineMedium
- ?.copyWith(color: colorHeadlineText)),
- const SizedBox(height: 15),
- Text("check_in_page_error_subtitle".tr(),
- textAlign: TextAlign.center,
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- const SizedBox(height: 15),
- Text(state.subtitleStringId,
- style: theme.textTheme.bodySmall),
- const SizedBox(height: 15),
- const Divider(
- color: colorDivider,
- height: 0,
- ),
- Row(
+ return BlocConsumer<CheckInCubit, CheckInState>(
+ listener: (context, state) {
+ switch (state.cardState) {
+ case CheckInStatus.loading:
+ playLoading();
+ break;
+ case CheckInStatus.roomFound:
+ playSuccess();
+ break;
+ case CheckInStatus.error:
+ playError();
+ break;
+ default:
+ break;
+ }
+ },
+ builder: (context, state) {
+ return Scaffold(
+ body: SafeArea(
+ child: Builder(
+ builder: (context) {
+ final position = getCardPosition(context);
+ return Stack(
+ fit: StackFit.expand,
+ children: [
+ AnimatedPositioned(
+ duration: const Duration(milliseconds: 200),
+ top: position,
+ left: 16,
+ right: 16,
+ curve: Easing.linear,
+ onEnd: onAnimationEnd,
+ child: ComwellCard(content: getCardContent(context)),
+ ),
+ if (state.cardState == CheckInStatus.error)
+ Align(
+ alignment: Alignment.bottomCenter,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: ElevatedButton(
- onPressed: () {
- context.pop();
- },
- style: ButtonStyle(
- backgroundColor:
- WidgetStatePropertyAll(sandColor[80]),
- foregroundColor:
- const WidgetStatePropertyAll(
- colorBackground)),
+ const SizedBox(height: 15),
+ Text(
+ "check_in_page_error_title".tr(),
+ textAlign: TextAlign.center,
+ style: theme.textTheme.headlineMedium?.copyWith(
+ color: colorHeadlineText,
+ ),
+ ),
+ const SizedBox(height: 15),
+ Text(
+ "check_in_page_error_subtitle".tr(),
+ textAlign: TextAlign.center,
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ const SizedBox(height: 15),
+ Text(state.subtitleStringId, style: theme.textTheme.bodySmall),
+ const SizedBox(height: 15),
+ const Divider(
+ color: colorDivider,
+ height: 0,
+ ),
+ Row(
+ children: [
+ Expanded(
child: Padding(
- padding: const EdgeInsets.symmetric(
- vertical: 16.0),
- child: Text("generic_continue".tr()),
+ padding: const EdgeInsets.all(16.0),
+ child: ElevatedButton(
+ onPressed: () {
+ context.pop();
+ },
+ style: ButtonStyle(
+ backgroundColor: WidgetStatePropertyAll(sandColor[80]),
+ foregroundColor: const WidgetStatePropertyAll(
+ colorBackground,
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 16.0),
+ child: Text("generic_continue".tr()),
+ ),
+ ),
),
),
- ),
+ ],
),
],
),
- ],
- ),
- ),
- if (state.checkInStatus is CheckInStatusYourDigitalCard)
- Align(
- alignment: Alignment.bottomCenter,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text("check_in_your_digital_card_nb".tr(),
- textAlign: TextAlign.center,
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- ),
- const SizedBox(height: 15),
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text(state.subtitleStringId,
- style: theme.textTheme.bodySmall),
- ),
- const SizedBox(height: 15),
- const Divider(
- color: colorDivider,
- height: 0,
- ),
- Row(
+ ),
+ if (state.cardState == CheckInStatus.done)
+ Align(
+ alignment: Alignment.bottomCenter,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: ElevatedButton(
- onPressed: () {
- cubit.onDonePressed();
- context.pop(true);
- },
- style: ButtonStyle(
- backgroundColor:
- WidgetStatePropertyAll(sandColor[80]),
- foregroundColor:
- const WidgetStatePropertyAll(
- colorBackground)),
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(
+ "check_in_your_digital_card_nb".tr(),
+ textAlign: TextAlign.center,
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: colorHeadlineText,
+ ),
+ ),
+ ),
+ const SizedBox(height: 15),
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(state.subtitleStringId, style: theme.textTheme.bodySmall),
+ ),
+ const SizedBox(height: 15),
+ const Divider(
+ color: colorDivider,
+ height: 0,
+ ),
+ Row(
+ children: [
+ Expanded(
child: Padding(
- padding: const EdgeInsets.symmetric(
- vertical: 16.0),
- child: Text("generic_done".tr()),
+ padding: const EdgeInsets.all(16.0),
+ child: ElevatedButton(
+ onPressed: () {
+ context.pop(true);
+ },
+ style: ButtonStyle(
+ backgroundColor: WidgetStatePropertyAll(sandColor[80]),
+ foregroundColor: const WidgetStatePropertyAll(
+ colorBackground,
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 16.0),
+ child: Text("generic_done".tr()),
+ ),
+ ),
),
),
- ),
+ ],
),
],
),
- ],
- ),
- )
- ],
- );
- }),
- ),
- );
- });
+ ),
+ ],
+ );
+ },
+ ),
+ ),
+ );
+ },
+ );
}
}
diff --git a/comwell_key_app/lib/check_in/check_in_route.dart b/comwell_key_app/lib/check_in/check_in_route.dart
new file mode 100644
index 00000000..f5e898b0
--- /dev/null
+++ b/comwell_key_app/lib/check_in/check_in_route.dart
@@ -0,0 +1,24 @@
+import 'package:comwell_key_app/check_in/bloc/check_in_cubit.dart';
+import 'package:comwell_key_app/check_in/check_in_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final checkInRoute = GoRoute(
+ path: AppRoutes.checkIn,
+ builder: (context, state) {
+ return BlocProvider(
+ create: (context) {
+ final extras = state.extra as List<dynamic>;
+ final booking = extras[0] as Booking;
+ final onlyKeys = extras[1] as bool;
+ if (onlyKeys) {
+ return CheckInCubit.initialOnlyKeys(booking);
+ }
+ return CheckInCubit(booking);
+ },
+ child: const CheckInPage(),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
index 67243db3..e5335925 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
@@ -20,8 +20,7 @@ import 'package:url_launcher/url_launcher.dart';
class CheckoutCubit extends Cubit<CheckoutState> {
final ProfileRepository profileRepository = locator<ProfileRepository>();
- final PreregistrationRepository preregistrationRepository =
- locator<PreregistrationRepository>();
+ final PreregistrationRepository preregistrationRepository = locator<PreregistrationRepository>();
final BookingDetailsRepository bookingDetailsRepository = locator<BookingDetailsRepository>();
final CheckOutRepository checkOutRepository;
final _tracking = locator<ComwellTracking>();
@@ -30,12 +29,10 @@ class CheckoutCubit extends Cubit<CheckoutState> {
late Booking booking;
final PaymentCubit paymentServicesCubit;
- CheckoutPage get currentPage =>
- CheckoutPage.fromIndex(pageController.page?.toInt() ?? 0);
+ CheckoutPage get currentPage => CheckoutPage.fromIndex(pageController.page?.toInt() ?? 0);
- CheckoutCubit(
- this.booking, this.checkOutRepository, this.paymentServicesCubit)
- : super(CheckoutState.initial(booking.balance ?? 0));
+ CheckoutCubit(this.booking, this.checkOutRepository, this.paymentServicesCubit)
+ : super(CheckoutState.initial(booking.balance ?? 0));
void init() async {
try {
@@ -43,7 +40,10 @@ class CheckoutCubit extends Cubit<CheckoutState> {
emit(state.loading());
final user = await profileRepository.fetchProfileSettings();
emit(state.clubPointsFetched(user.points));
- booking =await bookingDetailsRepository.getRemoteBookingDetails(booking.confirmationNumber, booking.hotelCode);
+ booking = await bookingDetailsRepository.getRemoteBookingDetails(
+ booking.confirmationNumber,
+ booking.hotelCode,
+ );
setItems(booking.addOnItems ?? []);
emit(state.loaded());
} catch (e) {
@@ -65,19 +65,24 @@ class CheckoutCubit extends Cubit<CheckoutState> {
Future<void> processPayment() async {
final analyticsEventItem = AnalyticsEventItem(
- hotelName: booking.hotelName,
- currency: "DKK",
- value: booking.balance?.toInt() ?? 0,
- placement: "placement",
- items: booking.addOnItems?.map((e) => e.description).toList() ?? [],
- itemId: "itemId",
- itemName: "itemName",
- price: booking.balance?.toInt() ?? 0,
- quantity: 1);
+ hotelName: booking.hotelName,
+ currency: "DKK",
+ value: booking.balance?.toInt() ?? 0,
+ placement: "placement",
+ items: booking.addOnItems?.map((e) => e.description).toList() ?? [],
+ itemId: "itemId",
+ itemName: "itemName",
+ price: booking.balance?.toInt() ?? 0,
+ quantity: 1,
+ );
_tracking.trackBeginCheckout(analyticsEventItem);
try {
- await paymentServicesCubit.createSession(booking.balance?.toInt() ?? 0,
- booking.confirmationNumber, state.applyClubPoints, booking.hotelCode);
+ await paymentServicesCubit.createSession(
+ booking.balance?.toInt() ?? 0,
+ booking.confirmationNumber,
+ state.applyClubPoints,
+ booking.hotelCode,
+ );
await Future<void>.delayed(const Duration(milliseconds: 4000));
} catch (e) {
emit(state.checkoutError());
@@ -115,7 +120,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
if (booking.balance == 0 || booking.balance == null) {
processCheckoutWithoutPaying();
} else {
- context.pushNamed(AppRoutes.paymentProcessing.name);
+ context.push(AppRoutes.paymentProcessing);
processPayment();
}
}
@@ -126,20 +131,20 @@ class CheckoutCubit extends Cubit<CheckoutState> {
if (_isAnimating) return true;
_isAnimating = true;
pageController
- .previousPage(
- duration: const Duration(milliseconds: 500),
- curve: Curves.fastOutSlowIn)
+ .previousPage(duration: const Duration(milliseconds: 500), curve: Curves.fastOutSlowIn)
.then((_) {
- _isAnimating = false;
- emit(state.pageChanged(currentPage));
- });
+ _isAnimating = false;
+ emit(state.pageChanged(currentPage));
+ });
return true;
}
void _navigateTo(CheckoutPage page) async {
- await pageController.animateToPage(page.index,
- duration: const Duration(milliseconds: 500),
- curve: Curves.fastOutSlowIn);
+ await pageController.animateToPage(
+ page.index,
+ duration: const Duration(milliseconds: 500),
+ curve: Curves.fastOutSlowIn,
+ );
emit(state.pageChanged(page));
_isAnimating = false;
}
@@ -160,12 +165,14 @@ class CheckoutCubit extends Cubit<CheckoutState> {
Future<void> checkOut() async {
try {
- booking =
- await bookingDetailsRepository.getRemoteBookingDetails(booking.confirmationNumber, booking.hotelCode);
+ booking = await bookingDetailsRepository.getRemoteBookingDetails(
+ booking.confirmationNumber,
+ booking.hotelCode,
+ );
if (booking.balance == 0 || booking.balance == null) {
await checkOutRepository.checkOut(booking.confirmationNumber);
-
+
emit(state.checkoutSuccess());
} else {
emit(state.checkoutError());
@@ -180,7 +187,6 @@ class CheckoutCubit extends Cubit<CheckoutState> {
switch (result) {
case PaymentAdvancedFinished():
case PaymentSessionFinished():
-
//This is here to add time so that the payment is represented in the BookingDetails
await Future<void>.delayed(const Duration(milliseconds: 2000));
diff --git a/comwell_key_app/lib/check_out/check_out_flow.dart b/comwell_key_app/lib/check_out/check_out_flow.dart
index e27afabd..4d88b76b 100644
--- a/comwell_key_app/lib/check_out/check_out_flow.dart
+++ b/comwell_key_app/lib/check_out/check_out_flow.dart
@@ -26,10 +26,9 @@ class CheckOutFlow extends StatelessWidget {
await Future<void>.delayed(const Duration(seconds: 1));
await cubit.checkOut();
if (cubit.state.successfulCheckout && context.mounted) {
- context.pushNamed(AppRoutes.checkOutSuccess.name,
- extra: cubit.booking.digitalCard);
+ context.push(AppRoutes.checkOutSuccess, extra: cubit.booking.digitalCard);
} else if (context.mounted) {
- context.pushNamed(AppRoutes.checkOutError.name);
+ context.push(AppRoutes.checkOutError);
}
}
},
diff --git a/comwell_key_app/lib/check_out/checkout_routes.dart b/comwell_key_app/lib/check_out/checkout_routes.dart
new file mode 100644
index 00000000..7d53f840
--- /dev/null
+++ b/comwell_key_app/lib/check_out/checkout_routes.dart
@@ -0,0 +1,41 @@
+import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
+import 'package:comwell_key_app/check_out/bloc/check_out_state.dart';
+import 'package:comwell_key_app/check_out/check_out_flow.dart';
+import 'package:comwell_key_app/check_out/pages/check_out_error_page.dart';
+import 'package:comwell_key_app/check_out/pages/check_out_success_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final checkOutRoutes = [_checkOutError, _checkOutSuccess, _checkOutFlow];
+
+final _checkOutError = GoRoute(
+ path: AppRoutes.checkOutError,
+ builder: (context, state) => const CheckOutErrorPage(),
+);
+
+final _checkOutSuccess = GoRoute(
+ path: AppRoutes.checkOutSuccess,
+ builder: (context, state) {
+ final digitalCard = state.extra as bool;
+ return CheckOutSuccessPage(digitalCard: digitalCard);
+ },
+);
+
+final _checkOutFlow = GoRoute(
+ path: AppRoutes.checkOut,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return BlocProvider(
+ create: (context) => CheckoutCubit(booking, locator(), context.read()),
+ child: BlocBuilder<CheckoutCubit, CheckoutState>(
+ builder: (context, state) {
+ return CheckOutFlow(key: ValueKey(state));
+ },
+ ),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/check_out/pages/check_out_error_page.dart b/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
index b053cd17..65716c3a 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
@@ -23,41 +23,40 @@ class CheckOutErrorPage extends StatelessWidget {
children: [
Text(
"checkout_page_processing_error_title".tr(),
- style: Theme.of(context)
- .textTheme
- .headlineMedium
- ?.copyWith(color: colorBackground),
+ style: Theme.of(
+ context,
+ ).textTheme.headlineMedium?.copyWith(color: colorBackground),
+ ),
+ Text(
+ "checkout_page_processing_error_subtitle".tr(),
+ textAlign: TextAlign.center,
+ style: Theme.of(context).textTheme.bodySmall?.copyWith(color: colorDivider),
),
- Text("checkout_page_processing_error_subtitle".tr(),
- textAlign: TextAlign.center,
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorDivider))
],
),
Row(
children: [
Expanded(
child: ElevatedButton(
- onPressed: () {
- Navigator.of(context).popUntil((route) =>
- route.settings.name ==
- AppRoutes.bookingDetails.name);
- },
- style: const ButtonStyle(
- backgroundColor:
- WidgetStatePropertyAll(colorBackground)),
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text(
- "generic_ok".tr(),
- style: const TextStyle(color: colorTertiary),
- ),
- )),
+ onPressed: () {
+ Navigator.of(
+ context,
+ ).popUntil((route) => route.settings.name == AppRoutes.bookingDetails);
+ },
+ style: const ButtonStyle(
+ backgroundColor: WidgetStatePropertyAll(colorBackground),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(
+ "generic_ok".tr(),
+ style: const TextStyle(color: colorTertiary),
+ ),
+ ),
+ ),
),
],
- )
+ ),
],
),
),
diff --git a/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart b/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
index f1d2537c..b6b7e5ee 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
@@ -71,10 +71,10 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
return BlocListener<CheckoutCubit, CheckoutState>(
listener: (context, state) {
if (state.successfulCheckout) {
- context.pushNamed(AppRoutes.checkOutSuccess.name,
+ context.push(AppRoutes.checkOutSuccess,
extra: cubit.booking.digitalCard);
} else {
- context.pushNamed(AppRoutes.checkOutError.name);
+ context.push(AppRoutes.checkOutError);
}
},
child: Scaffold(
diff --git a/comwell_key_app/lib/check_out/pages/check_out_success_page.dart b/comwell_key_app/lib/check_out/pages/check_out_success_page.dart
index 15c41adc..2ce52d91 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_success_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_success_page.dart
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
class CheckOutSuccessPage extends StatelessWidget {
final bool digitalCard;
+
const CheckOutSuccessPage({super.key, required this.digitalCard});
@override
@@ -26,45 +27,42 @@ class CheckOutSuccessPage extends StatelessWidget {
children: [
Text(
"checkout_page_processing_success_title".tr(),
- style: Theme.of(context)
- .textTheme
- .headlineMedium
- ?.copyWith(color: colorBackground),
+ style: Theme.of(
+ context,
+ ).textTheme.headlineMedium?.copyWith(color: colorBackground),
),
Text(
- digitalCard
- ? "checkout_page_processing_success_subtitle".tr()
- : "checkout_page_processing_success_subtitle_no_digital_card"
- .tr(),
- textAlign: TextAlign.center,
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorDivider))
+ digitalCard
+ ? "checkout_page_processing_success_subtitle".tr()
+ : "checkout_page_processing_success_subtitle_no_digital_card".tr(),
+ textAlign: TextAlign.center,
+ style: Theme.of(context).textTheme.bodySmall?.copyWith(color: colorDivider),
+ ),
],
),
Row(
children: [
Expanded(
child: ElevatedButton(
- onPressed: () {
- Navigator.of(context).popUntil((route) =>
- route.settings.name ==
- AppRoutes.bookingDetails.name);
- },
- style: const ButtonStyle(
- backgroundColor:
- WidgetStatePropertyAll(colorBackground)),
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Text(
- "generic_ok".tr(),
- style: const TextStyle(color: colorTertiary),
- ),
- )),
+ onPressed: () {
+ Navigator.of(
+ context,
+ ).popUntil((route) => route.settings.name == AppRoutes.bookingDetails);
+ },
+ style: const ButtonStyle(
+ backgroundColor: WidgetStatePropertyAll(colorBackground),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(
+ "generic_ok".tr(),
+ style: const TextStyle(color: colorTertiary),
+ ),
+ ),
+ ),
),
],
- )
+ ),
],
),
),
diff --git a/comwell_key_app/lib/choose_share_room/choose_share_room_page.dart b/comwell_key_app/lib/choose_share_room/choose_share_room_page.dart
index 24640ae0..3eeceb3e 100644
--- a/comwell_key_app/lib/choose_share_room/choose_share_room_page.dart
+++ b/comwell_key_app/lib/choose_share_room/choose_share_room_page.dart
@@ -12,31 +12,32 @@ import 'package:comwell_key_app/common/components/shimmer_loader/choose_share_ro
class ChooseShareRoomPage extends StatelessWidget {
final Booking booking;
+
const ChooseShareRoomPage({super.key, required this.booking});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
+ final cubit = context.read<ChooseShareRoomCubit>();
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: const ComwellAppBar(),
body: BlocBuilder<ChooseShareRoomCubit, ChooseShareRoomState>(
builder: (context, state) {
- final cubit = context.read<ChooseShareRoomCubit>();
-
if (state.isLoading) {
return const ChooseShareRoomShimmerLoader();
}
- if (state.error != null) {
+ if (state.errorMessage.isNotEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ComwellErrorWidget(
- title: "choose_room_error_title".tr(),
- subtitle: "choose_room_error_subtitle".tr()),
+ title: "choose_room_error_title".tr(),
+ subtitle: "choose_room_error_subtitle".tr(),
+ ),
],
),
);
@@ -57,25 +58,29 @@ class ChooseShareRoomPage extends StatelessWidget {
style: theme.textTheme.bodySmall,
),
const SizedBox(height: 24),
- ...cubit.rooms
+ ...state.rooms
.where((room) => room.assignedTo == null)
- .map((room) => ChooseRoomWidget(
- booking: booking,
+ .map(
+ (room) => ChooseRoomWidget(
+ booking: booking,
+ roomName: room.name,
+ description: room.description,
+ guests: room.guests,
+ imageAsset: room.imageAssets.first,
+ ),
+ ),
+ const SizedBox(height: 32),
+ if (state.rooms.any((room) => room.assignedTo != null))
+ ...state.rooms
+ .where((room) => room.assignedTo != null)
+ .map(
+ (room) => MyRoomWidget(
roomName: room.name,
description: room.description,
guests: room.guests,
imageAsset: room.imageAssets.first,
- )),
- const SizedBox(height: 32),
- if (cubit.rooms.any((room) => room.assignedTo != null))
- ...cubit.rooms
- .where((room) => room.assignedTo != null)
- .map((room) => MyRoomWidget(
- roomName: room.name,
- description: room.description,
- guests: room.guests,
- imageAsset: room.imageAssets.first,
- )),
+ ),
+ ),
const SizedBox(height: 32),
],
),
diff --git a/comwell_key_app/lib/choose_share_room/choose_share_room_route.dart b/comwell_key_app/lib/choose_share_room/choose_share_room_route.dart
new file mode 100644
index 00000000..536ab0d1
--- /dev/null
+++ b/comwell_key_app/lib/choose_share_room/choose_share_room_route.dart
@@ -0,0 +1,18 @@
+import 'package:comwell_key_app/choose_share_room/choose_share_room_page.dart';
+import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final chooseShareRoomRoute = GoRoute(
+ path: AppRoutes.chooseShareRoom,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return BlocProvider(
+ create: (context) => ChooseShareRoomCubit(locator()),
+ child: ChooseShareRoomPage(booking: booking),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/choose_share_room/components/choose_room_widget.dart b/comwell_key_app/lib/choose_share_room/components/choose_room_widget.dart
index d2c51788..f89935c6 100644
--- a/comwell_key_app/lib/choose_share_room/components/choose_room_widget.dart
+++ b/comwell_key_app/lib/choose_share_room/components/choose_room_widget.dart
@@ -32,158 +32,159 @@ class ChooseRoomWidget extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return BlocBuilder<ChooseShareRoomCubit, ChooseShareRoomState>(
- builder: (context, state) {
- final cubit = context.read<ChooseShareRoomCubit>();
- final isAssigned = cubit.rooms.any((room) =>
- room.confirmationNumber == booking.confirmationNumber &&
- room.assignedTo != null);
- return GestureDetector(
- onTap: () async {
-
- final result = await context.pushNamed(AppRoutes.roomInfo.name, extra: [booking, isAssigned]);
- if (result != null && result is bool) {
- await cubit.assignRoomToUser(
- booking.confirmationNumber, booking.firstName);
- }
-
- },
- child: Container(
- margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 0),
- decoration: BoxDecoration(
- border: Border.all(color: colorDivider),
- borderRadius: BorderRadius.circular(16),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- roomName,
- style: theme.textTheme.headlineSmall,
- ),
- const SizedBox(height: 4),
- SizedBox(
- width: 200,
- child: Text(
- description,
- style: theme.textTheme.bodySmall,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
+ builder: (context, state) {
+ final cubit = context.read<ChooseShareRoomCubit>();
+ final isAssigned = cubit.state.rooms.any(
+ (room) =>
+ room.confirmationNumber == booking.confirmationNumber && room.assignedTo != null,
+ );
+ return GestureDetector(
+ onTap: () async {
+ final result = await context.push(
+ AppRoutes.roomInfo,
+ extra: [booking, isAssigned],
+ );
+ if (result != null && result is bool) {
+ await cubit.assignRoomToUser(booking.confirmationNumber, booking.firstName);
+ }
+ },
+ child: Container(
+ margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 0),
+ decoration: BoxDecoration(
+ border: Border.all(color: colorDivider),
+ borderRadius: BorderRadius.circular(16),
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ roomName,
+ style: theme.textTheme.headlineSmall,
),
- ),
- ],
- ),
- ClipRRect(
- borderRadius: BorderRadius.circular(8),
- child: Image.asset(
- imageAsset,
- width: 60,
- height: 60,
- fit: BoxFit.cover,
+ const SizedBox(height: 4),
+ SizedBox(
+ width: 200,
+ child: Text(
+ description,
+ style: theme.textTheme.bodySmall,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ softWrap: true,
+ ),
+ ),
+ ],
),
- ),
- ],
- ),
- ),
- Padding(
- padding:
- const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8.0),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SvgPicture.asset("assets/icons/user-circle.svg",
- width: 20, height: 20),
- const SizedBox(width: 4),
- Text(
- '${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children > 0 ? ' | ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}',
- style: theme.textTheme.bodySmall,
- ),
- const VerticalDivider(color: colorDivider, thickness: 1.5),
- Text(
- 'read_more'.tr(),
- style: theme.textTheme.bodySmall?.copyWith(
- decoration: TextDecoration.underline,
+ ClipRRect(
+ borderRadius: BorderRadius.circular(8),
+ child: Image.asset(
+ imageAsset,
+ width: 60,
+ height: 60,
+ fit: BoxFit.cover,
+ ),
),
- ),
- ],
- ),
- ),
- if (extraInfo != null) ...[
- const SizedBox(height: 8),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Text(
- 'added_to_room'.tr(),
- style: theme.textTheme.bodySmall,
+ ],
),
),
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Text(
- extraInfo!,
- style: theme.textTheme.bodySmall
- ?.copyWith(fontWeight: FontWeight.bold),
+ padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8.0),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SvgPicture.asset("assets/icons/user-circle.svg", width: 20, height: 20),
+ const SizedBox(width: 4),
+ Text(
+ '${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children > 0 ? ' | ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}',
+ style: theme.textTheme.bodySmall,
+ ),
+ const VerticalDivider(color: colorDivider, thickness: 1.5),
+ Text(
+ 'read_more'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ],
),
),
- const SizedBox(height: 8),
- ],
- Column(
- children: [
- const Divider(color: colorDivider),
+ if (extraInfo != null) ...[
+ const SizedBox(height: 8),
Padding(
- padding: const EdgeInsets.only(
- left: 16.0, right: 16.0, top: 8.0, bottom: 16.0),
- child: SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ElevatedButton.styleFrom(
- elevation: 0,
- foregroundColor: Colors.white,
- ),
- onPressed: () async {
- if (isAssigned) {
- context.pushNamed(AppRoutes.shareRoom.name,
- extra: booking);
- return;
- }
- final result = await showDialog<bool>(
- context: context,
- barrierDismissible: false,
- builder: (context) {
- return const ShareRoomConfirmDialog();
- },
- );
- if (result != null && result) {
- await cubit.assignRoomToUser(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Text(
+ 'added_to_room'.tr(),
+ style: theme.textTheme.bodySmall,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Text(
+ extraInfo!,
+ style: theme.textTheme.bodySmall?.copyWith(fontWeight: FontWeight.bold),
+ ),
+ ),
+ const SizedBox(height: 8),
+ ],
+ Column(
+ children: [
+ const Divider(color: colorDivider),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16.0,
+ right: 16.0,
+ top: 8.0,
+ bottom: 16.0,
+ ),
+ child: SizedBox(
+ width: double.infinity,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ elevation: 0,
+ foregroundColor: Colors.white,
+ ),
+ onPressed: () async {
+ if (isAssigned) {
+ context.push(AppRoutes.shareRoom, extra: booking);
+ return;
+ }
+ final result = await showDialog<bool>(
+ context: context,
+ barrierDismissible: false,
+ builder: (context) {
+ return const ShareRoomConfirmDialog();
+ },
+ );
+ if (result != null && result) {
+ await cubit.assignRoomToUser(
booking.confirmationNumber,
- booking.firstName);
- if (context.mounted) {
- context.pop();
+ booking.firstName,
+ );
+ if (context.mounted) {
+ context.pop();
+ }
}
- }
- },
- child: Text(isAssigned
- ? 'share_room'.tr()
- : 'choose_room'.tr()),
+ },
+ child: Text(isAssigned ? 'share_room'.tr() : 'choose_room'.tr()),
+ ),
),
),
- ),
- ],
- ),
- ],
+ ],
+ ),
+ ],
+ ),
),
- ),
- );
- });
+ );
+ },
+ );
}
}
diff --git a/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_cubit.dart b/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_cubit.dart
index e5081e4a..7029f71a 100644
--- a/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_cubit.dart
+++ b/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_cubit.dart
@@ -1,25 +1,24 @@
+import 'package:comwell_key_app/base/base_cubit.dart';
import 'package:comwell_key_app/choose_share_room/choose_share_room_repository.dart';
import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_state.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:comwell_key_app/overview/models/room.dart';
import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:share_plus/share_plus.dart';
-class ChooseShareRoomCubit extends Cubit<ChooseShareRoomState> {
- final ChooseShareRoomRepository chooseShareRoomRepository;
- List<Room> rooms = [];
- ChooseShareRoomCubit(this.chooseShareRoomRepository)
- : super(ChooseShareRoomState.initial());
+class ChooseShareRoomCubit extends BaseCubit<ChooseShareRoomState> {
+ final ChooseShareRoomRepository _chooseShareRoomRepository;
+
+ ChooseShareRoomCubit(this._chooseShareRoomRepository) : super(const ChooseShareRoomState()) {
+ init();
+ }
void init() async {
- emit(ChooseShareRoomState.loading());
- rooms = await chooseShareRoomRepository.getMockRooms();
- emit(ChooseShareRoomState.main(rooms));
+ safeEmit(state.copyWith(isLoading: true));
+ final rooms = await _chooseShareRoomRepository.getMockRooms();
+ safeEmit(state.copyWith(rooms: rooms));
}
Future<void> shareRoom(Booking booking) async {
-
Share.share(
'${booking.hotelName}\n\n'
'${'dates'.tr()}: ${DateFormat('d. MMM').format(booking.startDate)} - ${DateFormat('d. MMM').format(booking.endDate)}\n'
@@ -29,19 +28,17 @@ class ChooseShareRoomCubit extends Cubit<ChooseShareRoomState> {
);
}
- Future<Room> assignRoomToUser(String roomId, String userId) async {
- emit(ChooseShareRoomState.loading());
+ Future<void> assignRoomToUser(String roomId, String userId) async {
try {
- final room = await chooseShareRoomRepository.assignRoom(roomId, userId);
-
- rooms =
- rooms.map((r) => r.confirmationNumber == roomId ? room : r).toList();
-
- emit(ChooseShareRoomState.main(rooms));
- return room;
- } catch (e) {
- emit(ChooseShareRoomState.error(e as Error));
- rethrow;
+ safeEmit(state.copyWith(isLoading: true));
+ final room = await _chooseShareRoomRepository.assignRoom(roomId, userId);
+ final rooms = state.rooms.map((r) => r.confirmationNumber == roomId ? room : r).toList();
+ safeEmit(state.copyWith(rooms: rooms));
+ } catch (e, st) {
+ logError(e, st);
+ safeEmit(state.copyWith(errorMessage: e.toString()));
+ } finally {
+ safeEmit(state.copyWith(isLoading: false));
}
}
}
diff --git a/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_state.dart b/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_state.dart
index 22674791..a572d7c4 100644
--- a/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_state.dart
+++ b/comwell_key_app/lib/choose_share_room/cubit/choose_share_room_state.dart
@@ -1,33 +1,14 @@
import 'package:comwell_key_app/overview/models/room.dart';
import 'package:equatable/equatable.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
-class ChooseShareRoomState extends Equatable {
- final Error? error;
- final bool isLoading;
- final List<Room> rooms;
+part '../../.generated/choose_share_room/cubit/choose_share_room_state.freezed.dart';
- const ChooseShareRoomState._(
- {required this.rooms, required this.error, required this.isLoading});
-
- ChooseShareRoomState.initial() : this._(rooms: [], error: null, isLoading: false);
-
- ChooseShareRoomState.loading() : this._(rooms: [], error: null, isLoading: true);
- ChooseShareRoomState.error(Error error) : this._(rooms: [], error: error, isLoading: false);
- const ChooseShareRoomState.loaded(List<Room> rooms) : this._(rooms: rooms, error: null, isLoading: false);
- ChooseShareRoomState.assigned(Room room) : this._(rooms: [room], error: null, isLoading: false);
- const ChooseShareRoomState.main(List<Room> rooms) : this._(rooms: rooms, error: null, isLoading: false);
-
- @override
- List<Object?> get props => [rooms, error, isLoading];
-
- ChooseShareRoomState copyWith({
- List<Room>? rooms,
- Error? error,
- bool? isLoading,
- }) {
- return ChooseShareRoomState._(
- rooms: rooms ?? this.rooms,
- error: error ?? this.error,
- isLoading: isLoading ?? this.isLoading);
- }
+@freezed
+abstract class ChooseShareRoomState with _$ChooseShareRoomState {
+ const factory ChooseShareRoomState({
+ @Default(false) bool isLoading,
+ @Default("") String errorMessage,
+ @Default([]) List<Room> rooms,
+ }) = _ChooseShareRoomState;
}
diff --git a/comwell_key_app/lib/choose_share_room/pages/room_info_page.dart b/comwell_key_app/lib/choose_share_room/pages/room_info_page.dart
index c8992ac3..63d9e65a 100644
--- a/comwell_key_app/lib/choose_share_room/pages/room_info_page.dart
+++ b/comwell_key_app/lib/choose_share_room/pages/room_info_page.dart
@@ -19,6 +19,7 @@ import 'package:go_router/go_router.dart';
class RoomInfoPage extends StatefulWidget {
final Booking booking;
final bool isAssigned;
+
const RoomInfoPage({super.key, required this.booking, required this.isAssigned});
@override
@@ -35,157 +36,152 @@ class _RoomInfoPageState extends State<RoomInfoPage> {
final room = Room.empty();
final facilities = <FacilityType>[];
final hasFacilities = facilities.isNotEmpty;
- const description = '';
+ const description = '';
final height = MediaQuery.of(context).size.height;
return BlocBuilder<ChooseShareRoomCubit, ChooseShareRoomState>(
- builder: (context, state) {
- if (state.isLoading) {
- return const RoomInfoShimmerLoader();
- }
+ builder: (context, state) {
+ if (state.isLoading) {
+ return const RoomInfoShimmerLoader();
+ }
- return Scaffold(
- extendBodyBehindAppBar: true,
- appBar: const ComwellAppBar(),
- backgroundColor: Colors.white,
- body: SingleChildScrollView(
- physics: const AlwaysScrollableScrollPhysics(),
- child: ConstrainedBox(
- constraints: BoxConstraints(
- minHeight: height - kComwellAppBarHeight - 80,
- ),
- child: Column(
- children: [
- // RoomImageCarousel(images: images.expand((x) => x).toList()),
- Container(
- width: double.infinity,
- decoration: const BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(24),
- topRight: Radius.circular(24),
+ return Scaffold(
+ extendBodyBehindAppBar: true,
+ appBar: const ComwellAppBar(),
+ backgroundColor: Colors.white,
+ body: SingleChildScrollView(
+ physics: const AlwaysScrollableScrollPhysics(),
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ minHeight: height - kComwellAppBarHeight - 80,
+ ),
+ child: Column(
+ children: [
+ // RoomImageCarousel(images: images.expand((x) => x).toList()),
+ Container(
+ width: double.infinity,
+ decoration: const BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.only(
+ topLeft: Radius.circular(24),
+ topRight: Radius.circular(24),
+ ),
),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- room.name,
- style: theme.textTheme.headlineLarge,
- ),
- if (room.tags.isNotEmpty)
- TagWidget(
- text: '${room.tags.first} M2',
- textColor: sandColor),
- ],
- ),
- const SizedBox(height: 12),
- Text(
- description,
- style: theme.textTheme.bodySmall,
- maxLines: _isExpanded ? null : 3,
- overflow: _isExpanded ? null : TextOverflow.ellipsis,
- ),
- const SizedBox(height: 4),
- if (description.length > 200) ...[
- GestureDetector(
- onTap: () {
- setState(() {
- _isExpanded = !_isExpanded;
- });
- },
- child: Text(
- _isExpanded ? 'read_less'.tr() : 'read_more'.tr(),
- style: theme.textTheme.bodySmall?.copyWith(
- color: sandColor,
- decoration: TextDecoration.underline,
- decorationColor: sandColor,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ room.name,
+ style: theme.textTheme.headlineLarge,
),
- ),
+ if (room.tags.isNotEmpty)
+ TagWidget(text: '${room.tags.first} M2', textColor: sandColor),
+ ],
),
- ],
- const SizedBox(height: 24),
- if (hasFacilities) ...[
- Wrap(
- spacing: 8,
- runSpacing: 8,
- children: [
- ...facilities.map((f) => FacilityIconText(
- facility: f, showDivider: true)),
- GestureDetector(
- onTap: () =>{},
- // _showFacilitiesSheet(context, facilities),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 4.0),
- child: Text(
- 'see_all_facilities'.tr(),
- style: theme.textTheme.bodySmall?.copyWith(
- color: sandColor,
- decoration: TextDecoration.underline,
- decorationColor: sandColor,
+ const SizedBox(height: 12),
+ Text(
+ description,
+ style: theme.textTheme.bodySmall,
+ maxLines: _isExpanded ? null : 3,
+ overflow: _isExpanded ? null : TextOverflow.ellipsis,
+ ),
+ const SizedBox(height: 4),
+ if (description.length > 200) ...[
+ GestureDetector(
+ onTap: () {
+ setState(() {
+ _isExpanded = !_isExpanded;
+ });
+ },
+ child: Text(
+ _isExpanded ? 'read_less'.tr() : 'read_more'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: sandColor,
+ decoration: TextDecoration.underline,
+ decorationColor: sandColor,
+ ),
+ ),
+ ),
+ ],
+ const SizedBox(height: 24),
+ if (hasFacilities) ...[
+ Wrap(
+ spacing: 8,
+ runSpacing: 8,
+ children: [
+ ...facilities.map(
+ (f) => FacilityIconText(facility: f, showDivider: true),
+ ),
+ GestureDetector(
+ onTap: () => {},
+ // _showFacilitiesSheet(context, facilities),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 4.0),
+ child: Text(
+ 'see_all_facilities'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: sandColor,
+ decoration: TextDecoration.underline,
+ decorationColor: sandColor,
+ ),
),
),
),
- ),
- ],
- ),
- const SizedBox(height: 32),
+ ],
+ ),
+ const SizedBox(height: 32),
+ ],
],
- ],
+ ),
),
),
- ),
- ],
+ ],
+ ),
),
),
- ),
- bottomNavigationBar: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const Divider(color: colorDivider),
- Padding(
- padding: const EdgeInsets.only(
- left: 16.0,
- right: 16.0,
- top: 16.0,
- bottom: 40,
- ),
- child: ElevatedButton(
- onPressed: () async {
- if (widget.isAssigned) {
- context.pushNamed(AppRoutes.shareRoom.name,
- extra: widget.booking);
- return;
- }
- await showDialog<bool>(
- context: context,
- builder: (context) {
- return const ShareRoomConfirmDialog();
- },
- );
+ bottomNavigationBar: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const Divider(color: colorDivider),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 16.0,
+ right: 16.0,
+ top: 16.0,
+ bottom: 40,
+ ),
+ child: ElevatedButton(
+ onPressed: () async {
+ if (widget.isAssigned) {
+ context.push(AppRoutes.shareRoom, extra: widget.booking);
+ return;
+ }
+ await showDialog<bool>(
+ context: context,
+ builder: (context) {
+ return const ShareRoomConfirmDialog();
+ },
+ );
- if (context.mounted) {
- context.pop(true);
- }
- },
- child: Text(
- widget.isAssigned ? 'share_room'.tr() : 'choose_room'.tr(),
- style: theme.textTheme.headlineSmall
- ?.copyWith(color: Colors.white),
+ if (context.mounted) {
+ context.pop(true);
+ }
+ },
+ child: Text(
+ widget.isAssigned ? 'share_room'.tr() : 'choose_room'.tr(),
+ style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
+ ),
),
),
- ),
- ],
- ),
- );
- });
+ ],
+ ),
+ );
+ },
+ );
}
-
}
diff --git a/comwell_key_app/lib/choose_share_room/pages/share_room_page.dart b/comwell_key_app/lib/choose_share_room/pages/share_room_page.dart
deleted file mode 100644
index d4d5ae68..00000000
--- a/comwell_key_app/lib/choose_share_room/pages/share_room_page.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
-import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_state.dart';
-import 'package:comwell_key_app/choose_share_room/pages/share_room_base_page_template.dart';
-import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-class ShareRoomPage extends StatelessWidget {
- final Booking booking;
- const ShareRoomPage({super.key, required this.booking});
-
- @override
- Widget build(BuildContext context) {
- return BlocBuilder<ChooseShareRoomCubit, ChooseShareRoomState>(
- builder: (context, state) {
- final cubit = context.read<ChooseShareRoomCubit>();
- return ShareRoomBasePageTemplate(booking: booking, onClicked: () {
- cubit.shareRoom(booking);
- }, isShared: false);
- }
- );
- }
-}
diff --git a/comwell_key_app/lib/common/components/comwell_app_bar.dart b/comwell_key_app/lib/common/components/comwell_app_bar.dart
index 570ce46a..1603f16c 100644
--- a/comwell_key_app/lib/common/components/comwell_app_bar.dart
+++ b/comwell_key_app/lib/common/components/comwell_app_bar.dart
@@ -70,7 +70,7 @@ class ComwellAppBar extends StatelessWidget implements PreferredSizeWidget {
color: Colors.white,
icon: "assets/icons/user-open.svg",
onPressed: () {
- context.goNamed(AppRoutes.profile.name);
+ context.go(AppRoutes.profile);
},
),
),
diff --git a/comwell_key_app/lib/contact/contact_route.dart b/comwell_key_app/lib/contact/contact_route.dart
new file mode 100644
index 00000000..1f480896
--- /dev/null
+++ b/comwell_key_app/lib/contact/contact_route.dart
@@ -0,0 +1,24 @@
+import 'package:comwell_key_app/contact/contact_page.dart';
+import 'package:comwell_key_app/contact/cubit/contact_cubit.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final contactRoute = GoRoute(
+ path: AppRoutes.contact,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return BlocProvider<ContactCubit>(
+ create: (BuildContext context) =>
+ ContactCubit(
+ locator(),
+ locator(),
+ locator(),
+ ),
+ child: ContactPage(hotelCode: booking.hotelCode),
+ );
+ },
+);
\ No newline at end of file
diff --git a/comwell_key_app/lib/contact/cubit/contact_cubit.dart b/comwell_key_app/lib/contact/cubit/contact_cubit.dart
index f0fb2b11..b4c1e942 100644
--- a/comwell_key_app/lib/contact/cubit/contact_cubit.dart
+++ b/comwell_key_app/lib/contact/cubit/contact_cubit.dart
@@ -11,20 +11,25 @@ import 'package:flutter/material.dart';
part 'contact_state.dart';
class ContactCubit extends Cubit<ContactState> {
- final ContactRepository contactRepository;
- final OverviewRepository overviewRepository;
- final ProfileRepository profileRepository;
+ final ContactRepository _contactRepository;
+ final OverviewRepository _overviewRepository;
+ final ProfileRepository _profileRepository;
final TextEditingController phoneNumberController = TextEditingController();
- late CountryCode countryCode = CountryCode.fromCountryCode('DK');
- late String phoneNumber = '';
- ContactCubit({required this.contactRepository, required this.overviewRepository, required this.profileRepository}) : super(const ContactState.initial());
+ CountryCode countryCode = CountryCode.fromCountryCode('DK');
+ String phoneNumber = '';
+
+ ContactCubit(
+ this._contactRepository,
+ this._overviewRepository,
+ this._profileRepository,
+ ) : super(const ContactState.initial());
Future<void> sendContact(String hotelCode) async {
emit(const ContactState.contactSend());
try {
- //final bookings = await overviewRepository.fetchAllBookingsForUser();
+ //final bookings = await _overviewRepository.fetchAllBookingsForUser();
// Send contact
- //contactRepository.sendContact(bookings.current.first.hotelCode);
+ //_contactRepository.sendContact(bookings.current.first.hotelCode);
emit(const ContactState.contactSent());
} catch (e) {
emit(const ContactState.contactError());
@@ -32,14 +37,13 @@ class ContactCubit extends Cubit<ContactState> {
}
Future<void> init() async {
- final user = await profileRepository.fetchProfileSettings();
+ final user = await _profileRepository.fetchProfileSettings();
final (countryCode, phoneNumber) = getCountryCodeFromPhoneNumber(user.phoneNumber);
-
+
this.countryCode = countryCode;
this.phoneNumber = phoneNumber;
phoneNumberController.text = phoneNumber;
-
emit(state.userLoaded(user: user));
}
diff --git a/comwell_key_app/lib/find_booking/find_booking_page.dart b/comwell_key_app/lib/find_booking/find_booking_page.dart
index 36a2796d..fa59c5ef 100644
--- a/comwell_key_app/lib/find_booking/find_booking_page.dart
+++ b/comwell_key_app/lib/find_booking/find_booking_page.dart
@@ -95,7 +95,7 @@ class FindBookingPageState extends State<FindBookingPage>
cubit.confirmationIdController.text,
cubit.lastNameController.text);
if (context.mounted) {
- context.pushNamed(AppRoutes.loadingPage.name);
+ context.push(AppRoutes.loadingPage);
}
}
: null,
diff --git a/comwell_key_app/lib/find_booking/find_booking_route.dart b/comwell_key_app/lib/find_booking/find_booking_route.dart
new file mode 100644
index 00000000..56ff61c5
--- /dev/null
+++ b/comwell_key_app/lib/find_booking/find_booking_route.dart
@@ -0,0 +1,26 @@
+import 'package:comwell_key_app/find_booking/cubit/find_booking_cubit.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/routing/app_routes.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final findBookingRoute = GoRoute(
+ path: AppRoutes.findBooking,
+ builder: (context, state) {
+ return BlocProvider(
+ create: (context) => FindBookingCubit(),
+ child: const FindBookingPage(),
+ );
+ },
+);
+
+final findBookingLoadingRoute = GoRoute(
+ path: AppRoutes.loadingPage,
+ builder: (context, state) {
+ return BlocProvider(
+ create: (context) => FindBookingCubit(),
+ child: const LoadingPage(),
+ );
+ },
+);
\ No newline at end of file
diff --git a/comwell_key_app/lib/force_update/force_update_route.dart b/comwell_key_app/lib/force_update/force_update_route.dart
new file mode 100644
index 00000000..de551aa3
--- /dev/null
+++ b/comwell_key_app/lib/force_update/force_update_route.dart
@@ -0,0 +1,10 @@
+import 'package:comwell_key_app/force_update/force_update_page.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:go_router/go_router.dart';
+
+final forceUpdateRoute = GoRoute(
+ path: AppRoutes.forceUpdate,
+ builder: (context, state) {
+ return const ForceUpdatePage();
+ },
+);
diff --git a/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart b/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart
index dd1bcf09..cc8e3845 100644
--- a/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart
+++ b/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart
@@ -14,16 +14,16 @@ class HotelInformationCubit extends Cubit<HotelInformationState> {
late final Hotel hotel;
final Booking booking;
- HotelInformationCubit(
- {required this.hotelInformationRepository, required this.booking})
- : super(const HotelInformationState.initial());
+ HotelInformationCubit({required this.hotelInformationRepository, required this.booking})
+ : super(const HotelInformationState.initial()) {
+ init();
+ }
void init() async {
emit(state.hotelLoading());
try {
- hotel = await hotelInformationRepository
- .fetchHotelInformation(booking.hotelCode);
-
+ hotel = await hotelInformationRepository.fetchHotelInformation(booking.hotelCode);
+
emit(state.hotelSuccess());
} catch (e) {
debugPrint("error fetching hotel information for ${booking.hotelCode}: $e");
diff --git a/comwell_key_app/lib/hotel_information/hotel_information_route.dart b/comwell_key_app/lib/hotel_information/hotel_information_route.dart
new file mode 100644
index 00000000..f480abf2
--- /dev/null
+++ b/comwell_key_app/lib/hotel_information/hotel_information_route.dart
@@ -0,0 +1,45 @@
+import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
+import 'package:comwell_key_app/hotel_information/hotel_information_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/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_router.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final _shellNavigatorKey = GlobalKey<NavigatorState>();
+
+final hotelInformationRoute = ShellRoute(
+ navigatorKey: _shellNavigatorKey,
+ parentNavigatorKey: rootNavigatorKey,
+ pageBuilder: (context, state, child) {
+ return NoTransitionPage(
+ child: BlocProvider(
+ create: (_) => HotelInformationCubit(
+ hotelInformationRepository: locator(),
+ booking: state.extra as Booking,
+ ),
+ child: HotelInformationPage(child: child),
+ ),
+ );
+ },
+ routes: [
+ GoRoute(
+ path: AppRoutes.hotelInformation,
+ builder: (context, state) {
+ return const HotelInformationMenu();
+ },
+ ),
+ GoRoute(
+ path: "${AppRoutes.hotelInformation}/${AppRoutes.facility}",
+ name: "${AppRoutes.hotelInformation}/${AppRoutes.facility}",
+ builder: (context, state) {
+ return FacilityPage(facility: state.extra as Facility);
+ },
+ ),
+ ],
+);
diff --git a/comwell_key_app/lib/hotel_information/pages/facility_page.dart b/comwell_key_app/lib/hotel_information/pages/facility_page.dart
index 0624add1..df09e370 100644
--- a/comwell_key_app/lib/hotel_information/pages/facility_page.dart
+++ b/comwell_key_app/lib/hotel_information/pages/facility_page.dart
@@ -11,7 +11,6 @@ class FacilityPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
-
return Scaffold(
backgroundColor: Colors.white,
body: Column(
@@ -33,10 +32,12 @@ class FacilityPage extends StatelessWidget {
),
],
),
- bottomSheet: facility.callToAction != null ? HotelBottomSheetButton(
- isLoading: false,
- onPressed: () {},
- ) : null,
+ bottomSheet: facility.callToAction != null
+ ? HotelBottomSheetButton(
+ isLoading: false,
+ onPressed: () {},
+ )
+ : null,
);
}
}
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 834c3d1a..f73ee58d 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
@@ -37,7 +37,7 @@ class HotelInformationMenu extends StatelessWidget {
title: facility.title,
onClick: () {
context.pushNamed(
- "${AppRoutes.hotelInformation.name}/${AppRoutes.facility.name}",
+ "${AppRoutes.hotelInformation}${AppRoutes.facility}",
extra: facility);
},
),
diff --git a/comwell_key_app/lib/housekeeping/house_keeping_route.dart b/comwell_key_app/lib/housekeeping/house_keeping_route.dart
new file mode 100644
index 00000000..777b4019
--- /dev/null
+++ b/comwell_key_app/lib/housekeeping/house_keeping_route.dart
@@ -0,0 +1,12 @@
+import 'package:comwell_key_app/housekeeping/housekeeping_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:go_router/go_router.dart';
+
+final houseKeepingRoute = GoRoute(
+ path: AppRoutes.houseKeeping,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return HousekeepingPage(booking: booking);
+ },
+);
diff --git a/comwell_key_app/lib/key/key_route.dart b/comwell_key_app/lib/key/key_route.dart
new file mode 100644
index 00000000..6052e8ea
--- /dev/null
+++ b/comwell_key_app/lib/key/key_route.dart
@@ -0,0 +1,12 @@
+import 'package:go_router/go_router.dart';
+
+import '../routing/app_routes.dart';
+import 'key_page.dart';
+
+final keyRoute = GoRoute(
+ path: AppRoutes.key,
+ builder: (context, state) {
+ final roomNumber = state.extra as String? ?? '';
+ return KeyPage(roomNumber: roomNumber);
+ },
+);
\ No newline at end of file
diff --git a/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart b/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart
index 46eb5ead..16481d0c 100644
--- a/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart
+++ b/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart
@@ -160,7 +160,7 @@ class BalanceBottomSheet extends StatelessWidget {
child: SizedBox(
width: double.infinity,
child: ElevatedButton(
- onPressed: () => cubit.canContinueToPayment ? context.pushNamed(AppRoutes.payMyBooking.name, extra: booking) : null,
+ onPressed: () => cubit.canContinueToPayment ? context.push(AppRoutes.payMyBooking, extra: booking) : null,
style: theme.elevatedButtonTheme.style?.copyWith(
backgroundColor: WidgetStatePropertyAll(cubit.canContinueToPayment ? sandColor : Colors.grey),
padding: const WidgetStatePropertyAll(
diff --git a/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart b/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart
index 5bc79cf3..07722137 100644
--- a/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart
+++ b/comwell_key_app/lib/my_booking/cubit/my_booking_cubit.dart
@@ -18,19 +18,24 @@ class MyBookingCubit extends Cubit<MyBookingState> {
final _tracking = locator<ComwellTracking>();
final PaymentCubit paymentServicesCubit;
- MyBookingCubit(this.myBookingRepository, this.paymentServicesCubit,
- {required Booking initialBooking})
- : super(MyBookingState(
- booking: initialBooking,
- isLoading: false,
- error: null,
- applyClubPoints: false,
- clubPoints: 500,
- isTermsAccepted: false,
- showTermsError: false,
- items: initialBooking.addOnItems ?? [],
- )) {
+ MyBookingCubit(
+ this.myBookingRepository,
+ this.paymentServicesCubit, {
+ required Booking initialBooking,
+ }) : super(
+ MyBookingState(
+ booking: initialBooking,
+ isLoading: false,
+ error: null,
+ applyClubPoints: false,
+ clubPoints: 500,
+ isTermsAccepted: false,
+ showTermsError: false,
+ items: initialBooking.addOnItems ?? [],
+ ),
+ ) {
booking = initialBooking;
+ init();
}
void init() async {
@@ -43,11 +48,9 @@ class MyBookingCubit extends Cubit<MyBookingState> {
}
int get totalAddonBalance =>
- booking.addOnItems?.fold(0, (sum, item) => sum! + item.price.toInt()) ??
- 0;
+ booking.addOnItems?.fold(0, (sum, item) => sum! + item.price.toInt()) ?? 0;
- bool get canContinueToPayment =>
- booking.balance != 0 || (state.items.isNotEmpty);
+ bool get canContinueToPayment => booking.balance != 0 || (state.items.isNotEmpty);
void onAcceptTermsChanged(bool value) {
if (value) {
@@ -72,19 +75,24 @@ class MyBookingCubit extends Cubit<MyBookingState> {
Future<void> processPayment() async {
//TODO: Finish this when upsales are implemented
final analyticsEventItem = AnalyticsEventItem(
- hotelName: booking.hotelName,
- currency: "DKK",
- value: booking.balance?.toInt() ?? 0,
- placement: "placement",
- items: booking.addOnItems?.map((e) => e.description).toList() ?? [],
- itemId: "itemId",
- itemName: "itemName",
- price: booking.balance?.toInt() ?? 0,
- quantity: 1);
+ hotelName: booking.hotelName,
+ currency: "DKK",
+ value: booking.balance?.toInt() ?? 0,
+ placement: "placement",
+ items: booking.addOnItems?.map((e) => e.description).toList() ?? [],
+ itemId: "itemId",
+ itemName: "itemName",
+ price: booking.balance?.toInt() ?? 0,
+ quantity: 1,
+ );
_tracking.trackBeginCheckout(analyticsEventItem);
try {
- await paymentServicesCubit.createSession(booking.balance?.toInt() ?? 0,
- booking.confirmationNumber, state.applyClubPoints, booking.hotelCode);
+ await paymentServicesCubit.createSession(
+ booking.balance?.toInt() ?? 0,
+ booking.confirmationNumber,
+ state.applyClubPoints,
+ booking.hotelCode,
+ );
await Future<void>.delayed(const Duration(milliseconds: 4000));
} catch (e) {
emit(state.setError());
diff --git a/comwell_key_app/lib/my_booking/my_booking_page.dart b/comwell_key_app/lib/my_booking/my_booking_page.dart
index 91a43341..f362e330 100644
--- a/comwell_key_app/lib/my_booking/my_booking_page.dart
+++ b/comwell_key_app/lib/my_booking/my_booking_page.dart
@@ -33,7 +33,7 @@ class MyBookingPage extends StatelessWidget {
if (!context.mounted) return;
Navigator.of(
context,
- ).popUntil((route) => route.settings.name == AppRoutes.bookingDetails.name);
+ ).popUntil((route) => route.settings.name == AppRoutes.bookingDetails);
}
},
child: Builder(
diff --git a/comwell_key_app/lib/my_booking/my_booking_route.dart b/comwell_key_app/lib/my_booking/my_booking_route.dart
new file mode 100644
index 00000000..b078a30a
--- /dev/null
+++ b/comwell_key_app/lib/my_booking/my_booking_route.dart
@@ -0,0 +1,53 @@
+import 'package:comwell_key_app/my_booking/cubit/my_booking_cubit.dart';
+import 'package:comwell_key_app/my_booking/my_booking_page.dart';
+import 'package:comwell_key_app/my_booking/pages/my_booking_payment_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final myBookingRoute = ShellRoute(
+ pageBuilder: (context, state, child) {
+ return CustomTransitionPage(
+ transitionsBuilder: (context, animation, secondaryAnimation, child) {
+ return SlideTransition(
+ position:
+ Tween<Offset>(
+ begin: const Offset(1.0, 0.0),
+ end: Offset.zero,
+ ).animate(
+ CurvedAnimation(
+ parent: animation,
+ curve: Curves.easeInOut,
+ ),
+ ),
+ child: child,
+ );
+ },
+ child: BlocProvider(
+ create: (context) => MyBookingCubit(
+ locator(),
+ context.read(),
+ initialBooking: state.extra as Booking,
+ ),
+ child: child,
+ ),
+ );
+ },
+ routes: [
+ GoRoute(
+ path: AppRoutes.myBooking,
+ builder: (context, state) {
+ return MyBookingPage(booking: state.extra as Booking);
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.payMyBooking,
+ builder: (context, state) {
+ return const MyBookingPaymentPage();
+ },
+ ),
+ ],
+);
diff --git a/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart b/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart
index 7aad0e25..886382a0 100644
--- a/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart
+++ b/comwell_key_app/lib/my_booking/pages/my_booking_payment_page.dart
@@ -53,7 +53,7 @@ class MyBookingPaymentPage extends StatelessWidget {
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 24.0, top: 16.0),
child: ElevatedButton(
onPressed: () {
- context.pushNamed(AppRoutes.paymentProcessing.name);
+ context.push(AppRoutes.paymentProcessing);
cubit.processPayment();
},
child: Text("pay_bill".tr(),
diff --git a/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart b/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
index 2a732a8f..923c5ab0 100644
--- a/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
+++ b/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
@@ -6,12 +6,17 @@ import 'package:flutter_bloc/flutter_bloc.dart';
class NotificationsCubit extends Cubit<NotificationsState> {
final NotificationsRepository notificationsRepository;
+
NotificationsCubit(this.notificationsRepository)
- : super(const NotificationsState(
+ : super(
+ const NotificationsState(
allNotifications: [],
isLoading: false,
error: null,
- ));
+ ),
+ ) {
+ init();
+ }
Iterable<NotificationPermission> notificationPermissions = [];
late User user;
@@ -25,90 +30,105 @@ class NotificationsCubit extends Cubit<NotificationsState> {
];
Iterable<NotificationPermission> _filterVisiblePermissions(
- Iterable<NotificationPermission> permissions) {
- return permissions.where((permission) => _visiblePermissionTypes
- .any((type) => type.notificationPermissionId == permission.code));
+ Iterable<NotificationPermission> permissions,
+ ) {
+ return permissions.where(
+ (permission) =>
+ _visiblePermissionTypes.any((type) => type.notificationPermissionId == permission.code),
+ );
}
void init() async {
- emit(NotificationsState(
- allNotifications: notificationPermissions,
- isLoading: true,
- error: null,
- ));
- try {
- notificationPermissions =
- await notificationsRepository.fetchNotificationPermissions();
-
- notificationPermissions =
- _filterVisiblePermissions(notificationPermissions);
- emit(NotificationsState(
+ emit(
+ NotificationsState(
allNotifications: notificationPermissions,
- isLoading: false,
+ isLoading: true,
error: null,
- ));
+ ),
+ );
+ try {
+ notificationPermissions = await notificationsRepository.fetchNotificationPermissions();
+
+ notificationPermissions = _filterVisiblePermissions(notificationPermissions);
+ emit(
+ NotificationsState(
+ allNotifications: notificationPermissions,
+ isLoading: false,
+ error: null,
+ ),
+ );
} catch (e) {
- emit(NotificationsState(
- allNotifications: notificationPermissions,
- isLoading: false,
- error: Error(),
- ));
+ emit(
+ NotificationsState(
+ allNotifications: notificationPermissions,
+ isLoading: false,
+ error: Error(),
+ ),
+ );
}
}
void onNotificationPermissionClicked(String name) {
notificationPermissions = notificationPermissions
- .map((permission) => permission.displayName == name
- ? permission.copyWith(
- given: !permission.given,
- notificationPermissionDescription:
- permission.notificationPermissionDescription)
- : permission)
+ .map(
+ (permission) => permission.displayName == name
+ ? permission.copyWith(
+ given: !permission.given,
+ notificationPermissionDescription: permission.notificationPermissionDescription,
+ )
+ : permission,
+ )
.toList();
- emit(NotificationsState(
- allNotifications: notificationPermissions,
- isLoading: false,
- error: null,
- ));
+ emit(
+ NotificationsState(
+ allNotifications: notificationPermissions,
+ isLoading: false,
+ error: null,
+ ),
+ );
}
void updateAllPermissionsUI(bool value) {
notificationPermissions = notificationPermissions
- .map((permission) => permission.copyWith(
- given: value,
- notificationPermissionDescription:
- permission.notificationPermissionDescription,
- ))
+ .map(
+ (permission) => permission.copyWith(
+ given: value,
+ notificationPermissionDescription: permission.notificationPermissionDescription,
+ ),
+ )
.toList();
- emit(NotificationsState(
- allNotifications: notificationPermissions,
- isLoading: false,
- error: null,
- ));
+ emit(
+ NotificationsState(
+ allNotifications: notificationPermissions,
+ isLoading: false,
+ error: null,
+ ),
+ );
}
- void updatePreferences(
- Iterable<NotificationPermission> notificationPermissions) async {
- await notificationsRepository.updateNotificationPreferences(
- notificationPermissions);
+ void updatePreferences(Iterable<NotificationPermission> notificationPermissions) async {
+ await notificationsRepository.updateNotificationPreferences(notificationPermissions);
- emit(NotificationsState(
- allNotifications: notificationPermissions,
- isLoading: false,
- error: null,
- ));
+ emit(
+ NotificationsState(
+ allNotifications: notificationPermissions,
+ isLoading: false,
+ error: null,
+ ),
+ );
}
void fetchNotificationPermissions() async {
- notificationPermissions =
- await notificationsRepository.fetchNotificationPermissions();
+ notificationPermissions = await notificationsRepository.fetchNotificationPermissions();
- emit(NotificationsState(
- allNotifications: notificationPermissions,
- isLoading: false,
- error: null,
- ));
+ emit(
+ NotificationsState(
+ allNotifications: notificationPermissions,
+ isLoading: false,
+ error: null,
+ ),
+ );
}
}
diff --git a/comwell_key_app/lib/notifications/notifications_route.dart b/comwell_key_app/lib/notifications/notifications_route.dart
new file mode 100644
index 00000000..7a49e1cd
--- /dev/null
+++ b/comwell_key_app/lib/notifications/notifications_route.dart
@@ -0,0 +1,18 @@
+import 'package:comwell_key_app/notifications/cubit/notifications_cubit.dart';
+import 'package:comwell_key_app/notifications/notifications_page.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final notificationsRoute = GoRoute(
+ path: AppRoutes.notifications,
+ builder: (context, state) {
+ return BlocProvider(
+ create: (context) => NotificationsCubit(locator()),
+ child: const NotificationsPage(
+ notificationPermissions: [],
+ ),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/overview/components/booking_list_item_view.dart b/comwell_key_app/lib/overview/components/booking_list_item_view.dart
index e4ee11c8..4e0e3727 100644
--- a/comwell_key_app/lib/overview/components/booking_list_item_view.dart
+++ b/comwell_key_app/lib/overview/components/booking_list_item_view.dart
@@ -28,8 +28,7 @@ class BookingListItemView extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return InkWell(
- onTap: () => context.pushNamed(AppRoutes.pastCancelledBookings.name,
- extra: [booking, isCancelled]),
+ onTap: () => context.push(AppRoutes.pastCancelledBookings, extra: [booking, isCancelled]),
child: Container(
height: 66,
margin: const EdgeInsets.only(bottom: 8, left: 8, right: 8),
@@ -46,8 +45,9 @@ class BookingListItemView extends StatelessWidget {
margin: const EdgeInsets.all(0),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
- topLeft: Radius.circular(6),
- bottomLeft: Radius.circular(6)),
+ topLeft: Radius.circular(6),
+ bottomLeft: Radius.circular(6),
+ ),
),
width: 84,
height: 66,
@@ -63,32 +63,31 @@ class BookingListItemView extends StatelessWidget {
Padding(
padding: const EdgeInsets.all(8),
child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- hotelName,
- style: theme.textTheme.headlineSmall,
- ),
- Row(
- children: [
- SvgPicture.asset("assets/icons/ic_calendar.svg",
- width: 16, height: 16),
- const SizedBox(width: 4),
- Text(
- DateFormat('d. MMM').format(startDate),
- style: theme.textTheme.bodySmall,
- ),
- const SizedBox(width: 4),
- const Icon(Icons.arrow_forward,
- size: 16, color: colorTertiary),
- const SizedBox(width: 4),
- Text(
- DateFormat('d. MMM').format(endDate),
- style: theme.textTheme.bodySmall,
- ),
- ],
- )
- ]),
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ hotelName,
+ style: theme.textTheme.headlineSmall,
+ ),
+ Row(
+ children: [
+ SvgPicture.asset("assets/icons/ic_calendar.svg", width: 16, height: 16),
+ const SizedBox(width: 4),
+ Text(
+ DateFormat('d. MMM').format(startDate),
+ style: theme.textTheme.bodySmall,
+ ),
+ const SizedBox(width: 4),
+ const Icon(Icons.arrow_forward, size: 16, color: colorTertiary),
+ const SizedBox(width: 4),
+ Text(
+ DateFormat('d. MMM').format(endDate),
+ style: theme.textTheme.bodySmall,
+ ),
+ ],
+ ),
+ ],
+ ),
),
const Spacer(),
if (isCancelled)
diff --git a/comwell_key_app/lib/overview/components/current_booking_list_item_view.dart b/comwell_key_app/lib/overview/components/current_booking_list_item_view.dart
index 51ee8d6b..15e08b2c 100644
--- a/comwell_key_app/lib/overview/components/current_booking_list_item_view.dart
+++ b/comwell_key_app/lib/overview/components/current_booking_list_item_view.dart
@@ -1,4 +1,3 @@
-
import 'package:comwell_key_app/overview/components/guest_list_circles.dart';
import 'package:comwell_key_app/overview/components/prepare_room_widget.dart';
import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
@@ -26,9 +25,7 @@ class CurrentBookingListItem extends StatelessWidget {
final overviewCubit = context.read<OverviewCubit>();
return Container(
- height: booking.reservationStatus == ReservationStatus.newreservation
- ? 327
- : 258,
+ height: booking.reservationStatus == ReservationStatus.newreservation ? 327 : 258,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(10)),
border: Border.all(
@@ -38,48 +35,51 @@ class CurrentBookingListItem extends StatelessWidget {
),
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: InkWell(
- onTap: () =>
- context.pushNamed(AppRoutes.bookingDetails.name, extra: booking),
+ onTap: () => context.push(AppRoutes.bookingDetails, extra: booking),
child: Column(
children: [
ClipRRect(
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(10),
- topRight: Radius.circular(10)),
- child: Stack(
- children: [
- Image.asset(booking.image,
- height: 180, width: double.infinity, fit: BoxFit.fill),
- // Guest circles in the top-left corner
- if (booking.guests.length > 1)
- Positioned(
- top: 16,
- left: 16,
- child: GuestListCirclesWidget(
- guests: booking.guests,
- userButtonSize: userButtonSize,
- userButtonOverlap: userButtonOverlap,
- onTap: () {
- _showGuestList(
- overviewCubit,
- context,
- booking,
- booking.guests,
- "${booking.firstName} ${booking.lastName}");
- },
- ),
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(10),
+ topRight: Radius.circular(10),
+ ),
+ child: Stack(
+ children: [
+ Image.asset(booking.image, height: 180, width: double.infinity, fit: BoxFit.fill),
+ // Guest circles in the top-left corner
+ if (booking.guests.length > 1)
+ Positioned(
+ top: 16,
+ left: 16,
+ child: GuestListCirclesWidget(
+ guests: booking.guests,
+ userButtonSize: userButtonSize,
+ userButtonOverlap: userButtonOverlap,
+ onTap: () {
+ _showGuestList(
+ overviewCubit,
+ context,
+ booking,
+ booking.guests,
+ "${booking.firstName} ${booking.lastName}",
+ );
+ },
),
- ],
- )),
+ ),
+ ],
+ ),
+ ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
- Text(booking.hotelName,
- style: theme.textTheme.headlineMedium,
- textAlign: TextAlign.start),
+ Text(
+ booking.hotelName,
+ style: theme.textTheme.headlineMedium,
+ textAlign: TextAlign.start,
+ ),
SizedBox(
height: 20,
child: Row(
@@ -91,14 +91,17 @@ class CurrentBookingListItem extends StatelessWidget {
children: [
SvgPicture.asset("assets/icons/ic_calendar.svg"),
const SizedBox(width: 4),
- Text(DateFormat('d. MMM').format(booking.startDate),
- style: theme.textTheme.bodySmall),
+ Text(
+ DateFormat('d. MMM').format(booking.startDate),
+ style: theme.textTheme.bodySmall,
+ ),
const SizedBox(width: 4),
- const Icon(Icons.arrow_forward,
- size: 16, color: colorTertiary),
+ const Icon(Icons.arrow_forward, size: 16, color: colorTertiary),
const SizedBox(width: 4),
- Text(DateFormat('d. MMM').format(booking.endDate),
- style: theme.textTheme.bodySmall),
+ Text(
+ DateFormat('d. MMM').format(booking.endDate),
+ style: theme.textTheme.bodySmall,
+ ),
],
),
const VerticalDivider(),
@@ -109,8 +112,9 @@ class CurrentBookingListItem extends StatelessWidget {
SvgPicture.asset("assets/icons/ic_user_circle.svg"),
const SizedBox(width: 4),
Text(
- "${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children >= 1 ? ', ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}",
- style: theme.textTheme.bodySmall),
+ "${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children >= 1 ? ', ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}",
+ style: theme.textTheme.bodySmall,
+ ),
],
),
],
@@ -119,12 +123,11 @@ class CurrentBookingListItem extends StatelessWidget {
],
),
),
- if (booking.reservationStatus ==
- ReservationStatus.newreservation) ...[
+ if (booking.reservationStatus == ReservationStatus.newreservation) ...[
Divider(
color: Colors.grey.shade300,
),
- const PrepareRoomWidget()
+ const PrepareRoomWidget(),
],
],
),
@@ -134,11 +137,12 @@ class CurrentBookingListItem extends StatelessWidget {
}
Future<dynamic> _showGuestList(
- OverviewCubit overviewCubit,
- BuildContext context,
- Booking booking,
- Iterable<Guest> guests,
- String bookerName) async {
+ OverviewCubit overviewCubit,
+ BuildContext context,
+ Booking booking,
+ Iterable<Guest> guests,
+ String bookerName,
+) async {
final theme = Theme.of(context);
final guestListWithoutBooker = guests
.where((guest) => "${guest.firstName} ${guest.lastName}" != bookerName)
@@ -167,22 +171,24 @@ Future<dynamic> _showGuestList(
child: Column(
children: [
Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 16.0, vertical: 8.0),
+ padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text('handle_guests_title'.tr(),
- style: theme.textTheme.titleLarge?.copyWith(
- color: colorTertiary,
- fontWeight: FontWeight.w600,
- )),
+ Text(
+ 'handle_guests_title'.tr(),
+ style: theme.textTheme.titleLarge?.copyWith(
+ color: colorTertiary,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
ElevatedButton(
style: ElevatedButton.styleFrom(
- backgroundColor: sandColor[40],
- shape: const CircleBorder(),
- elevation: 0,
- minimumSize: const Size(40, 40)),
+ backgroundColor: sandColor[40],
+ shape: const CircleBorder(),
+ elevation: 0,
+ minimumSize: const Size(40, 40),
+ ),
child: const Icon(Icons.close, color: colorTertiary),
onPressed: () {
Navigator.pop(bottomSheetContext);
@@ -192,18 +198,20 @@ Future<dynamic> _showGuestList(
),
),
Expanded(
- child: GuestList(
- isOverview: true,
- guests: guestListWithoutBooker,
- selectedGuests: const [],
- onGuestSelected: (_) {},
- onGuestRemoved: (int guestId) {
- overviewCubit.removeGuestsFromBooking(
+ child: GuestList(
+ isOverview: true,
+ guests: guestListWithoutBooker,
+ selectedGuests: const [],
+ onGuestSelected: (_) {},
+ onGuestRemoved: (int guestId) {
+ overviewCubit.removeGuestsFromBooking(
booking.confirmationNumber,
booking.hotelCode,
- guestId);
- },
- )),
+ guestId,
+ );
+ },
+ ),
+ ),
],
),
),
diff --git a/comwell_key_app/lib/overview/components/find_booking_button.dart b/comwell_key_app/lib/overview/components/find_booking_button.dart
index 963bc689..efad7ab4 100644
--- a/comwell_key_app/lib/overview/components/find_booking_button.dart
+++ b/comwell_key_app/lib/overview/components/find_booking_button.dart
@@ -16,7 +16,7 @@ class FindBookingButton extends StatelessWidget {
left: 18.0, right: 18.0, bottom: 0.0, top: 18.0),
child: OutlinedButton.icon(
onPressed: () async {
- context.pushNamed(AppRoutes.findBooking.name);
+ context.push(AppRoutes.findBooking);
},
icon: SvgPicture.asset('assets/icons/loop.svg'),
label: Text(
diff --git a/comwell_key_app/lib/overview/components/room_selection_widget.dart b/comwell_key_app/lib/overview/components/room_selection_widget.dart
index eb1eb2b4..36404d04 100644
--- a/comwell_key_app/lib/overview/components/room_selection_widget.dart
+++ b/comwell_key_app/lib/overview/components/room_selection_widget.dart
@@ -20,7 +20,7 @@ class RoomSelectionWidget extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: InkWell(
onTap: () {
- context.pushNamed(AppRoutes.chooseShareRoom.name, extra: booking);
+ context.push(AppRoutes.chooseShareRoom, extra: booking);
},
child: Container(
decoration: BoxDecoration(
diff --git a/comwell_key_app/lib/overview/overview_page.dart b/comwell_key_app/lib/overview/overview_page.dart
index 7284c531..49f27b90 100644
--- a/comwell_key_app/lib/overview/overview_page.dart
+++ b/comwell_key_app/lib/overview/overview_page.dart
@@ -75,7 +75,7 @@ class OverviewTabViewState extends State<OverviewPage>
final checkedInBooking = overviewCubit.getCheckedInBooking();
if (checkedInBooking != null) {
- context.pushNamed(AppRoutes.bookingDetails.name, extra: checkedInBooking);
+ context.push(AppRoutes.bookingDetails, extra: checkedInBooking);
}
}
@@ -275,7 +275,7 @@ class OverviewTabViewState extends State<OverviewPage>
confirmButtonTextColor: colorTertiary,
cancelButtonText: "booking_not_found_cancel".tr(),
onConfirm: () {
- context.pushNamed(AppRoutes.findBooking.name);
+ context.push(AppRoutes.findBooking);
Navigator.of(context).pop(); // Close the dialog
},
onCancel: () {
diff --git a/comwell_key_app/lib/overview/overview_route.dart b/comwell_key_app/lib/overview/overview_route.dart
index e5016650..c53f415c 100644
--- a/comwell_key_app/lib/overview/overview_route.dart
+++ b/comwell_key_app/lib/overview/overview_route.dart
@@ -1,18 +1,14 @@
-import 'package:comwell_key_app/booking_details/bloc/booking_details_bloc.dart';
-import 'package:comwell_key_app/booking_details/booking_details_page.dart';
+import 'package:comwell_key_app/booking_details/booking_details_route.dart';
import 'package:comwell_key_app/connection_state/connection_state_listener.dart';
-import 'package:comwell_key_app/key/key_page.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:comwell_key_app/overview/past_cancelled_booking_detail_page.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:comwell_key_app/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_page.dart';
+import 'package:comwell_key_app/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_route.dart';
import 'package:go_router/go_router.dart';
import '../profile/profile_page.dart';
import '../profile_settings/components/change_password_modal.dart';
import '../profile_settings/profile_settings_page.dart';
import '../routing/app_routes.dart';
-import '../utils/locator.dart';
import 'overview_page.dart';
RouteBase overviewRoute = GoRoute(
@@ -27,21 +23,18 @@ RouteBase overviewRoute = GoRoute(
routes: [
GoRoute(
path: "profile",
- name: AppRoutes.profile.name,
builder: (context, state) {
return const ProfilePage();
},
routes: [
GoRoute(
path: "profile_settings",
- name: AppRoutes.profileSettings.name,
builder: (context, state) {
return const ProfileSettingsPage();
},
routes: [
GoRoute(
path: 'change_password',
- name: AppRoutes.changePassword.name,
builder: (context, state) {
return const ChangePasswordModal();
},
@@ -50,44 +43,5 @@ RouteBase overviewRoute = GoRoute(
),
],
),
- GoRoute(
- path: AppRoutes.pastCancelledBookings.name,
- name: AppRoutes.pastCancelledBookings.name,
- builder: (context, state) {
- final extras = state.extra as List<dynamic>;
- Booking booking = extras[0] as Booking;
- bool isCancelled = extras[1] as bool;
- return PastCancelledBookingDetailPage(booking: booking, isCancelled: isCancelled);
- },
- ),
- GoRoute(
- path: AppRoutes.bookingDetails.name,
- name: AppRoutes.bookingDetails.name,
- builder: (context, state) {
- final booking = state.extra as Booking;
- return BlocProvider<BookingDetailsBloc>(
- create: (BuildContext context) => BookingDetailsBloc(
- booking: booking,
- locator(),
- locator(),
- locator(),
- locator(),
- locator(),
- locator(),
- ),
- child: const BookingDetailsPage(),
- );
- },
- routes: [
- GoRoute(
- path: "key",
- name: AppRoutes.key.name,
- builder: (context, state) {
- final roomNumber = state.extra as String? ?? '';
- return KeyPage(roomNumber: roomNumber);
- },
- ),
- ],
- ),
],
);
diff --git a/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart b/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
deleted file mode 100644
index ae19a9ef..00000000
--- a/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
+++ /dev/null
@@ -1,184 +0,0 @@
-import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
-import 'package:comwell_key_app/overview/components/bill_download_modal.dart';
-import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:comwell_key_app/services/mappers/booking_mapper.dart';
-import 'package:comwell_key_app/themes/comwell_colors.dart' show colorError;
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_svg/flutter_svg.dart';
-
-import '../themes/light_theme.dart';
-
-class PastCancelledBookingDetailPage extends StatelessWidget {
- final Booking booking;
- final bool isCancelled;
-
- const PastCancelledBookingDetailPage(
- {super.key, required this.booking, this.isCancelled = false});
-
- @override
- Widget build(BuildContext context) {
- final theme = Theme.of(context);
- return Scaffold(
- appBar: const ComwellAppBar(
- shouldShowProfileButton: false,
- ),
- backgroundColor: Theme.of(context).colorScheme.surface,
- body: Padding(
- padding: const EdgeInsets.all(16.0),
- child: ListView(
- children: [
- const SizedBox(height: 20),
- Text(
- 'my_booking'.tr(),
- style: theme.textTheme.headlineLarge,
- ),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Text('booking_reference'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- subtitle: Text(booking.confirmationNumber,
- style: theme.textTheme.headlineSmall),
- ),
- const Divider(color: colorDivider),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- textAlign: TextAlign.start,
- 'check_in'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- Text(
- DateFormat('d. MMM yyyy')
- .format(booking.startDate)
- .toString(),
- style: theme.textTheme.headlineSmall),
- ],
- ),
- const SizedBox(width: 60),
- const Icon(Icons.arrow_forward),
- const SizedBox(width: 20),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('check_out'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- Text(
- DateFormat('d. MMM yyyy')
- .format(booking.endDate)
- .toString(),
- style: theme.textTheme.headlineSmall)
- ],
- ),
- ],
- )),
- const Divider(color: colorDivider),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Text('booking_details'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- subtitle: Text(
- booking.toRoomType(),
- style: theme.textTheme.headlineSmall,
- ),
- ),
- const Divider(color: colorDivider),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Text('number_of_guests'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- subtitle: Text(
- "${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children >= 1 ? ', ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}",
- style: theme.textTheme.headlineSmall),
- ),
- const Divider(color: colorDivider),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Text('booker'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- subtitle: Text(
- "${booking.firstName} ${booking.lastName}",
- style: theme.textTheme.headlineSmall),
- ),
- const Divider(color: colorDivider),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Text('booking_date'.tr(),
- style: theme.textTheme.bodySmall
- ?.copyWith(color: colorHeadlineText)),
- subtitle: Text(
- DateFormat('d. MMM yyyy')
- .format(booking.bookingDate)
- .toString(),
- style: theme.textTheme.headlineSmall)),
- const Divider(color: colorDivider),
- ListTile(
- contentPadding: const EdgeInsets.symmetric(horizontal: 0),
- title: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('payment'.tr(),
- style: theme.textTheme.headlineLarge),
- const SizedBox(height: 16),
- Text('payment_method'.tr(),
- style: theme.textTheme.bodySmall?.copyWith(
- color: colorHeadlineText,
- )),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text('•••• •••• •••• 1234',
- style: theme.textTheme.bodyMedium),
- const SizedBox(width: 8),
- isCancelled
- ? Text('overview_tabbar_cancelled'.tr(),
- style: theme.textTheme.bodyMedium
- ?.copyWith(color: colorError))
- : SvgPicture.asset('assets/images/master.svg',
- width: 30, height: 30),
- ],
- ),
- const SizedBox(height: 8),
- const Divider(color: colorDivider),
- const SizedBox(height: 8),
- Text('bill'.tr(),
- style: theme.textTheme.bodySmall?.copyWith(
- color: colorHeadlineText,
- )),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text('get_bill'.tr(),
- style: theme.textTheme.headlineSmall),
- InkWell(
- onTap: () {
- showModalBottomSheet<void>(
- context: context,
- isScrollControlled: true,
- builder: (context) => BillDownloadModal(
- onDownload: () {},
- initialEmail: 'test@test.com'));
- },
- child: SvgPicture.asset(
- 'assets/icons/download_bill.svg')),
- ],
- ),
- ])),
- const Divider(color: colorDivider)
- ],
- ),
- ),
- );
- }
-}
diff --git a/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart b/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart
index eb15622e..b3201a64 100644
--- a/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart
+++ b/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart
@@ -50,7 +50,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
'document_type_passport'.tr(),
'document_type_id_card'.tr(),
'document_type_driver_license'.tr(),
- 'document_type_other'.tr()
+ 'document_type_other'.tr(),
];
String selectedDocumentType = '';
@@ -59,61 +59,38 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
bool _isAnimating = false;
PreregistrationCubit({required this.booking})
- : super(const PreregistrationState(
- isLoading: false,
- selected: false,
- availableRoomUpgrades: [],
- addOnUpgrades: [],
- selectedRoomUpgrade: '',
- missingInformation: false,
- extrasTotalPrice: 0,
- termsAndConditionsAccepted: false,
- forceUpdate: false,
- user: null,
- phoneNumber: null,
- countryCode: null,
- isPhoneNumberValid: false,
- isFirstNameValid: false,
- isLastNameValid: false,
- isAddressValid: false,
- isPostalCodeValid: false,
- isCityValid: false,
- selectedCountry: '')) {
+ : super(
+ const PreregistrationState(
+ isLoading: false,
+ selected: false,
+ availableRoomUpgrades: [],
+ addOnUpgrades: [],
+ selectedRoomUpgrade: '',
+ missingInformation: false,
+ extrasTotalPrice: 0,
+ termsAndConditionsAccepted: false,
+ forceUpdate: false,
+ user: null,
+ phoneNumber: null,
+ countryCode: null,
+ isPhoneNumberValid: false,
+ isFirstNameValid: false,
+ isLastNameValid: false,
+ isAddressValid: false,
+ isPostalCodeValid: false,
+ isCityValid: false,
+ selectedCountry: '',
+ ),
+ ) {
_tracking.trackScreenView(
"Pre-registration - Betalingskort",
"/pre-registration/betalingskort",
);
-
- phoneNumberTextController.addListener(() {
- emit(state.copyWith(
- isPhoneNumberValid: isPhoneNumberValid,
- missingInformation: false,
- ));
- });
-
- addressTextController.addListener(() {
- emit(state.copyWith(
- isAddressValid: isAddressValid,
- missingInformation: false,
- ));
- });
-
- postalCodeTextController.addListener(() {
- emit(state.copyWith(
- isPostalCodeValid: isPostalCodeValid,
- missingInformation: false,
- ));
- });
-
- cityTextController.addListener(() {
- emit(state.copyWith(
- isCityValid: isCityValid,
- missingInformation: false,
- ));
- });
+ init();
}
void init() async {
+ setupListeners();
emit(state.copyWith(isLoading: true));
try {
final user = await _profileRepository.fetchProfileSettings();
@@ -130,20 +107,62 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
phoneNumberTextController.text = phoneNumber ?? '';
final upSales = await _upSalesRepository.getUpSales(
- booking.confirmationNumber, booking.hotelCode);
- emit(state
- .loaded(user: user, upSales: upSales)
- .copyWith(
- selectedCountry: countryCode?.code ?? 'DK',
- countryCode: countryCode,
- phoneNumber: phoneNumber,
- ));
+ booking.confirmationNumber,
+ booking.hotelCode,
+ );
+ emit(
+ state
+ .loaded(user: user, upSales: upSales)
+ .copyWith(
+ selectedCountry: countryCode?.code ?? 'DK',
+ countryCode: countryCode,
+ phoneNumber: phoneNumber,
+ ),
+ );
} on Exception catch (e) {
debugPrint("error fetching preregistration: $e");
emit(state.copyWith(isLoading: false));
}
}
+ void setupListeners() {
+ phoneNumberTextController.addListener(() {
+ emit(
+ state.copyWith(
+ isPhoneNumberValid: isPhoneNumberValid,
+ missingInformation: false,
+ ),
+ );
+ });
+
+ addressTextController.addListener(() {
+ emit(
+ state.copyWith(
+ isAddressValid: isAddressValid,
+ missingInformation: false,
+ ),
+ );
+ });
+
+ postalCodeTextController.addListener(() {
+ emit(
+ state.copyWith(
+ isPostalCodeValid: isPostalCodeValid,
+ missingInformation: false,
+ ),
+ );
+ });
+
+ cityTextController.addListener(() {
+ emit(
+ state.copyWith(
+ isCityValid: isCityValid,
+ missingInformation: false,
+ ),
+ );
+ });
+ }
+
void onDocumentTypeSelected(String documentType) {
selectedDocumentType = documentType;
emit(state.copyWith(selectedDocumentType: documentType));
@@ -152,12 +171,13 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
void onAddressContinueClicked() {
if (isAddressValid && isCityValid && isPostalCodeValid) {
final updatedUser = state.user!.copyWith(
- address: Address(
- street: addressTextController.text,
- zipCode: postalCodeTextController.text,
- city: cityTextController.text,
- country: state.selectedCountry,
- ));
+ address: Address(
+ street: addressTextController.text,
+ zipCode: postalCodeTextController.text,
+ city: cityTextController.text,
+ country: state.selectedCountry,
+ ),
+ );
emit(state.copyWith(user: updatedUser));
_navigateNextPage();
@@ -169,11 +189,14 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
void onProfileContinueClicked() {
if (isFirstNameValid && isLastNameValid && isPhoneNumberValid) {
final phoneNumber = concatCountryCodeAndPhoneNumber(
- countryCode!, phoneNumberTextController.text);
+ countryCode!,
+ phoneNumberTextController.text,
+ );
final updatedUser = state.user!.copyWith(
- firstName: firstNameTextController.text,
- lastName: lastNameTextController.text,
- phoneNumber: phoneNumber);
+ firstName: firstNameTextController.text,
+ lastName: lastNameTextController.text,
+ phoneNumber: phoneNumber,
+ );
emit(state.copyWith(user: updatedUser));
_navigateNextPage();
@@ -222,45 +245,49 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
}
void onPaymentMethodSelected(StoredPaymentMethod paymentMethod) {
- emit(state.copyWith(
- selectedPaymentMethod: paymentMethod,
- missingInformation: false,
- ));
+ emit(
+ state.copyWith(
+ selectedPaymentMethod: paymentMethod,
+ missingInformation: false,
+ ),
+ );
}
void addToCart() {
final analyticsEventItem = AnalyticsEventItem(
- hotelName: "Comwell",
- currency: "DKK",
- value: 500,
- placement: "placement",
- items: ["items"],
- itemId: "itemId",
- itemName: "itemName",
- price: 200,
- quantity: 200);
+ hotelName: "Comwell",
+ currency: "DKK",
+ value: 500,
+ placement: "placement",
+ items: ["items"],
+ itemId: "itemId",
+ itemName: "itemName",
+ price: 200,
+ quantity: 200,
+ );
_tracking.trackAddToCart(analyticsEventItem);
}
void removeToCard() {
final analyticsEventItem = AnalyticsEventItem(
- hotelName: "Comwell",
- currency: "DKK",
- value: 500,
- placement: "placement",
- items: ["items"],
- itemId: "itemId",
- itemName: "itemName",
- price: 200,
- quantity: 200);
+ hotelName: "Comwell",
+ currency: "DKK",
+ value: 500,
+ placement: "placement",
+ items: ["items"],
+ itemId: "itemId",
+ itemName: "itemName",
+ price: 200,
+ quantity: 200,
+ );
_tracking.trackRemoveFromCart(analyticsEventItem);
}
void _onConfirmPressed(BuildContext context) async {
emit(state.copyWith(isLoading: true));
try {
- final hasUpSales = state.addOnUpgrades.any((e) => e.isAddedToCart) ||
- state.selectedRoomUpgrade.isNotEmpty;
+ final hasUpSales =
+ state.addOnUpgrades.any((e) => e.isAddedToCart) || state.selectedRoomUpgrade.isNotEmpty;
await _profileSettingsRepository.updateUser(state.user!);
if (hasUpSales) {
@@ -284,8 +311,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
comwellClubMarketingConsentChoice: false,
);
- final preRegResponse = await _preregistrationRepository
- .createPreregistration(preregRequest);
+ final preRegResponse = await _preregistrationRepository.createPreregistration(preregRequest);
if (preRegResponse != null) {
Future.delayed(const Duration(seconds: 3), () {
@@ -309,12 +335,15 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
// Convert selected up sales to AddOnList objects using their individual quantities
final List<AddOnList> addonList = state.addOnUpgrades
- .map((upgrade) =>
- AddOnList(itemCode: upgrade.id, quantity: upgrade.quantity))
+ .map((upgrade) => AddOnList(itemCode: upgrade.id, quantity: upgrade.quantity))
.toList();
await _upSalesRepository.addUpSalesToBooking(
- booking.confirmationNumber, booking.hotelCode, roomType, addonList);
+ booking.confirmationNumber,
+ booking.hotelCode,
+ roomType,
+ addonList,
+ );
}
void onEditProfileClicked() {
@@ -356,9 +385,11 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
void _navigateTo(PreregistrationPage page) async {
if (_isAnimating) return;
_isAnimating = true;
- await pageController.animateToPage(page.index,
- duration: const Duration(milliseconds: 500),
- curve: Curves.fastOutSlowIn);
+ await pageController.animateToPage(
+ page.index,
+ duration: const Duration(milliseconds: 500),
+ curve: Curves.fastOutSlowIn,
+ );
emit(state.copyWith(forceUpdate: true));
_isAnimating = false;
}
@@ -367,8 +398,9 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
if (_isAnimating) return;
_isAnimating = true;
await pageController.nextPage(
- duration: const Duration(milliseconds: 500),
- curve: Curves.fastOutSlowIn);
+ duration: const Duration(milliseconds: 500),
+ curve: Curves.fastOutSlowIn,
+ );
emit(state.copyWith(forceUpdate: true));
_isAnimating = false;
}
@@ -377,8 +409,9 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
if (_isAnimating) return;
_isAnimating = true;
await pageController.previousPage(
- duration: const Duration(milliseconds: 500),
- curve: Curves.fastOutSlowIn);
+ duration: const Duration(milliseconds: 500),
+ curve: Curves.fastOutSlowIn,
+ );
emit(state.copyWith(forceUpdate: true));
_isAnimating = false;
}
@@ -387,12 +420,9 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
//This is the total price of the selected up sales and the price of the selected
//room upgrade if it is selected
- return selectedAddOnUpgrades.fold(
- 0, (sum, upgrade) => sum + upgrade.price * upgrade.quantity) +
+ return selectedAddOnUpgrades.fold(0, (sum, upgrade) => sum + upgrade.price * upgrade.quantity) +
(state.selectedRoomUpgrade.isNotEmpty
- ? state.availableRoomUpgrades
- .firstWhere((e) => e.id == state.selectedRoomUpgrade)
- .price
+ ? state.availableRoomUpgrades.firstWhere((e) => e.id == state.selectedRoomUpgrade).price
: 0);
}
@@ -401,14 +431,12 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
(state.selectedRoomUpgrade.isNotEmpty ? 1 : 0);
List<AddOnUpgrade> get otherUpgrades {
- final selectedUpgrades =
- state.addOnUpgrades.where((upgrade) => !upgrade.isService).toList();
+ final selectedUpgrades = state.addOnUpgrades.where((upgrade) => !upgrade.isService).toList();
return selectedUpgrades;
}
List<AddOnUpgrade> get selectedAddOnUpgrades {
- final selectedUpgrades =
- state.addOnUpgrades.where((upgrade) => upgrade.isAddedToCart).toList();
+ final selectedUpgrades = state.addOnUpgrades.where((upgrade) => upgrade.isAddedToCart).toList();
return selectedUpgrades;
}
@@ -432,12 +460,10 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
bool get isCityValid => cityTextController.text.isNotEmpty;
- bool get isDocumentNumberValid =>
- documentNumberTextController.text.isNotEmpty;
+ bool get isDocumentNumberValid => documentNumberTextController.text.isNotEmpty;
bool get isPhoneNumberValid =>
- phoneNumberTextController.text.length >= 7 &&
- phoneNumberTextController.text.length < 16;
+ phoneNumberTextController.text.length >= 7 && phoneNumberTextController.text.length < 16;
bool get isFirstNameValid => firstNameTextController.text.isNotEmpty;
@@ -469,8 +495,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
case PreregistrationPage.address:
return "generic_continue".tr();
case PreregistrationPage.upSales:
- if (selectedAddOnUpgrades.isEmpty &&
- state.selectedRoomUpgrade.isEmpty) {
+ if (selectedAddOnUpgrades.isEmpty && state.selectedRoomUpgrade.isEmpty) {
return "continue_without_up_sales".tr();
}
return "generic_continue".tr();
diff --git a/comwell_key_app/lib/pregistration/preregistration_route.dart b/comwell_key_app/lib/pregistration/preregistration_route.dart
new file mode 100644
index 00000000..c29b2565
--- /dev/null
+++ b/comwell_key_app/lib/pregistration/preregistration_route.dart
@@ -0,0 +1,18 @@
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/pregistration/cubit/preregistration_cubit.dart';
+import 'package:comwell_key_app/pregistration/preregistration_flow.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final preregistrationRoute = GoRoute(
+ path: AppRoutes.preregistration,
+ builder: (context, state) {
+ final extras = state.extra as List<dynamic>;
+ final booking = extras[0] as Booking;
+ return BlocProvider(
+ create: (context) => PreregistrationCubit(booking: booking),
+ child: const PreregistrationFlow(),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_page.dart b/comwell_key_app/lib/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_page.dart
new file mode 100644
index 00000000..d8e23834
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_page.dart
@@ -0,0 +1,196 @@
+import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/overview/components/bill_download_modal.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/services/mappers/booking_mapper.dart';
+import 'package:comwell_key_app/themes/comwell_colors.dart' show colorError;
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+import '../../../themes/light_theme.dart';
+
+class PastCancelledBookingDetailPage extends StatelessWidget {
+ final Booking booking;
+ final bool isCancelled;
+
+ const PastCancelledBookingDetailPage({
+ super.key,
+ required this.booking,
+ this.isCancelled = false,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+ return Scaffold(
+ appBar: const ComwellAppBar(
+ shouldShowProfileButton: false,
+ ),
+ backgroundColor: Theme.of(context).colorScheme.surface,
+ body: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: ListView(
+ children: [
+ const SizedBox(height: 20),
+ Text(
+ 'my_booking'.tr(),
+ style: theme.textTheme.headlineLarge,
+ ),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text(
+ 'booking_reference'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ subtitle: Text(booking.confirmationNumber, style: theme.textTheme.headlineSmall),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ textAlign: TextAlign.start,
+ 'check_in'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ Text(
+ DateFormat('d. MMM yyyy').format(booking.startDate).toString(),
+ style: theme.textTheme.headlineSmall,
+ ),
+ ],
+ ),
+ const SizedBox(width: 60),
+ const Icon(Icons.arrow_forward),
+ const SizedBox(width: 20),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'check_out'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ Text(
+ DateFormat('d. MMM yyyy').format(booking.endDate).toString(),
+ style: theme.textTheme.headlineSmall,
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text(
+ 'booking_details'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ subtitle: Text(
+ booking.toRoomType(),
+ style: theme.textTheme.headlineSmall,
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text(
+ 'number_of_guests'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ subtitle: Text(
+ "${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children >= 1 ? ', ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}",
+ style: theme.textTheme.headlineSmall,
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text(
+ 'booker'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ subtitle: Text(
+ "${booking.firstName} ${booking.lastName}",
+ style: theme.textTheme.headlineSmall,
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text(
+ 'booking_date'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText),
+ ),
+ subtitle: Text(
+ DateFormat('d. MMM yyyy').format(booking.bookingDate).toString(),
+ style: theme.textTheme.headlineSmall,
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('payment'.tr(), style: theme.textTheme.headlineLarge),
+ const SizedBox(height: 16),
+ Text(
+ 'payment_method'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: colorHeadlineText,
+ ),
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text('•••• •••• •••• 1234', style: theme.textTheme.bodyMedium),
+ const SizedBox(width: 8),
+ isCancelled
+ ? Text(
+ 'overview_tabbar_cancelled'.tr(),
+ style: theme.textTheme.bodyMedium?.copyWith(color: colorError),
+ )
+ : SvgPicture.asset('assets/images/master.svg', width: 30, height: 30),
+ ],
+ ),
+ const SizedBox(height: 8),
+ const Divider(color: colorDivider),
+ const SizedBox(height: 8),
+ Text(
+ 'bill'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: colorHeadlineText,
+ ),
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text('get_bill'.tr(), style: theme.textTheme.headlineSmall),
+ InkWell(
+ onTap: () {
+ showModalBottomSheet<void>(
+ context: context,
+ isScrollControlled: true,
+ builder: (context) =>
+ BillDownloadModal(onDownload: () {}, initialEmail: 'test@test.com'),
+ );
+ },
+ child: SvgPicture.asset('assets/icons/download_bill.svg'),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_route.dart b/comwell_key_app/lib/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_route.dart
new file mode 100644
index 00000000..73c004ca
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_route.dart
@@ -0,0 +1,15 @@
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_page.dart';
+import 'package:go_router/go_router.dart';
+
+import '../../../routing/app_routes.dart';
+
+final pastCancelledBookingDetailsRoute = GoRoute(
+ path: AppRoutes.pastCancelledBookings,
+ builder: (context, state) {
+ final extras = state.extra as List<dynamic>;
+ Booking booking = extras[0] as Booking;
+ bool isCancelled = extras[1] as bool;
+ return PastCancelledBookingDetailPage(booking: booking, isCancelled: isCancelled);
+ },
+);
diff --git a/comwell_key_app/lib/presentation/screens/payment_processing/payment_processing_route.dart b/comwell_key_app/lib/presentation/screens/payment_processing/payment_processing_route.dart
new file mode 100644
index 00000000..50f4f24d
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/payment_processing/payment_processing_route.dart
@@ -0,0 +1,32 @@
+import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/common/const.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+import 'package:payment_plugin/payment_plugin.dart';
+
+import '../../../utils/locator.dart';
+
+final paymentProcessingRoute = GoRoute(
+ path: AppRoutes.paymentProcessing,
+ builder: (context, state) => const PaymentProcessingPage(),
+);
+
+final paymentCardRoute = GoRoute(
+ path: AppRoutes.paymentCards,
+ builder: (context, state) {
+ return BlocProvider(
+ create: (context) => PaymentCardsCubit(adyenRepository: locator()),
+ child: Builder(
+ builder: (context) {
+ final scaffold = state.uri.queryParameters[needsScaffold] == 'true';
+ return PaymentCardsPage(
+ needScaffold: scaffold,
+ appBar: const ComwellAppBar(shouldShowProfileButton: false),
+ );
+ },
+ ),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/presentation/screens/room_info/room_info_route.dart b/comwell_key_app/lib/presentation/screens/room_info/room_info_route.dart
new file mode 100644
index 00000000..8a7a6c5e
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/room_info/room_info_route.dart
@@ -0,0 +1,20 @@
+import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
+import 'package:comwell_key_app/choose_share_room/pages/room_info_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final roomInfoRoute = GoRoute(
+ path: AppRoutes.roomInfo,
+ builder: (context, state) {
+ final extras = state.extra as List<dynamic>;
+ final booking = extras[0] as Booking;
+ final isAssigned = extras[1] as bool;
+ return BlocProvider(
+ create: (context) => ChooseShareRoomCubit(locator()),
+ child: RoomInfoPage(booking: booking, isAssigned: isAssigned),
+ );
+ },
+);
\ No newline at end of file
diff --git a/comwell_key_app/lib/presentation/screens/share_room/share_room_page.dart b/comwell_key_app/lib/presentation/screens/share_room/share_room_page.dart
new file mode 100644
index 00000000..d4d5ae68
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/share_room/share_room_page.dart
@@ -0,0 +1,23 @@
+import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
+import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_state.dart';
+import 'package:comwell_key_app/choose_share_room/pages/share_room_base_page_template.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+class ShareRoomPage extends StatelessWidget {
+ final Booking booking;
+ const ShareRoomPage({super.key, required this.booking});
+
+ @override
+ Widget build(BuildContext context) {
+ return BlocBuilder<ChooseShareRoomCubit, ChooseShareRoomState>(
+ builder: (context, state) {
+ final cubit = context.read<ChooseShareRoomCubit>();
+ return ShareRoomBasePageTemplate(booking: booking, onClicked: () {
+ cubit.shareRoom(booking);
+ }, isShared: false);
+ }
+ );
+ }
+}
diff --git a/comwell_key_app/lib/presentation/screens/share_room/share_room_route.dart b/comwell_key_app/lib/presentation/screens/share_room/share_room_route.dart
new file mode 100644
index 00000000..3f0cad5e
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/share_room/share_room_route.dart
@@ -0,0 +1,18 @@
+import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
+import 'package:comwell_key_app/presentation/screens/share_room/share_room_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final shareRoomRoute = GoRoute(
+ path: AppRoutes.shareRoom,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return BlocProvider(
+ create: (context) => ChooseShareRoomCubit(locator()),
+ child: ShareRoomPage(booking: booking),
+ );
+ },
+);
\ No newline at end of file
diff --git a/comwell_key_app/lib/profile/components/profile_page_widget.dart b/comwell_key_app/lib/profile/components/profile_page_widget.dart
index 097233af..312a6110 100644
--- a/comwell_key_app/lib/profile/components/profile_page_widget.dart
+++ b/comwell_key_app/lib/profile/components/profile_page_widget.dart
@@ -73,7 +73,7 @@ class ProfilePageWidget extends StatelessWidget {
text: 'profile_settings_profile_menu'.tr(),
trailingIcon: Icons.chevron_right,
onTap: () async {
- await context.pushNamed(AppRoutes.profileSettings.name);
+ await context.push(AppRoutes.profileSettings);
cubit.init();
},
),
@@ -87,10 +87,7 @@ class ProfilePageWidget extends StatelessWidget {
text: 'payment_card_profile_menu'.tr(),
trailingIcon: Icons.chevron_right,
onTap: () {
- context.pushNamed(
- AppRoutes.paymentCards.name,
- queryParameters: {needsScaffold: 'true'},
- );
+ context.push("${AppRoutes.paymentCards}?needsScaffold=true");
},
),
const Padding(
@@ -103,7 +100,7 @@ class ProfilePageWidget extends StatelessWidget {
trailingIcon: Icons.chevron_right,
text: 'notifications_profile_menu'.tr(),
onTap: () {
- context.pushNamed(AppRoutes.notifications.name);
+ context.push(AppRoutes.notifications);
},
),
const Padding(
@@ -151,7 +148,10 @@ class ProfilePageWidget extends StatelessWidget {
future: context.read<ProfileCubit>().getVersion(),
builder: (context, snapshot) {
if (snapshot.hasData) {
- return Text(snapshot.requireData, style: TextStyle(color: Colors.grey[500]));
+ return Text(
+ snapshot.requireData,
+ style: TextStyle(color: Colors.grey[500]),
+ );
}
return const SizedBox.shrink();
},
diff --git a/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart b/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart
index 85e81523..c280cd15 100644
--- a/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart
+++ b/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart
@@ -13,24 +13,26 @@ class ReceivedSharedBookingCubit extends Cubit<ReceivedSharedBookingState> {
late String hmsConfirmationNumber;
late Booking booking;
- final ShareBookingRepository shareBookingRepository =
- locator<ShareBookingRepository>();
- final ProfileRepository profileRepository = locator<ProfileRepository>();
- final BookingDetailsRepository bookingDetailsRepository = locator<BookingDetailsRepository>();
+ final ShareBookingRepository _shareBookingRepository;
+ final BookingDetailsRepository _bookingDetailsRepository;
- ReceivedSharedBookingCubit(this.sharingId, this.hotelCode)
- : super(const ReceivedSharedBookingState.loading());
+ ReceivedSharedBookingCubit(
+ this._shareBookingRepository,
+ this._bookingDetailsRepository, {
+ required this.sharingId,
+ required this.hotelCode,
+ }) : super(const ReceivedSharedBookingState.loading()) {
+ init();
+ }
void init() async {
emit(const ReceivedSharedBookingState.loading());
try {
- final response = await shareBookingRepository.consumeRoomSharingLink(
- sharingId, hotelCode);
+ final response = await _shareBookingRepository.consumeRoomSharingLink(sharingId, hotelCode);
hmsConfirmationNumber = response.confirmationNumber;
- booking = await bookingDetailsRepository.getBookingDetails(
- hmsConfirmationNumber, hotelCode);
+ booking = await _bookingDetailsRepository.getBookingDetails(hmsConfirmationNumber, hotelCode);
emit(const ReceivedSharedBookingState.loaded());
} catch (e) {
diff --git a/comwell_key_app/lib/received_shared_booking/received_shared_booking_route.dart b/comwell_key_app/lib/received_shared_booking/received_shared_booking_route.dart
new file mode 100644
index 00000000..27f2363b
--- /dev/null
+++ b/comwell_key_app/lib/received_shared_booking/received_shared_booking_route.dart
@@ -0,0 +1,23 @@
+import 'package:comwell_key_app/received_shared_booking/cubit/received_shared_booking_cubit.dart';
+import 'package:comwell_key_app/received_shared_booking/received_shared_booking_page.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final receivedSharedBookingRoute = GoRoute(
+ path: AppRoutes.receivedSharedBooking,
+ builder: (context, state) {
+ final sharingId = state.uri.queryParameters['sharingId'];
+ final hotelCode = state.uri.queryParameters['hotelCode'];
+ return BlocProvider(
+ create: (context) => ReceivedSharedBookingCubit(
+ locator(),
+ locator(),
+ sharingId: sharingId ?? '',
+ hotelCode: hotelCode ?? '',
+ ),
+ child: const ReceivedSharedBookingPage(),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart b/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart
index 081bacb3..f29a8408 100644
--- a/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart
+++ b/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart
@@ -12,22 +12,25 @@ class ReceivedSharedRoomCubit extends Cubit<ReceivedSharedRoomState> {
late String hmsConfirmationNumber;
late Booking booking;
- final ShareBookingRepository shareBookingRepository =
- locator<ShareBookingRepository>();
- final ProfileRepository profileRepository = locator<ProfileRepository>();
- final BookingDetailsRepository bookingDetailsRepository = locator<BookingDetailsRepository>();
+ final ShareBookingRepository _shareBookingRepository;
+ final BookingDetailsRepository _bookingDetailsRepository;
- ReceivedSharedRoomCubit(this.sharingId, this.hotelCode)
- : super(const ReceivedSharedRoomState.loading());
+ ReceivedSharedRoomCubit(
+ this._shareBookingRepository,
+ this._bookingDetailsRepository, {
+ required this.sharingId,
+ required this.hotelCode,
+ }) : super(const ReceivedSharedRoomState.loading()) {
+ init();
+ }
void init() async {
emit(const ReceivedSharedRoomState.loading());
try {
- final response = await shareBookingRepository.consumeRoomSharingLink(sharingId, hotelCode);
+ final response = await _shareBookingRepository.consumeRoomSharingLink(sharingId, hotelCode);
hmsConfirmationNumber = response.confirmationNumber;
- booking = await bookingDetailsRepository.getBookingDetails(
- hmsConfirmationNumber, hotelCode);
+ booking = await _bookingDetailsRepository.getBookingDetails(hmsConfirmationNumber, hotelCode);
emit(const ReceivedSharedRoomState.loaded());
} catch (e) {
diff --git a/comwell_key_app/lib/received_shared_room/received_shared_room_route.dart b/comwell_key_app/lib/received_shared_room/received_shared_room_route.dart
new file mode 100644
index 00000000..a47a3e35
--- /dev/null
+++ b/comwell_key_app/lib/received_shared_room/received_shared_room_route.dart
@@ -0,0 +1,23 @@
+import 'package:comwell_key_app/received_shared_room/cubit/received_shared_room_cubit.dart';
+import 'package:comwell_key_app/received_shared_room/received_shared_room_page.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final receivedSharedRoomRoute = GoRoute(
+ path: AppRoutes.receivedSharedRoom,
+ builder: (context, state) {
+ final sharingId = state.uri.queryParameters['sharingId'];
+ final hotelCode = state.uri.queryParameters['hotelCode'];
+ return BlocProvider(
+ create: (context) => ReceivedSharedRoomCubit(
+ locator(),
+ locator(),
+ sharingId: sharingId ?? '',
+ hotelCode: hotelCode ?? '',
+ ),
+ child: const ReceivedSharedRoomPage(),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/redeem_debug/bloc/redeem_cubit.dart b/comwell_key_app/lib/redeem_debug/bloc/redeem_cubit.dart
deleted file mode 100644
index 1b46d18a..00000000
--- a/comwell_key_app/lib/redeem_debug/bloc/redeem_cubit.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-import 'package:comwell_key_app/base/base_cubit.dart';
-import 'package:comwell_key_app/utils/secure_storage.dart';
-import 'package:comwell_key_app/utils/seos_repository.dart';
-import 'package:flutter/material.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-
-part '../../.generated/redeem_debug/bloc/redeem_cubit.freezed.dart';
-
-class RedeemCubit extends BaseCubit<RedeemScreenState> {
- RedeemCubit(this._seosRepository, this._secureStorage) : super(const RedeemScreenState());
-
- final SeosRepository _seosRepository;
- final SecureStorage _secureStorage;
- final invitationCodeFieldController = TextEditingController();
-
- Future<void> onRedeem() async {
- try {
- safeEmit(state.copyWith(isLoading: true));
- final code = invitationCodeFieldController.value.toString();
- await _seosRepository.setupEndpoint(code);
- await _secureStorage.write("invitation", code);
- } catch (e, st) {
- logError(e, st);
- } finally {
- safeEmit(state.copyWith(isLoading: false));
- }
- }
-}
-
-@freezed
-abstract class RedeemScreenState with _$RedeemScreenState {
- const factory RedeemScreenState({
- @Default(false) bool isLoading,
- }) = _RedeemScreenState;
-}
diff --git a/comwell_key_app/lib/redeem_debug/redeem_page.dart b/comwell_key_app/lib/redeem_debug/redeem_page.dart
deleted file mode 100644
index 43fbb0e0..00000000
--- a/comwell_key_app/lib/redeem_debug/redeem_page.dart
+++ /dev/null
@@ -1,80 +0,0 @@
-import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
-import 'package:comwell_key_app/redeem_debug/bloc/redeem_cubit.dart';
-import 'package:comwell_key_app/routing/app_routes.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:go_router/go_router.dart';
-import 'widgets/invitation_code_textfield.dart';
-import '../common/extensions/scaffold_messenger_state_extension.dart';
-
-class RedeemPage extends StatelessWidget {
- const RedeemPage({super.key});
-
- @override
- Widget build(BuildContext context) {
- final cubit = context.read<RedeemCubit>();
- return BlocBuilder<RedeemCubit, RedeemScreenState>(
- builder: (context, state) {
- return Scaffold(
- extendBodyBehindAppBar: true,
- appBar: const ComwellAppBar(shouldShowAppBar: true),
- body: SafeArea(
- child: Center(
- child: Padding(
- padding: const EdgeInsets.all(15.0),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Text(
- 'Invitation Code:',
- style: Theme.of(context).textTheme.titleMedium,
- ),
- const SizedBox(height: 10.0),
- InvitationCodeTextField(
- valueController: cubit.invitationCodeFieldController,
- ),
- const SizedBox(height: 15.0),
- ElevatedButton(
- onPressed: state.isLoading
- ? null
- : () {
- _onTapRedeem(context);
- },
- child: Builder(
- builder: (context) {
- if (state.isLoading) {
- return const CircularProgressIndicator(color: Colors.white);
- }
- return Text(
- 'Register',
- style: Theme.of(context).textTheme.titleLarge,
- );
- },
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- },
- );
- }
-
- void _onTapRedeem(BuildContext context) async {
- final cubit = context.read<RedeemCubit>();
- try {
- cubit.onRedeem();
- if (!context.mounted) return;
- context.goNamed(AppRoutes.bookingDetails.name);
- } catch (e) {
- ScaffoldMessenger.of(context).showActionSnackBar(
- content: Text('Unable to redeem - ${e.toString()}'),
- label: 'Retry',
- onPressed: () => _onTapRedeem(context),
- );
- }
- }
-}
diff --git a/comwell_key_app/lib/redeem_debug/redeem_route.dart b/comwell_key_app/lib/redeem_debug/redeem_route.dart
deleted file mode 100644
index 08aaa421..00000000
--- a/comwell_key_app/lib/redeem_debug/redeem_route.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-import 'package:comwell_key_app/redeem_debug/redeem_page.dart';
-import 'package:go_router/go_router.dart';
-
-import '../routing/app_routes.dart';
-
-final redeemRoute = GoRoute(
- path: AppRoutes.redeem,
- builder: (context, state) => const RedeemPage(),
-);
diff --git a/comwell_key_app/lib/redeem_debug/widgets/invitation_code_formatter.dart b/comwell_key_app/lib/redeem_debug/widgets/invitation_code_formatter.dart
deleted file mode 100644
index 7d10efe6..00000000
--- a/comwell_key_app/lib/redeem_debug/widgets/invitation_code_formatter.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-
-class InvitationCodeFormatter extends TextInputFormatter {
- final String sample;
- final String separator;
-
- InvitationCodeFormatter({
- required this.sample,
- required this.separator,
- });
-
- @override
- TextEditingValue formatEditUpdate(
- TextEditingValue oldValue,
- TextEditingValue newValue
- ) {
- if (newValue.text.length > oldValue.text.length) {
- if (newValue.text.characters.last == separator ||
- newValue.text.length > sample.length) {
- return oldValue;
- }
- if (newValue.text.length < sample.length &&
- sample[newValue.text.length - 1] == separator) {
- return TextEditingValue(
- text:
- '${oldValue.text}$separator${newValue.text.substring(newValue.text.length - 1)}'
- .toUpperCase(),
- selection:
- TextSelection.collapsed(
- offset: newValue.selection.end + 1)
- );
- }
- }
- return TextEditingValue(
- text: newValue.text.toUpperCase(),
- selection: newValue.selection,
- );
- }
-}
\ No newline at end of file
diff --git a/comwell_key_app/lib/redeem_debug/widgets/invitation_code_textfield.dart b/comwell_key_app/lib/redeem_debug/widgets/invitation_code_textfield.dart
deleted file mode 100644
index 08ff9137..00000000
--- a/comwell_key_app/lib/redeem_debug/widgets/invitation_code_textfield.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-
-import 'invitation_code_formatter.dart';
-
-class InvitationCodeTextField extends StatelessWidget {
- InvitationCodeTextField({super.key, required this.valueController});
-
- String? get invitationCode =>
- _formKey.currentState?.validate() == true ? valueController.text : null;
-
- final _formKey = GlobalKey<FormState>();
- final TextEditingController valueController;
-
- @override
- Widget build(BuildContext context) => Form(
- key: _formKey,
- child: TextFormField(
- autofocus: true,
- controller: valueController,
- inputFormatters: [
- FilteringTextInputFormatter.allow(RegExp(r'[0-9a-zA-Z-]')),
- InvitationCodeFormatter(sample: 'xxxx-xxxx-xxxx-xxxx', separator: '-'),
- ],
- decoration: const InputDecoration(
- border: OutlineInputBorder(),
- hintText: 'XXXX-XXXX-XXXX-XXXX',
- contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0),
- ),
- validator: (value) {
- if (value == null || value.isEmpty) {
- return 'Please enter an invitation code';
- } else if (value.replaceAll('-', '').length != 16) {
- return 'Please enter a valid invitation code';
- } else {
- return null;
- }
- },
- ),
- );
-}
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 66a16850..b6690331 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -1,87 +1,36 @@
import 'package:comwell_key_app/authentication/authentication_repository.dart';
-import 'package:comwell_key_app/check_in/bloc/check_in_cubit.dart';
-import 'package:comwell_key_app/check_in/check_in_page.dart';
-import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
-import 'package:comwell_key_app/check_out/bloc/check_out_state.dart';
-import 'package:comwell_key_app/check_out/check_out_flow.dart';
-import 'package:comwell_key_app/check_out/check_out_repository.dart';
-import 'package:comwell_key_app/check_out/pages/check_out_error_page.dart';
-import 'package:comwell_key_app/check_out/pages/check_out_success_page.dart';
-import 'package:comwell_key_app/choose_share_room/choose_share_room_page.dart';
-import 'package:comwell_key_app/choose_share_room/choose_share_room_repository.dart';
-import 'package:comwell_key_app/choose_share_room/cubit/choose_share_room_cubit.dart';
-import 'package:comwell_key_app/choose_share_room/pages/room_info_page.dart';
-import 'package:comwell_key_app/choose_share_room/pages/share_room_page.dart';
-import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
-import 'package:comwell_key_app/common/const.dart';
-import 'package:comwell_key_app/contact/contact_page.dart';
-import 'package:comwell_key_app/contact/cubit/contact_cubit.dart';
-import 'package:comwell_key_app/contact/repository/contact_repository.dart';
-import 'package:comwell_key_app/find_booking/cubit/find_booking_cubit.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/force_update/force_update_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/cubit/hotel_information_cubit.dart';
-import 'package:comwell_key_app/hotel_information/hotel_information_page.dart';
-import 'package:comwell_key_app/housekeeping/housekeeping_page.dart';
+import 'package:comwell_key_app/booking_details/booking_details_route.dart';
+import 'package:comwell_key_app/check_out/checkout_routes.dart';
+import 'package:comwell_key_app/choose_share_room/choose_share_room_route.dart';
+import 'package:comwell_key_app/housekeeping/house_keeping_route.dart';
+import 'package:comwell_key_app/my_booking/my_booking_route.dart';
+import 'package:comwell_key_app/notifications/notifications_route.dart';
+import 'package:comwell_key_app/pregistration/preregistration_route.dart';
+import 'package:comwell_key_app/presentation/screens/payment_processing/payment_processing_route.dart';
+import 'package:comwell_key_app/presentation/screens/room_info/room_info_route.dart';
+import 'package:comwell_key_app/contact/contact_route.dart';
+import 'package:comwell_key_app/find_booking/find_booking_route.dart';
+import 'package:comwell_key_app/force_update/force_update_route.dart';
+import 'package:comwell_key_app/key/key_route.dart';
import 'package:comwell_key_app/login/login_route.dart';
-import 'package:comwell_key_app/my_booking/cubit/my_booking_cubit.dart';
-import 'package:comwell_key_app/my_booking/my_booking_page.dart';
-import 'package:comwell_key_app/my_booking/my_booking_repository.dart';
-import 'package:comwell_key_app/my_booking/pages/my_booking_payment_page.dart';
-import 'package:comwell_key_app/notifications/cubit/notifications_cubit.dart';
-import 'package:comwell_key_app/notifications/notifications_page.dart';
-import 'package:comwell_key_app/notifications/notifications_repository.dart';
-import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/overview/overview_route.dart';
-import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
-import 'package:comwell_key_app/overview/repository/overview_repository.dart';
-import 'package:comwell_key_app/pregistration/cubit/preregistration_cubit.dart';
-import 'package:comwell_key_app/pregistration/preregistration_flow.dart';
+import 'package:comwell_key_app/presentation/screens/past_cancelled_booking_details/past_cancelled_booking_detail_route.dart';
import 'package:comwell_key_app/presentation/screens/webview/webview_route.dart';
-import 'package:comwell_key_app/profile/profile_repository.dart';
-import 'package:comwell_key_app/received_shared_booking/cubit/received_shared_booking_cubit.dart';
-import 'package:comwell_key_app/received_shared_booking/received_shared_booking_page.dart';
-import 'package:comwell_key_app/received_shared_room/cubit/received_shared_room_cubit.dart';
-import 'package:comwell_key_app/received_shared_room/received_shared_room_page.dart';
-import 'package:comwell_key_app/redeem_debug/redeem_route.dart';
+import 'package:comwell_key_app/received_shared_booking/received_shared_booking_route.dart';
+import 'package:comwell_key_app/received_shared_room/received_shared_room_route.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/routing/go_router_observer.dart';
-import 'package:comwell_key_app/share/cubit/share_booking_cubit.dart';
-import 'package:comwell_key_app/share/share_booking_page.dart';
-import 'package:comwell_key_app/up_sales/cubit/up_sales_cubit.dart';
-import 'package:comwell_key_app/up_sales/cubit/up_sales_state.dart';
-import 'package:comwell_key_app/up_sales/models/addon_upgrade.dart';
-import 'package:comwell_key_app/up_sales/models/room_upgrade.dart';
-import 'package:comwell_key_app/up_sales/models/room_upgrade_list.dart';
-import 'package:comwell_key_app/up_sales/pages/addon_upgrade_page.dart';
-import 'package:comwell_key_app/up_sales/pages/processing/up_sales_error_page.dart';
-import 'package:comwell_key_app/up_sales/pages/room_upgrade_page.dart';
-import 'package:comwell_key_app/up_sales/pages/services_upgrade_page.dart';
-import 'package:comwell_key_app/up_sales/pages/up_sale_confirmation_page.dart';
-import 'package:comwell_key_app/up_sales/pages/processing/up_sales_processing_page.dart';
-import 'package:comwell_key_app/up_sales/up_sales_repository.dart';
-import 'package:comwell_key_app/up_sales/up_sales_catalog.dart';
+import 'package:comwell_key_app/share/share_booking_route.dart';
+import 'package:comwell_key_app/up_sales/up_sales_route.dart';
import 'package:comwell_key_app/utils/context_utils.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
-import 'package:payment_plugin/domain/repositories/adyen_repository.dart';
-import 'package:payment_plugin/presentation/app/bloc/payment_cards_cubit.dart';
-import 'package:payment_plugin/presentation/app/bloc/payment_cubit.dart';
-import 'package:payment_plugin/presentation/screens/payment_cards_page.dart';
-import 'package:payment_plugin/presentation/screens/payment_processing_page.dart';
-import '../hotel_information/repository/hotel_information_repository.dart';
import '../presentation/screens/onboarding/onboarding_routes.dart';
import '../utils/locator.dart';
final _rootNavigatorKey = GlobalKey<NavigatorState>();
final rootNavigatorKey = _rootNavigatorKey;
-final _shellNavigatorKey = GlobalKey<NavigatorState>();
final authExceptions = [AppRoutes.webview];
@@ -134,450 +83,27 @@ final router = GoRouter(
notificationsPermissionRoute,
usageTrackingPermissionRoute,
overviewRoute,
- redeemRoute,
webviewRoute,
- ShellRoute(
- navigatorKey: _shellNavigatorKey,
- parentNavigatorKey: _rootNavigatorKey,
- pageBuilder: (context, state, child) {
- return NoTransitionPage(
- child: BlocProvider(
- create: (_) => HotelInformationCubit(
- hotelInformationRepository: locator<HotelInformationRepository>(),
- booking: state.extra as Booking,
- )..init(),
- child: HotelInformationPage(child: child),
- ),
- );
- },
- routes: [
- GoRoute(
- path: "/${AppRoutes.hotelInformation.name}",
- name: AppRoutes.hotelInformation.name,
- builder: (context, state) {
- return const HotelInformationMenu();
- },
- ),
- GoRoute(
- path: "/${AppRoutes.hotelInformation.name}/${AppRoutes.facility.name}",
- name: "${AppRoutes.hotelInformation.name}/${AppRoutes.facility.name}",
- builder: (context, state) {
- return FacilityPage(facility: state.extra as Facility);
- },
- ),
- ],
- ),
- GoRoute(
- path: '/${AppRoutes.contact.name}',
- name: AppRoutes.contact.name,
- builder: (context, state) {
- final booking = state.extra as Booking;
- return BlocProvider<ContactCubit>(
- create: (BuildContext context) => ContactCubit(
- contactRepository: locator<ContactRepository>(),
- overviewRepository: locator<OverviewRepository>(),
- profileRepository: locator<ProfileRepository>(),
- )..init(),
- child: ContactPage(hotelCode: booking.hotelCode),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.findBooking.name}",
- name: AppRoutes.findBooking.name,
- builder: (context, state) {
- return BlocProvider(
- create: (context) => FindBookingCubit(),
- child: const FindBookingPage(),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.shareBooking.name}",
- name: AppRoutes.shareBooking.name,
- builder: (context, state) {
- final booking = state.extra as Booking;
- return BlocProvider(
- create: (context) => ShareBookingCubit(),
- child: ShareBookingPage(booking: booking),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.bookingDetails.name}/:id",
- name: "booking_deep_link",
- builder: (context, state) {
- final bookingId = state.pathParameters['id']!;
- context.read<OverviewCubit>().findBookingById(bookingId);
- return const LoadingPage();
- },
- ),
- GoRoute(
- path: "/${AppRoutes.loadingPage.name}",
- name: AppRoutes.loadingPage.name,
- builder: (context, state) {
- return BlocProvider(
- create: (context) => FindBookingCubit(),
- child: const LoadingPage(),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.checkIn.name}",
- name: AppRoutes.checkIn.name,
- builder: (context, state) {
- return BlocProvider(
- create: (context) {
- final extras = state.extra as List<dynamic>;
- final booking = extras[0] as Booking;
- final onlyKeys = extras[1] as bool;
- if (onlyKeys) {
- return CheckInCubit.initialOnlyKeys(booking);
- }
- return CheckInCubit(booking);
- },
- child: const CheckInPage(),
- );
- },
- ),
- ShellRoute(
- pageBuilder: (context, state, child) {
- return CustomTransitionPage(
- transitionsBuilder: (context, animation, secondaryAnimation, child) {
- return SlideTransition(
- position:
- Tween<Offset>(
- begin: const Offset(1.0, 0.0),
- end: Offset.zero,
- ).animate(
- CurvedAnimation(
- parent: animation,
- curve: Curves.easeInOut,
- ),
- ),
- child: child,
- );
- },
- child: BlocProvider(
- create: (context) => MyBookingCubit(
- locator<MyBookingRepository>(),
- context.read<PaymentCubit>(),
- initialBooking: state.extra as Booking,
- )..init(),
- child: child,
- ),
- );
- },
- routes: [
- GoRoute(
- path: "/${AppRoutes.myBooking.name}",
- name: AppRoutes.myBooking.name,
- builder: (context, state) {
- return MyBookingPage(booking: state.extra as Booking);
- },
- ),
- GoRoute(
- path: "/${AppRoutes.payMyBooking.name}",
- name: AppRoutes.payMyBooking.name,
- builder: (context, state) {
- return const MyBookingPaymentPage();
- },
- ),
- ],
- ),
- GoRoute(
- path: "/${AppRoutes.paymentCards.name}",
- name: AppRoutes.paymentCards.name,
- builder: (context, state) {
- return BlocProvider(
- create: (context) => PaymentCardsCubit(adyenRepository: locator<AdyenRepository>()),
- child: Builder(
- builder: (context) {
- final scaffold = state.uri.queryParameters[needsScaffold] == 'true';
- return PaymentCardsPage(
- needScaffold: scaffold,
- appBar: const ComwellAppBar(shouldShowProfileButton: false),
- );
- },
- ),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.preregistration.name}",
- name: AppRoutes.preregistration.name,
- builder: (context, state) {
- final extras = state.extra as List<dynamic>;
- final booking = extras[0] as Booking;
- return BlocProvider(
- create: (context) => PreregistrationCubit(booking: booking)..init(),
- child: const PreregistrationFlow(),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.houseKeeping.name}",
- name: AppRoutes.houseKeeping.name,
- builder: (context, state) {
- final booking = state.extra as Booking;
- return HousekeepingPage(booking: booking);
- },
- ),
- GoRoute(
- path: "/${AppRoutes.checkOut.name}",
- name: AppRoutes.checkOut.name,
- builder: (context, state) {
- final booking = state.extra as Booking;
- return BlocProvider(
- create: (context) =>
- CheckoutCubit(booking, locator<CheckOutRepository>(), context.read<PaymentCubit>())
- ..init(),
- child: BlocBuilder<CheckoutCubit, CheckoutState>(
- builder: (context, state) {
- return CheckOutFlow(key: ValueKey(state));
- },
- ),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.paymentProcessing.name}",
- name: AppRoutes.paymentProcessing.name,
- builder: (context, state) => const PaymentProcessingPage(),
- ),
- GoRoute(
- path: "/${AppRoutes.notifications.name}",
- name: AppRoutes.notifications.name,
- builder: (context, state) {
- return BlocProvider(
- create: (context) => NotificationsCubit(locator<NotificationsRepository>())..init(),
- child: const NotificationsPage(
- notificationPermissions: [],
- ),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.checkOutSuccess.name}",
- name: AppRoutes.checkOutSuccess.name,
- builder: (context, state) {
- final digitalCard = state.extra as bool;
- return CheckOutSuccessPage(digitalCard: digitalCard);
- },
- ),
- GoRoute(
- path: "/${AppRoutes.checkOutError.name}",
- name: AppRoutes.checkOutError.name,
- builder: (context, state) => const CheckOutErrorPage(),
- ),
- ShellRoute(
- pageBuilder: (context, state, child) {
- return CustomTransitionPage<void>(
- key: state.pageKey,
- child: BlocProvider(
- create: (_) {
- final extras = state.extra as List<dynamic>;
-
- return UpSalesCubit(
- upSaleRepository: locator<UpSalesRepository>(),
- booking: extras[0] as Booking,
- )..init();
- },
- child: child,
- ),
- transitionsBuilder: (context, animation, secondaryAnimation, child) {
- return SlideTransition(
- position:
- Tween<Offset>(
- begin: const Offset(1.0, 0.0),
- end: Offset.zero,
- ).animate(
- CurvedAnimation(
- parent: animation,
- curve: Curves.easeInOut,
- ),
- ),
- child: child,
- );
- },
- transitionDuration: const Duration(milliseconds: 250),
- );
- },
- routes: [
- GoRoute(
- path: "/${AppRoutes.upSalesCatalog.name}",
- name: AppRoutes.upSalesCatalog.name,
- builder: (context, state) {
- return const UpSalesCatalog();
- },
- ),
- GoRoute(
- path: "/${AppRoutes.roomUpgrade.name}",
- name: AppRoutes.roomUpgrade.name,
- builder: (context, state) {
- return RoomUpgradePage(roomUpgradeList: state.extra as RoomUpgradeList);
- },
- ),
- GoRoute(
- path: "/${AppRoutes.addonUpgrade.name}",
- name: AppRoutes.addonUpgrade.name,
- builder: (context, state) {
- final extras = state.extra as List<dynamic>;
- return AddonUpgradePage(
- addonUpgrade: extras[0] as AddOnUpgrade,
- extrasTotalPrice: extras[1] as int,
- selectedRoomUpgrade: extras[2] as String,
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.servicesUpgrade.name}",
- name: AppRoutes.servicesUpgrade.name,
- builder: (context, state) {
- return ServicesUpgradePage(roomUpgradeList: state.extra as RoomUpgradeList);
- },
- ),
- GoRoute(
- path: "/${AppRoutes.upSaleConfirmation.name}",
- name: AppRoutes.upSaleConfirmation.name,
- builder: (context, state) {
- final extras = state.extra as List<dynamic>;
- final selectedUpSales = extras[0] as List<AddOnUpgrade?>;
- final extrasTotalPrice = extras[1] as int;
- final selectedRoomUpgrade = extras[2] as RoomUpgrade?;
- return UpSaleConfirmationPage(
- selectedUpSales: selectedUpSales.whereType<AddOnUpgrade>().toList(),
- extrasTotalPrice: extrasTotalPrice,
- selectedRoomUpgrade: selectedRoomUpgrade,
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.upSalesProcessing.name}",
- name: AppRoutes.upSalesProcessing.name,
- builder: (context, state) {
- final cubit = context.read<UpSalesCubit>();
- cubit.addUpSalesToBooking();
-
- return BlocBuilder<UpSalesCubit, UpSalesState>(
- builder: (context, state) {
- return UpSalesProcessingPage(key: ValueKey(state));
- },
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.upSalesError.name}",
- name: AppRoutes.upSalesError.name,
- builder: (context, state) => const UpSalesErrorPage(),
- ),
- ],
- ),
- GoRoute(
- path: "/${AppRoutes.chooseShareRoom.name}",
- name: AppRoutes.chooseShareRoom.name,
- builder: (context, state) {
- final booking = state.extra as Booking;
- return BlocProvider(
- create: (context) => ChooseShareRoomCubit(locator<ChooseShareRoomRepository>())..init(),
- child: ChooseShareRoomPage(booking: booking),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.roomInfo.name}",
- name: AppRoutes.roomInfo.name,
- builder: (context, state) {
- final extras = state.extra as List<dynamic>;
- final booking = extras[0] as Booking;
- final isAssigned = extras[1] as bool;
- return BlocProvider(
- create: (context) => ChooseShareRoomCubit(locator<ChooseShareRoomRepository>()),
- child: RoomInfoPage(booking: booking, isAssigned: isAssigned),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.shareRoom.name}",
- builder: (context, state) {
- final booking = state.extra as Booking;
- return BlocProvider(
- create: (context) => ChooseShareRoomCubit(locator<ChooseShareRoomRepository>()),
- child: ShareRoomPage(booking: booking),
- );
- },
- ),
- GoRoute(
- path: AppRoutes.receivedSharedRoom,
- builder: (context, state) {
- final sharingId = state.uri.queryParameters['sharingId'];
- final hotelCode = state.uri.queryParameters['hotelCode'];
- debugPrint("Received shared room: $sharingId $hotelCode ${state.uri}");
- return BlocProvider(
- create: (context) => ReceivedSharedRoomCubit(sharingId ?? '', hotelCode ?? '')..init(),
- child: const ReceivedSharedRoomPage(),
- );
- },
- ),
- GoRoute(
- path: AppRoutes.receivedSharedBooking,
- builder: (context, state) {
- final sharingId = state.uri.queryParameters['sharingId'];
- final hotelCode = state.uri.queryParameters['hotelCode'];
- debugPrint("Received shared booking: $sharingId $hotelCode ${state.uri}");
- return BlocProvider(
- create: (context) => ReceivedSharedBookingCubit(sharingId ?? '', hotelCode ?? '')..init(),
- child: const ReceivedSharedBookingPage(),
- );
- },
- ),
- GoRoute(
- path: "/${AppRoutes.forceUpdate.name}",
- name: AppRoutes.forceUpdate.name,
- builder: (context, state) {
- return const ForceUpdatePage();
- },
- ),
- /* GoRoute(
- path: "/keys",
- name: AppRoutes.keys.name,
- builder: (context, state) {
- List<MobileKeysKey> keys = state.extra as List<MobileKeysKey>;
- return KeyPage(List<mobileKey>: keys);
- },
- ) */
- /*
- GoRoute(
- path: "/login",
- name: AppRoutes.login.name,
- builder: (context, state) => const LoginPage(),
- ),
- GoRoute(
- path: "/room/:exercise_id",
- pageBuilder: (context, state) {
- String exerciseId = state.pathParameters["exercise_id"] as String;
- Exercise? arg = exerciseMap[exerciseId];
- String roomName = "";
- if (arg == null) {
- context.go("/");
- } else {
- roomName = "${arg.name}_${const Uuid().v4()}";
- }
-
- return CustomTransitionPage<void>(
- key: state.pageKey,
- child: arg == null
- ? Container()
- : RoomPage(roomName: roomName, exercise: arg),
- transitionsBuilder:
- (context, animation, secondaryAnimation, child) {
- return FadeTransition(
- opacity: animation,
- child: child,
- );
- },
- transitionDuration: const Duration(milliseconds: 1000),
- );
- }) */
+ pastCancelledBookingDetailsRoute,
+ bookingDetailsRoute,
+ keyRoute,
+ chooseShareRoomRoute,
+ contactRoute,
+ findBookingRoute,
+ shareBookingRoute,
+ forceUpdateRoute,
+ receivedSharedBookingRoute,
+ bookingDetailsWithIdRoute,
+ findBookingLoadingRoute,
+ myBookingRoute,
+ paymentCardRoute,
+ preregistrationRoute,
+ houseKeepingRoute,
+ paymentProcessingRoute,
+ notificationsRoute,
+ ...checkOutRoutes,
+ upSalesRoute,
+ roomInfoRoute,
+ receivedSharedRoomRoute,
],
);
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index d2c01b3e..551fc0c8 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -1,55 +1,49 @@
-enum AppRoutes {
- welcome,
- initial,
- key,
- keys,
- settings,
- sheet,
- profile,
- profileSettings,
- bookingDetails,
- pastCancelledBookings,
- findBooking,
- loadingPage,
- changePassword,
- checkIn,
- contact,
- preregistration,
- hotelInformation,
- facility,
- houseKeeping,
- checkOut,
- paymentCards,
- shareBooking,
- notifications,
- myBooking,
- upSalesCatalog,
- roomUpgrade,
- addonUpgrade,
- servicesUpgrade,
- upSaleConfirmation,
- upSalesProcessing,
- chooseShareRoom,
- roomInfo,
- shareRoom,
- forceUpdate,
- upSalesError,
- sharedbooking,
- payMyBooking,
- paymentProcessing,
- checkOutSuccess,
- checkOutError,
- onboarding;
-
+abstract class AppRoutes {
static const splash = "/";
static const login = "/login";
static const forceLogin = "/login?forced=true";
static const overview = "/overview";
static const redeem = "/redeem";
static const webview = "/webview";
+ static const key = "/key";
+ static const pastCancelledBookings = "/past-cancelled-bookings";
+ static const bookingDetailsWithId = "/booking-details/:id";
+ static const bookingDetails = "/booking-details";
static const onboardingBluetooth = "/onboarding/bluetooth";
static const onboardingNotification = "/onboarding/notification";
static const onboardingUsageTracking = "/onboarding/usage-tracking";
static const receivedSharedRoom = "/received-shared-room";
static const receivedSharedBooking = "/received-shared-booking";
+ static const checkOutSuccess = "/checkout-success";
+ static const paymentProcessing = "/payment-processing";
+ static const profile = "/profile";
+ static const profileSettings = "/profile-settings";
+ static const findBooking = "/find-booking";
+ static const loadingPage = "/loading-page";
+ static const changePassword = "/change-password";
+ static const checkIn = "/check-in";
+ static const contact = "/contact";
+ static const preregistration = "/preregistration";
+ static const hotelInformation = "/hotel-information";
+ static const facility = "/facility";
+ static const houseKeeping = "/house-keeping";
+ static const checkOut = "/check-out";
+ static const paymentCards = "/payment-cards";
+ static const shareBooking = "/share-booking";
+ static const notifications = "/notifications";
+ static const myBooking = "/my-booking";
+ static const upSalesCatalog = "/up-sales-catalog";
+ static const roomUpgrade = "/room-upgrade";
+ static const addonUpgrade = "/addon-upgrade";
+ static const servicesUpgrade = "/services-upgrade";
+ static const upSaleConfirmation = "/up-sale-confirmation";
+ static const upSalesProcessing = "/up-sales-processing";
+ static const chooseShareRoom = "/choose-share-room";
+ static const roomInfo = "/room-info";
+ static const shareRoom = "/share-room";
+ static const forceUpdate = "/force-update";
+ static const upSalesError = "/up-sales-error";
+ static const sharedBooking = "/shared-booking";
+ static const payMyBooking = "/pay-my-booking";
+ static const checkOutError = "/check-out-error";
}
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index 5c00efdd..dc1cc59c 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -67,83 +67,6 @@ class Api {
return response.data!.map((e) => BookingDTO.fromJson(e as Json)).toList();
}
- /* Future<StoredPaymentsResponse?> getPaymentMethods() async {
- final response = await dio.get<Json>(ApiEndpoints.storedPaymentMethods);
- return StoredPaymentsResponse.fromJson(response.data!);
- } */
-
- /* Future<dynamic> createAdyenSession(String bookingId, bool usePoints, String hotelCode) async {
- final body = {
- "hotelCode": hotelCode,
- "bookingConfirmationNumber": bookingId,
- "returnUrl": ApiEndpoints.returnUrl,
- "usePoints": usePoints,
- };
- final json = jsonEncode(body);
- final response =
- await dio.post<dynamic>(ApiEndpoints.createAdyenSession, data: json);
-
- return response.data;
- }
-
- Future<dynamic> createAdyenSessionForCards() async {
- final body = {
- "returnUrl": ApiEndpoints.returnUrl,
- };
- final json = jsonEncode(body);
- final response = await dio
- .post<dynamic>(ApiEndpoints.createAdyenSessionForCards, data: json);
- return response.data;
- }
-
- Future<dynamic> listAvailablePaymentMethods() async {
- final response =
- await dio.get<dynamic>(ApiEndpoints.listAvailablePaymentMethods);
- return response.data;
- }
-
- Future<dynamic> storePaymentMethod(PaymentMethod paymentMethod) async {
- final body = {
- "paymentMethod": paymentMethod,
- };
- final json = jsonEncode(body);
- final response =
- await dio.post<dynamic>(ApiEndpoints.storedPaymentMethods, data: json);
- return response.data;
- }
-
- Future<dynamic> removePaymentMethod(String cardId) async {
- final response = await dio
- .delete<dynamic>("${ApiEndpoints.storedPaymentMethods}/$cardId");
- return response.data;
- }
-
- Future<Json> submitPayment(Json paymentResult, String shopperReference,
- String merchantAccount) async {
- final Json headers = {
- "content-type": "application/json",
- "x-API-key": dotenv.env["ADYEN_TEST_KEY"]
- };
- final Map<String, dynamic> data = {
- "shopperReference": shopperReference,
- "amount": {"value:": 0, "currency": "DKK"},
- "countryCode": "DK",
- "merchantAccount": merchantAccount,
- "returnUrl": "comwell://",
- "reference": "flutter-test_${DateTime.now().millisecondsSinceEpoch}",
- "channel": "iOS",
- };
- data.addAll(paymentResult);
- data.remove("storePaymentMethod");
- debugPrint("Data: $data");
- final response = await dio.post<Json>(ApiEndpoints.adyenPayments,
- data: data,
- options: Options(
- headers: headers,
- ));
- return response.data!;
- }
- */
Future<Response<dynamic>> fetchProfileSettings() async {
final response = await dio.get<dynamic>(ApiEndpoints.getGuestProfile);
return response;
diff --git a/comwell_key_app/lib/share/cubit/share_booking_cubit.dart b/comwell_key_app/lib/share/cubit/share_booking_cubit.dart
index 3e682e0d..46c4c0f1 100644
--- a/comwell_key_app/lib/share/cubit/share_booking_cubit.dart
+++ b/comwell_key_app/lib/share/cubit/share_booking_cubit.dart
@@ -10,10 +10,12 @@ import 'package:share_plus/share_plus.dart';
part 'share_booking_state.dart';
class ShareBookingCubit extends Cubit<ShareBookingState> {
- final ShareBookingRepository shareBookingRepository =
- locator<ShareBookingRepository>();
+ final ShareBookingRepository _shareBookingRepository;
- ShareBookingCubit() : super(const ShareBookingState.initial());
+ final Booking booking;
+
+ ShareBookingCubit(this._shareBookingRepository, {required this.booking})
+ : super(const ShareBookingState.initial());
void updateSelectedGuests(Iterable<Guest> guests) {
emit(state.updateSelectedGuests(guests));
@@ -28,16 +30,17 @@ class ShareBookingCubit extends Cubit<ShareBookingState> {
Future<void> createRoomSharingLink(Booking booking) async {
emit(state.loading());
- final link = await shareBookingRepository.createRoomSharingLink(
- booking.confirmationNumber, booking.hotelCode, 0);
+ final link = await _shareBookingRepository.createRoomSharingLink(
+ booking.confirmationNumber,
+ booking.hotelCode,
+ 0,
+ );
if (link != null && link.isNotEmpty) {
Share.share(
- 'share_booking_message'.tr(args: [
- "${booking.firstName} ${booking.lastName}",
- booking.hotelName,
- link
- ]),
+ 'share_booking_message'.tr(
+ args: ["${booking.firstName} ${booking.lastName}", booking.hotelName, link],
+ ),
subject: 'comwell_booking'.tr(),
);
emit(state.loaded());
diff --git a/comwell_key_app/lib/share/share_booking_page.dart b/comwell_key_app/lib/share/share_booking_page.dart
index c8e30336..c24f527a 100644
--- a/comwell_key_app/lib/share/share_booking_page.dart
+++ b/comwell_key_app/lib/share/share_booking_page.dart
@@ -6,8 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:comwell_key_app/share/cubit/share_booking_cubit.dart';
class ShareBookingPage extends StatefulWidget {
- final Booking booking;
- const ShareBookingPage({super.key, required this.booking});
+ const ShareBookingPage({super.key});
@override
State<ShareBookingPage> createState() => _ShareBookingPageState();
@@ -25,29 +24,32 @@ class _ShareBookingPageState extends State<ShareBookingPage> {
@override
Widget build(BuildContext context) {
return BlocListener<ShareBookingCubit, ShareBookingState>(
- listener: (context, state) {
- if (state.error != null) {
- _errorTimer?.cancel();
- _errorTimer = Timer(const Duration(seconds: 5), () {
- if (mounted) {
- context.read<ShareBookingCubit>().clearSelection();
- }
- });
- } else {
- _errorTimer?.cancel();
- }
- }, child: BlocBuilder<ShareBookingCubit, ShareBookingState>(
- builder: (context, state) {
- final cubit = context.read<ShareBookingCubit>();
-
- return ShareBookingBaseTemplate(
- booking: widget.booking,
- onClicked: () {
- cubit.createRoomSharingLink(widget.booking);
- },
- isShared: false,
- isLoading: state.isLoading,
- error: state.error);
- }));
+ listener: (context, state) {
+ if (state.error != null) {
+ _errorTimer?.cancel();
+ _errorTimer = Timer(const Duration(seconds: 5), () {
+ if (mounted) {
+ context.read<ShareBookingCubit>().clearSelection();
+ }
+ });
+ } else {
+ _errorTimer?.cancel();
+ }
+ },
+ child: BlocBuilder<ShareBookingCubit, ShareBookingState>(
+ builder: (context, state) {
+ final cubit = context.read<ShareBookingCubit>();
+ return ShareBookingBaseTemplate(
+ booking: cubit.booking,
+ onClicked: () {
+ cubit.createRoomSharingLink(cubit.booking);
+ },
+ isShared: false,
+ isLoading: state.isLoading,
+ error: state.error,
+ );
+ },
+ ),
+ );
}
}
diff --git a/comwell_key_app/lib/share/share_booking_route.dart b/comwell_key_app/lib/share/share_booking_route.dart
new file mode 100644
index 00000000..58eab1a8
--- /dev/null
+++ b/comwell_key_app/lib/share/share_booking_route.dart
@@ -0,0 +1,18 @@
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/share/cubit/share_booking_cubit.dart';
+import 'package:comwell_key_app/share/share_booking_page.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final shareBookingRoute = GoRoute(
+ path: AppRoutes.shareBooking,
+ builder: (context, state) {
+ final booking = state.extra as Booking;
+ return BlocProvider(
+ create: (context) => ShareBookingCubit(locator(), booking: booking),
+ child: const ShareBookingPage(),
+ );
+ },
+);
diff --git a/comwell_key_app/lib/up_sales/components/catalog/addon_upgrade_catalog.dart b/comwell_key_app/lib/up_sales/components/catalog/addon_upgrade_catalog.dart
index 1235fbce..2042b79f 100644
--- a/comwell_key_app/lib/up_sales/components/catalog/addon_upgrade_catalog.dart
+++ b/comwell_key_app/lib/up_sales/components/catalog/addon_upgrade_catalog.dart
@@ -28,7 +28,7 @@ class AddOnUpgradeCatalog extends StatelessWidget {
final isSelected = addOnUpgrades.elementAt(index).isAddedToCart;
return GestureDetector(
onTap: () async {
- final quantity = await context.pushNamed(AppRoutes.addonUpgrade.name, extra: [
+ final quantity = await context.push(AppRoutes.addonUpgrade, extra: [
addOnUpgrades.elementAt(index),
extrasTotalPrice,
selectedRoomUpgrade,
@@ -42,7 +42,7 @@ class AddOnUpgradeCatalog extends StatelessWidget {
height: 268,
upgrade: addOnUpgrades.elementAt(index),
isSelected: isSelected,
- routeName: AppRoutes.addonUpgrade.name,
+ routeName: AppRoutes.addonUpgrade,
showCounter: true,
isAddon: true,
onTap: (upgrade) {},
diff --git a/comwell_key_app/lib/up_sales/components/catalog/room_upgrade_catalog.dart b/comwell_key_app/lib/up_sales/components/catalog/room_upgrade_catalog.dart
index 3a1a5dc1..559e80e3 100644
--- a/comwell_key_app/lib/up_sales/components/catalog/room_upgrade_catalog.dart
+++ b/comwell_key_app/lib/up_sales/components/catalog/room_upgrade_catalog.dart
@@ -50,8 +50,8 @@ class RoomUpgradeCatalog extends StatelessWidget {
return GestureDetector(
onTap: () async {
- final result = await context.pushNamed(
- AppRoutes.roomUpgrade.name,
+ final result = await context.push(
+ AppRoutes.roomUpgrade,
extra: RoomUpgradeList(
booking: booking,
roomUpgrade: roomUpgrade,
@@ -71,7 +71,7 @@ class RoomUpgradeCatalog extends StatelessWidget {
height: kUpSalesServiceWidgetHeightLarge,
upgrade: roomUpgrade,
isSelected: isSelected,
- routeName: AppRoutes.roomUpgrade.name,
+ routeName: AppRoutes.roomUpgrade,
showCounter: false,
onTap: (upgrade) {
onTap(upgrade);
diff --git a/comwell_key_app/lib/up_sales/components/catalog/service_catalog.dart b/comwell_key_app/lib/up_sales/components/catalog/service_catalog.dart
index c0f82bce..0ca9c273 100644
--- a/comwell_key_app/lib/up_sales/components/catalog/service_catalog.dart
+++ b/comwell_key_app/lib/up_sales/components/catalog/service_catalog.dart
@@ -41,8 +41,8 @@ class ServiceCatalog extends StatelessWidget {
final isSelected = upSales.elementAt(index).isSelected;
return GestureDetector(
onTap: () async {
- final result = await context.pushNamed(
- AppRoutes.servicesUpgrade.name,
+ final result = await context.push(
+ AppRoutes.servicesUpgrade,
extra: RoomUpgradeList(
booking: booking,
addOnUpgrade: upSales.elementAt(index),
diff --git a/comwell_key_app/lib/up_sales/components/up_sales_catalog_button.dart b/comwell_key_app/lib/up_sales/components/up_sales_catalog_button.dart
index 202e808d..37f956ae 100644
--- a/comwell_key_app/lib/up_sales/components/up_sales_catalog_button.dart
+++ b/comwell_key_app/lib/up_sales/components/up_sales_catalog_button.dart
@@ -17,7 +17,7 @@ class UpSalesCatalogButton extends StatelessWidget {
return GestureDetector(
onTap: () {
- context.pushNamed(AppRoutes.upSalesCatalog.name, extra: [upSales, booking]);
+ context.push(AppRoutes.upSalesCatalog, extra: [upSales, booking]);
},
child: Container(
width: double.infinity,
diff --git a/comwell_key_app/lib/up_sales/components/up_sales_continue_button.dart b/comwell_key_app/lib/up_sales/components/up_sales_continue_button.dart
index 21849f33..fa4f349f 100644
--- a/comwell_key_app/lib/up_sales/components/up_sales_continue_button.dart
+++ b/comwell_key_app/lib/up_sales/components/up_sales_continue_button.dart
@@ -33,7 +33,7 @@ class UpSalesContinueButton extends StatelessWidget {
child: ElevatedButton(
onPressed: () {
if (!isUpSalesEmpty) {
- context.pushNamed(AppRoutes.upSaleConfirmation.name, extra: [
+ context.push(AppRoutes.upSaleConfirmation, extra: [
selectedUpSales,
extrasTotalPrice,
selectedRoomUpgrade
diff --git a/comwell_key_app/lib/up_sales/cubit/up_sales_cubit.dart b/comwell_key_app/lib/up_sales/cubit/up_sales_cubit.dart
index a4bc691d..ce4c8571 100644
--- a/comwell_key_app/lib/up_sales/cubit/up_sales_cubit.dart
+++ b/comwell_key_app/lib/up_sales/cubit/up_sales_cubit.dart
@@ -15,21 +15,28 @@ class UpSalesCubit extends Cubit<UpSalesState> {
final Booking booking;
UpSalesCubit({required this.upSaleRepository, required this.booking})
- : super(UpSalesState.initial());
+ : super(UpSalesState.initial()) {
+ init();
+ }
void init() async {
emit(state.loading());
upSales = await upSaleRepository.getRemoteUpSales(
- booking.confirmationNumber, booking.hotelCode);
+ booking.confirmationNumber,
+ booking.hotelCode,
+ );
- emit(UpSalesState(
+ emit(
+ UpSalesState(
selected: false,
addOnUpgrades: upSales.addOnUpgrades,
availableRoomUpgrades: upSales.roomUpgrades,
selectedRoomUpgrade: '',
isLoading: false,
processingState: UpSalesProcessingStateNotStarted(),
- error: null));
+ error: null,
+ ),
+ );
try {
emit(state.loaded(upSales: upSales));
} catch (e) {
@@ -57,24 +64,19 @@ class UpSalesCubit extends Cubit<UpSalesState> {
//This is the total price of the selected up sales and the price of the selected
//room upgrade if it is selected
- return selectedAddOnUpgrades.fold(
- 0, (sum, upgrade) => sum + upgrade.price * upgrade.quantity) +
+ return selectedAddOnUpgrades.fold(0, (sum, upgrade) => sum + upgrade.price * upgrade.quantity) +
(state.selectedRoomUpgrade.isNotEmpty
- ? upSales.roomUpgrades
- .firstWhere((e) => e.id == state.selectedRoomUpgrade)
- .price
+ ? upSales.roomUpgrades.firstWhere((e) => e.id == state.selectedRoomUpgrade).price
: 0);
}
List<AddOnUpgrade> get selectedAddOnUpgrades {
- final selectedUpgrades =
- state.addOnUpgrades.where((upgrade) => upgrade.isAddedToCart).toList();
+ final selectedUpgrades = state.addOnUpgrades.where((upgrade) => upgrade.isAddedToCart).toList();
return selectedUpgrades;
}
List<AddOnUpgrade> get otherUpgrades {
- final selectedUpgrades =
- state.addOnUpgrades.where((upgrade) => !upgrade.isService).toList();
+ final selectedUpgrades = state.addOnUpgrades.where((upgrade) => !upgrade.isService).toList();
return selectedUpgrades;
}
@@ -91,12 +93,15 @@ class UpSalesCubit extends Cubit<UpSalesState> {
// Convert selected up sales to AddOnList objects using their individual quantities
final List<AddOnList> addonList = state.addOnUpgrades
.where((upgrade) => upgrade.quantity > 0)
- .map((upgrade) =>
- AddOnList(itemCode: upgrade.id, quantity: upgrade.quantity))
+ .map((upgrade) => AddOnList(itemCode: upgrade.id, quantity: upgrade.quantity))
.toList();
await upSaleRepository.addUpSalesToBooking(
- booking.confirmationNumber, booking.hotelCode, roomType, addonList);
+ booking.confirmationNumber,
+ booking.hotelCode,
+ roomType,
+ addonList,
+ );
await Future<void>.delayed(const Duration(seconds: 2));
emit(state.processingStateUpdated(UpSalesProcessingStateSuccess()));
} catch (e) {
diff --git a/comwell_key_app/lib/up_sales/pages/processing/up_sales_error_page.dart b/comwell_key_app/lib/up_sales/pages/processing/up_sales_error_page.dart
index fe55d108..60a3e06d 100644
--- a/comwell_key_app/lib/up_sales/pages/processing/up_sales_error_page.dart
+++ b/comwell_key_app/lib/up_sales/pages/processing/up_sales_error_page.dart
@@ -41,7 +41,7 @@ class UpSalesErrorPage extends StatelessWidget {
onPressed: () {
Navigator.of(context).popUntil((route) =>
route.settings.name ==
- AppRoutes.bookingDetails.name);
+ AppRoutes.bookingDetails);
},
style: const ButtonStyle(
backgroundColor:
diff --git a/comwell_key_app/lib/up_sales/pages/processing/up_sales_processing_page.dart b/comwell_key_app/lib/up_sales/pages/processing/up_sales_processing_page.dart
index 0d457592..e92e09e0 100644
--- a/comwell_key_app/lib/up_sales/pages/processing/up_sales_processing_page.dart
+++ b/comwell_key_app/lib/up_sales/pages/processing/up_sales_processing_page.dart
@@ -48,7 +48,6 @@ class _UpSalesProcessingPageState extends State<UpSalesProcessingPage>
repeat: false,
);
await Future<void>.delayed(const Duration(seconds: 2));
-
}
void playSuccess() async {
@@ -59,8 +58,7 @@ class _UpSalesProcessingPageState extends State<UpSalesProcessingPage>
);
await Future<void>.delayed(const Duration(seconds: 2));
if (mounted) {
- Navigator.of(context).popUntil(
- (route) => route.settings.name == AppRoutes.bookingDetails.name);
+ Navigator.of(context).popUntil((route) => route.settings.name == AppRoutes.bookingDetails);
}
}
@@ -72,33 +70,35 @@ class _UpSalesProcessingPageState extends State<UpSalesProcessingPage>
body: Container(
alignment: Alignment.center,
color: sandColor[80],
- child: Builder(builder: (context) {
- final processingState = cubit.state.processingState;
- if (processingState is UpSalesProcessingStateError) {
- return const UpSalesErrorPage();
- }
- return Lottie.asset(
- 'assets/animations/load_animation.json',
- controller: animationController,
- onLoaded: (composition) {
- if (loadingComposition == null) {
- loadingComposition = composition;
- animationController.duration = composition.duration;
- switch (cubit.state.processingState) {
- case UpSalesProcessingStateSuccess _:
- playSuccess();
- case UpSalesProcessingStateError _:
- playError();
- default:
- playLoading(cubit);
+ child: Builder(
+ builder: (context) {
+ final processingState = cubit.state.processingState;
+ if (processingState is UpSalesProcessingStateError) {
+ return const UpSalesErrorPage();
+ }
+ return Lottie.asset(
+ 'assets/animations/load_animation.json',
+ controller: animationController,
+ onLoaded: (composition) {
+ if (loadingComposition == null) {
+ loadingComposition = composition;
+ animationController.duration = composition.duration;
+ switch (cubit.state.processingState) {
+ case UpSalesProcessingStateSuccess _:
+ playSuccess();
+ case UpSalesProcessingStateError _:
+ playError();
+ default:
+ playLoading(cubit);
+ }
}
- }
- },
- fit: BoxFit.cover,
- width: 64,
- height: 64,
- );
- }),
+ },
+ fit: BoxFit.cover,
+ width: 64,
+ height: 64,
+ );
+ },
+ ),
),
);
}
diff --git a/comwell_key_app/lib/up_sales/pages/services_upgrade_page.dart b/comwell_key_app/lib/up_sales/pages/services_upgrade_page.dart
index eb73e869..47f15056 100644
--- a/comwell_key_app/lib/up_sales/pages/services_upgrade_page.dart
+++ b/comwell_key_app/lib/up_sales/pages/services_upgrade_page.dart
@@ -12,6 +12,7 @@ import 'package:go_router/go_router.dart';
class ServicesUpgradePage extends StatelessWidget {
final RoomUpgradeList roomUpgradeList;
+
const ServicesUpgradePage({
super.key,
required this.roomUpgradeList,
@@ -67,22 +68,23 @@ class ServicesUpgradePage extends StatelessWidget {
Container(
width: double.infinity,
color: Theme.of(context).colorScheme.surface,
- padding:
- const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text(roomUpgradeList.addOnUpgrade?.name ?? '',
- style: theme.textTheme.headlineLarge),
Text(
- "total_charge_value".tr(args: [
- roomUpgradeList.addOnUpgrade?.price.toString() ??
- '0'
- ]),
- style: theme.textTheme.headlineLarge),
+ roomUpgradeList.addOnUpgrade?.name ?? '',
+ style: theme.textTheme.headlineLarge,
+ ),
+ Text(
+ "total_charge_value".tr(
+ args: [roomUpgradeList.addOnUpgrade?.price.toString() ?? '0'],
+ ),
+ style: theme.textTheme.headlineLarge,
+ ),
],
),
const SizedBox(height: 12),
@@ -91,7 +93,8 @@ class ServicesUpgradePage extends StatelessWidget {
child: Text(
roomUpgradeList.addOnUpgrade?.description ?? '',
style: theme.textTheme.bodySmall?.copyWith(
- color: Theme.of(context).colorScheme.onSurface),
+ color: Theme.of(context).colorScheme.onSurface,
+ ),
),
),
],
@@ -109,12 +112,14 @@ class ServicesUpgradePage extends StatelessWidget {
if (roomUpgradeList.isSinglePurchase) {
cubit.toggleSelectedUpgrade(roomUpgradeList.addOnUpgrade!);
- context.pushNamed(AppRoutes.upSaleConfirmation.name,
- extra: [
- cubit.selectedAddOnUpgrades,
- cubit.extrasTotalPrice,
- roomUpgradeList.roomUpgrade
- ]);
+ context.push(
+ AppRoutes.upSaleConfirmation,
+ extra: [
+ cubit.selectedAddOnUpgrades,
+ cubit.extrasTotalPrice,
+ roomUpgradeList.roomUpgrade,
+ ],
+ );
}
},
onContinue: () {
@@ -126,32 +131,20 @@ class ServicesUpgradePage extends StatelessWidget {
isSelected
? Text(
"remove_from_booking".tr(),
- style: theme.textTheme.headlineSmall
- ?.copyWith(color: Colors.white),
+ style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
)
: Text(
"add_to_booking".tr(),
- style: theme.textTheme.headlineSmall
- ?.copyWith(color: Colors.white),
+ style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
),
isSelected
? Text(
- "-${"total_charge_value".tr(args: [
- roomUpgradeList.addOnUpgrade?.price
- .toString() ??
- '0'
- ])}",
- style: theme.textTheme.headlineSmall
- ?.copyWith(color: Colors.white),
+ "-${"total_charge_value".tr(args: [roomUpgradeList.addOnUpgrade?.price.toString() ?? '0'])}",
+ style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
)
: Text(
- "+${"total_charge_value".tr(args: [
- roomUpgradeList.addOnUpgrade?.price
- .toString() ??
- '0'
- ])}",
- style: theme.textTheme.headlineSmall
- ?.copyWith(color: Colors.white),
+ "+${"total_charge_value".tr(args: [roomUpgradeList.addOnUpgrade?.price.toString() ?? '0'])}",
+ style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
),
],
),
diff --git a/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart b/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart
index 5caaa4e0..3c25079d 100644
--- a/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart
+++ b/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart
@@ -146,7 +146,7 @@ class UpSaleConfirmationPage extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurface)
: null,
action: () async {
- context.pushNamed(AppRoutes.upSalesProcessing.name,
+ context.push(AppRoutes.upSalesProcessing,
extra: [selectedUpSales, selectedRoomUpgrade]);
return true;
diff --git a/comwell_key_app/lib/up_sales/up_sales_route.dart b/comwell_key_app/lib/up_sales/up_sales_route.dart
new file mode 100644
index 00000000..8e4f593f
--- /dev/null
+++ b/comwell_key_app/lib/up_sales/up_sales_route.dart
@@ -0,0 +1,114 @@
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/up_sales/cubit/up_sales_cubit.dart';
+import 'package:comwell_key_app/up_sales/cubit/up_sales_state.dart';
+import 'package:comwell_key_app/up_sales/models/addon_upgrade.dart';
+import 'package:comwell_key_app/up_sales/models/room_upgrade.dart';
+import 'package:comwell_key_app/up_sales/models/room_upgrade_list.dart';
+import 'package:comwell_key_app/up_sales/pages/addon_upgrade_page.dart';
+import 'package:comwell_key_app/up_sales/pages/processing/up_sales_error_page.dart';
+import 'package:comwell_key_app/up_sales/pages/processing/up_sales_processing_page.dart';
+import 'package:comwell_key_app/up_sales/pages/room_upgrade_page.dart';
+import 'package:comwell_key_app/up_sales/pages/services_upgrade_page.dart';
+import 'package:comwell_key_app/up_sales/pages/up_sale_confirmation_page.dart';
+import 'package:comwell_key_app/up_sales/up_sales_catalog.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+final upSalesRoute = ShellRoute(
+ pageBuilder: (context, state, child) {
+ return CustomTransitionPage<void>(
+ key: state.pageKey,
+ child: BlocProvider(
+ create: (_) {
+ final extras = state.extra as List<dynamic>;
+ return UpSalesCubit(
+ upSaleRepository: locator(),
+ booking: extras[0] as Booking,
+ );
+ },
+ child: child,
+ ),
+ transitionsBuilder: (context, animation, secondaryAnimation, child) {
+ return SlideTransition(
+ position:
+ Tween<Offset>(
+ begin: const Offset(1.0, 0.0),
+ end: Offset.zero,
+ ).animate(
+ CurvedAnimation(
+ parent: animation,
+ curve: Curves.easeInOut,
+ ),
+ ),
+ child: child,
+ );
+ },
+ transitionDuration: const Duration(milliseconds: 250),
+ );
+ },
+ routes: [
+ GoRoute(
+ path: AppRoutes.upSalesCatalog,
+ builder: (context, state) {
+ return const UpSalesCatalog();
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.roomUpgrade,
+ builder: (context, state) {
+ return RoomUpgradePage(roomUpgradeList: state.extra as RoomUpgradeList);
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.addonUpgrade,
+ builder: (context, state) {
+ final extras = state.extra as List<dynamic>;
+ return AddonUpgradePage(
+ addonUpgrade: extras[0] as AddOnUpgrade,
+ extrasTotalPrice: extras[1] as int,
+ selectedRoomUpgrade: extras[2] as String,
+ );
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.servicesUpgrade,
+ builder: (context, state) {
+ return ServicesUpgradePage(roomUpgradeList: state.extra as RoomUpgradeList);
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.upSaleConfirmation,
+ builder: (context, state) {
+ final extras = state.extra as List<dynamic>;
+ final selectedUpSales = extras[0] as List<AddOnUpgrade?>;
+ final extrasTotalPrice = extras[1] as int;
+ final selectedRoomUpgrade = extras[2] as RoomUpgrade?;
+ return UpSaleConfirmationPage(
+ selectedUpSales: selectedUpSales.whereType<AddOnUpgrade>().toList(),
+ extrasTotalPrice: extrasTotalPrice,
+ selectedRoomUpgrade: selectedRoomUpgrade,
+ );
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.upSalesProcessing,
+ builder: (context, state) {
+ final cubit = context.read<UpSalesCubit>();
+ cubit.addUpSalesToBooking();
+
+ return BlocBuilder<UpSalesCubit, UpSalesState>(
+ builder: (context, state) {
+ return UpSalesProcessingPage(key: ValueKey(state));
+ },
+ );
+ },
+ ),
+ GoRoute(
+ path: AppRoutes.upSalesError,
+ builder: (context, state) => const UpSalesErrorPage(),
+ ),
+ ],
+);