email verification process improvement.

development
Sikander Saleem 3 years ago
parent 0ac7a0f2f1
commit 40037e0c7e

@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
android.jetifier.blacklist=bcprov-jdk15on

@ -37,7 +37,19 @@ APIException _throwAPIException(Response response) {
case 403:
return APIException(APIException.FORBIDDEN);
case 404:
return APIException(APIException.NOT_FOUND);
APIError apiError;
if (response.body != null && response.body.isNotEmpty) {
// var jsonError = jsonDecode(response.body);
apiError = APIError(404, response.body.toString());
}
return APIException(APIException.BAD_REQUEST, error: apiError);
case 409:
APIError apiError;
if (response.body != null && response.body.isNotEmpty) {
var jsonError = jsonDecode(response.body);
apiError = APIError(409, jsonError['statusMessage']);
}
return APIException(APIException.BAD_REQUEST, error: apiError);
case 500:
return APIException(APIException.INTERNAL_SERVER_ERROR);
case 444:
@ -63,7 +75,7 @@ class ApiClient {
}
if (!kReleaseMode) {
print("Url:$url");
print("body:$jsonObject");
print("body:${jsonEncode(jsonObject)}");
}
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
try {

@ -29,7 +29,7 @@ class UserApiClient {
"lastName": _lastName,
"countryCode": _countryCode,
"mobileNumber": _phone,
"isUserLock": false,
"isUserLock": true,
"gender": 0,
"passWrongAttempt": 0,
"statusId": 0,

@ -27,6 +27,14 @@ class AppState {
this._copyRight = _copyRight;
}
ContentInfoDataModel _userCopyRight;
ContentInfoDataModel get getCopyRightContentInfoModel => _userCopyRight;
void setCopyRightContentInfoModel(ContentInfoDataModel _userCopyRight) {
this._userCopyRight = _userCopyRight;
}
AuthenticationUserModel _authenticationUser;
bool get isUserLogin => _authenticationUser != null;

@ -3,6 +3,7 @@ class ApiConsts {
// static String baseUrl = "http://20.203.25.82"; // production server
// static String baseUrl = "http://18.221.16.125"; // new production server
static String baseUrl = "https://www.tangheemalquran.com"; // new production server Words
// static String baseUrl = "https://api.cssynapses.com"; // synapsis server Words
static String baseUrlServices = baseUrl + "/services/"; // production server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String authentication = baseUrlServices + "api/Authentication/";

@ -12,7 +12,7 @@ class Utils {
static void showToast(String message) {
Fluttertoast.showToast(
msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
msg: message, toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
}
static dynamic getNotNullValue(List<dynamic> list, int index) {
@ -26,7 +26,7 @@ class Utils {
static int stringToHex(String colorCode) {
try {
return int.parse(colorCode.replaceAll("#", "0xff"));
} catch(ex){
} catch (ex) {
return (0xff000000);
}
}
@ -61,6 +61,8 @@ class Utils {
var message = exception.error?.errorMessage;
if (message == null) {
message = exception.message;
} else if (message == '"not authorized"') {
message = "يرجى توثيق حسابك من خلال الرابط الذي تم إرساله إلى بريدك الإلكتروني";
}
errorMessage = message;
}

@ -10,9 +10,11 @@ import 'package:tangheem/classes/colors.dart';
import 'package:tangheem/classes/consts.dart';
import 'package:tangheem/classes/utils.dart';
import 'package:tangheem/models/authentication_user_model.dart';
import 'package:tangheem/models/content_info_model.dart';
import 'package:tangheem/models/navigation_model.dart';
import 'package:tangheem/models/quick_links_model.dart';
import 'package:tangheem/ui/dialogs/change_password_dialog.dart';
import 'package:tangheem/ui/dialogs/general_dialog.dart';
import 'package:tangheem/ui/screens/bookmark_screen.dart';
import 'package:tangheem/ui/screens/content_info_screen.dart';
import 'package:tangheem/ui/screens/home_screen.dart';
@ -37,6 +39,7 @@ class _CommonAppbarState extends State<CommonAppbar> {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
List<QuickLinksData> quickLinks = [];
List<NavigationDataModel> navigationList = [];
ContentInfoDataModel _userCopyRight;
@override
void initState() {
@ -44,24 +47,21 @@ class _CommonAppbarState extends State<CommonAppbar> {
getPrefs();
getNavigation();
getQuickLinks();
//getCopyRight();
getCopyRight();
}
// void getCopyRight() async {
// if (AppState().getContentInfoModel == null) {
// try {
// var model = await TangheemUserApiClient().getContentInfo(3);
// var contentList = model?.data ?? [];
// if (contentList.length > 0) {
// _copyRight = contentList.first;
// AppState().setContentInfoModel(_copyRight);
// }
// } catch (ex) {}
// } else {
// _copyRight = AppState().getContentInfoModel;
// }
// setState(() {});
// }
void getCopyRight() async {
if (AppState().getCopyRightContentInfoModel == null) {
try {
ContentInfoModel _userCopyRight = await TangheemUserApiClient().getContentInfo(3);
this._userCopyRight = _userCopyRight.data.first;
AppState().setCopyRightContentInfoModel(this._userCopyRight);
} catch (ex) {}
} else {
_userCopyRight = AppState().getCopyRightContentInfoModel;
}
setState(() {});
}
void getNavigation() async {
if (AppState().getNavigationModel?.data == null) {
@ -176,8 +176,15 @@ class _CommonAppbarState extends State<CommonAppbar> {
} finally {
Utils.hideLoading(context);
}
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.remove(GlobalConsts.userAuthData);
AppState().setAuthenticationModel(null);
await showDialog(
context: context,
barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8),
builder: (BuildContext context) => GeneralDialog(message: "تم تغيير كلمة المرور بنجاح , الرجاء إعادة تسجيل الدخول من خلال الرابط المرسل إلى بريدك الإلكتروني"),
);
Navigator.pop(context);
Utils.showToast("تم تغيير كلمة المرور بنجاح");
}
Widget drawerView() {
@ -371,18 +378,40 @@ class _CommonAppbarState extends State<CommonAppbar> {
),
Padding(
padding: EdgeInsets.only(left: 32, right: 32, bottom: 8),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Powered by Cloud Solutions",
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(fontSize: 14, color: Colors.black87),
if (_userCopyRight != null) ...[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_userCopyRight.content,
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(fontSize: 14, color: Colors.black87),
),
SizedBox(width: 8),
Image.network(ApiConsts.baseUrl + _userCopyRight.exposeFilePath, height: 25, width: 30)
],
),
SizedBox(height: 8),
],
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Powered by Cloud Solutions",
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(fontSize: 14, color: Colors.black87),
),
SizedBox(width: 8),
SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30)
],
),
SizedBox(width: 8),
SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30)
],
),
)

@ -84,7 +84,7 @@ class _ContentInfoScreenState extends State<ContentInfoScreen> {
),
title: Text(
contentList[index].contentTypeNameAr,
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue),
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue,fontWeight: FontWeight.w600),
),
subtitle: Text(
" ${contentList[index].content}",

@ -59,6 +59,7 @@ class _LoginScreenState extends State<LoginScreen> {
Utils.showLoading(context);
try {
_authenticationUser = await AuthenticationApiClient().authenticateUser(_email, _password);
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString(GlobalConsts.userAuthData, jsonEncode(_authenticationUser.toJson()));
AppState().setAuthenticationModel(_authenticationUser);

@ -47,62 +47,73 @@ class _MemberScreenState extends State<MemberScreen> {
? SizedBox()
: membersList.isEmpty
? NoDataUI()
: ListView.separated(
: ListView(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(16),
itemCount: membersList.length,
separatorBuilder: (context, index) {
return SizedBox(height: 8);
},
itemBuilder: (context, index) {
String encodedImage = membersList.elementAt(index).picture;
if (encodedImage.contains("data:image/png;base64,")) {
encodedImage = encodedImage.replaceAll("data:image/png;base64,", "");
}
if (encodedImage.contains("data:image/jpeg;base64,")) {
encodedImage = encodedImage.replaceAll("data:image/jpeg;base64,", "");
}
var temp = base64Decode(encodedImage);
children: [
Text(
"أعضاء اللجنة الإشرافية",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1.5),
),
SizedBox(height: 12),
ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: membersList.length,
separatorBuilder: (context, index) {
return SizedBox(height: 8);
},
itemBuilder: (context, index) {
String encodedImage = membersList.elementAt(index).picture;
if (encodedImage.contains("data:image/png;base64,")) {
encodedImage = encodedImage.replaceAll("data:image/png;base64,", "");
}
if (encodedImage.contains("data:image/jpeg;base64,")) {
encodedImage = encodedImage.replaceAll("data:image/jpeg;base64,", "");
}
var temp = base64Decode(encodedImage);
return ListTile(
tileColor: Colors.white,
leading: Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
image: membersList.length < 1
? null
: DecorationImage(
fit: BoxFit.cover,
image: MemoryImage(temp),
),
borderRadius: BorderRadius.all(
Radius.circular(30.0),
return ListTile(
tileColor: Colors.white,
leading: Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
image: membersList.length < 1
? null
: DecorationImage(
fit: BoxFit.cover,
image: MemoryImage(temp),
),
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
),
child: membersList.length < 1
? ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
child: SvgPicture.asset(
"assets/icons/chat_user.svg",
clipBehavior: Clip.antiAlias,
),
)
: null,
),
),
child: membersList.length < 1
? ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
child: SvgPicture.asset(
"assets/icons/chat_user.svg",
clipBehavior: Clip.antiAlias,
),
)
: null,
),
title: Text(
membersList[index].firstName + " " + membersList[index].lastName,
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue),
),
subtitle: Text(
" ${membersList[index].description.trim()}",
style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue),
),
isThreeLine: true,
);
},
title: Text(
membersList[index].firstName + " " + membersList[index].lastName,
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue, fontWeight: FontWeight.w600),
),
subtitle: Text(
" ${membersList[index].description.trim()}",
style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue),
),
isThreeLine: true,
);
},
),
],
);
}
}

