6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit a557f58a
Changed files
.../lib/login/components/forced_logout_banner.dart | 55 +++ comwell_key_app/lib/login/login_page.dart | 52 +-- comwell_key_app/lib/main.dart | 4 + .../components/empty_card_content_widget.dart | 55 +++ .../lib/profile/components/error_page_widget.dart | 89 ++++ .../profile/components/logout_dialog_widget.dart | 78 ++++ .../profile/components/profile_page_widget.dart | 297 +++++++++++++ comwell_key_app/lib/profile/profile_page.dart | 479 +-------------------- .../booking_details_repository_test.dart | 9 +- 9 files changed, 589 insertions(+), 529 deletions(-)
Diff
diff --git a/comwell_key_app/lib/login/components/forced_logout_banner.dart b/comwell_key_app/lib/login/components/forced_logout_banner.dart
new file mode 100644
index 00000000..f536f2ad
--- /dev/null
+++ b/comwell_key_app/lib/login/components/forced_logout_banner.dart
@@ -0,0 +1,55 @@
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+
+class ForcedLogoutBanner extends StatelessWidget {
+ const ForcedLogoutBanner({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+ return Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Container(
+ height: 100,
+ width: double.infinity,
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(10),
+ ),
+ padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 16),
+ child: Row(
+ children: [
+ Container(
+ width: 64,
+ height: 64,
+ decoration: BoxDecoration(
+ color: Colors.red.withValues(alpha: 0.1),
+ shape: BoxShape.circle,
+ ),
+ child: const Icon(
+ Icons.error_outline,
+ color: Colors.red,
+ size: 36,
+ ),
+ ),
+ const SizedBox(width: 16),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('error_logout'.tr(),
+ style: theme.textTheme.titleMedium!.copyWith(
+ color: Colors.red, fontWeight: FontWeight.bold)),
+ Text('error_logout_subtitle'.tr(),
+ softWrap: true,
+ style: theme.textTheme.bodySmall!
+ .copyWith(color: Colors.red)),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/login/login_page.dart b/comwell_key_app/lib/login/login_page.dart
index 8a629bb4..8230aad1 100644
--- a/comwell_key_app/lib/login/login_page.dart
+++ b/comwell_key_app/lib/login/login_page.dart
@@ -1,11 +1,11 @@
import 'package:comwell_key_app/authentication/authentication_repository.dart';
import 'package:comwell_key_app/login/auth.dart';
import 'package:comwell_key_app/login/components/create_user_button.dart';
+import 'package:comwell_key_app/login/components/forced_logout_banner.dart';
import 'package:comwell_key_app/login/components/login_button.dart';
import 'package:comwell_key_app/login/components/azure_b2c_widget.dart';
import 'package:comwell_key_app/tracking/comwell_tracking.dart';
import 'package:comwell_key_app/utils/locator.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
@@ -32,7 +32,7 @@ class LoginPage extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- if (forced) _forcedLogoutBanner(context),
+ if (forced) const ForcedLogoutBanner(),
// Logo
Expanded(
flex: 3,
@@ -89,51 +89,3 @@ class LoginPage extends StatelessWidget {
}
}
-Widget _forcedLogoutBanner(BuildContext context) {
- final theme = Theme.of(context);
-
- return Padding(
- padding: const EdgeInsets.all(16.0),
- child: Container(
- height: 100,
- width: double.infinity,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(10),
- ),
- padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 16),
- child: Row(
- children: [
- Container(
- width: 64,
- height: 64,
- decoration: BoxDecoration(
- color: Colors.red.withValues(alpha: 0.1),
- shape: BoxShape.circle,
- ),
- child: const Icon(
- Icons.error_outline,
- color: Colors.red,
- size: 36,
- ),
- ),
- const SizedBox(width: 16),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('error_logout'.tr(),
- style: theme.textTheme.titleMedium!.copyWith(
- color: Colors.red, fontWeight: FontWeight.bold)),
- Text('error_logout_subtitle'.tr(),
- softWrap: true,
- style:
- theme.textTheme.bodySmall!.copyWith(color: Colors.red)),
- ],
- ),
- ),
- ],
- ),
- ),
- );
-}
diff --git a/comwell_key_app/lib/main.dart b/comwell_key_app/lib/main.dart
index 7ecefcd4..557e8e12 100644
--- a/comwell_key_app/lib/main.dart
+++ b/comwell_key_app/lib/main.dart
@@ -20,6 +20,10 @@ void runMainApp(FirebaseOptions firebaseOptions) async {
envFile = '.env.stage';
} else if (appFlavor == 'prod') {
envFile = '.env.prod';
+ } else if (appFlavor == 'debugTest') {
+ envFile = '.env.stage';
+ } else if (appFlavor == 'releaseTest') {
+ envFile = '.env.stage';
}
debugPrint("Current flavor: $appFlavor");
diff --git a/comwell_key_app/lib/profile/components/empty_card_content_widget.dart b/comwell_key_app/lib/profile/components/empty_card_content_widget.dart
new file mode 100644
index 00000000..7d0027c5
--- /dev/null
+++ b/comwell_key_app/lib/profile/components/empty_card_content_widget.dart
@@ -0,0 +1,55 @@
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+
+class EmptyCardContentWidget extends StatelessWidget {
+ const EmptyCardContentWidget({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+
+ return SizedBox(
+ width: double.infinity,
+ height: double.infinity,
+ child: Stack(
+ children: [
+ Positioned(
+ top: 20,
+ left: 20,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(32),
+ ),
+ child: Text(
+ 'error'.tr(),
+ style: theme.textTheme.bodySmall!.copyWith(
+ color: Colors.black,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ),
+ Positioned(
+ bottom: 20,
+ left: 20,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'profile_error_name'.tr(),
+ style: theme.textTheme.bodySmall!.copyWith(
+ color: Colors.black,
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/profile/components/error_page_widget.dart b/comwell_key_app/lib/profile/components/error_page_widget.dart
new file mode 100644
index 00000000..949a3e9a
--- /dev/null
+++ b/comwell_key_app/lib/profile/components/error_page_widget.dart
@@ -0,0 +1,89 @@
+import 'package:comwell_key_app/common/components/comwell_card_component.dart';
+import 'package:comwell_key_app/common/components/round_icon_button.dart';
+import 'package:comwell_key_app/profile/components/empty_card_content_widget.dart';
+import 'package:comwell_key_app/profile/components/logout_dialog_widget.dart';
+import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
+import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+class ErrorPageWidget extends StatelessWidget {
+ const ErrorPageWidget({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return SafeArea(
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 20),
+ child: Container(
+ alignment: Alignment.centerRight,
+ child: RoundIconButton(
+ icon: "assets/icons/close-icon.svg",
+ color: Colors.white,
+ onPressed: () {
+ context.pop();
+ }),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ children: [
+ ComwellCard(
+ content: const EmptyCardContentWidget(),
+ backgroundColor: sandColor[10]!),
+ ],
+ ),
+ ),
+ const SizedBox(height: 10),
+ Expanded(
+ child: Container(
+ color: Colors.white,
+ child: Column(
+ children: [
+ const SizedBox(height: 20),
+ Center(
+ child: OutlinedButton(
+ style: OutlinedButton.styleFrom(
+ side: const BorderSide(color: colorDivider),
+ ),
+ onPressed: () {
+ showDialog<void>(
+ context: context,
+ builder: (context) => LogoutDialogWidget(
+ cubit: context.read<ProfileCubit>(),
+ ),
+ );
+ },
+ child: Text(
+ 'logout_profile_menu'.tr(),
+ style: TextStyle(color: Colors.grey[600]),
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ FutureBuilder<String>(
+ future: context.read<ProfileCubit>().getVersion(),
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ return Text(snapshot.data!,
+ style: TextStyle(color: Colors.grey[500]));
+ }
+ return const SizedBox.shrink();
+ },
+ ),
+ const SizedBox(height: 20),
+ const Spacer(),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/profile/components/logout_dialog_widget.dart b/comwell_key_app/lib/profile/components/logout_dialog_widget.dart
new file mode 100644
index 00000000..d6ff5b59
--- /dev/null
+++ b/comwell_key_app/lib/profile/components/logout_dialog_widget.dart
@@ -0,0 +1,78 @@
+import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
+import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+
+class LogoutDialogWidget extends StatelessWidget {
+ final ProfileCubit cubit;
+ const LogoutDialogWidget({super.key, required this.cubit});
+
+ @override
+ Widget build(BuildContext context) {
+
+ return Dialog(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(20),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(24.0),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ "logout_dialog_title".tr(),
+ textAlign: TextAlign.center,
+ style: const TextStyle(
+ color: Colors.black,
+ fontSize: 18,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ const SizedBox(height: 24),
+ SizedBox(
+ width: double.infinity,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: sandColor,
+ padding: const EdgeInsets.symmetric(vertical: 16),
+ ),
+ onPressed: () {
+ cubit.logOutPressed();
+ },
+ child: Text(
+ "logout_profile_menu".tr(),
+ style: const TextStyle(
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ color: Colors.white,
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: 12),
+ SizedBox(
+ width: double.infinity,
+ child: OutlinedButton(
+ style: OutlinedButton.styleFrom(
+ side: BorderSide(color: Colors.grey[400]!),
+ padding: const EdgeInsets.symmetric(vertical: 16),
+ ),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ child: Text(
+ "cancel".tr(),
+ style: const TextStyle(
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ color: Colors.black,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
\ 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
new file mode 100644
index 00000000..d5113249
--- /dev/null
+++ b/comwell_key_app/lib/profile/components/profile_page_widget.dart
@@ -0,0 +1,297 @@
+import 'package:comwell_key_app/common/components/comwell_card_component.dart';
+import 'package:comwell_key_app/common/components/round_icon_button.dart';
+import 'package:comwell_key_app/profile/components/comwell_club_signup_bottom_sheet.dart';
+import 'package:comwell_key_app/profile/components/logout_dialog_widget.dart';
+import 'package:comwell_key_app/profile/components/profile_settings_item.dart';
+import 'package:comwell_key_app/profile/cubit/profile_cubit.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';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:flutter_svg/svg.dart';
+import 'package:go_router/go_router.dart';
+import 'package:url_launcher/url_launcher.dart';
+
+class ProfilePageWidget extends StatelessWidget {
+ final ProfileCubit cubit;
+ const ProfilePageWidget({super.key, required this.cubit});
+
+ @override
+ Widget build(BuildContext context) {
+ final user = cubit.state.user;
+ final isActive = cubit.state.user!.clubLevel != '';
+
+ return SafeArea(
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 20),
+ child: Container(
+ alignment: Alignment.centerRight,
+ child: RoundIconButton(
+ icon: "assets/icons/close-icon.svg",
+ color: Colors.white,
+ onPressed: () {
+ context.pop();
+ }),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ children: [
+ ComwellCard(
+ content: getCardContent(context, cubit, isActive),
+ backgroundColor: isActive ? sandColor : sandColor[10]!),
+ ],
+ ),
+ ),
+ const SizedBox(height: 10),
+ Expanded(
+ child: Container(
+ color: Colors.white,
+ child: Column(
+ children: [
+ const SizedBox(height: 10),
+ !isActive
+ ? Container(
+ margin: const EdgeInsets.symmetric(horizontal: 16),
+ padding: const EdgeInsets.symmetric(vertical: 16),
+ decoration: BoxDecoration(
+ color: sandColor[10],
+ borderRadius:
+ const BorderRadius.all(Radius.circular(10)),
+ ),
+ height: 115,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
+ children: [
+ GestureDetector(
+ onTap: () async {
+ await showModalBottomSheet<void>(
+ context: context,
+ isScrollControlled: true,
+ backgroundColor: Colors.white,
+ builder: (context) =>
+ ComwellClubSignupBottomSheet(
+ user: user!),
+ );
+ cubit.init();
+ },
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text("become_cc_member_title".tr(),
+ textAlign: TextAlign.start,
+ style: const TextStyle(
+ color: Colors.black,
+ fontSize: 16,
+ fontWeight: FontWeight.w600)),
+ SizedBox(
+ width: 250,
+ child: Text(
+ "become_cc_member_subtitle".tr(),
+ textAlign: TextAlign.start,
+ maxLines: 4,
+ style: const TextStyle(
+ color: Colors.black,
+ fontSize: 14,
+ fontWeight: FontWeight.w500),
+ ),
+ ),
+ ],
+ ),
+ ),
+ const Icon(
+ Icons.chevron_right,
+ color: Colors.black,
+ size: 24,
+ ),
+ ],
+ ),
+ )
+ : const SizedBox(),
+ const SizedBox(height: 10),
+ profileSettingsItem(
+ context,
+ icon: Image.asset('assets/icons/user-circle.png'),
+ text: 'profile_settings_profile_menu'.tr(),
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ await context.pushNamed(AppRoutes.profileSettings.name);
+ cubit.init();
+ },
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16.0),
+ child: Divider(color: colorDivider),
+ ),
+ profileSettingsItem(
+ context,
+ icon: Image.asset('assets/icons/card.png'),
+ text: 'payment_card_profile_menu'.tr(),
+ trailingIcon: Icons.chevron_right,
+ onTap: () {
+ context.pushNamed(AppRoutes.paymentCards.name);
+ },
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16.0),
+ child: Divider(color: colorDivider),
+ ),
+ profileSettingsItem(
+ context,
+ icon: Image.asset('assets/icons/bell.png'),
+ trailingIcon: Icons.chevron_right,
+ text: 'notifications_profile_menu'.tr(),
+ onTap: () {
+ context.pushNamed(AppRoutes.notifications.name);
+ },
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16.0),
+ child: Divider(color: colorDivider),
+ ),
+ const SizedBox(height: 10),
+ if (isActive) ...[
+ profileSettingsItem(
+ context,
+ icon: SvgPicture.asset('assets/icons/c_logo.svg'),
+ text: "Comwell Club",
+ trailingIcon: Icons.open_in_new,
+ onTap: () {
+ launchUrl(Uri.parse('https://comwell.com/profile'));
+ },
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16.0),
+ child: Divider(color: colorDivider),
+ ),
+ ],
+ const SizedBox(height: 10),
+ Center(
+ child: OutlinedButton(
+ style: OutlinedButton.styleFrom(
+ side: const BorderSide(color: colorDivider),
+ ),
+ onPressed: () {
+ showDialog<void>(
+ context: context,
+ builder: (context) => LogoutDialogWidget(
+ cubit: context.read<ProfileCubit>(),
+ ),
+ );
+ },
+ child: Text(
+ 'logout_profile_menu'.tr(),
+ style: TextStyle(color: Colors.grey[600]),
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ FutureBuilder<String>(
+ future: context.read<ProfileCubit>().getVersion(),
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ return Text(snapshot.data!,
+ style: TextStyle(color: Colors.grey[500]));
+ }
+ return const SizedBox.shrink();
+ },
+ ),
+ const SizedBox(height: 20),
+ const Spacer(),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget getCardContent(
+ BuildContext context, ProfileCubit cubit, bool isActive) {
+ final theme = Theme.of(context);
+ final user = cubit.state.user!;
+
+ return SizedBox(
+ width: double.infinity,
+ height: double.infinity,
+ child: Stack(
+ children: [
+ Positioned(
+ top: 20,
+ left: 20,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(32),
+ ),
+ child: Text(
+ isActive ? 'Comwell Club' : 'comwell_club_inactive'.tr(),
+ style: theme.textTheme.bodySmall!.copyWith(
+ color: Colors.black,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ),
+ Positioned(
+ bottom: 20,
+ left: 20,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'Navn',
+ style: TextStyle(
+ color: isActive ? Colors.white : Colors.black,
+ fontSize: 14,
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ Text(
+ '${user.firstName} ${user.lastName}',
+ style: TextStyle(
+ color: isActive ? Colors.white : Colors.black,
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ],
+ ),
+ ),
+ if (isActive)
+ Positioned(
+ bottom: 20,
+ right: 20,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Text(
+ 'points'.tr(),
+ style: const TextStyle(
+ color: Colors.white,
+ fontSize: 14,
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ Text(
+ '${user.points} ${'points'.tr()}',
+ style: const TextStyle(
+ color: Colors.white,
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/profile/profile_page.dart b/comwell_key_app/lib/profile/profile_page.dart
index f33ea757..88ecfa17 100644
--- a/comwell_key_app/lib/profile/profile_page.dart
+++ b/comwell_key_app/lib/profile/profile_page.dart
@@ -1,17 +1,10 @@
-import 'package:comwell_key_app/common/components/comwell_card_component.dart';
-import 'package:comwell_key_app/common/components/round_icon_button.dart';
-import 'package:comwell_key_app/profile/components/comwell_club_signup_bottom_sheet.dart';
-import 'package:comwell_key_app/profile/components/profile_settings_item.dart';
+import 'package:comwell_key_app/profile/components/error_page_widget.dart';
+import 'package:comwell_key_app/profile/components/profile_page_widget.dart';
import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
-import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/secure_storage.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:flutter_svg/svg.dart';
-import 'package:go_router/go_router.dart';
-import 'package:url_launcher/url_launcher.dart';
class ProfilePage extends StatelessWidget {
final SecureStorage secureStorage = SecureStorage();
@@ -30,476 +23,12 @@ class ProfilePage extends StatelessWidget {
if (state.isLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state.error != null) {
- return _buildErrorPage(context);
+ return const ErrorPageWidget();
} else {
- return _buildProfilePage(cubit, context);
+ return ProfilePageWidget(cubit: cubit);
}
},
),
);
}
-
- Widget _buildErrorPage(BuildContext context) {
- return SafeArea(
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.only(top: 20),
- child: Container(
- alignment: Alignment.centerRight,
- child: RoundIconButton(
- icon: "assets/icons/close-icon.svg",
- color: Colors.white,
- onPressed: () {
- context.pop();
- }),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- children: [
- ComwellCard(
- content: getEmptyCardContent(context),
- backgroundColor: sandColor[10]!),
- ],
- ),
- ),
- const SizedBox(height: 10),
- Expanded(
- child: Container(
- color: Colors.white,
- child: Column(
- children: [
- const SizedBox(height: 20),
- Center(
- child: OutlinedButton(
- style: OutlinedButton.styleFrom(
- side: const BorderSide(color: colorDivider),
- ),
- onPressed: () {
- showLogoutDialog(context);
- },
- child: Text(
- 'logout_profile_menu'.tr(),
- style: TextStyle(color: Colors.grey[600]),
- ),
- ),
- ),
- const SizedBox(height: 16),
- FutureBuilder<String>(
- future: context.read<ProfileCubit>().getVersion(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return Text(snapshot.data!,
- style: TextStyle(color: Colors.grey[500]));
- }
- return const SizedBox.shrink();
- },
- ),
- const SizedBox(height: 20),
- const Spacer(),
- ],
- ),
- ),
- ),
- ],
- ),
- );
- }
-
- Widget _buildProfilePage(ProfileCubit cubit, BuildContext context) {
- final user = cubit.state.user;
- final isActive = cubit.state.user!.clubLevel != '';
-
- return SafeArea(
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.only(top: 20),
- child: Container(
- alignment: Alignment.centerRight,
- child: RoundIconButton(
- icon: "assets/icons/close-icon.svg",
- color: Colors.white,
- onPressed: () {
- context.pop();
- }),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- children: [
- ComwellCard(
- content: getCardContent(context, cubit, isActive),
- backgroundColor: isActive ? sandColor : sandColor[10]!),
- ],
- ),
- ),
- const SizedBox(height: 10),
- Expanded(
- child: Container(
- color: Colors.white,
- child: Column(
- children: [
- const SizedBox(height: 10),
- !isActive
- ? Container(
- margin: const EdgeInsets.symmetric(horizontal: 16),
- padding: const EdgeInsets.symmetric(vertical: 16),
- decoration: BoxDecoration(
- color: sandColor[10],
- borderRadius:
- const BorderRadius.all(Radius.circular(10)),
- ),
- height: 115,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- GestureDetector(
- onTap: () async {
- await showModalBottomSheet<void>(
- context: context,
- isScrollControlled: true,
- backgroundColor: Colors.white,
- builder: (context) =>
- ComwellClubSignupBottomSheet(
- user: user!),
- );
- cubit.init();
- },
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text("become_cc_member_title".tr(),
- textAlign: TextAlign.start,
- style: const TextStyle(
- color: Colors.black,
- fontSize: 16,
- fontWeight: FontWeight.w600)),
- SizedBox(
- width: 250,
- child: Text(
- "become_cc_member_subtitle".tr(),
- textAlign: TextAlign.start,
- maxLines: 4,
- style: const TextStyle(
- color: Colors.black,
- fontSize: 14,
- fontWeight: FontWeight.w500),
- ),
- ),
- ],
- ),
- ),
- const Icon(
- Icons.chevron_right,
- color: Colors.black,
- size: 24,
- ),
- ],
- ),
- )
- : const SizedBox(),
- const SizedBox(height: 10),
- profileSettingsItem(
- context,
- icon: Image.asset('assets/icons/user-circle.png'),
- text: 'profile_settings_profile_menu'.tr(),
- trailingIcon: Icons.chevron_right,
- onTap: () async {
- await context.pushNamed(AppRoutes.profileSettings.name);
- cubit.init();
- },
- ),
- const Padding(
- padding: EdgeInsets.symmetric(horizontal: 16.0),
- child: Divider(color: colorDivider),
- ),
- profileSettingsItem(
- context,
- icon: Image.asset('assets/icons/card.png'),
- text: 'payment_card_profile_menu'.tr(),
- trailingIcon: Icons.chevron_right,
- onTap: () {
- context.pushNamed(AppRoutes.paymentCards.name);
- },
- ),
- const Padding(
- padding: EdgeInsets.symmetric(horizontal: 16.0),
- child: Divider(color: colorDivider),
- ),
- profileSettingsItem(
- context,
- icon: Image.asset('assets/icons/bell.png'),
- trailingIcon: Icons.chevron_right,
- text: 'notifications_profile_menu'.tr(),
- onTap: () {
- context.pushNamed(AppRoutes.notifications.name);
- },
- ),
- const Padding(
- padding: EdgeInsets.symmetric(horizontal: 16.0),
- child: Divider(color: colorDivider),
- ),
- const SizedBox(height: 10),
- if (isActive) ...[
- profileSettingsItem(
- context,
- icon: SvgPicture.asset('assets/icons/c_logo.svg'),
- text: "Comwell Club",
- trailingIcon: Icons.open_in_new,
- onTap: () {
- launchUrl(Uri.parse('https://comwell.com/profile'));
- },
- ),
- const Padding(
- padding: EdgeInsets.symmetric(horizontal: 16.0),
- child: Divider(color: colorDivider),
- ),
- ],
- const SizedBox(height: 10),
- Center(
- child: OutlinedButton(
- style: OutlinedButton.styleFrom(
- side: const BorderSide(color: colorDivider),
- ),
- onPressed: () {
- showLogoutDialog(context);
- },
- child: Text(
- 'logout_profile_menu'.tr(),
- style: TextStyle(color: Colors.grey[600]),
- ),
- ),
- ),
- const SizedBox(height: 16),
- FutureBuilder<String>(
- future: context.read<ProfileCubit>().getVersion(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return Text(snapshot.data!,
- style: TextStyle(color: Colors.grey[500]));
- }
- return const SizedBox.shrink();
- },
- ),
- const SizedBox(height: 20),
- const Spacer(),
- ],
- ),
- ),
- ),
- ],
- ),
- );
- }
-
- Future<AlertDialog?> showLogoutDialog(BuildContext context) {
- final cubit = context.read<ProfileCubit>();
-
- return showDialog<AlertDialog>(
- context: context,
- builder: (BuildContext context) {
- return Dialog(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(20),
- ),
- child: Padding(
- padding: const EdgeInsets.all(24.0),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- "logout_dialog_title".tr(),
- textAlign: TextAlign.center,
- style: const TextStyle(
- color: Colors.black,
- fontSize: 18,
- fontWeight: FontWeight.w600,
- ),
- ),
- const SizedBox(height: 24),
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: sandColor,
- padding: const EdgeInsets.symmetric(vertical: 16),
- ),
- onPressed: () {
- cubit.logOutPressed();
- },
- child: Text(
- "logout_profile_menu".tr(),
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.w600,
- color: Colors.white,
- ),
- ),
- ),
- ),
- const SizedBox(height: 12),
- SizedBox(
- width: double.infinity,
- child: OutlinedButton(
- style: OutlinedButton.styleFrom(
- side: BorderSide(color: Colors.grey[400]!),
- padding: const EdgeInsets.symmetric(vertical: 16),
- ),
- onPressed: () {
- context.pop();
- },
- child: Text(
- "cancel".tr(),
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.w600,
- color: Colors.black,
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- );
- });
- }
-
- Widget getEmptyCardContent(
- BuildContext context) {
- final theme = Theme.of(context);
-
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: Stack(
- children: [
- Positioned(
- top: 20,
- left: 20,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(32),
- ),
- child: Text(
- 'error'.tr(),
- style: theme.textTheme.bodySmall!.copyWith(
- color: Colors.black,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- ),
- Positioned(
- bottom: 20,
- left: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'profile_error_name'.tr(),
- style: theme.textTheme.bodySmall!.copyWith(
- color: Colors.black,
- fontSize: 16,
- fontWeight: FontWeight.w600,
- ),
- ),
- ],
- ),
- ),
-
- ],
- ),
- );
- }
-
- Widget getCardContent(
- BuildContext context, ProfileCubit cubit, bool isActive) {
- final theme = Theme.of(context);
- final user = cubit.state.user!;
-
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: Stack(
- children: [
- Positioned(
- top: 20,
- left: 20,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(32),
- ),
- child: Text(
- isActive ? 'Comwell Club' : 'comwell_club_inactive'.tr(),
- style: theme.textTheme.bodySmall!.copyWith(
- color: Colors.black,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- ),
- Positioned(
- bottom: 20,
- left: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'Navn',
- style: TextStyle(
- color: isActive ? Colors.white : Colors.black,
- fontSize: 14,
- fontWeight: FontWeight.w400,
- ),
- ),
- Text(
- '${user.firstName} ${user.lastName}',
- style: TextStyle(
- color: isActive ? Colors.white : Colors.black,
- fontSize: 16,
- fontWeight: FontWeight.w600,
- ),
- ),
- ],
- ),
- ),
- if (isActive)
- Positioned(
- bottom: 20,
- right: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(
- 'points'.tr(),
- style: const TextStyle(
- color: Colors.white,
- fontSize: 14,
- fontWeight: FontWeight.w400,
- ),
- ),
- Text(
- '${user.points} ${'points'.tr()}',
- style: const TextStyle(
- color: Colors.white,
- fontSize: 16,
- fontWeight: FontWeight.w600,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }
}
diff --git a/comwell_key_app/test/booking_details_test/booking_details_repository_test.dart b/comwell_key_app/test/booking_details_test/booking_details_repository_test.dart
index 18b600bf..b5ff68a7 100644
--- a/comwell_key_app/test/booking_details_test/booking_details_repository_test.dart
+++ b/comwell_key_app/test/booking_details_test/booking_details_repository_test.dart
@@ -1,4 +1,5 @@
// Import necessary testing packages and mockito
+import 'package:comwell_key_app/booking_details/booking_details_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:seos_mobile_keys_plugin/seos_mobile_keys_plugin.dart';
@@ -7,14 +8,14 @@ class MockSeosMobileKeysPlugin extends Mock implements SeosMobileKeysPlugin {}
void main() {
// Declare the mock SeosMobileKeysPlugin
- // late SeosMobileKeysPlugin mockSeosMobileKeysPlugin;
- // late BookingDetailsRepository bookingDetailsRepository;
+ late SeosMobileKeysPlugin mockSeosMobileKeysPlugin;
+ late BookingDetailsRepository bookingDetailsRepository;
// Setup function runs before every test
setUp(() {
// Initialize the mock SeosMobileKeysPlugin
TestWidgetsFlutterBinding.ensureInitialized();
- // mockSeosMobileKeysPlugin = MockSeosMobileKeysPlugin();
- // bookingDetailsRepository = BookingDetailsRepository();
+ mockSeosMobileKeysPlugin = MockSeosMobileKeysPlugin();
+ bookingDetailsRepository = BookingDetailsRepository();
});
}
\ No newline at end of file