api methods added,
parent
43a44cba93
commit
aac94f590f
@ -0,0 +1,150 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:http/io_client.dart';
|
||||||
|
import 'package:tangheem/exceptions/api_exception.dart';
|
||||||
|
|
||||||
|
typedef FactoryConstructor<U> = U Function(dynamic);
|
||||||
|
|
||||||
|
class APIError {
|
||||||
|
int errorCode;
|
||||||
|
String errorMessage;
|
||||||
|
|
||||||
|
APIError(this.errorCode, this.errorMessage);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {'errorCode': errorCode, 'errorMessage': errorMessage};
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return jsonEncode(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
APIException _throwAPIException(Response response) {
|
||||||
|
switch (response.statusCode) {
|
||||||
|
case 400:
|
||||||
|
APIError apiError;
|
||||||
|
if (response.body != null && response.body.isNotEmpty) {
|
||||||
|
var jsonError = jsonDecode(response.body);
|
||||||
|
apiError = APIError(jsonError['errorCode'], jsonError['errorMessage']);
|
||||||
|
}
|
||||||
|
return APIException(APIException.BAD_REQUEST, error: apiError);
|
||||||
|
case 401:
|
||||||
|
return APIException(APIException.UNAUTHORIZED);
|
||||||
|
case 403:
|
||||||
|
return APIException(APIException.FORBIDDEN);
|
||||||
|
case 404:
|
||||||
|
return APIException(APIException.NOT_FOUND);
|
||||||
|
case 500:
|
||||||
|
return APIException(APIException.INTERNAL_SERVER_ERROR);
|
||||||
|
case 444:
|
||||||
|
var downloadUrl = response.headers["location"];
|
||||||
|
return APIException(APIException.UPGRADE_REQUIRED, arguments: downloadUrl);
|
||||||
|
default:
|
||||||
|
return APIException(APIException.OTHER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ApiClient {
|
||||||
|
static final ApiClient _instance = ApiClient._internal();
|
||||||
|
ApiClient._internal();
|
||||||
|
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 {
|
||||||
|
var _headers = {'Accept': 'application/json'};
|
||||||
|
if (headers != null && headers.isNotEmpty) {
|
||||||
|
_headers.addAll(headers);
|
||||||
|
}
|
||||||
|
print("Url:$url");
|
||||||
|
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
|
||||||
|
try {
|
||||||
|
var jsonData = jsonDecode(response.body);
|
||||||
|
return factoryConstructor(jsonData);
|
||||||
|
} catch (ex, tr) {
|
||||||
|
print('${ex.runtimeType}\n$ex\n$tr');
|
||||||
|
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Response> postJsonForResponse<T>(String url, T jsonObject, {String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0}) async {
|
||||||
|
String requestBody;
|
||||||
|
if (jsonObject != null) {
|
||||||
|
requestBody = jsonEncode(jsonObject);
|
||||||
|
if (headers == null) {
|
||||||
|
headers = {'Content-Type': 'application/json'};
|
||||||
|
} else {
|
||||||
|
headers['Content-Type'] = 'application/json';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Response> _postForResponse(String url, requestBody, {String token, Map<String, dynamic> queryParameters, Map<String, String> headers, int retryTimes = 0}) async {
|
||||||
|
try {
|
||||||
|
var _headers = <String, String>{};
|
||||||
|
if (token != null) {
|
||||||
|
_headers['Authorization'] = 'Bearer $token';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (headers != null && headers.isNotEmpty) {
|
||||||
|
_headers.addAll(headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queryParameters != null) {
|
||||||
|
var queryString = new Uri(queryParameters: queryParameters).query;
|
||||||
|
url = url + '?' + queryString;
|
||||||
|
}
|
||||||
|
var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 12));
|
||||||
|
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
return response;
|
||||||
|
} else {
|
||||||
|
throw _throwAPIException(response);
|
||||||
|
}
|
||||||
|
} on SocketException catch (e) {
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
throw APIException(APIException.OTHER, arguments: e);
|
||||||
|
}
|
||||||
|
} on HttpException catch (e) {
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
throw APIException(APIException.OTHER, arguments: e);
|
||||||
|
}
|
||||||
|
} on TimeoutException catch (e) {
|
||||||
|
throw APIException(APIException.TIMEOUT, arguments: e);
|
||||||
|
} on ClientException catch (e) {
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
throw APIException(APIException.OTHER, arguments: e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 client = IOClient(httpClient);
|
||||||
|
try {
|
||||||
|
return await fn(client);
|
||||||
|
} finally {
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Response> _post(url, {Map<String, String> headers, body, Encoding encoding}) => _withClient((client) => client.post(url, headers: headers, body: body, encoding: encoding));
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class AuthenticationApiClient{
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:tangheem/api/api_client.dart';
|
||||||
|
import 'package:tangheem/classes/consts.dart';
|
||||||
|
import 'package:tangheem/models/aya_model.dart';
|
||||||
|
import 'package:tangheem/models/surah_model.dart';
|
||||||
|
|
||||||
|
class TangheemUserApiClient {
|
||||||
|
static final TangheemUserApiClient _instance = TangheemUserApiClient._internal();
|
||||||
|
TangheemUserApiClient._internal();
|
||||||
|
factory TangheemUserApiClient() => _instance;
|
||||||
|
|
||||||
|
Future<SurahModel> getSurahs() async {
|
||||||
|
String url = "${ApiConsts.tangheemUsers}AlSuar_Get";
|
||||||
|
var postParams = {};
|
||||||
|
return await ApiClient().postJsonForObject((json) => SurahModel.fromJson(json), url, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<AyaModel> getAyaByRange(int itemsPerPage, int currentPageNo, int surahID, int ayahFrom, int ayahTo) async {
|
||||||
|
String url = "${ApiConsts.tangheemUsers}AyatByRange_Get";
|
||||||
|
var postParams = {"itemsPerPage": itemsPerPage, "currentPageNo": currentPageNo, "sortFieldName": "string", "isSortAsc": true, "surahID": surahID, "ayahFrom": ayahFrom, "ayahTo": ayahTo};
|
||||||
|
return await ApiClient().postJsonForObject((json) => AyaModel.fromJson(json), url, postParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
class UserApiClient {}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
class Const {
|
class ColorConsts {
|
||||||
static Color primaryBlack = Color(0xff1C2238);
|
static Color primaryBlack = Color(0xff1C2238);
|
||||||
static Color primaryBlue = Color(0xff374061);
|
static Color primaryBlue = Color(0xff374061);
|
||||||
|
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
class ApiConsts {
|
||||||
|
static String baseUrl = "http://10.200.204.20:2801/"; // Local server
|
||||||
|
static String authentication = baseUrl + "api/Authentication/";
|
||||||
|
static String tangheemUsers = baseUrl + "api/TangheemUsers/";
|
||||||
|
static String user = baseUrl + "api/User/";
|
||||||
|
}
|
||||||
@ -1,9 +1,56 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:tangheem/exceptions/api_exception.dart';
|
||||||
|
import 'package:tangheem/ui/dialogs/loading_dialog.dart';
|
||||||
|
import 'colors.dart';
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
|
static bool _isLoadingVisible = false;
|
||||||
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_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void showLoading(BuildContext context) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_isLoadingVisible = true;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierColor: ColorConsts.primaryBlack.withOpacity(0.5),
|
||||||
|
builder: (BuildContext context) => LoadingDialog(),
|
||||||
|
).then((value) {
|
||||||
|
_isLoadingVisible = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hideLoading(BuildContext context) {
|
||||||
|
if (_isLoadingVisible) {
|
||||||
|
_isLoadingVisible = false;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
_isLoadingVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleException(dynamic exception, Function(String) onErrorMessage) {
|
||||||
|
String errorMessage;
|
||||||
|
if (exception is APIException) {
|
||||||
|
if (exception.message == APIException.UNAUTHORIZED) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
var message = exception.error?.errorMessage;
|
||||||
|
if (message == null) {
|
||||||
|
message = exception.message;
|
||||||
|
}
|
||||||
|
errorMessage = message;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorMessage = APIException.UNKNOWN;
|
||||||
|
}
|
||||||
|
if (onErrorMessage != null) {
|
||||||
|
onErrorMessage(errorMessage);
|
||||||
|
} else {
|
||||||
|
showToast(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'package:tangheem/api/api_client.dart';
|
||||||
|
|
||||||
|
class APIException implements Exception {
|
||||||
|
static const String BAD_REQUEST = 'api_common_bad_request';
|
||||||
|
static const String UNAUTHORIZED = 'api_common_unauthorized';
|
||||||
|
static const String FORBIDDEN = 'api_common_forbidden';
|
||||||
|
static const String NOT_FOUND = 'api_common_not_found';
|
||||||
|
static const String INTERNAL_SERVER_ERROR = 'api_common_internal_server_error';
|
||||||
|
static const String UPGRADE_REQUIRED = 'api_common_upgrade_required';
|
||||||
|
static const String BAD_RESPONSE_FORMAT = 'api_common_bad_response_format';
|
||||||
|
static const String OTHER = 'api_common_http_error';
|
||||||
|
static const String TIMEOUT = 'api_common_http_timeout';
|
||||||
|
static const String UNKNOWN = 'unexpected_error';
|
||||||
|
|
||||||
|
final String message;
|
||||||
|
final APIError error;
|
||||||
|
final arguments;
|
||||||
|
|
||||||
|
const APIException(this.message, {this.arguments, this.error});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {'message': message, 'error': error, 'arguments': '$arguments'};
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return jsonEncode(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
class AuthenticationUserModel {
|
||||||
|
int totalItemsCount;
|
||||||
|
int statusCode;
|
||||||
|
String message;
|
||||||
|
Data data;
|
||||||
|
|
||||||
|
AuthenticationUserModel(
|
||||||
|
{this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||||
|
|
||||||
|
AuthenticationUserModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
statusCode = json['statusCode'];
|
||||||
|
message = json['message'];
|
||||||
|
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
data['statusCode'] = this.statusCode;
|
||||||
|
data['message'] = this.message;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data.toJson();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
String token;
|
||||||
|
String userId;
|
||||||
|
String email;
|
||||||
|
String mobileNumber;
|
||||||
|
String userName;
|
||||||
|
|
||||||
|
Data({this.token, this.userId, this.email, this.mobileNumber, this.userName});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
token = json['token'];
|
||||||
|
userId = json['userId'];
|
||||||
|
email = json['email'];
|
||||||
|
mobileNumber = json['mobileNumber'];
|
||||||
|
userName = json['userName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['token'] = this.token;
|
||||||
|
data['userId'] = this.userId;
|
||||||
|
data['email'] = this.email;
|
||||||
|
data['mobileNumber'] = this.mobileNumber;
|
||||||
|
data['userName'] = this.userName;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
class AyaModel {
|
||||||
|
int totalItemsCount;
|
||||||
|
int statusCode;
|
||||||
|
String message;
|
||||||
|
List<Data> data;
|
||||||
|
|
||||||
|
AyaModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||||
|
|
||||||
|
AyaModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
statusCode = json['statusCode'];
|
||||||
|
message = json['message'];
|
||||||
|
if (json['data'] != null) {
|
||||||
|
data = new List<Data>();
|
||||||
|
json['data'].forEach((v) {
|
||||||
|
data.add(new Data.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
data['statusCode'] = this.statusCode;
|
||||||
|
data['message'] = this.message;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
int surahID;
|
||||||
|
String surahNameAR;
|
||||||
|
String surahNameEN;
|
||||||
|
int numberOfAyahs;
|
||||||
|
String englishNameTranslation;
|
||||||
|
int revelationID;
|
||||||
|
String revelationType;
|
||||||
|
int ayahID;
|
||||||
|
int numberInSurah;
|
||||||
|
int page;
|
||||||
|
int quarterID;
|
||||||
|
int juzID;
|
||||||
|
int manzil;
|
||||||
|
bool sajda;
|
||||||
|
String ayahText;
|
||||||
|
Null eighthsID;
|
||||||
|
|
||||||
|
Data(
|
||||||
|
{this.surahID,
|
||||||
|
this.surahNameAR,
|
||||||
|
this.surahNameEN,
|
||||||
|
this.numberOfAyahs,
|
||||||
|
this.englishNameTranslation,
|
||||||
|
this.revelationID,
|
||||||
|
this.revelationType,
|
||||||
|
this.ayahID,
|
||||||
|
this.numberInSurah,
|
||||||
|
this.page,
|
||||||
|
this.quarterID,
|
||||||
|
this.juzID,
|
||||||
|
this.manzil,
|
||||||
|
this.sajda,
|
||||||
|
this.ayahText,
|
||||||
|
this.eighthsID});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
surahID = json['surahID'];
|
||||||
|
surahNameAR = json['surahNameAR'];
|
||||||
|
surahNameEN = json['surahNameEN'];
|
||||||
|
numberOfAyahs = json['numberOfAyahs'];
|
||||||
|
englishNameTranslation = json['englishNameTranslation'];
|
||||||
|
revelationID = json['revelation_ID'];
|
||||||
|
revelationType = json['revelationType'];
|
||||||
|
ayahID = json['ayahID'];
|
||||||
|
numberInSurah = json['numberInSurah'];
|
||||||
|
page = json['page'];
|
||||||
|
quarterID = json['quarter_ID'];
|
||||||
|
juzID = json['juz_ID'];
|
||||||
|
manzil = json['manzil'];
|
||||||
|
sajda = json['sajda'];
|
||||||
|
ayahText = json['ayah_Text'];
|
||||||
|
eighthsID = json['eighths_ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['surahID'] = this.surahID;
|
||||||
|
data['surahNameAR'] = this.surahNameAR;
|
||||||
|
data['surahNameEN'] = this.surahNameEN;
|
||||||
|
data['numberOfAyahs'] = this.numberOfAyahs;
|
||||||
|
data['englishNameTranslation'] = this.englishNameTranslation;
|
||||||
|
data['revelation_ID'] = this.revelationID;
|
||||||
|
data['revelationType'] = this.revelationType;
|
||||||
|
data['ayahID'] = this.ayahID;
|
||||||
|
data['numberInSurah'] = this.numberInSurah;
|
||||||
|
data['page'] = this.page;
|
||||||
|
data['quarter_ID'] = this.quarterID;
|
||||||
|
data['juz_ID'] = this.juzID;
|
||||||
|
data['manzil'] = this.manzil;
|
||||||
|
data['sajda'] = this.sajda;
|
||||||
|
data['ayah_Text'] = this.ayahText;
|
||||||
|
data['eighths_ID'] = this.eighthsID;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
class SurahModel {
|
||||||
|
int totalItemsCount;
|
||||||
|
int statusCode;
|
||||||
|
String message;
|
||||||
|
List<Data> data;
|
||||||
|
|
||||||
|
SurahModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||||
|
|
||||||
|
SurahModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
statusCode = json['statusCode'];
|
||||||
|
message = json['message'];
|
||||||
|
if (json['data'] != null) {
|
||||||
|
data = new List<Data>();
|
||||||
|
json['data'].forEach((v) {
|
||||||
|
data.add(new Data.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
data['statusCode'] = this.statusCode;
|
||||||
|
data['message'] = this.message;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
int id;
|
||||||
|
int surahID;
|
||||||
|
String nameAR;
|
||||||
|
String nameEN;
|
||||||
|
int numberOfAyahs;
|
||||||
|
String englishNameTranslation;
|
||||||
|
int revelationID;
|
||||||
|
String revelationType;
|
||||||
|
|
||||||
|
Data(
|
||||||
|
{this.id,
|
||||||
|
this.surahID,
|
||||||
|
this.nameAR,
|
||||||
|
this.nameEN,
|
||||||
|
this.numberOfAyahs,
|
||||||
|
this.englishNameTranslation,
|
||||||
|
this.revelationID,
|
||||||
|
this.revelationType});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
surahID = json['surahID'];
|
||||||
|
nameAR = json['nameAR'];
|
||||||
|
nameEN = json['nameEN'];
|
||||||
|
numberOfAyahs = json['numberOfAyahs'];
|
||||||
|
englishNameTranslation = json['englishNameTranslation'];
|
||||||
|
revelationID = json['revelation_ID'];
|
||||||
|
revelationType = json['revelationType'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['surahID'] = this.surahID;
|
||||||
|
data['nameAR'] = this.nameAR;
|
||||||
|
data['nameEN'] = this.nameEN;
|
||||||
|
data['numberOfAyahs'] = this.numberOfAyahs;
|
||||||
|
data['englishNameTranslation'] = this.englishNameTranslation;
|
||||||
|
data['revelation_ID'] = this.revelationID;
|
||||||
|
data['revelationType'] = this.revelationType;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
class UserRegistrationModel {
|
||||||
|
String userName;
|
||||||
|
String password;
|
||||||
|
String email;
|
||||||
|
String countryCode;
|
||||||
|
String mobileNumber;
|
||||||
|
bool isUserLock;
|
||||||
|
int gender;
|
||||||
|
int passWrongAttempt;
|
||||||
|
int statusId;
|
||||||
|
bool isEmailVerified;
|
||||||
|
bool isMobileVerified;
|
||||||
|
|
||||||
|
UserRegistrationModel(
|
||||||
|
{this.userName, this.password, this.email, this.countryCode, this.mobileNumber, this.isUserLock, this.gender, this.passWrongAttempt, this.statusId, this.isEmailVerified, this.isMobileVerified});
|
||||||
|
|
||||||
|
UserRegistrationModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
userName = json['userName'];
|
||||||
|
password = json['password'];
|
||||||
|
email = json['email'];
|
||||||
|
countryCode = json['countryCode'];
|
||||||
|
mobileNumber = json['mobileNumber'];
|
||||||
|
isUserLock = json['isUserLock'];
|
||||||
|
gender = json['gender'];
|
||||||
|
passWrongAttempt = json['passWrongAttempt'];
|
||||||
|
statusId = json['statusId'];
|
||||||
|
isEmailVerified = json['isEmailVerified'];
|
||||||
|
isMobileVerified = json['isMobileVerified'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['userName'] = this.userName;
|
||||||
|
data['password'] = this.password;
|
||||||
|
data['email'] = this.email;
|
||||||
|
data['countryCode'] = this.countryCode;
|
||||||
|
data['mobileNumber'] = this.mobileNumber;
|
||||||
|
data['isUserLock'] = this.isUserLock;
|
||||||
|
data['gender'] = this.gender;
|
||||||
|
data['passWrongAttempt'] = this.passWrongAttempt;
|
||||||
|
data['statusId'] = this.statusId;
|
||||||
|
data['isEmailVerified'] = this.isEmailVerified;
|
||||||
|
data['isMobileVerified'] = this.isMobileVerified;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:tangheem/classes/colors.dart';
|
||||||
|
|
||||||
|
class LoadingDialog extends StatefulWidget {
|
||||||
|
LoadingDialog({Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_LoadingDialogState createState() {
|
||||||
|
return _LoadingDialogState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoadingDialogState extends State<LoadingDialog> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
insetPadding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
child: Directionality(
|
||||||
|
textDirection: TextDirection.rtl,
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(ColorConsts.textGrey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue