6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 6c2b8470

AuthorMikkel Thygesen<mth@dwarf.dk>
Date2025-01-31 14:35:48 +0100
455: Adjusted seos implemetation

Changed files

comwell_key_app/assets/translations/da-DK.json     |   7 +-
 comwell_key_app/assets/translations/en-US.json     |   8 +-
 .../booking_details/bloc/booking_details_bloc.dart |   3 +-
 .../lib/booking_details/booking_details_page.dart  |  70 +++++---------
 .../components/preregister_button.dart             |  39 ++++++++
 .../lib/check_in/bloc/check_in_cubit.dart          |  33 +++----
 comwell_key_app/lib/key/key_page.dart              | 104 +++++++++++----------
 comwell_key_app/lib/routing/app_router.dart        |  19 ++--
 comwell_key_app/lib/services/api.dart              |   3 +-
 .../interceptors/response_handle_interceptor.dart  |  12 +--
 comwell_key_app/lib/utils/seos_repository.dart     |   7 +-
 11 files changed, 153 insertions(+), 152 deletions(-)

Diff

diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index e2a7f774..b6a3da00 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -110,12 +110,6 @@
"preregistration_confirmation_extras_card_title_singular": "1 valgt Tilkøb",
"preregistration_confirmation_extras_card_title_plural": "{} valgte tilkøb",
"preregistration_confirmation_extras_card_subtitle": "Skrives på din værelsesregning",
- "need_help": "Har du brug for hjælp?",
- "call_us": "Ring til os",
- "call_us_description": "Har du brug for at komme i kontakt med et af vores hoteller? Benyt knappen nedenfor for at ringe op.",
- "get_a_call": "Bliv ringet op",
- "get_a_call_description": "Indtast dit telefonnummer herunder og bliv ringet op.",
- "telephone_number": "Telefonnummer",
"comwell_telephone_number": "+4570274274",
"booking_details_page_hotel_information_button_title": "Hotelinformation",
"booking_details_page_hotel_information_button_subtitle": "Find relevant information om hotellet",
@@ -141,6 +135,7 @@
"housekeeping_page_supplies": "Forsyninger",
"booking_details_page_housekeeping_button_title": "Bestil housekeeping",
"booking_details_page_housekeeping_button_subtitle": "Ønsker du ekstra rengøring eller opfyldning på værelset, kan du altid bestille det her - uden omkostninger",
+ "booking_details_page_practical_information": "Praktisk information",
"need_help": "Har du brug for hjælp?",
"call_us": "Ring til os",
"call_us_description": "Har du brug for at komme i kontakt med et af vores hoteller? Benyt knappen nedenfor for at ringe op.",
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index 580d5bc2..bd30bc22 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -134,13 +134,7 @@
"housekeeping_page_cleaning": "Cleaning",
"booking_details_page_housekeeping_button_title": "Order housekeeping",
"booking_details_page_housekeeping_button_subtitle": "Order here",
- "need_help": "Need help?",
- "call_us": "Call us",
- "call_us_description": "Enter your phone number below and we will call you.",
- "get_a_call": "Get a call",
- "get_a_call_description": "Enter your phone number below and we will call you.",
- "telephone_number": "Telephone number",
- "comwell_telefon_number": "+4570274274",
+ "booking_details_page_practical_information": "Practical information",
"hotel_information_page_menu_restaurants_title": "Restaurants",
"hotel_information_page_menu_restaurants_subtitle": "Read about our restaurant",
"hotel_information_page_menu_spa_title": "Spa",
diff --git a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
index 163ca79d..e0e0a06b 100644
--- a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
+++ b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
@@ -69,8 +69,7 @@ class BookingDetailsBloc
if (event.endpointNeedsUpdate) {
//await bookingDetailsRepository.updateEndpoint();
}
- final List<MobileKeysKey> keys =
- []; //await bookingDetailsRepository.refreshKeys();
+ final List<MobileKeysKey> keys = await seosRepository.refreshKeys();
if (keys.length == 1) {
emit(state.validKey(keys[0]));
} else if (keys.length > 1) {
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 a268043d..521b5174 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -1,7 +1,8 @@
+import 'package:comwell_key_app/booking_details/components/preregister_button.dart';
import 'package:comwell_key_app/common/components/bottom_sheet_widget.dart';
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
-import 'package:comwell_key_app/home/components/housekeeping_button.dart';
-import 'package:comwell_key_app/home/components/practical_information_button.dart';
+import 'package:comwell_key_app/booking_details/components/housekeeping_button.dart';
+import 'package:comwell_key_app/booking_details/components/practical_information_button.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -12,11 +13,8 @@ import 'package:go_router/go_router.dart';
import 'package:slider_button/slider_button.dart';
import 'bloc/booking_details_bloc.dart';
-import 'components/housekeeping_button.dart';
-import 'components/room_key_widget.dart';
class BookingDetailsPage extends StatefulWidget {
-
const BookingDetailsPage({super.key});
@override
@@ -40,7 +38,7 @@ class _BookingDetailsPage extends State<BookingDetailsPage> {
if (state.status == BookingDetailsStatus.setupError) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Failed to start Mobile Keys Plugin')));
- context.read<BookingDetailsBloc>().add(SetupEndpoint());
+ //context.read<BookingDetailsBloc>().add(SetupEndpoint());
}
if (state.status == BookingDetailsStatus.setupComplete) {
context
@@ -77,9 +75,6 @@ class _BookingDetailsPage extends State<BookingDetailsPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Spacer(),
- RoomKeyWidget(onPressed: () {
- context.pushNamed(AppRoutes.contact.name);
- }),
if (state.status == BookingDetailsStatus.invalidOrNoKey)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
@@ -91,8 +86,7 @@ class _BookingDetailsPage extends State<BookingDetailsPage> {
},
child: const Text('Get Key')),
),
- if (state.status == BookingDetailsStatus.validKey ||
- state.status == BookingDetailsStatus.multipleKeys)
+
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SliderButton(
@@ -124,31 +118,40 @@ class _BookingDetailsPage extends State<BookingDetailsPage> {
),
BottomSheetWidget(
widgetChildren: [
- HousekeepingButton(key: ValueKey(state.isHouseKeepingOrdered)),
+ HousekeepingButton(
+ key: ValueKey(state.isHouseKeepingOrdered)),
const SizedBox(height: 20),
- const Text("Practical information"),
+ Text("booking_details_page_practical_information".tr()),
const SizedBox(height: 20),
Row(children: [
Expanded(
child: AspectRatio(
- aspectRatio: 175/220,
+ aspectRatio: 175 / 220,
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);
+ context
+ .pushNamed(AppRoutes.hotelInformation.name);
}),
),
),
const SizedBox(width: 8),
Expanded(
child: AspectRatio(
- aspectRatio: 175/220,
+ aspectRatio: 175 / 220,
child: PracticalInformationButton(
iconPath: "assets/icons/ic_telephone.svg",
- title: "booking_details_page_contact_button_title".tr(),
- subtitle: "booking_details_page_contact_button_subtitle".tr(),
+ title: "booking_details_page_contact_button_title"
+ .tr(),
+ subtitle:
+ "booking_details_page_contact_button_subtitle"
+ .tr(),
onClick: () {
context.pushNamed(AppRoutes.contact.name);
}),
@@ -158,32 +161,7 @@ class _BookingDetailsPage extends State<BookingDetailsPage> {
const SizedBox(height: 16),
const Text('Rooms'),
const SizedBox(height: 12),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: HousekeepingButton(
- key: ValueKey(state.isHouseKeepingOrdered)),
- ),
- const SizedBox(height: 12),
- ElevatedButton(
- onPressed: () {
- context.pushNamed(AppRoutes.checkIn.name,
- pathParameters: {"booking_id": "hello world"});
- },
- style: ButtonStyle(
- backgroundColor:
- WidgetStateProperty.resolveWith((states) {
- if (states.contains(WidgetState.disabled)) {
- return Colors.grey;
- }
- return const Color(0xffAA8D65);
- }),
- foregroundColor:
- const WidgetStatePropertyAll(Colors.white)),
- child: const Padding(
- padding: EdgeInsets.symmetric(vertical: 16.0),
- child: Text("Klargør dit værelse"),
- ),
- ),
+ const PreregisterButton(),
const Text('Keys'),
const SizedBox(height: 400),
],
diff --git a/comwell_key_app/lib/booking_details/components/preregister_button.dart b/comwell_key_app/lib/booking_details/components/preregister_button.dart
new file mode 100644
index 00000000..bdc94621
--- /dev/null
+++ b/comwell_key_app/lib/booking_details/components/preregister_button.dart
@@ -0,0 +1,39 @@
+import 'package:comwell_key_app/booking_details/bloc/booking_details_bloc.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+import '../../routing/app_routes.dart';
+
+class PreregisterButton extends StatelessWidget {
+ const PreregisterButton({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final bloc = context.read<BookingDetailsBloc>();
+ final booking = bloc.booking;
+ return ElevatedButton(
+ onPressed: () {
+ context.pushNamed(AppRoutes.checkIn.name, extra: booking);
+ },
+ style: ButtonStyle(
+ backgroundColor: WidgetStateProperty.resolveWith((states) {
+ if (states.contains(WidgetState.disabled)) {
+ return Colors.grey;
+ }
+ return const Color(0xffAA8D65);
+ }),
+ foregroundColor: const WidgetStatePropertyAll(Colors.white)),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 16.0),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
+ children: [
+ Text("prepare_room".tr()),
+ ],
+ ),
+ ),
+ );
+ }
+}
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 665e4851..4cb8d7f5 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
@@ -3,39 +3,32 @@ 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:comwell_key_app/utils/seos_repository.dart';
+import 'package:flutter/foundation.dart';
+import 'package:seos_mobile_keys_plugin/app_usage_api.dart';
+
+import '../../utils/locator.dart';
class CheckInCubit extends Cubit<CheckInState> {
final _checkInRepository = CheckInRepository();
- final _seosRepository = SeosRepository();
+ final _seosRepository = locator<SeosRepository>();
- final String bookingId;
late final Booking booking;
- CheckInCubit(this.bookingId) : super(CheckInState.initial()) {
- getBooking();
- }
-
- void getBooking() async {
- emit(state.setLoading(true));
- try {
- booking = await _checkInRepository.getBooking(bookingId);
- emit(state.setLoading(false));
- startLoading();
- } catch (err) {
- emit(state.checkInStatusError(Exception(err.toString())));
- }
+ CheckInCubit(this.booking) : super(CheckInState.initial()) {
+ init();
}
- Future<void> startLoading() async {
+ Future<void> init() async {
try {
- await Future<void>.delayed(const Duration(seconds: 1));
+ await Future<void>.delayed(const Duration(milliseconds: 500));
emit(state.checkInStatusLoading());
- await _checkInRepository.checkIn(booking.confirmationId);
+ await _seosRepository.startMobilePlugin();
emit(state.checkInStatusRoomFound(roomNumber: booking.roomNumber));
- await _seosRepository.refreshKeys();
+ final keys = await _seosRepository.refreshKeys();
+ print("qqq $keys");
emit(state.checkInStatusYourDigitalCard(roomNumber: booking.roomNumber));
} catch (err, st) {
- print("err=$err, $st");
+ if (kDebugMode) print("qqq err=$err, $st");
emit(state.setLoading(false));
emit(state.checkInStatusError(Exception(err.toString())));
}
diff --git a/comwell_key_app/lib/key/key_page.dart b/comwell_key_app/lib/key/key_page.dart
index 72e1c264..668013b2 100644
--- a/comwell_key_app/lib/key/key_page.dart
+++ b/comwell_key_app/lib/key/key_page.dart
@@ -16,62 +16,64 @@ class KeyPage extends StatelessWidget {
return BlocBuilder<KeyBloc, KeyState>(builder: (context, state) {
//if (state.status == KeyStatus.scanning || state.status != KeyStatus.openClosestReaderSuccess) {
return FocusDetector(
- child: Container(
- padding: const EdgeInsets.all(8),
- color: Colors.black,
- child: SafeArea(
- child: Column(
- children: [
- Stack(
- children: [
- Center(
- heightFactor: 2,
- child: Text(
- "open_room".tr(),
- style: Theme.of(context)
- .textTheme
- .headlineMedium
- ?.copyWith(color: Colors.white),
+ child: SafeArea(
+ child: Scaffold(
+ backgroundColor: Colors.black,
+ body: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: Column(
+ children: [
+ Stack(
+ children: [
+ Center(
+ heightFactor: 2,
+ child: Text(
+ "open_room".tr(),
+ style: Theme.of(context)
+ .textTheme
+ .headlineMedium
+ ?.copyWith(color: Colors.white),
+ ),
),
- ),
- Align(
- alignment: AlignmentDirectional.centerEnd,
- child: RoundIconButton(
- color: Colors.white,
- onPressed: () {
- context.pop();
- },
- icon: "assets/icons/close-icon.svg",
+ Align(
+ alignment: AlignmentDirectional.centerEnd,
+ child: RoundIconButton(
+ color: Colors.white,
+ onPressed: () {
+ context.pop();
+ },
+ icon: "assets/icons/close-icon.svg",
+ ),
),
+ ],
+ ),
+ const SizedBox(height: 10),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Image.asset(
+ 'assets/images/room_key_with_number.png',
+ fit: BoxFit.cover,
),
- ],
- ),
- const SizedBox(height: 10),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Image.asset(
- 'assets/images/room_key_with_number.png',
+ ),
+ const SizedBox(height: 20),
+ Lottie.asset(
+ 'assets/animations/scan.json',
+ height: 64,
+ width: 64,
fit: BoxFit.cover,
+ animate: true,
),
- ),
- const SizedBox(height: 20),
- Lottie.asset(
- 'assets/animations/scan.json',
- height: 64,
- width: 64,
- fit: BoxFit.cover,
- animate: true,
- ),
- const SizedBox(height: 10),
- _buildStatusText(state.status, context),
- const Spacer(),
- Image.asset(
- 'assets/images/seos_by_assa_logo.png',
- height: 42,
- fit: BoxFit.cover,
- ),
- const SizedBox(height: 40),
- ],
+ const SizedBox(height: 10),
+ _buildStatusText(state.status, context),
+ const Spacer(),
+ Image.asset(
+ 'assets/images/seos_by_assa_logo.png',
+ height: 42,
+ fit: BoxFit.cover,
+ ),
+ const SizedBox(height: 40),
+ ],
+ ),
),
),
),
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 4e7197c7..ceb287fc 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -5,7 +5,6 @@ import 'package:comwell_key_app/check_in/check_in_page.dart';
import 'package:comwell_key_app/contact/contact_page.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/home/home_page.dart';
import 'package:comwell_key_app/hotel_information/components/hotel_information_menu.dart';
import 'package:comwell_key_app/hotel_information/components/restaurant_page.dart';
import 'package:comwell_key_app/hotel_information/components/spa_facility_page.dart';
@@ -37,7 +36,6 @@ import '../utils/locator.dart';
import '../booking_details/bloc/booking_details_bloc.dart';
import '../booking_details/booking_details_page.dart';
import '../booking_details/booking_details_repository.dart';
-import '../utils/locator.dart';
final _rootNavigatorKey = GlobalKey<NavigatorState>();
final _shellNavigatorKey = GlobalKey<NavigatorState>();
@@ -100,14 +98,18 @@ GoRouter goRouter(AuthenticationBloc authBloc) {
return const HotelInformationMenu();
}),
GoRoute(
- path: "/${AppRoutes.hotelInformation.name}/${AppRoutes.spa.name}",
- name: "${AppRoutes.hotelInformation.name}/${AppRoutes.spa.name}",
+ path:
+ "/${AppRoutes.hotelInformation.name}/${AppRoutes.spa.name}",
+ name:
+ "${AppRoutes.hotelInformation.name}/${AppRoutes.spa.name}",
builder: (context, state) {
return const SpaFacilityPage();
}),
GoRoute(
- path: "/${AppRoutes.hotelInformation.name}/${AppRoutes.restaurant.name}",
- name: "${AppRoutes.hotelInformation.name}/${AppRoutes.restaurant.name}",
+ path:
+ "/${AppRoutes.hotelInformation.name}/${AppRoutes.restaurant.name}",
+ name:
+ "${AppRoutes.hotelInformation.name}/${AppRoutes.restaurant.name}",
builder: (context, state) {
final restaurant = state.extra as Restaurant;
return RestaurantPage(restaurant: restaurant);
@@ -133,12 +135,11 @@ GoRouter goRouter(AuthenticationBloc authBloc) {
builder: (context, state) => const FindBookingPage(),
),
GoRoute(
- path: "/${AppRoutes.checkIn.name}/:booking_id",
+ path: "/${AppRoutes.checkIn.name}",
name: AppRoutes.checkIn.name,
builder: (context, state) {
- final bookingId = state.pathParameters["booking_id"] as String;
return BlocProvider(
- create: (context) => CheckInCubit(bookingId),
+ create: (context) => CheckInCubit(state.extra as Booking),
child: const CheckInPage(),
);
}),
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index 1ceae3d3..9b1b83cd 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -45,8 +45,7 @@ class Api {
}
Future<Response<dynamic>> provisionKey(String bookingId) async {
- return await dio
- .post('/keys/v1/ProvisionKey', data: {'bookingId': bookingId});
+ return dio.post('/keys/v1/ProvisionKey', data: {'bookingId': bookingId});
}
Future<dynamic> fetchProfileSettings() async {
diff --git a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
index 9180c63b..524a26be 100644
--- a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
+++ b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
@@ -1,3 +1,7 @@
+
+import 'dart:developer';
+import 'dart:io';
+
import 'package:comwell_key_app/services/token_error_type.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
@@ -14,8 +18,7 @@ class ResponseHandleInterceptor extends Interceptor {
@override
Future<dynamic> onRequest(
RequestOptions options, RequestInterceptorHandler handler) async {
- final String? accessToken =
- await _secureStorageService.read(key: constants.accessToken);
+ final String? accessToken = await _secureStorageService.read(key: constants.accessToken);
final String? refreshToken =
await _secureStorageService.read(key: constants.refreshToken);
@@ -30,10 +33,7 @@ class ResponseHandleInterceptor extends Interceptor {
return handler.reject(error);
}
- options.headers.addAll({
- 'Authorization': accessToken,
- 'Ocp-Apim-Subscription-Key': dotenv.env['OCP_APIM_SUBSCRIPTION_KEY']!,
- });
+ options.headers[HttpHeaders.authorizationHeader] = "Bearer $accessToken";
return handler.next(options);
}
diff --git a/comwell_key_app/lib/utils/seos_repository.dart b/comwell_key_app/lib/utils/seos_repository.dart
index e626f717..dcfb7972 100644
--- a/comwell_key_app/lib/utils/seos_repository.dart
+++ b/comwell_key_app/lib/utils/seos_repository.dart
@@ -1,4 +1,5 @@
import 'package:comwell_key_app/services/api.dart';
+import 'package:comwell_key_app/utils/locator.dart';
import 'package:comwell_key_app/utils/secure_storage.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
@@ -9,7 +10,7 @@ import 'package:comwell_key_app/common/const.dart' as constants;
class SeosRepository {
final secureStorage = SecureStorage();
final api = Api();
- final seosMobileKeysPlugin = SeosMobileKeysPlugin();
+ final seosMobileKeysPlugin = locator<SeosMobileKeysPlugin>();
Future<bool> startMobilePlugin() async {
final mobileKeysOptions = {
@@ -40,7 +41,7 @@ class SeosRepository {
Future<bool> isEndpointSetup({bool firstLaunch = true}) async {
try {
- return await seosMobileKeysPlugin.isEndpointSetup();
+ return seosMobileKeysPlugin.isEndpointSetup();
} catch (e) {
throw Exception('Failed to check if endpoint setup - ${e.toString()}');
}
@@ -55,7 +56,7 @@ class SeosRepository {
if (hasKey != null) {
final DateTime hasKeyDate = DateTime.parse(hasKey);
if (DateTime.now().difference(hasKeyDate).inDays < 1) {
- return;
+ // return;
}
}