6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 9e8a7a4a

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-05-09 10:59:20 +0200
Finished checkin and added new env files for staging and development

Changed files

comwell_key_app/.gitignore                         |  3 ++
 comwell_key_app/assets/translations/da-DK.json     |  3 +-
 comwell_key_app/assets/translations/en-US.json     |  4 +-
 .../lib/booking_details/booking_details_page.dart  | 39 +++++++++++++++---
 .../components/unlock_room_button.dart             |  2 +-
 .../lib/check_in/bloc/check_in_cubit.dart          |  3 +-
 .../lib/check_in/bloc/check_in_state.dart          | 14 ++++---
 comwell_key_app/lib/check_in/check_in_page.dart    | 46 +++++++++++++---------
 .../lib/check_in/check_in_repository.dart          |  5 ++-
 comwell_key_app/lib/key/key_page.dart              |  1 +
 comwell_key_app/lib/main.dart                      | 23 ++++++++++-
 comwell_key_app/lib/main_dev.dart                  |  1 -
 comwell_key_app/lib/services/api.dart              | 11 +++---
 comwell_key_app/pubspec.yaml                       |  2 +
 14 files changed, 114 insertions(+), 43 deletions(-)

Diff

diff --git a/comwell_key_app/.gitignore b/comwell_key_app/.gitignore
index d6cb89af..8ef63b06 100644
--- a/comwell_key_app/.gitignore
+++ b/comwell_key_app/.gitignore
@@ -36,6 +36,9 @@ migrate_working_dir/
.pub/
/build/
.env
+.env.dev
+.env.stage
+.env.prod
android/app/.cxx
# Symbolication related
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 6a096ded..983af49d 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -237,5 +237,6 @@
"share_booking": "Del ophold",
"total_charge": "I alt til betaling",
"early_checkin": "Tidlig check-in",
- "payed": "BETALT"
+ "payed": "BETALT",
+ "room_prefix": "Værelse {}"
}
\ No newline at end of file
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index 77d0fa1e..157761a5 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -237,6 +237,6 @@
"share_booking": "Share booking",
"total_charge": "I alt til betaling",
"early_checkin": "Early check-in",
- "payed": "PAYED"
-
+ "payed": "PAYED",
+ "room_prefix": "Room {}"
}
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 55f98239..bab7212b 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -27,9 +27,10 @@ class BookingDetailsPage extends StatelessWidget {
listener: (context, state) {},
builder: (context, state) {
final cubit = context.read<BookingDetailsBloc>();
+ final theme = Theme.of(context);
+
print("Booking: ${cubit.booking}");
if (state.status == BookingDetailsStatus.initial) {
-
cubit.add(InitialEvent());
}
return Scaffold(
@@ -69,13 +70,16 @@ class BookingDetailsPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Spacer(),
- _buildBookingDetails(context, state, cubit),
+ if (cubit.booking.roomNumber != '')
+ _buildRoomNumberContainer(context, theme, cubit),
+ _buildBookingDetails(context, state, cubit, theme),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Divider(color: Colors.grey[400]),
),
const SizedBox(height: 10),
- if (state.keys.isNotEmpty)
+ if (state.keys.isNotEmpty &&
+ cubit.booking.roomNumber != '')
const UnlockRoomButton()
else
const CheckInButton(),
@@ -147,8 +151,33 @@ class BookingDetailsPage extends StatelessWidget {
);
}
- Widget _buildBookingDetails(BuildContext context, BookingDetailsState state, BookingDetailsBloc cubit) {
- final theme = Theme.of(context);
+ Widget _buildRoomNumberContainer(
+ BuildContext context, ThemeData theme, BookingDetailsBloc cubit) {
+ return Align(
+ alignment: Alignment.topLeft,
+ child: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(32),
+ border: Border.all(color: Colors.white, width: 2),
+
+ ),
+ child: Text(
+ 'room_prefix'.tr(args: [cubit.booking.roomNumber]),
+ style: theme.textTheme.titleLarge!.copyWith(
+ color: Colors.white,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildBookingDetails(BuildContext context, BookingDetailsState state,
+ BookingDetailsBloc cubit, ThemeData theme) {
return InkWell(
onTap: () {
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 ccaab257..d219a418 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
@@ -17,7 +17,7 @@ class UnlockRoomButton extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SliderButton(
backgroundColor: sandColor,
- width: 300,
+ width: double.infinity,
icon: Center(
child: SvgPicture.asset(
'assets/icons/Union.svg',
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 b93feced..83561cd4 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
@@ -18,9 +18,10 @@ class CheckInCubit extends Cubit<CheckInState> {
await Future<void>.delayed(const Duration(milliseconds: 500));
emit(state.checkInStatusLoading());
await _checkInRepository.checkIn(booking.confirmationId);
+ emit(state.checkInStatusRoomFound(roomNumber: booking.roomNumber));
await _checkInRepository.checkIfSetup();
await tryGetKeys();
- emit(state.checkInStatusRoomFound(roomNumber: booking.roomNumber));
+
await Future<void>.delayed(const Duration(milliseconds: 1000));
emit(state.checkInStatusYourDigitalCard(roomNumber: booking.roomNumber));
} catch (err, st) {
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 272f5ef3..3ea1cf6e 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,3 +1,5 @@
+import 'package:easy_localization/easy_localization.dart';
+
import '../../overview/models/booking.dart';
class CheckInState {
@@ -20,22 +22,22 @@ class CheckInState {
case CheckInStatusInitial _:
return "";
case CheckInStatusLoading _:
- return "check_in_loading_title";
+ return "check_in_loading_title".tr();
case CheckInStatusRoomFound _:
- return "check_in_room_found_title";
+ return "check_in_room_found_title".tr();
case CheckInStatusYourDigitalCard _:
- return "check_in_your_digital_card_title";
+ return "check_in_your_digital_card_title".tr();
case CheckInStatusRoomNotFound _:
- return "check_in_room_not_found_title";
+ return "check_in_room_not_found_title".tr();
case CheckInStatusError _:
- return "check_in_error_title";
+ return "check_in_error_title".tr();
}
}
String get subtitleStringId {
switch (checkInStatus) {
case CheckInStatusYourDigitalCard _:
- return "check_in_your_digital_card_subtitle";
+ return "check_in_your_digital_card_subtitle".tr();
default:
return "";
}
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 3681eb5a..dc04832e 100644
--- a/comwell_key_app/lib/check_in/check_in_page.dart
+++ b/comwell_key_app/lib/check_in/check_in_page.dart
@@ -21,10 +21,22 @@ class _CheckInPageState extends State<CheckInPage>
var animationDone = false;
late final LottieComposition loadingComposition;
late final AnimationController animationController;
+ late final Widget loadingAnimation;
@override
void initState() {
animationController = AnimationController(vsync: this);
+ loadingAnimation = Lottie.asset(
+ 'assets/animations/load_animation.json',
+ controller: animationController,
+ onLoaded: (composition) {
+ loadingComposition = composition;
+ animationController.duration = composition.duration;
+ },
+ fit: BoxFit.cover,
+ width: 64,
+ height: 64,
+ );
super.initState();
}
@@ -89,17 +101,7 @@ class _CheckInPageState extends State<CheckInPage>
),
);
} else {
- return Lottie.asset(
- 'assets/animations/load_animation.json',
- controller: animationController,
- onLoaded: (composition) {
- loadingComposition = composition;
- animationController.duration = composition.duration;
- },
- fit: BoxFit.cover,
- width: 64,
- height: 64,
- );
+ return loadingAnimation;
}
}
@@ -107,8 +109,9 @@ class _CheckInPageState extends State<CheckInPage>
Widget build(BuildContext context) {
final mq = MediaQuery.of(context);
final cubit = context.read<CheckInCubit>();
+ final theme = Theme.of(context);
- return BlocConsumer<CheckInCubit, CheckInState>(listener: (context, state) {
+ return BlocConsumer<CheckInCubit, CheckInState>(listener: (context, state) {
switch (state.checkInStatus) {
case CheckInStatusInitial _:
playLoading();
@@ -145,6 +148,10 @@ class _CheckInPageState extends State<CheckInPage>
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
+ const SizedBox(height: 15),
+ Text(state.subtitleStringId,
+ style: theme.textTheme.bodySmall),
+ const SizedBox(height: 15),
const Divider(
color: Colors.black12,
height: 0,
@@ -183,15 +190,18 @@ class _CheckInPageState extends State<CheckInPage>
mainAxisSize: MainAxisSize.min,
children: [
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ padding: const EdgeInsets.all(16.0),
child: Text("check_in_your_digital_card_nb".tr(),
textAlign: TextAlign.center,
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: Colors.black45)),
+ style: theme.textTheme.bodySmall?.copyWith(color: Colors.black45)),
+ ),
+ const SizedBox(height: 15),
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Text(state.subtitleStringId,
+ style: theme.textTheme.bodySmall),
),
- const SizedBox(height: 30),
+ const SizedBox(height: 15),
const Divider(
color: Colors.black12,
height: 0,
diff --git a/comwell_key_app/lib/check_in/check_in_repository.dart b/comwell_key_app/lib/check_in/check_in_repository.dart
index daf95b65..8ba00e8e 100644
--- a/comwell_key_app/lib/check_in/check_in_repository.dart
+++ b/comwell_key_app/lib/check_in/check_in_repository.dart
@@ -19,10 +19,11 @@ class CheckInRepository {
final seosRepository = locator<SeosRepository>();
final profileRepository = locator<ProfileRepository>();
- Future<void> checkIn(String confirmationId) async {
+ Future<dynamic> checkIn(String confirmationId) async {
try {
final response = await api.checkIn(confirmationId);
- print("response in checkInRepository: ${response.data}");
+ print("response in checkInRepository: ${response}");
+ return response;
} on DioException catch (err) {
if (err.response?.data != null) {
final errorData = err.response?.data as Map<String, dynamic>;
diff --git a/comwell_key_app/lib/key/key_page.dart b/comwell_key_app/lib/key/key_page.dart
index cde3cfa6..affc8245 100644
--- a/comwell_key_app/lib/key/key_page.dart
+++ b/comwell_key_app/lib/key/key_page.dart
@@ -15,6 +15,7 @@ class KeyPage extends StatelessWidget {
Widget build(BuildContext context) {
context.read<KeyBloc>().add(const StartScanning());
return BlocBuilder<KeyBloc, KeyState>(builder: (context, state) {
+
//if (state.status == KeyStatus.scanning || state.status != KeyStatus.openClosestReaderSuccess) {
return FocusDetector(
child: SafeArea(
diff --git a/comwell_key_app/lib/main.dart b/comwell_key_app/lib/main.dart
index 2c474b44..87781b96 100644
--- a/comwell_key_app/lib/main.dart
+++ b/comwell_key_app/lib/main.dart
@@ -12,7 +12,28 @@ import 'comwell_app.dart';
void runMainApp(FirebaseOptions firebaseOptions) async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
- await dotenv.load(fileName: ".env");
+
+ // Load the appropriate .env file based on the flavor
+ String envFile = '.env';
+ if (appFlavor == 'develop') {
+ envFile = '.env.dev';
+ } else if (appFlavor == 'stage') {
+ envFile = '.env.stage';
+ } else if (appFlavor == 'prod') {
+ envFile = '.env.prod';
+ }
+
+ debugPrint("Current flavor: $appFlavor");
+ debugPrint("Loading environment file: $envFile");
+
+ try {
+ await dotenv.load(fileName: '.env');
+ debugPrint("Successfully loaded environment file");
+ } catch (e) {
+ debugPrint("Error loading environment file: $e");
+ rethrow;
+ }
+
await configureFirebase();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
setupLocator();
diff --git a/comwell_key_app/lib/main_dev.dart b/comwell_key_app/lib/main_dev.dart
index 64db2747..ae8c5ec2 100644
--- a/comwell_key_app/lib/main_dev.dart
+++ b/comwell_key_app/lib/main_dev.dart
@@ -1,6 +1,5 @@
import 'package:comwell_key_app/firebase_options.dart';
import 'package:comwell_key_app/main.dart';
-
void main() async {
runMainApp(DefaultFirebaseOptions.currentPlatform);
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index e68ef8e8..cb67c81c 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -152,14 +152,15 @@ class Api {
return response;
}
- Future<Response<dynamic>> checkIn(String confirmationId) async {
+ Future<Json> checkIn(String confirmationId) async {
final body = {
"confirmationId": confirmationId,
};
- final json = jsonEncode(body);
- final response = await dio.post<dynamic>(ApiEndpoints.checkIn, data: json);
+ final data = jsonEncode(body);
+ print("json in api: $data");
+ final response = await dio.post<Json>(ApiEndpoints.checkIn, data: data);
print("response in api: ${response.data}");
- return response;
+ return response.data!;
}
Future<void> sendContact(String hotelCode) async {}
@@ -198,7 +199,7 @@ class Api {
final response =
await dio.post<String>(ApiEndpoints.createEndpointRegistration);
final json = jsonDecode(response.data!) as Map<String, dynamic>;
- return json["InvitationCode"]! as String;
+ return json["invitationCode"]! as String;
}
Future<void> provisionKey(String bookingId) async {
diff --git a/comwell_key_app/pubspec.yaml b/comwell_key_app/pubspec.yaml
index 71246a0e..9b549322 100644
--- a/comwell_key_app/pubspec.yaml
+++ b/comwell_key_app/pubspec.yaml
@@ -85,6 +85,8 @@ flutter:
- assets/images/
- assets/icons/
- .env
+ - .env.dev
+ - .env.stage
# To add assets to your application, add an assets section, like this:
# assets: