Skip to content

Commit 892dd6d

Browse files
authored
Merge pull request #1932 from airqo-platform/account-link-reminder
Reminder For Merging Email and Phone number in the profile section
2 parents a090f7f + cb2d222 commit 892dd6d

11 files changed

+236
-45
lines changed

mobile/lib/l10n/app_en.arb

+6-3
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@
363363
"youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe" :" You would be required to add your email to your profile on the mobile app to enable you access the ",
364364
"withOneAccount":" with one account.",
365365
"addMyEmail":"Add my email",
366-
"remindMeLater":"Remind me later"
367-
368-
}
366+
"remindMeLater":"Remind me later",
367+
"addMyEmailToMyProfile":"Add my email to my profile",
368+
"addYourEmailToYourProfileToEnableYouToAccessThe" : "Add your email to your profile to enable you to access the ",
369+
"accessDeeperAirQualityInsights":"Access deeper Air Quality insights",
370+
"usingYourAirQoMobileAppAccount":"using your AirQo mobile app account"
371+
}

mobile/lib/l10n/app_fr.arb

+5-1
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,9 @@
353353
"youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe" : " Vous devrez ajouter votre e-mail à votre profil sur l'application mobile pour vous permettre d'accéder au ",
354354
"withOneAccount":" avec un compte.",
355355
"addMyEmail":"ajouter mon e-mail",
356-
"remindMeLater":"Rappelez-moi plus tard"
356+
"remindMeLater":"Rappelez-moi plus tard",
357+
"addMyEmailToMyProfile":"Ajoutez mon e-mail à mon profil",
358+
"addYourEmailToYourProfileToEnableYouToAccessThe" : "Ajoutez votre e-mail à votre profil pour vous permettre d'accéder au ",
359+
"accessDeeperAirQualityInsights":"Accéder à des informations plus approfondies sur la qualité de l'air",
360+
"usingYourAirQoMobileAppAccount":"En utilisant votre compte AirQo Mobile App"
357361
}

mobile/lib/l10n/app_lg.arb

+5-2
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@
355355
"youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe":" Wandibadde weetaaga okwongera email yo ku profile yo ku app y'essimu okukusobozesa okuyingira mu ",
356356
"withOneAccount":" nga erina akawunti emu.",
357357
"addMyEmail":"Yongerako email yange",
358-
"remindMeLater":"Nzijukiza oluvannyuma"
359-
358+
"remindMeLater":"Nzijukiza oluvannyuma",
359+
"addMyEmailToMyProfile":"Yongerako email yange ku profile yange",
360+
"addYourEmailToYourProfileToEnableYouToAccessThe" : "Yongerako email yo ku profile yo okukusobozesa okuyingira mu ",
361+
"accessDeeperAirQualityInsights":"okwekenenya okw'omutindo gw'empewo",
362+
"usingYourAirQoMobileAppAccount":"okuva ku akawunti yo ku app ya AirQo"
360363
}

mobile/lib/l10n/app_pt.arb

+5-1
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,9 @@
353353
"youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe":" Você deverá adicionar seu e-mail ao seu perfil no aplicativo móvel para permitir o acesso ao ",
354354
"withOneAccount":" com uma conta.",
355355
"addMyEmail":"Adicionar meu e-mail",
356-
"remindMeLater":"Lembre-me mais tarde"
356+
"remindMeLater":"Lembre-me mais tarde",
357+
"addMyEmailToMyProfile":"Adicionar meu e-mail ao meu perfil",
358+
"addYourEmailToYourProfileToEnableYouToAccessThe" : "Adicione seu e-mail ao seu perfil para permitir o acesso ao ",
359+
"accessDeeperAirQualityInsights":"acesso a insights mais profundos sobre a qualidade do ar",
360+
"usingYourAirQoMobileAppAccount":"Usando sua conta do aplicativo móvel AirQo"
357361
}

mobile/lib/l10n/app_sw.arb

