Merge remote-tracking branch 'origin/development' into development

development
Sikander Saleem 3 years ago
commit bb9aea99ea

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

@ -37,7 +37,19 @@ APIException _throwAPIException(Response response) {
case 403: case 403:
return APIException(APIException.FORBIDDEN); return APIException(APIException.FORBIDDEN);
case 404: 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: case 500:
return APIException(APIException.INTERNAL_SERVER_ERROR); return APIException(APIException.INTERNAL_SERVER_ERROR);
case 444: case 444:
@ -63,7 +75,7 @@ class ApiClient {
} }
if (!kReleaseMode) { if (!kReleaseMode) {
print("Url:$url"); print("Url:$url");
print("body:$jsonObject"); print("body:${jsonEncode(jsonObject)}");
} }
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes); var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
try { try {

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

@ -27,6 +27,14 @@ class AppState {
this._copyRight = _copyRight; this._copyRight = _copyRight;
} }
ContentInfoDataModel _userCopyRight;
ContentInfoDataModel get getCopyRightContentInfoModel => _userCopyRight;
void setCopyRightContentInfoModel(ContentInfoDataModel _userCopyRight) {
this._userCopyRight = _userCopyRight;
}
AuthenticationUserModel _authenticationUser; AuthenticationUserModel _authenticationUser;
bool get isUserLogin => _authenticationUser != null; 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://20.203.25.82"; // production server
// static String baseUrl = "http://18.221.16.125"; // new 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://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 = baseUrl + "/services/"; // production server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String authentication = baseUrlServices + "api/Authentication/"; static String authentication = baseUrlServices + "api/Authentication/";

@ -12,7 +12,7 @@ class Utils {
static void showToast(String message) { static void showToast(String message) {
Fluttertoast.showToast( 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) { static dynamic getNotNullValue(List<dynamic> list, int index) {
@ -26,7 +26,7 @@ class Utils {
static int stringToHex(String colorCode) { static int stringToHex(String colorCode) {
try { try {
return int.parse(colorCode.replaceAll("#", "0xff")); return int.parse(colorCode.replaceAll("#", "0xff"));
} catch(ex){ } catch (ex) {
return (0xff000000); return (0xff000000);
} }
} }
@ -61,6 +61,8 @@ class Utils {
var message = exception.error?.errorMessage; var message = exception.error?.errorMessage;
if (message == null) { if (message == null) {
message = exception.message; message = exception.message;
} else if (message == '"not authorized"') {
message = "يرجى توثيق حسابك من خلال الرابط الذي تم إرساله إلى بريدك الإلكتروني";
} }
errorMessage = message; errorMessage = message;
} }

@ -10,9 +10,11 @@ import 'package:tangheem/classes/colors.dart';
import 'package:tangheem/classes/consts.dart'; import 'package:tangheem/classes/consts.dart';
import 'package:tangheem/classes/utils.dart'; import 'package:tangheem/classes/utils.dart';
import 'package:tangheem/models/authentication_user_model.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/navigation_model.dart';
import 'package:tangheem/models/quick_links_model.dart'; import 'package:tangheem/models/quick_links_model.dart';
import 'package:tangheem/ui/dialogs/change_password_dialog.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/bookmark_screen.dart';
import 'package:tangheem/ui/screens/content_info_screen.dart'; import 'package:tangheem/ui/screens/content_info_screen.dart';
import 'package:tangheem/ui/screens/home_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>(); final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
List<QuickLinksData> quickLinks = []; List<QuickLinksData> quickLinks = [];
List<NavigationDataModel> navigationList = []; List<NavigationDataModel> navigationList = [];
ContentInfoDataModel _userCopyRight;
@override @override
void initState() { void initState() {
@ -44,24 +47,21 @@ class _CommonAppbarState extends State<CommonAppbar> {
getPrefs(); getPrefs();
getNavigation(); getNavigation();
getQuickLinks(); getQuickLinks();
//getCopyRight(); getCopyRight();
} }
// void getCopyRight() async { void getCopyRight() async {
// if (AppState().getContentInfoModel == null) { if (AppState().getCopyRightContentInfoModel == null) {
// try { try {
// var model = await TangheemUserApiClient().getContentInfo(3); ContentInfoModel _userCopyRight = await TangheemUserApiClient().getContentInfo(3);
// var contentList = model?.data ?? []; this._userCopyRight = _userCopyRight.data.first;
// if (contentList.length > 0) { AppState().setCopyRightContentInfoModel(this._userCopyRight);
// _copyRight = contentList.first; } catch (ex) {}
// AppState().setContentInfoModel(_copyRight); } else {
// } _userCopyRight = AppState().getCopyRightContentInfoModel;
// } catch (ex) {} }
// } else { setState(() {});
// _copyRight = AppState().getContentInfoModel; }
// }
// setState(() {});
// }
void getNavigation() async { void getNavigation() async {
if (AppState().getNavigationModel?.data == null) { if (AppState().getNavigationModel?.data == null) {
@ -176,8 +176,15 @@ class _CommonAppbarState extends State<CommonAppbar> {
} finally { } finally {
Utils.hideLoading(context); 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); Navigator.pop(context);
Utils.showToast("تم تغيير كلمة المرور بنجاح");
} }
Widget drawerView() { Widget drawerView() {
@ -371,18 +378,40 @@ class _CommonAppbarState extends State<CommonAppbar> {
), ),
Padding( Padding(
padding: EdgeInsets.only(left: 32, right: 32, bottom: 8), padding: EdgeInsets.only(left: 32, right: 32, bottom: 8),
child: Row( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( if (_userCopyRight != null) ...[
"Powered by Cloud Solutions", Row(
maxLines: 1, crossAxisAlignment: CrossAxisAlignment.center,
textAlign: TextAlign.right, mainAxisAlignment: MainAxisAlignment.center,
style: TextStyle(fontSize: 14, color: Colors.black87), 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( title: Text(
contentList[index].contentTypeNameAr, contentList[index].contentTypeNameAr,
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue), style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue,fontWeight: FontWeight.w600),
), ),
subtitle: Text( subtitle: Text(
" ${contentList[index].content}", " ${contentList[index].content}",

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

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

@ -8,6 +8,7 @@ import 'package:tangheem/extensions/string_extensions.dart';
import 'package:tangheem/models/country_model.dart'; import 'package:tangheem/models/country_model.dart';
import 'package:tangheem/models/general_response_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/bottom_sheets/country_selection_bottom_sheet.dart';
import 'package:tangheem/ui/dialogs/general_dialog.dart';
import 'package:tangheem/widgets/common_textfield_widget.dart'; import 'package:tangheem/widgets/common_textfield_widget.dart';
class RegistrationScreen extends StatefulWidget { 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 { void registerUser(String _firstName, String _lastName, String _email, String _password, String _countryCode, String _phone) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
GeneralResponseModel model = await UserApiClient().registerUser(_firstName, _lastName, _email, _password, _countryCode, _phone); GeneralResponseModel model = await UserApiClient().registerUser(_firstName, _lastName, _email, _password, _countryCode, _phone);
if(model.message == "UserRegistration Already Exists") { if (model.message == "UserRegistration Already Exists") {
Utils.showToast("البريد الإلكتروني مستخدم سابقا"); Utils.showToast("البريد الإلكتروني مستخدم سابقا");
Utils.hideLoading(context); Utils.hideLoading(context);
return; return;
} }
Utils.showToast("تم إنشاء الحساب بنجاح");
Utils.hideLoading(context); Utils.hideLoading(context);
await showDialog(
context: context,
barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8),
builder: (BuildContext context) => GeneralDialog(message: "تم إنشاء الحساب بنجاح , الرجاء توثيق الحساب من خلال الرابط المرسل إلى بريدك الإلكتروني"),
);
Navigator.pop(context); Navigator.pop(context);
} catch (ex) { } catch (ex) {
if (mounted) Utils.handleException(ex, null); if (mounted) Utils.handleException(ex, null);
@ -162,7 +167,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
SizedBox(width: 8), SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
"أقر بأني إطلعت على شروط الاستخدام و سياسية الخصوصية و أوافق عليها", "أقر بأن جميع البيانات المدخلة أعلاه صحيحة",
style: TextStyle(color: Colors.white, fontSize: 13), style: TextStyle(color: Colors.white, fontSize: 13),
), ),
), ),
@ -174,6 +179,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
height: 50, height: 50,
child: TextButton( child: TextButton(
onPressed: () { onPressed: () {
if (_emailController.text.length < 1) {
Utils.showToast("يرجى إدخال البريد الإلكتروني");
return;
}
if (_firstNameController.text.length < 1) { if (_firstNameController.text.length < 1) {
Utils.showToast("يرجى إدخال الاسم الأول"); Utils.showToast("يرجى إدخال الاسم الأول");
return; return;
@ -182,10 +191,6 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
Utils.showToast("يرجى إدخال الاسم الأخير"); Utils.showToast("يرجى إدخال الاسم الأخير");
return; return;
} }
if (_emailController.text.length < 1) {
Utils.showToast("يرجى إدخال البريد الإلكتروني");
return;
}
if (_selectedCountry?.countryCode == null) { if (_selectedCountry?.countryCode == null) {
Utils.showToast("يرجى اختيار الدولة"); Utils.showToast("يرجى اختيار الدولة");
return; return;
@ -193,6 +198,9 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
if (_mobileNumberController.text.length < 1) { if (_mobileNumberController.text.length < 1) {
Utils.showToast("يرجى إدخال رقم الجوال"); Utils.showToast("يرجى إدخال رقم الجوال");
return; return;
} else if (_mobileNumberController.text.length < 8 || _mobileNumberController.text.length > 12) {
Utils.showToast("رقم الهاتف غير صحيح");
return;
} }
if (_passwordController.text.length < 1) { if (_passwordController.text.length < 1) {
Utils.showToast("يرجى إدخال كلمة المرور"); Utils.showToast("يرجى إدخال كلمة المرور");
@ -221,8 +229,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
_firstNameController.text, _lastNameController.text, _emailController.text, _passwordController.text, _selectedCountry?.countryCode, _mobileNumberController.text); _firstNameController.text, _lastNameController.text, _emailController.text, _passwordController.text, _selectedCountry?.countryCode, _mobileNumberController.text);
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: ColorConsts.secondaryPink, backgroundColor: ColorConsts.secondaryPink,
foregroundColor: Colors.white,
textStyle: TextStyle(fontSize: 16, fontFamily: "DroidKufi"), textStyle: TextStyle(fontSize: 16, fontFamily: "DroidKufi"),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0), borderRadius: BorderRadius.circular(6.0),

@ -524,7 +524,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: ColorConsts.gradientOrange, backgroundColor: ColorConsts.gradientOrange,
primary: ColorConsts.primaryBlue, foregroundColor: ColorConsts.primaryBlue,
padding: EdgeInsets.only(top: 4, bottom: 4, right: 8, left: 8), padding: EdgeInsets.only(top: 4, bottom: 4, right: 8, left: 8),
textStyle: TextStyle(color: Colors.white, fontSize: 12), textStyle: TextStyle(color: Colors.white, fontSize: 12),
), ),
@ -843,7 +843,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
borderRadius: BorderRadius.circular(30), borderRadius: BorderRadius.circular(30),
onTap: () async { onTap: () async {
if (!AppState().isUserLogin) { if (!AppState().isUserLogin) {
Widget cancelButton = FlatButton( Widget cancelButton = TextButton(style: TextButton.styleFrom(backgroundColor: ColorConsts.sliderBackground,foregroundColor: ColorConsts.primaryBlack),
child: Text("أرغب بالتسجيل"), child: Text("أرغب بالتسجيل"),
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(context);
@ -853,22 +853,21 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
} }
}, },
); );
Widget continueButton = FlatButton( Widget continueButton = TextButton(style: TextButton.styleFrom(backgroundColor: ColorConsts.sliderBackground,foregroundColor: ColorConsts.primaryBlack),
child: Text("استمرار كضيف"), child: Text("استمرار كضيف"),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
return; return;
}, },
); );
AlertDialog alert = AlertDialog( AlertDialog alert = AlertDialog(
content: Text("هذه الخاصية متاحه فقط للأعضاء المسجلين"), content: Text("هذه الخاصية متاحه فقط للأعضاء المسجلين"),
actionsAlignment:MainAxisAlignment.spaceEvenly,
actions: [ actions: [
cancelButton, cancelButton,
continueButton, continueButton,
], ],
); );
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {

Loading…
Cancel
Save