6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit e95f737c
Changed files
.../comwell_club_signup_bottom_sheet.dart | 8 +---- .../components/address_bottom_sheet.dart | 4 ++- .../components/comwell_text_field.dart | 2 +- .../components/date_time_picker.dart | 28 +++++++++++++--- .../cubit/profile_settings_cubit.dart | 2 +- .../profile_settings/profile_settings_page.dart | 38 ++++++++++++++-------- comwell_key_app/lib/utils/address_utils.dart | 19 +++++++++++ 7 files changed, 73 insertions(+), 28 deletions(-)
Diff
diff --git a/comwell_key_app/lib/profile/components/comwell_club_signup_bottom_sheet.dart b/comwell_key_app/lib/profile/components/comwell_club_signup_bottom_sheet.dart
index ad65aa7b..e22fd08a 100644
--- a/comwell_key_app/lib/profile/components/comwell_club_signup_bottom_sheet.dart
+++ b/comwell_key_app/lib/profile/components/comwell_club_signup_bottom_sheet.dart
@@ -153,13 +153,7 @@ class _ComwellClubSignupBottomSheetState
),
),
const SizedBox(height: 16),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: DateTimePicker(
- title: "profile_settings_birthday".tr(),
- initialValue: widget.user.birthDate,
- ),
- ),
+
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
diff --git a/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart b/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
index 239ff495..67277a66 100644
--- a/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
+++ b/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
@@ -34,7 +34,9 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
_zipCodeController =
TextEditingController(text: widget.user.address.zipCode);
_cityController = TextEditingController(text: widget.user.address.city);
- _selectedCountry = widget.user.address.country;
+ _selectedCountry = widget.user.address.country != '' ? widget.user.address.country : 'DK';
+
+ print('selectedCountry: $_selectedCountry');
}
@override
diff --git a/comwell_key_app/lib/profile_settings/components/comwell_text_field.dart b/comwell_key_app/lib/profile_settings/components/comwell_text_field.dart
index 75f4d677..83d4490f 100644
--- a/comwell_key_app/lib/profile_settings/components/comwell_text_field.dart
+++ b/comwell_key_app/lib/profile_settings/components/comwell_text_field.dart
@@ -63,7 +63,7 @@ class ComwellTextFieldState extends State<ComwellTextField> {
contentPadding: const EdgeInsets.symmetric(vertical: 0),
),
- style: Theme.of(context).textTheme.headlineSmall,
+ style: !widget.readOnly ? theme.textTheme.headlineSmall : theme.textTheme.headlineSmall?.copyWith(color: Colors.black.withValues(alpha: 0.5)),
onSubmitted: widget.onSubmitted,
),
),
diff --git a/comwell_key_app/lib/profile_settings/components/date_time_picker.dart b/comwell_key_app/lib/profile_settings/components/date_time_picker.dart
index 0c7fea45..a4cecd6e 100644
--- a/comwell_key_app/lib/profile_settings/components/date_time_picker.dart
+++ b/comwell_key_app/lib/profile_settings/components/date_time_picker.dart
@@ -8,10 +8,8 @@ import 'package:comwell_key_app/profile_settings/cubit/profile_settings_cubit.da
class DateTimePicker extends StatefulWidget {
final String title;
final DateTime initialValue;
- const DateTimePicker({
- required this.title,
- required this.initialValue,
- super.key});
+ const DateTimePicker(
+ {required this.title, required this.initialValue, super.key});
@override
State<DateTimePicker> createState() => _DatePickerState();
@@ -26,6 +24,28 @@ class _DatePickerState extends State<DateTimePicker> {
}
Future<void> _selectDate(BuildContext context) async => showDatePicker(
+ builder: (context, child) {
+ final theme = Theme.of(context);
+
+ return Theme(
+ data: theme.copyWith(
+ colorScheme: ColorScheme.light(
+ primary: sandColor,
+ onPrimary: Colors.white,
+ onSurface: Colors.black.withValues(alpha: 0.65),
+ surface: Colors.white,
+ onError: Colors.red,
+ ),
+ textButtonTheme: TextButtonThemeData(
+ style: TextButton.styleFrom(
+ foregroundColor: Colors.black.withValues(alpha: 0.65),
+ overlayColor: sandColor,
+ ),
+ ),
+ ),
+ child: child!,
+ );
+ },
context: context,
initialDate: widget.initialValue,
firstDate: DateTime(0),
diff --git a/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart b/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart
index b87937b9..98f3b1ba 100644
--- a/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart
+++ b/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart
@@ -56,7 +56,7 @@ class ProfileSettingsCubit extends Cubit<ProfileSettingsState> {
}
- //TODO: Add this to the comwell signup page when backend is ready
+
void updateBirthDate(DateTime birthDate) {
if (state.user != null) {
final updatedUser = state.user!.copyWith(birthDate: birthDate);
diff --git a/comwell_key_app/lib/profile_settings/profile_settings_page.dart b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
index 97ed4044..e76ef81d 100644
--- a/comwell_key_app/lib/profile_settings/profile_settings_page.dart
+++ b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
@@ -1,16 +1,18 @@
- import 'package:comwell_key_app/authentication/authentication_repository.dart';
+import 'package:comwell_key_app/authentication/authentication_repository.dart';
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/common/components/generic_dialog.dart';
import 'package:comwell_key_app/login/auth.dart';
import 'package:comwell_key_app/login/components/azure_b2c_widget.dart';
import 'package:comwell_key_app/profile_settings/components/address_bottom_sheet.dart';
import 'package:comwell_key_app/profile_settings/components/comwell_text_field.dart';
+import 'package:comwell_key_app/profile_settings/components/date_time_picker.dart';
import 'package:comwell_key_app/profile_settings/components/intl_phone_field.dart';
import 'package:comwell_key_app/profile_settings/components/text_field_with_trailing_icon.dart';
import 'package:comwell_key_app/profile_settings/cubit/profile_settings_cubit.dart';
import 'package:comwell_key_app/profile_settings/model/address.dart';
import 'package:comwell_key_app/profile_settings/model/user.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:comwell_key_app/utils/address_utils.dart';
import 'package:comwell_key_app/utils/locator.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/gestures.dart';
@@ -20,7 +22,6 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class ProfileSettingsPage extends StatelessWidget {
-
const ProfileSettingsPage({super.key});
@override
@@ -56,6 +57,7 @@ class ProfileSettingsPage extends StatelessWidget {
Widget _buildProfileSettingsPage(
ThemeData theme, ProfileSettingsState state, BuildContext context) {
final cubit = context.read<ProfileSettingsCubit>();
+ final address = formatAddress(state.user!.address);
return Scaffold(
resizeToAvoidBottomInset: false,
@@ -72,7 +74,8 @@ class ProfileSettingsPage extends StatelessWidget {
children: [
const SizedBox(height: 36),
Text("profile_settings".tr(),
- style: theme.textTheme.headlineLarge,
+ style: theme.textTheme.headlineLarge
+ ?.copyWith(color: Colors.black.withValues(alpha: 0.65)),
textAlign: TextAlign.start),
const SizedBox(height: 36),
ComwellTextField(
@@ -94,11 +97,11 @@ class ProfileSettingsPage extends StatelessWidget {
}),
const SizedBox(height: 8),
ComwellTextField(
- fieldName: "profile_settings_email".tr(),
- initialValue: state.user!.email,
- readOnly: true,
- controller: TextEditingController(text: state.user!.email),
- ),
+ fieldName: "profile_settings_email".tr(),
+ initialValue: state.user!.email,
+ readOnly: true,
+ controller: TextEditingController(text: state.user!.email),
+ ),
const SizedBox(height: 8),
IntlPhoneField(
title: "profile_settings_phone".tr(),
@@ -112,11 +115,10 @@ class ProfileSettingsPage extends StatelessWidget {
const SizedBox(height: 8),
TextFieldWithTrailingIcon(
title: "profile_settings_address".tr(),
- text:
- "${state.user!.address.street}, ${state.user!.address.city}, ${state.user!.address.zipCode}, ${state.user!.address.country}",
+ text: address,
trailingIcon: "assets/icons/edit-alt.svg",
onTap: () async {
- final response = await showModalBottomSheet<Address>(
+ final response = await showModalBottomSheet<Address>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.white,
@@ -131,6 +133,11 @@ class ProfileSettingsPage extends StatelessWidget {
},
showTitle: true),
const SizedBox(height: 8),
+ DateTimePicker(
+ title: "profile_settings_birthday".tr(),
+ initialValue: state.user!.birthDate,
+ ),
+ const SizedBox(height: 8),
TextFieldWithTrailingIcon(
title: "profile_settings_edit_password".tr(),
text: "profile_settings_edit_password".tr(),
@@ -212,9 +219,9 @@ class ProfileSettingsPage extends StatelessWidget {
);
}
- Future<dynamic> openChangePasswordModal(BuildContext context, Auth authEnum) {
+ Future<dynamic> openChangePasswordModal(BuildContext context, Auth authEnum) {
return showCupertinoModalBottomSheet(
- enableDrag: false,
+ enableDrag: false,
backgroundColor: Colors.orange,
topRadius: const Radius.circular(30),
elevation: 5,
@@ -229,7 +236,10 @@ class ProfileSettingsPage extends StatelessWidget {
child: SizedBox(
height: 700,
width: 400,
- child: AzureB2CWidget(authEnum: authEnum, authenticationRepository: locator<AuthenticationRepository>()),
+ child: AzureB2CWidget(
+ authEnum: authEnum,
+ authenticationRepository:
+ locator<AuthenticationRepository>()),
),
),
);
diff --git a/comwell_key_app/lib/utils/address_utils.dart b/comwell_key_app/lib/utils/address_utils.dart
new file mode 100644
index 00000000..0f4c3eed
--- /dev/null
+++ b/comwell_key_app/lib/utils/address_utils.dart
@@ -0,0 +1,19 @@
+ import 'package:comwell_key_app/profile_settings/model/address.dart';
+
+String formatAddress(Address address) {
+ final List<String> parts = [];
+
+ if (address.zipCode.isNotEmpty) {
+ parts.add(address.zipCode);
+ }
+
+ if (address.city.isNotEmpty) {
+ parts.add(address.city);
+ }
+
+ if (address.country.isNotEmpty) {
+ parts.add(address.country);
+ }
+
+ return parts.join(', ');
+ }
\ No newline at end of file