+5-1
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,9 @@
354354
"youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe":" Utahitajika kuongeza barua pepe yako kwenye wasifu wako kwenye programu ya simu ili kukuwezesha kufikia ",
355355
"withOneAccount":" na akaunti moja.",
356356
"addMyEmail":"Ongeza barua pepe yangu",
357-
"remindMeLater":"Nikumbushe baadaye"
357+
"remindMeLater":"Nikumbushe baadaye",
358+
"addMyEmailToMyProfile":"Ongeza barua pepe yangu kwenye wasifu wangu",
359+
"addYourEmailToYourProfileToEnableYouToAccessThe" : "Ongeza barua pepe yako kwenye wasifu wako ili uweze kufikia ",
360+
"accessDeeperAirQualityInsights":"fikia maelezo zaidi ya ubora wa hewa",
361+
"usingYourAirQoMobileAppAccount":"Kwa kutumia akaunti yako ya programu ya simu ya AirQo"
358362
}

mobile/lib/screens/email_link/email_link_page.dart

+11-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Future<dynamic> bottomSheetEmailLink(BuildContext context) async {
1717
bool shouldShowBottomSheet = true;
1818
int remindMeLaterTimestamp = prefs.getInt('remindMeLaterTimestamp') ?? 0;
1919

20-
if (remindMeLaterTimestamp > 0) {
20+
if (remindMeLaterTimestamp > 3) {
2121
DateTime lastRemindTimestamp =
2222
DateTime.fromMillisecondsSinceEpoch(remindMeLaterTimestamp);
2323
DateTime now = DateTime.now();
@@ -84,7 +84,8 @@ Future<dynamic> bottomSheetEmailLink(BuildContext context) async {
8484
width: 295.53,
8585
height: 67,
8686
child: AutoSizeText(
87-
AppLocalizations.of(context)!.weAreShufflingThingsAroundForYou,
87+
AppLocalizations.of(context)!
88+
.weAreShufflingThingsAroundForYou,
8889
textAlign: TextAlign.center,
8990
style: TextStyle(
9091
color: CustomColors.quizColorBlack,
@@ -101,8 +102,9 @@ Future<dynamic> bottomSheetEmailLink(BuildContext context) async {
101102
textAlign: TextAlign.center,
102103
text: TextSpan(
103104
children: [
104-
TextSpan(
105-
text:AppLocalizations.of(context)!.youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe,
105+
TextSpan(
106+
text: AppLocalizations.of(context)!
107+
.youWouldBeRequiredToAddYourEmailToYourProfileOnTheMobileAppToEnableYouAccessThe,
106108
style: const TextStyle(
107109
color: Color(0xFF485972),
108110
fontSize: 13.24,
@@ -131,8 +133,9 @@ Future<dynamic> bottomSheetEmailLink(BuildContext context) async {
131133
}
132134
},
133135
),
134-
TextSpan(
135-
text: AppLocalizations.of(context)!.withOneAccount,
136+
TextSpan(
137+
text: AppLocalizations.of(context)!
138+
.withOneAccount,
136139
style: const TextStyle(
137140
color: Color(0xFF485972),
138141
fontSize: 13.24,
@@ -152,7 +155,7 @@ Future<dynamic> bottomSheetEmailLink(BuildContext context) async {
152155
},
153156
));
154157
},
155-
child: EmailLinkActionButton(
158+
child: EmailLinkActionButton(
156159
text: AppLocalizations.of(context)!.addMyEmail,
157160
),
158161
),
@@ -165,7 +168,7 @@ Future<dynamic> bottomSheetEmailLink(BuildContext context) async {
165168
DateTime.now().millisecondsSinceEpoch,
166169
);
167170
},
168-
child: EmailLinkSkipButton(
171+
child: EmailLinkSkipButton(
169172
text: AppLocalizations.of(context)!.remindMeLater,
170173
),
171174
),

mobile/lib/screens/email_link/email_link_widgets.dart

+15-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
99
import 'package:flutter_bloc/flutter_bloc.dart';
1010
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
1111
import 'package:flutter_svg/flutter_svg.dart';
12+
import 'package:shared_preferences/shared_preferences.dart';
1213

1314
class EmailLinkActionButton extends StatelessWidget {
1415
const EmailLinkActionButton({
@@ -115,7 +116,7 @@ class EmailLinkErrorMessage extends StatelessWidget {
115116
),
116117
Expanded(
117118
child: AutoSizeText(
118-
'Your Email is already registered ',
119+
AppLocalizations.of(context)!.yourEmailIsAlreadyRegistered,
119120
maxLines: 1,
120121
overflow: TextOverflow.ellipsis,
121122
textAlign: TextAlign.center,
@@ -189,12 +190,20 @@ class SkipLinkButtons extends StatelessWidget {
189190
children: [
190191
const SizedBox(height: 8),
191192
GestureDetector(
192-
onTap: () {
193-
Navigator.push(
193+
onTap: () async {
194+
SharedPreferences prefs =
195+
await SharedPreferences.getInstance();
196+
prefs.setInt(
197+
'remindMeLaterTimestamp',
198+
DateTime.now().millisecondsSinceEpoch,
199+
);
200+
Navigator.pop(context);
201+
Navigator.pushAndRemoveUntil(
194202
context,
195-
MaterialPageRoute(
196-
builder: (context) => const HomePage(),
197-
),
203+
MaterialPageRoute(builder: (context) {
204+
return const HomePage();
205+
}),
206+
(r) => true,
198207
);
199208
},
200209
child: Text(

mobile/lib/screens/home_page.dart

-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ class _HomePageState extends State<HomePage> {
250250
} else if (user.isAnonymous) {
251251
return;
252252
}
253-
await Future.delayed(const Duration(seconds: 2));
254253
if (mounted) {
255254
await bottomSheetEmailLink(context);
256255
}

mobile/lib/screens/profile/profile_view.dart

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:app/blocs/blocs.dart';
22
import 'package:app/models/models.dart';
3+
import 'package:app/services/firebase_service.dart';
34
import 'package:app/themes/theme.dart';
45
import 'package:app/widgets/widgets.dart';
56
import 'package:flutter/material.dart';
@@ -14,6 +15,16 @@ class ProfileView extends StatelessWidget {
1415

1516
@override
1617
Widget build(BuildContext context) {
18+
final user = CustomAuth.getUser();
19+
bool showLinkAccountReminder = false;
20+
21+
if (user != null && user.phoneNumber != null) {
22+
if (user.email != null) {
23+
} else if (user.isAnonymous) {
24+
} else {
25+
showLinkAccountReminder = true;
26+
}
27+
}
1728
return BlocBuilder<ProfileBloc, Profile>(
1829
builder: (context, profile) {
1930
if (profile.isAnonymous) {
@@ -24,9 +35,15 @@ class ProfileView extends StatelessWidget {
2435
appBar: ProfileViewAppBar(profile),
2536
body: AppSafeArea(
2637
horizontalPadding: 16,
27-
child: Column(
38+
child: ListView(
2839
children: <Widget>[
2940
const SizedBox(height: 10),
41+
//TODO new feature loading
42+
Visibility(
43+
visible: showLinkAccountReminder,
44+
child: const LinkAccountReminder(),
45+
),
46+
const SizedBox(height: 6),
3047
ProfileSection(profile),
3148
const SizedBox(height: 16),
3249
CardSection(
@@ -37,7 +54,7 @@ class ProfileView extends StatelessWidget {
3754
isBottomItem: true,
3855
isTopItem: true,
3956
),
40-
const Spacer(),
57+
const SizedBox(height: 10),
4158
const SignOutButton(),
4259
const SizedBox(height: 10),
4360
],

mobile/lib/screens/profile/profile_widgets.dart

+129
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ import 'dart:io';
33
import 'package:app/blocs/blocs.dart';
44
import 'package:app/constants/constants.dart';
55
import 'package:app/models/models.dart';
6+
import 'package:app/screens/email_link/confirm_account_details.dart';
67
import 'package:app/screens/notification/notification_page.dart';
78
import 'package:app/services/services.dart';
89
import 'package:app/themes/theme.dart';
910
import 'package:app/utils/utils.dart';
1011
import 'package:app/widgets/widgets.dart';
1112
import 'package:auto_size_text/auto_size_text.dart';
1213
import 'package:cached_network_image/cached_network_image.dart';
14+
import 'package:flutter/cupertino.dart';
15+
import 'package:flutter/gestures.dart';
1316
import 'package:flutter/material.dart';
1417
import 'package:flutter/services.dart';
1518
import 'package:flutter_bloc/flutter_bloc.dart';
1619
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
1720
import 'package:flutter_svg/svg.dart';
1821
import 'package:image_picker/image_picker.dart';
22+
import 'package:url_launcher/url_launcher.dart';
1923

2024
import '../favourite_places/favourite_places_page.dart';
2125
import '../feedback/feedback_page.dart';
@@ -1080,3 +1084,128 @@ class GuestProfileView extends StatelessWidget {
10801084
);
10811085
}
10821086
}
1087+
1088+
class LinkAccountReminder extends StatelessWidget {
1089+
const LinkAccountReminder({super.key});
1090+
1091+
@override
1092+
Widget build(BuildContext context) {
1093+
return Card(
1094+
shape: RoundedRectangleBorder(
1095+
borderRadius: BorderRadius.circular(8),
1096+
),
1097+
color: const Color.fromARGB(255, 184, 217, 255),
1098+
elevation: 1,
1099+
child: Padding(
1100+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
1101+
child: SizedBox(
1102+
child: Column(
1103+
crossAxisAlignment: CrossAxisAlignment.start,
1104+
mainAxisAlignment: MainAxisAlignment.center,
1105+
children: [
1106+
Text(
1107+
AppLocalizations.of(context)!.accessDeeperAirQualityInsights,
1108+
style: const TextStyle(
1109+
color: Color.fromARGB(197, 0, 0, 0),
1110+
fontSize: 18,
1111+
fontWeight: FontWeight.w600,
1112+
),
1113+
),
1114+
const SizedBox(height: 4),
1115+
RichText(
1116+
textAlign: TextAlign.start,
1117+
text: TextSpan(
1118+
children: [
1119+
TextSpan(
1120+
text: AppLocalizations.of(context)!
1121+
.addYourEmailToYourProfileToEnableYouToAccessThe,
1122+
style: const TextStyle(
1123+
color: Color(0xFF485972),
1124+
fontSize: 13.24,
1125+
fontWeight: FontWeight.w400,
1126+
),
1127+
),
1128+
TextSpan(
1129+
text: "AirQo analytics ",
1130+
style: TextStyle(
1131+
color: CustomColors.appColorBlue,
1132+
fontSize: 13.24,
1133+
fontWeight: FontWeight.w400,
1134+
decoration: TextDecoration.underline,
1135+
),
1136+
recognizer: TapGestureRecognizer()
1137+
..onTap = () async {
1138+
Uri url = Uri.parse('https://platform.airqo.net');
1139+
if (await canLaunchUrl(url)) {
1140+
await launchUrl(
1141+
url,
1142+
mode: LaunchMode.inAppBrowserView,
1143+
);
1144+
} else {
1145+
throw 'Could not launch $url';
1146+
}
1147+
},
1148+
),
1149+
TextSpan(
1150+
text: AppLocalizations.of(context)!
1151+
.usingYourAirQoMobileAppAccount,
1152+
style: const TextStyle(
1153+
color: Color(0xFF485972),
1154+
fontSize: 13.24,
1155+
fontWeight: FontWeight.w400,
1156+
),
1157+
),
1158+
],
1159+
),
1160+
),
1161+
const SizedBox(height: 8),
1162+
MaterialButton(
1163+
height: 40,
1164+
color: CustomColors.appBodyColor,
1165+
onPressed: () async {
1166+
Navigator.push(context, MaterialPageRoute(
1167+
builder: (context) {
1168+
return const EmailLinkScreen();
1169+
},
1170+
));
1171+
},
1172+
padding: const EdgeInsets.only(top: 8, bottom: 8),
1173+
shape: RoundedRectangleBorder(
1174+
borderRadius: BorderRadius.circular(20),
1175+
),
1176+
child: Row(
1177+
children: [
1178+
Padding(
1179+
padding: const EdgeInsets.only(left: 16, right: 10),
1180+
child: Text(
1181+
AppLocalizations.of(context)!.addMyEmailToMyProfile,
1182+
style: TextStyle(
1183+
color: CustomColors.appColorBlue,
1184+
fontSize: 14,
1185+
fontWeight: FontWeight.w400,
1186+
)),
1187+
),
1188+
const SizedBox(width: 10),
1189+
Container(
1190+
height: 35,
1191+
width: 35,
1192+
decoration: const BoxDecoration(
1193+
color: Color.fromARGB(255, 184, 217, 255),
1194+
shape: BoxShape.circle,
1195+
),
1196+
child: Icon(
1197+
Icons.arrow_forward_ios_rounded,
1198+
size: 18,
1199+
color: CustomColors.appColorBlue,
1200+
),
1201+
),
1202+
],
1203+
),
1204+
),
1205+
],
1206+
),
1207+
),
1208+
),
1209+
);
1210+
}
1211+
}

0 commit comments

Comments
 (0)