diff --git a/android/gradle.properties b/android/gradle.properties index a673820..f233e28 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true android.enableR8=true +android.jetifier.blacklist=bcprov-jdk15on \ No newline at end of file diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index 89817ad..a2d9f7d 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -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 { diff --git a/lib/api/user_api_client.dart b/lib/api/user_api_client.dart index 696ba30..4d56b4a 100644 --- a/lib/api/user_api_client.dart +++ b/lib/api/user_api_client.dart @@ -29,7 +29,7 @@ class UserApiClient { "lastName": _lastName, "countryCode": _countryCode, "mobileNumber": _phone, - "isUserLock": false, + "isUserLock": true, "gender": 0, "passWrongAttempt": 0, "statusId": 0, diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 99744ab..8b24e02 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -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; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index a42d180..b384e4e 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -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/"; diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index df4c7bd..751ef18 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -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 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; } diff --git a/lib/ui/common_appbar.dart b/lib/ui/common_appbar.dart index 213a420..373f905 100644 --- a/lib/ui/common_appbar.dart +++ b/lib/ui/common_appbar.dart @@ -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 { final GlobalKey _scaffoldKey = new GlobalKey(); List quickLinks = []; List navigationList = []; + ContentInfoDataModel _userCopyRight; @override void initState() { @@ -44,24 +47,21 @@ class _CommonAppbarState extends State { 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 { } 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 { ), 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) ], ), ) diff --git a/lib/ui/screens/content_info_screen.dart b/lib/ui/screens/content_info_screen.dart index 4837804..565db17 100644 --- a/lib/ui/screens/content_info_screen.dart +++ b/lib/ui/screens/content_info_screen.dart @@ -84,7 +84,7 @@ class _ContentInfoScreenState extends State { ), 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}", diff --git a/lib/ui/screens/login_screen.dart b/lib/ui/screens/login_screen.dart index f29686c..85a2bf3 100644 --- a/lib/ui/screens/login_screen.dart +++ b/lib/ui/screens/login_screen.dart @@ -59,6 +59,7 @@ class _LoginScreenState extends State { 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); diff --git a/lib/ui/screens/member_screen.dart b/lib/ui/screens/member_screen.dart index 5156030..d6e254d 100644 --- a/lib/ui/screens/member_screen.dart +++ b/lib/ui/screens/member_screen.dart @@ -47,62 +47,73 @@ class _MemberScreenState extends State { ? 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, + ); + }, + ), + ], ); } } diff --git a/lib/ui/screens/registration_screen.dart b/lib/ui/screens/registration_screen.dart index 05b1d0c..1b16805 100644 --- a/lib/ui/screens/registration_screen.dart +++ b/lib/ui/screens/registration_screen.dart @@ -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 { 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);