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

development
Sikander Saleem 3 years ago
commit 17633a1d48

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -1,5 +1,5 @@
sdk.dir=C:\\Users\\sikander.saleem\\Documents\\Sdks\\android
flutter.sdk=C:\\Users\\sikander.saleem\\Documents\\Sdks\\flutter
flutter.buildMode=release
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1

@ -39,7 +39,7 @@ APIException _throwAPIException(Response response) {
case 404:
APIError apiError;
if (response.body != null && response.body.isNotEmpty) {
// var jsonError = jsonDecode(response.body);
// var jsonError = jsonDecode(response.body);
apiError = APIError(404, response.body.toString());
}
return APIException(APIException.BAD_REQUEST, error: apiError);
@ -68,7 +68,7 @@ class ApiClient {
factory ApiClient() => _instance;
Future<U> postJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url, T jsonObject,
{String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0}) async {
{String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0, bool isPutRequest = false}) async {
var _headers = {'Accept': 'application/json'};
if (headers != null && headers.isNotEmpty) {
_headers.addAll(headers);
@ -77,7 +77,11 @@ class ApiClient {
print("Url:$url");
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,
isPutRequest: isPutRequest);
try {
var jsonData = jsonDecode(response.body);
return factoryConstructor(jsonData);
@ -86,7 +90,8 @@ class ApiClient {
}
}
Future<Response> postJsonForResponse<T>(String url, T jsonObject, {String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0}) async {
Future<Response> postJsonForResponse<T>(String url, T jsonObject,
{String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0, bool isPutRequest = false}) async {
String requestBody;
if (jsonObject != null) {
requestBody = jsonEncode(jsonObject);
@ -97,10 +102,14 @@ class ApiClient {
}
}
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes);
return await _postForResponse(url, requestBody, token: token,
queryParameters: queryParameters,
headers: headers,
retryTimes: retryTimes,
isPutRequest: isPutRequest);
}
Future<Response> _postForResponse(String url, requestBody, {String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0}) async {
Future<Response> _postForResponse(String url, requestBody, {String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0, bool isPutRequest = false}) async {
try {
var _headers = <String, String>{};
if (token != null) {
@ -115,7 +124,7 @@ class ApiClient {
var queryString = new Uri(queryParameters: queryParameters).query;
url = url + '?' + queryString;
}
var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(minutes: 2));
var response = await _post(Uri.parse(url), body: requestBody, headers: _headers, isPutRequest: isPutRequest).timeout(Duration(minutes: 2));
if (response.statusCode >= 200 && response.statusCode < 300) {
return response;
@ -126,7 +135,11 @@ class ApiClient {
if (retryTimes > 0) {
print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
return await _postForResponse(url, requestBody, token: token,
queryParameters: queryParameters,
headers: headers,
retryTimes: retryTimes - 1,
isPutRequest: isPutRequest);
} else {
throw APIException(APIException.OTHER, arguments: e);
}
@ -134,7 +147,11 @@ class ApiClient {
if (retryTimes > 0) {
print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
return await _postForResponse(url, requestBody, token: token,
queryParameters: queryParameters,
headers: headers,
retryTimes: retryTimes - 1,
isPutRequest: isPutRequest);
} else {
throw APIException(APIException.OTHER, arguments: e);
}
@ -144,7 +161,11 @@ class ApiClient {
if (retryTimes > 0) {
print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
return await _postForResponse(url, requestBody, token: token,
queryParameters: queryParameters,
headers: headers,
retryTimes: retryTimes - 1,
isPutRequest: isPutRequest);
} else {
throw APIException(APIException.OTHER, arguments: e);
}
@ -154,7 +175,8 @@ class ApiClient {
bool _certificateCheck(X509Certificate cert, String host, int port) => true;
Future<T> _withClient<T>(Future<T> Function(Client) fn) async {
var httpClient = HttpClient()..badCertificateCallback = _certificateCheck;
var httpClient = HttpClient()
..badCertificateCallback = _certificateCheck;
var client = IOClient(httpClient);
try {
return await fn(client);
@ -163,5 +185,12 @@ class ApiClient {
}
}
Future<Response> _post(url, {Map<String, String> headers, body, Encoding encoding}) => _withClient((client) => client.post(url, headers: headers, body: body, encoding: encoding));
Future<Response> _post(url, {Map<String, String> headers, body, Encoding encoding, bool isPutRequest = false}) =>
_withClient((client) {
if (isPutRequest) {
return client.put(url, headers: headers, body: body, encoding: encoding);
} else {
return client.post(url, headers: headers, body: body, encoding: encoding);
}
});
}

@ -46,6 +46,12 @@ class UserApiClient {
return await ApiClient().postJsonForObject((json) => GeneralResponseModel.fromJson(json), url, postParams);
}
Future<GeneralResponseModel> deleteAccount(String userId) async {
String url = "${ApiConsts.user}UserRegistration_Delete";
var postParams = {"userId": userId};
return await ApiClient().postJsonForObject((json) => GeneralResponseModel.fromJson(json), url, postParams, isPutRequest: true);
}
Future<GeneralResponseModel> verifyOTP(String _email, int _otp) async {
String url = "${ApiConsts.user}OTPVerification";
var postParams = {"email": _email, "opt": _otp};

@ -41,6 +41,8 @@ class AppState {
String get token => _authenticationUser?.result?.data?.token;
String get userId => _authenticationUser?.result?.data?.userId;
String get userEmail => _authenticationUser?.result?.data?.email;
void setAuthenticationModel(AuthenticationUserModel _authenticationUser) {

@ -68,6 +68,7 @@ class _CommonAppbarState extends State<CommonAppbar> {
try {
var model = await TangheemUserApiClient().getNavigation();
navigationList = model?.data ?? [];
navigationList.removeWhere((element) => element.navigationId == 9); // this is for temporary, to release app on app store as file size are about 100 mbs
navigationList.sort((a, b) => a.orderNo.compareTo(b.orderNo));
AppState().setNavigationModel(model);
} catch (ex) {}
@ -101,6 +102,24 @@ class _CommonAppbarState extends State<CommonAppbar> {
}
}
void deleteUserAccount() async {
Utils.showLoading(context);
try {
await UserApiClient().deleteAccount(AppState().userId);
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.remove(GlobalConsts.userAuthData);
AppState().setAuthenticationModel(null);
Utils.showToast("تم حذف الحساب");
Navigator.pop(context);
Utils.hideLoading(context);
} catch (ex) {
if (mounted) {
Utils.hideLoading(context);
Utils.handleException(ex, null);
}
}
}
@override
void dispose() {
super.dispose();
@ -324,35 +343,59 @@ class _CommonAppbarState extends State<CommonAppbar> {
),
);
});
} else {
} else if (index == 1) {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.remove(GlobalConsts.userAuthData);
AppState().setAuthenticationModel(null);
Utils.showToast("تسجيل خروج المستخدم");
Navigator.pop(context);
} else {
await showDialog(
context: context,
barrierColor: ColorConsts.secondaryWhite.withOpacity(0.8),
builder: (BuildContext context) => GeneralDialog(
message: 'بحذف حسابك ، ستتم إزالة بياناتك ولن تتمكن من استرداد حسابك. \ n انقر فوق "نعم" لحذف حسابك.',
onTap: () {
Navigator.pop(context);
deleteUserAccount();
},
showCancelButton: true,
),
);
}
},
icon: SvgPicture.asset("assets/icons/fa_key.svg", height: 25, width: 30, color: ColorConsts.textGrey1),
itemBuilder: (_) => <PopupMenuItem<int>>[
PopupMenuItem(
value: 0,
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 24,
padding: EdgeInsets.fromLTRB(4, 0, 4, 0),
height: 36,
child: Center(
child: Text(
'تغيير كلمة المرور',
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 14),
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 16),
),
),
),
PopupMenuItem(
value: 1,
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 24,
padding: EdgeInsets.fromLTRB(4, 0, 4, 0),
height: 36,
child: Center(
child: Text(
'تسجيل خروج',
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 14),
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 16),
),
),
),
PopupMenuItem(
value: 2,
padding: EdgeInsets.fromLTRB(4, 0, 4, 0),
height: 36,
child: Center(
child: Text(
'حذف الحساب',
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 16),
),
),
),

@ -3,7 +3,10 @@ import 'package:tangheem/classes/colors.dart';
class GeneralDialog extends StatelessWidget {
final String message;
GeneralDialog({Key key, this.message}) : super(key: key);
final VoidCallback onTap;
final bool showCancelButton;
GeneralDialog({Key key, this.message, this.onTap, this.showCancelButton = false}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -30,22 +33,49 @@ class GeneralDialog extends StatelessWidget {
style: TextStyle(color: Colors.white),
),
SizedBox(height: 32),
SizedBox(
width: double.infinity,
height: 40,
child: TextButton(
onPressed: () => Navigator.pop(context),
style: TextButton.styleFrom(
primary: Colors.white,
padding: EdgeInsets.all(2),
backgroundColor: ColorConsts.secondaryPink,
textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
Row(
children: [
if (showCancelButton)
Expanded(
child: SizedBox(
width: double.infinity,
height: 40,
child: TextButton(
onPressed: () => Navigator.pop(context),
style: TextButton.styleFrom(
primary: Colors.black87,
padding: EdgeInsets.all(2),
backgroundColor: ColorConsts.textHintGrey,
textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
child: Text("لا"),
),
),
),
if (showCancelButton) SizedBox(width: 16),
Expanded(
child: SizedBox(
width: double.infinity,
height: 40,
child: TextButton(
onPressed: onTap ?? () => Navigator.pop(context),
style: TextButton.styleFrom(
primary: Colors.white,
padding: EdgeInsets.all(2),
backgroundColor: ColorConsts.secondaryPink,
textStyle: TextStyle(fontSize: 14, fontFamily: "DroidKufi"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
child: Text("نعم"),
),
),
),
child: Text("نعم"),
),
],
),
],
),

@ -52,7 +52,7 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
return Scaffold(
backgroundColor: ColorConsts.secondaryWhite,
body: SingleChildScrollView(
padding: EdgeInsets.all(32.0),
padding: EdgeInsets.all(21.0),
physics: BouncingScrollPhysics(),
child: Container(
width: MediaQuery.of(context).size.width,

@ -81,7 +81,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
return Scaffold(
backgroundColor: ColorConsts.secondaryWhite,
body: SingleChildScrollView(
padding: EdgeInsets.all(32.0),
padding: EdgeInsets.all(21.0),
physics: BouncingScrollPhysics(),
child: Container(
width: MediaQuery.of(context).size.width,

@ -119,7 +119,7 @@ class _HomeScreenState extends State<HomeScreen> {
void showWelcomeVideoDialog() async {
prefs = await SharedPreferences.getInstance();
String permLink = "aAmP-WcI6dg";
String permLink = "-PqP0BCiTlE";
String link = prefs.getString(GlobalConsts.welcomeVideoUrl) ?? permLink;
if (permLink == link) {
await prefs.setString(GlobalConsts.welcomeVideoUrl, permLink);

@ -87,7 +87,7 @@ class _LoginScreenState extends State<LoginScreen> {
child: Directionality(
textDirection: TextDirection.rtl,
child: SingleChildScrollView(
padding: EdgeInsets.all(32.0),
padding: EdgeInsets.all(21.0),
physics: BouncingScrollPhysics(),
child: Container(
width: MediaQuery.of(context).size.width,

@ -88,7 +88,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
return Scaffold(
backgroundColor: ColorConsts.secondaryWhite,
body: SingleChildScrollView(
padding: EdgeInsets.all(32.0),
padding: EdgeInsets.all(21.0),
physics: BouncingScrollPhysics(),
child: Container(
width: MediaQuery.of(context).size.width,
@ -143,7 +143,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
),
SizedBox(height: 8),
CommonTextFieldWidget(
hint: " رقم الجوال${" (" + (_selectedCountry?.countryCode ?? "+9xx") + " xxxxxxxxx)"}",
hint: " رقم الجوال (اختياري)${" (" + (_selectedCountry?.countryCode ?? "+9xx") + " xxxxxxxxx)"}",
controller: _mobileNumberController,
suffixWidget: Text(_selectedCountry?.countryCode ?? "", textDirection: TextDirection.ltr),
),
@ -195,10 +195,12 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
Utils.showToast("يرجى اختيار الدولة");
return;
}
if (_mobileNumberController.text.length < 1) {
Utils.showToast("يرجى إدخال رقم الجوال");
return;
} else if (_mobileNumberController.text.length < 8 || _mobileNumberController.text.length > 12) {
// if (_mobileNumberController.text.length < 1) {
// Utils.showToast("يرجى إدخال رقم الجوال");
// return;
// } else
if (_mobileNumberController.text.isNotEmpty && (_mobileNumberController.text.length < 8 || _mobileNumberController.text.length > 12)) {
Utils.showToast("رقم الهاتف غير صحيح");
return;
}

Loading…
Cancel
Save