Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(recipients_app): Fix profile update, fix contact dialog button #711

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions recipients_app/lib/view/pages/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class AccountPageState extends State<AccountPage> {
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;

final recipient =
context.watch<AuthCubit>().state.recipient ?? widget.recipient;

return BlocConsumer<AuthCubit, AuthState>(
listener: (context, state) {
if (state.status == AuthStatus.updateRecipientSuccess) {
Expand Down Expand Up @@ -151,7 +154,7 @@ class AccountPageState extends State<AccountPage> {
onSubmitted: (value) {
if (value != null && value.isNotEmpty)
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(firstName: value),
recipient.copyWith(firstName: value),
);
},
),
Expand All @@ -168,7 +171,7 @@ class AccountPageState extends State<AccountPage> {
onSubmitted: (value) {
if (value != null && value.isNotEmpty)
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(
recipient.copyWith(
lastName: value,
),
);
Expand All @@ -180,7 +183,7 @@ class AccountPageState extends State<AccountPage> {
hintText: localizations.callingName,
onSubmitted: (value) =>
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(callingName: value),
recipient.copyWith(callingName: value),
),
),
const SizedBox(height: 16),
Expand All @@ -200,7 +203,7 @@ class AccountPageState extends State<AccountPage> {
value: "other",
),
],
value: widget.recipient.gender,
value: recipient.gender,
validator: (value) {
if (value == null || value.isEmpty) {
return localizations.genderError;
Expand All @@ -209,7 +212,7 @@ class AccountPageState extends State<AccountPage> {
},
onChanged: (value) =>
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(
recipient.copyWith(
gender: value,
),
),
Expand All @@ -223,14 +226,14 @@ class AccountPageState extends State<AccountPage> {
firstDate: DateTime(1950),
lastDate: DateTime(DateTime.now().year - 10),
initialDate:
widget.recipient.birthDate?.toDate() ?? DateTime(2000),
recipient.birthDate?.toDate() ?? DateTime(2000),
context: context,
).then((value) {
if (value != null) {
final timestamp = Timestamp.fromDate(value);

context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(
recipient.copyWith(
birthDate: timestamp,
),
);
Expand Down Expand Up @@ -273,10 +276,10 @@ class AccountPageState extends State<AccountPage> {
// change language accordingly
context.read<SettingsCubit>().changeLanguage(value!);
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(selectedLanguage: value),
recipient.copyWith(selectedLanguage: value),
);
},
value: widget.recipient.selectedLanguage,
value: recipient.selectedLanguage,
),

const SizedBox(height: 16),
Expand All @@ -286,7 +289,7 @@ class AccountPageState extends State<AccountPage> {
onSubmitted: (value) {
if (value != null && value.isNotEmpty)
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(email: value),
recipient.copyWith(email: value),
);
},
keyboardType: TextInputType.emailAddress,
Expand All @@ -305,7 +308,7 @@ class AccountPageState extends State<AccountPage> {
onSubmitted: (value) {
if (value != null && value.isNotEmpty) {
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(
recipient.copyWith(
mobileMoneyPhone: Phone(int.parse(value)),
),
);
Expand Down Expand Up @@ -336,7 +339,7 @@ class AccountPageState extends State<AccountPage> {
value: "africell_money",
),
],
value: widget.recipient.paymentProvider,
value: recipient.paymentProvider,
validator: (value) {
if (value == null || value.isEmpty) {
return localizations.paymentProviderError;
Expand All @@ -346,7 +349,7 @@ class AccountPageState extends State<AccountPage> {
onChanged: (value) => context
.read<AuthCubit>()
.updateRecipient(
widget.recipient.copyWith(paymentProvider: value)),
recipient.copyWith(paymentProvider: value)),
),
const SizedBox(height: 24),

Expand Down Expand Up @@ -374,7 +377,7 @@ class AccountPageState extends State<AccountPage> {
onSubmitted: (value) {
if (value != null && value.isNotEmpty)
context.read<AuthCubit>().updateRecipient(
widget.recipient.copyWith(
recipient.copyWith(
communicationMobilePhone: Phone(
int.parse(value),
),
Expand Down Expand Up @@ -411,7 +414,10 @@ class AccountPageState extends State<AccountPage> {
Text(localizations.supportInfo),
const SizedBox(height: 16),
ButtonBig(
onPressed: () => const SocialIncomeContactDialog(),
onPressed: () => showDialog(
context: context,
builder: (context) => const SocialIncomeContactDialog(),
),
label: localizations.getInTouch,
),
const SizedBox(height: 24),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class SocialIncomeContactDialog extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(AppSizes.radiusMedium),
color: AppColors.backgroundColor,
border: Border.all(
color: Theme.of(context).primaryColor,
),
),
child: Padding(
padding: AppSpacings.a16,
Expand All @@ -38,19 +35,19 @@ class SocialIncomeContactDialog extends StatelessWidget {
),
Text(
localizations.supportTeam,
style: const TextStyle(fontSize: 24),
style: Theme.of(context).textTheme.headlineLarge,
),
Text(
localizations.getInTouch,
style: const TextStyle(fontSize: 15, color: Colors.grey),
style: Theme.of(context).textTheme.bodyLarge,
)
],
),
Column(
children: [
_IconAndContact(
contactMethod: "WhatsApp",
contactDetails: "+41 76 251 55 69",
contactDetails: "+232 75 588647",
onOpen: (String value) => openWhatsapp(context, value),
),
const SizedBox(height: 16),
Expand All @@ -62,7 +59,7 @@ class SocialIncomeContactDialog extends StatelessWidget {
const SizedBox(height: 16),
_IconAndContact(
contactMethod: localizations.email,
contactDetails: "support@socialincome.org",
contactDetails: "hello@socialincome.org",
onOpen: (String value) => writeEmail(value),
),
],
Expand Down
Loading