@ -8,6 +8,7 @@ import 'package:tangheem/extensions/string_extensions.dart';
import 'package:tangheem/models/country_model.dart';
import 'package:tangheem/models/general_response_model.dart';
import 'package:tangheem/ui/bottom_sheets/country_selection_bottom_sheet.dart';
import 'package:tangheem/ui/dialogs/general_dialog.dart';
import 'package:tangheem/widgets/common_textfield_widget.dart';
class RegistrationScreen extends StatefulWidget {
@ -58,14 +59,18 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
void registerUser(String _firstName, String _lastName, String _email, String _password, String _countryCode, String _phone) async {
Utils.showLoading(context);
try {
GeneralResponseModel model = await UserApiClient().registerUser(_firstName, _lastName, _email, _password, _countryCode, _phone);
if(model.message == "UserRegistration Already Exists") {
GeneralResponseModel model = await UserApiClient().registerUser(_firstName, _lastName, _email, _password, _countryCode, _phone);
if (model.message == "UserRegistration Already Exists") {
Utils.showToast("البريد الإلكتروني مستخدم سابقا");
Utils.hideLoading(context);
return;
}
Utils.showToast("تم إنشاء الحساب بنجاح");
Utils.hideLoading(context);
await showDialog(
context: context,
barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8),
builder: (BuildContext context) => GeneralDialog(message: "تم إنشاء الحساب بنجاح , الرجاء توثيق الحساب من خلال الرابط المرسل إلى بريدك الإلكتروني"),
);
Navigator.pop(context);
} catch (ex) {
if (mounted) Utils.handleException(ex, null);

Loading…
Cancel
Save