|
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:doctor/common/preloader.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
//const Color primaryColor = Color(0XFF1786A3);
|
|
|
|
const Color primaryColor = Color(0XFF99405B);
|
|
|
|
const Color secondaryColor = Color(0XFFD9D9D9);
|
|
|
|
const Color buttonColors = Color(0XFF1786A3);
|
|
|
|
const Color greyColor = Color(0XFF8F8E8E);
|
|
|
|
const Color textFieldStartColor = Colors.grey;
|
|
|
|
const Color screenBackgroundColor = Color(0XFFEAF6FF);
|
|
|
|
const Color screenBackgroundColord = Colors.black12;
|
|
|
|
const Color dashboardbackground = Color(0XFFF5F5F5);
|
|
|
|
|
|
|
|
//Color AppBarGradient_1 = Color(0XFF1258F6);
|
|
|
|
Color AppBarGradient_1 = Color(0XFF99405B);
|
|
|
|
|
|
|
|
TextStyle PreloaderText() {
|
|
|
|
return TextStyle(color: Color(0XFF99405B));
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle labelTextStyle() {
|
|
|
|
return TextStyle(color: primaryColor, fontSize: 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle labelTextStyleOrderMedicine() {
|
|
|
|
return TextStyle(color: primaryColor, fontSize: 12,fontWeight: FontWeight.bold);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle haveMotorTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: Colors.red, fontSize: 12, fontWeight: FontWeight.bold);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle textButtonStyle() {
|
|
|
|
return TextStyle(color: primaryColor, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle textButtonStyleReports() {
|
|
|
|
return TextStyle(color: Colors.white, fontSize: 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle iconBelowTextStyle() {
|
|
|
|
return TextStyle(fontSize: 10, color: primaryColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle valuesTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle recordDetailsHeading() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle problemTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.red
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle headingsTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: primaryColor
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle startAndStopHeading() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: primaryColor,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Text capacitySuffixText() {
|
|
|
|
return Text('in Ltrs.');
|
|
|
|
}
|
|
|
|
|
|
|
|
Text dimensionSuffixText() {
|
|
|
|
return Text('in fts');
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle dashboardTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle labelTextStyleBold() {
|
|
|
|
return TextStyle(
|
|
|
|
color: primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle serverIssueTextStyle() {
|
|
|
|
return TextStyle(color: Colors.red, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle bottomSheetValuesTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle wrapTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: primaryColor,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle wrapTextStyleBlack() {
|
|
|
|
return TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle withoutWrapTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle bmiTextStyle() {
|
|
|
|
return TextStyle(
|
|
|
|
color: primaryColor,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle drawerListItemsTextStyle() {
|
|
|
|
return TextStyle(color: Colors.white);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle drawerHeaderTextStyle() {
|
|
|
|
return TextStyle(color: Colors.white, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle drawerHeaderTextStyleNew() {
|
|
|
|
return TextStyle(color: Colors.black, fontSize: 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle textFormFieldFilledTextStyle() {
|
|
|
|
return TextStyle(color: secondaryColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InputDecoration textFormFieldDecoration(IconData icon, var text) {
|
|
|
|
return InputDecoration(
|
|
|
|
filled: true,
|
|
|
|
fillColor: primaryColor,
|
|
|
|
prefixIcon: Icon(
|
|
|
|
icon,
|
|
|
|
color: secondaryColor,
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide(color: secondaryColor)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: secondaryColor),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: secondaryColor),
|
|
|
|
),
|
|
|
|
labelText: text,
|
|
|
|
/*labelStyle: TextStyle(
|
|
|
|
color: myFocusNode.hasFocus ? Colors.blue : Colors.black
|
|
|
|
)*/
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: secondaryColor,fontWeight: FontWeight.bold //<-- SEE HERE
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDecoration textFormFieldDecorationBMI(IconData icon, var text) {
|
|
|
|
return InputDecoration(
|
|
|
|
//filled: true,
|
|
|
|
//fillColor: Colors.white,
|
|
|
|
prefixIcon: Icon(
|
|
|
|
icon,
|
|
|
|
color: primaryColor,
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide(color: primaryColor)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: primaryColor),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: primaryColor),
|
|
|
|
),
|
|
|
|
labelText: text,
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
//color: Colors.black, //<-- SEE HERE
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final GlobalKey<State> preloaderWindowKey = new GlobalKey<State>();
|
|
|
|
Future<void> preloaderWindow(BuildContext context) async {
|
|
|
|
try {
|
|
|
|
Dialogs.showLoadingDialog(context, preloaderWindowKey);
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AppSettings {
|
|
|
|
static SharedPreferences sharedPreferences =
|
|
|
|
SharedPreferences.getInstance() as SharedPreferences;
|
|
|
|
static String doctorName = '';
|
|
|
|
static String specialization = '';
|
|
|
|
static String qualification = '';
|
|
|
|
static List placeOfPractices = [];
|
|
|
|
static String placeOfPractice1 = '';
|
|
|
|
static String placeOfPractice2 = '';
|
|
|
|
static String placeOfPractice3 = '';
|
|
|
|
static String placeOfPracticeAddress1 = '';
|
|
|
|
static String placeOfPracticeAddress2 = '';
|
|
|
|
static String placeOfPracticeAddress3 = '';
|
|
|
|
static String doctorAddress = '';
|
|
|
|
static String email = '';
|
|
|
|
static String age = '';
|
|
|
|
static String gender = '';
|
|
|
|
static String phoneNumber = '';
|
|
|
|
static String accessToken = '';
|
|
|
|
static String doctorId = '';
|
|
|
|
static double doctorLatitude = 0;
|
|
|
|
static double doctorLongitude = 0;
|
|
|
|
static String customerIdsign = '';
|
|
|
|
static String profileImage = '';
|
|
|
|
static List<String> storedPreferenceValidKeys = ['doctorname', 'access_token'];
|
|
|
|
static String preloadText = 'Please wait';
|
|
|
|
static String latitude = '';
|
|
|
|
static String longitude = '';
|
|
|
|
static bool servicestatus = false;
|
|
|
|
static bool haspermission = false;
|
|
|
|
static late LocationPermission permission;
|
|
|
|
static late Position position;
|
|
|
|
static String long = "", lat = "";
|
|
|
|
late StreamSubscription<Position> positionStream;
|
|
|
|
static String fcmId = '';
|
|
|
|
static String serverToken =
|
|
|
|
'AAAAA66BLaA:APA91bHcmbyiNN8hCL-t-M9oH-u7ZMOl74fcImMM2DQZLgdyY98Wu9XxME-CTPcjpjU6Yy48ouxISrOMb9lpa3PJofh8qciUKMNxV2al-bDvGvPP_VVaH0mrTHzR56hdkGy1Zl-0frDO';
|
|
|
|
|
|
|
|
static String qrCode = '';
|
|
|
|
static String originalQrCode = '';
|
|
|
|
|
|
|
|
|
|
|
|
//api urls
|
|
|
|
//static String host = 'http://35.200.129.165:4000/api/';
|
|
|
|
static String host = 'http://cloudh.in:4000/api/';
|
|
|
|
static String loginUrl = host + 'doctorlogin';
|
|
|
|
static String signUpUrl = host + 'addDoctor';
|
|
|
|
static String sendSmsUrl = host + 'sendSms';
|
|
|
|
static String phoneVerificationUrl = host + 'doctorphone';
|
|
|
|
static String uploadPicUrl = host + 'uploadsDoctorProfilePicture';
|
|
|
|
static String updateProfileUrl = host + 'updateDoctor';
|
|
|
|
static String resetTokenUrl = host + 'reset_token';
|
|
|
|
static String generateQRCodeUrl = host + 'generate-qrcode-doctor';
|
|
|
|
static String getAllConectedPatientsDataUrl = host + 'customerDetails';
|
|
|
|
static String getRecordsDataUrl = host + 'getAllRecords';
|
|
|
|
static String getDynamicCodeUrl = host + 'records';
|
|
|
|
static String dynamicCodeVerificationUrl = host + 'verifyDynamicCode';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static File? updatedImage;
|
|
|
|
static String image = '';
|
|
|
|
static String profilePictureUrl = '';
|
|
|
|
|
|
|
|
/*Formatter*/
|
|
|
|
static String formNum(String s) {
|
|
|
|
var comma = NumberFormat('#,##,###', 'en_IN');
|
|
|
|
return comma.format(
|
|
|
|
int.parse(s),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static String formDouble(String s) {
|
|
|
|
var comma = NumberFormat('#,##,###.##', 'en_IN');
|
|
|
|
return comma.format(
|
|
|
|
double.parse(s),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Preloader */
|
|
|
|
static GlobalKey<State> preLoaderKey = new GlobalKey<State>();
|
|
|
|
|
|
|
|
static Future<void> preLoaderDialog(BuildContext context) async {
|
|
|
|
try {
|
|
|
|
preLoaderKey = new GlobalKey<State>();
|
|
|
|
Dialogs.showLoadingDialog(context, preLoaderKey);
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
////request headers with content type
|
|
|
|
static Future<Map<String, String>> buildRequestHeaders() async {
|
|
|
|
Map<String, String> _headers = new Map<String, String>();
|
|
|
|
_headers[HttpHeaders.contentTypeHeader] = 'application/json';
|
|
|
|
_headers['Authorization'] = accessToken;
|
|
|
|
return _headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
//request headers without content type
|
|
|
|
static Future<Map<String, String>> buildPutRequestHeaders() async {
|
|
|
|
Map<String, String> _headers = new Map<String, String>();
|
|
|
|
_headers['Authorization'] = accessToken;
|
|
|
|
return _headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<Map<String, String>> buildPutRequestHeadersForResetToken() async {
|
|
|
|
Map<String, String> _headers = new Map<String, String>();
|
|
|
|
return _headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shared preferences save,get and clear data
|
|
|
|
static saveData(String _key, _value, type) async {
|
|
|
|
sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
if (type == 'STRING') {
|
|
|
|
await sharedPreferences.setString(_key, _value.toString());
|
|
|
|
} else if (type == 'INTEGER') {
|
|
|
|
await sharedPreferences.setInt(_key, _value);
|
|
|
|
} else if (type == 'BOOL') {
|
|
|
|
await sharedPreferences.setBool(_key, _value);
|
|
|
|
} else if (type == 'DOUBLE') {
|
|
|
|
await sharedPreferences.setDouble(_key, _value);
|
|
|
|
}
|
|
|
|
else if (type == 'LIST') {
|
|
|
|
await sharedPreferences.setStringList(_key, _value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static getData(String _key, type) async {
|
|
|
|
sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
if (type == 'STRING') {
|
|
|
|
return sharedPreferences.getString(_key) ?? '';
|
|
|
|
} else if (type == 'INTEGER') {
|
|
|
|
return sharedPreferences.getInt(_key) ?? -1;
|
|
|
|
} else if (type == 'BOOL') {
|
|
|
|
return sharedPreferences.getBool(_key) ?? -1;
|
|
|
|
} else if (type == 'DOUBLE') {
|
|
|
|
return sharedPreferences.getDouble(_key) ?? -1;
|
|
|
|
}
|
|
|
|
else if (type == 'LIST') {
|
|
|
|
return sharedPreferences.getStringList(_key) ?? -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static clearSharedPrefeences() async {
|
|
|
|
sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
await sharedPreferences.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Sign in check*/
|
|
|
|
static Future<bool> isSigIn() async {
|
|
|
|
bool isSignInCheck = true;
|
|
|
|
for (var eachKey in storedPreferenceValidKeys) {
|
|
|
|
if (await getData(eachKey, 'STRING') == '') {
|
|
|
|
isSignInCheck = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isSignInCheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> internetConnectivity() async {
|
|
|
|
try {
|
|
|
|
final result = await InternetAddress.lookup('google.com');
|
|
|
|
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} on SocketException catch (_) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Apis Starts here*/
|
|
|
|
|
|
|
|
static Future<bool> signUp(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(signUpUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
print(_response);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> sendSms(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(sendSmsUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> phoneVerification(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(phoneVerificationUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> login(payload) async {
|
|
|
|
var response = await http.post(Uri.parse(loginUrl),
|
|
|
|
body: json.encode(payload),
|
|
|
|
headers: {'Content-type': 'application/json'});
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
try {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
|
|
|
|
if (_response['simplydata']['error'] == false) {
|
|
|
|
await saveAvailableReportAndLocationsInMemory(_response);
|
|
|
|
//await saveProfilePic(_response);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// display error toast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> resetToken() async {
|
|
|
|
var uri = Uri.parse(resetTokenUrl + '/' + doctorId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
// var response = await http.get(uri, headers: await buildPutRequestHeaders());
|
|
|
|
var response = await http.get(uri,
|
|
|
|
headers: await buildPutRequestHeadersForResetToken());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
print(response.body);
|
|
|
|
var res = jsonDecode(response.body);
|
|
|
|
print(res);
|
|
|
|
|
|
|
|
accessToken = res['access_token'];
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> uploadImageHTTPNew(file) async {
|
|
|
|
var request = http.MultipartRequest(
|
|
|
|
'POST', Uri.parse(uploadPicUrl + '/' + doctorId));
|
|
|
|
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
|
|
|
|
var res = await request.send();
|
|
|
|
var response = await http.Response.fromStream(res);
|
|
|
|
return response.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> updateProfile(payload) async {
|
|
|
|
var uri = Uri.parse(updateProfileUrl + '/' + doctorId);
|
|
|
|
try {
|
|
|
|
var response = await http.put(uri,
|
|
|
|
body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
var _response = json.decode(response.body);
|
|
|
|
|
|
|
|
doctorName = _response['armintahealthdata']['doctorName'];
|
|
|
|
phoneNumber = _response['armintahealthdata']['phone'];
|
|
|
|
email = _response['armintahealthdata']['emails'][0]['email'];
|
|
|
|
age = _response['armintahealthdata']['age'].toString();
|
|
|
|
gender=_response['armintahealthdata']['gender'].toString();
|
|
|
|
specialization=_response['armintahealthdata']['specialization'].toString();
|
|
|
|
qualification=_response['armintahealthdata']['qualification'].toString();
|
|
|
|
if(_response['armintahealthdata']['placeOfPractice'].length>0){
|
|
|
|
placeOfPractice1=_response['armintahealthdata']['placeOfPractice'][0]['hospitalName']??'';
|
|
|
|
placeOfPracticeAddress1=_response['armintahealthdata']['placeOfPractice'][0]['address']??'';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await saveData('phone', _response['armintahealthdata']['phone'], 'STRING');
|
|
|
|
await saveData('email', _response['armintahealthdata']['emails'][0]['email'], 'STRING');
|
|
|
|
await saveData('doctorname', _response['armintahealthdata']['doctorName'], 'STRING');
|
|
|
|
await saveData('age', _response['armintahealthdata']['age'].toString(), 'STRING');
|
|
|
|
await saveData('specialization', _response['armintahealthdata']['specialization'], 'STRING');
|
|
|
|
await saveData('qualification', _response['armintahealthdata']['qualification'], 'STRING');
|
|
|
|
await saveData('gender', _response['armintahealthdata']['gender'], 'STRING');
|
|
|
|
if(_response['armintahealthdata']['placeOfPractice'].length>0){
|
|
|
|
await saveData('placeOfPractice1',_response['armintahealthdata']['placeOfPractice'][0]['hospitalName']??'', 'STRING');
|
|
|
|
await saveData('placeOfPracticeAddress1', _response['armintahealthdata']['placeOfPractice'][0]['address']??'', 'STRING');
|
|
|
|
}
|
|
|
|
|
|
|
|
await loadDataFromMemory();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> generateQRCode() async {
|
|
|
|
var uri = Uri.parse(generateQRCodeUrl + '/' + doctorId);
|
|
|
|
|
|
|
|
var response = await http.post(uri, headers: await buildPutRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri, headers: await buildPutRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllConectedPatients() async {
|
|
|
|
var uri = Uri.parse(getAllConectedPatientsDataUrl + '/' + doctorId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getAllRecords(customerId) async {
|
|
|
|
var uri = Uri.parse(getRecordsDataUrl + '/' + customerId);
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.get(uri, headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<String> getDynamicCode(payload) async {
|
|
|
|
var uri = Uri.parse(getDynamicCodeUrl );
|
|
|
|
//uri = uri.replace(query: 'customerId=$customerId');
|
|
|
|
|
|
|
|
var response = await http.post(uri,body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri,body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return response.body;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<bool> dynamicCodeVerification(payload) async {
|
|
|
|
var uri = Uri.parse(dynamicCodeVerificationUrl + '/'+doctorId);
|
|
|
|
var response = await http.post(uri, body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (response.statusCode == 401) {
|
|
|
|
bool status = await AppSettings.resetToken();
|
|
|
|
if (status) {
|
|
|
|
response = await http.post(uri, body: json.encode(payload), headers: await buildRequestHeaders());
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Apis ends here*/
|
|
|
|
|
|
|
|
//save data local
|
|
|
|
static Future<void> saveAvailableReportAndLocationsInMemory(dynamic input) async {
|
|
|
|
// save login name information
|
|
|
|
await saveData('doctorname', input['simplydata']['doctorName'], 'STRING');
|
|
|
|
await saveData('access_token', input['simplydata']['access_token'], 'STRING');
|
|
|
|
await saveData('phone', input['simplydata']['phone'], 'STRING');
|
|
|
|
await saveData('email', input['simplydata']['email'][0]['email'], 'STRING');
|
|
|
|
await saveData('doctorId', input['simplydata']['doctorId'], 'STRING');
|
|
|
|
await saveData('profile', input['simplydata']['picture'], 'STRING');
|
|
|
|
await saveData('user_address', input['simplydata']['address1'], 'STRING');
|
|
|
|
await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE');
|
|
|
|
await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE');
|
|
|
|
await saveData('fcmId', input['simplydata']['fcmId'], 'STRING');
|
|
|
|
await saveData('age', input['simplydata']['age'], 'STRING');
|
|
|
|
await saveData('gender', input['simplydata']['gender'], 'STRING');
|
|
|
|
await saveData('qrCode', input['simplydata']['qrCode'], 'STRING');
|
|
|
|
await saveData('specialization', input['simplydata']['specialization'], 'STRING');
|
|
|
|
await saveData('qualification', input['simplydata']['qualification'], 'STRING');
|
|
|
|
if(input['simplydata']['placeOfPractice'].length>0){
|
|
|
|
await saveData('placeOfPractice1', input['simplydata']['placeOfPractice'][0]['hospitalName']??'', 'STRING');
|
|
|
|
await saveData('placeOfPractice2', input['simplydata']['placeOfPractice'][1]['hospitalName']??'', 'STRING');
|
|
|
|
await saveData('placeOfPractice3', input['simplydata']['placeOfPractice'][2]['hospitalName']??'', 'STRING');
|
|
|
|
await saveData('placeOfPracticeAddress1', input['simplydata']['placeOfPractice'][0]['address']??'', 'STRING');
|
|
|
|
await saveData('placeOfPracticeAddress2', input['simplydata']['placeOfPractice'][1]['address']??'', 'STRING');
|
|
|
|
await saveData('placeOfPracticeAddress3', input['simplydata']['placeOfPractice'][2]['address']??'', 'STRING');
|
|
|
|
}
|
|
|
|
|
|
|
|
//await saveData('age', input['simplydata']['age'], 'STRING');
|
|
|
|
//latitude,longitude
|
|
|
|
await loadDataFromMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<void> loadDataFromMemory() async {
|
|
|
|
doctorName = await getData('doctorname', 'STRING');
|
|
|
|
accessToken = await getData('access_token', 'STRING');
|
|
|
|
email = await getData('email', 'STRING');
|
|
|
|
doctorAddress = await getData('user_address', 'STRING');
|
|
|
|
phoneNumber = await getData('phone', 'STRING');
|
|
|
|
doctorId = await getData('doctorId', 'STRING');
|
|
|
|
doctorLatitude = await getData('latitude', 'DOUBLE');
|
|
|
|
doctorLongitude = await getData('longitude', 'DOUBLE');
|
|
|
|
profilePictureUrl = await getData('profile', 'STRING');
|
|
|
|
specialization= await getData('specialization', 'STRING');
|
|
|
|
qualification= await getData('qualification', 'STRING');
|
|
|
|
fcmId = await getData('fcmId', 'STRING');
|
|
|
|
age = await getData('age', 'STRING');
|
|
|
|
gender = await getData('gender', 'STRING');
|
|
|
|
originalQrCode = await getData('qrCode', 'STRING');
|
|
|
|
String dataUri = originalQrCode;
|
|
|
|
|
|
|
|
// Split the data URI at the comma to extract the Base64 part
|
|
|
|
List<String> parts = dataUri.split(",");
|
|
|
|
String? base64String = parts.length == 2 ? parts[1] : null;
|
|
|
|
|
|
|
|
if (base64String != null) {
|
|
|
|
qrCode=base64String;
|
|
|
|
} else {
|
|
|
|
print("Invalid data URI");
|
|
|
|
}
|
|
|
|
placeOfPractice1= await getData('placeOfPractice1', 'STRING');
|
|
|
|
placeOfPractice2= await getData('placeOfPractice2', 'STRING');
|
|
|
|
placeOfPractice3= await getData('placeOfPractice3', 'STRING');
|
|
|
|
placeOfPracticeAddress1= await getData('placeOfPracticeAddress1', 'STRING');
|
|
|
|
placeOfPracticeAddress2= await getData('placeOfPracticeAddress2', 'STRING');
|
|
|
|
placeOfPracticeAddress3= await getData('placeOfPracticeAddress3', 'STRING');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void longSuccessToast(String message) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: message,
|
|
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 16.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void longSuccessToast1(String message) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: message,
|
|
|
|
toastLength: Toast.LENGTH_LONG,
|
|
|
|
gravity: ToastGravity.CENTER,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 16.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void longFailedToast(String message) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: message,
|
|
|
|
toastLength: Toast.LENGTH_LONG,
|
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
timeInSecForIosWeb: 1,
|
|
|
|
backgroundColor: Colors.red,
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontSize: 16.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Widget noDataUI(String _tabName) {
|
|
|
|
_tabName = _tabName ?? '';
|
|
|
|
return Container(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Image(
|
|
|
|
image: AssetImage('images/no_data.png'),
|
|
|
|
width: 200,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
'There is no data to show you right now.',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Colors.grey[600],
|
|
|
|
fontFamily: 'Swis2',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
_tabName,
|
|
|
|
style: TextStyle(fontSize: 15, fontFamily: 'Swis1'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static appBar(String title) {
|
|
|
|
title = title ?? '';
|
|
|
|
return AppBar(
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
title: Text(title),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*location*/
|
|
|
|
static checkGps() async {
|
|
|
|
servicestatus = await Geolocator.isLocationServiceEnabled();
|
|
|
|
if (servicestatus) {
|
|
|
|
permission = await Geolocator.checkPermission();
|
|
|
|
|
|
|
|
if (permission == LocationPermission.denied) {
|
|
|
|
permission = await Geolocator.requestPermission();
|
|
|
|
if (permission == LocationPermission.denied) {
|
|
|
|
print('Location permissions are denied');
|
|
|
|
} else if (permission == LocationPermission.deniedForever) {
|
|
|
|
print("'Location permissions are permanently denied");
|
|
|
|
} else {
|
|
|
|
haspermission = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
haspermission = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (haspermission) {
|
|
|
|
/*setState(() {
|
|
|
|
//refresh the UI
|
|
|
|
});*/
|
|
|
|
|
|
|
|
await getLocation();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print("GPS Service is not enabled, turn on GPS location");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static getLocation() async {
|
|
|
|
position = await Geolocator.getCurrentPosition(
|
|
|
|
desiredAccuracy: LocationAccuracy.high);
|
|
|
|
/*print(position.longitude); //Output: 80.24599079
|
|
|
|
print(position.latitude);*/ //Output: 29.6593457
|
|
|
|
|
|
|
|
long = await position.longitude.toString();
|
|
|
|
lat = await position.latitude.toString();
|
|
|
|
|
|
|
|
/*setState(() {
|
|
|
|
//refresh UI
|
|
|
|
});*/
|
|
|
|
|
|
|
|
LocationSettings locationSettings = LocationSettings(
|
|
|
|
accuracy: LocationAccuracy.high, //accuracy of the location data
|
|
|
|
distanceFilter: 100, //minimum distance (measured in meters) a
|
|
|
|
//device must move horizontally before an update event is generated;
|
|
|
|
);
|
|
|
|
|
|
|
|
StreamSubscription<Position> positionStream =
|
|
|
|
Geolocator.getPositionStream(locationSettings: locationSettings)
|
|
|
|
.listen((Position position) {
|
|
|
|
print(position.longitude); //Output: 80.24599079
|
|
|
|
print(position.latitude); //Output: 29.6593457
|
|
|
|
|
|
|
|
long = position.longitude.toString();
|
|
|
|
lat = position.latitude.toString();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|