You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.2 KiB
Dart
78 lines
2.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
import 'package:doctor_app_flutter/providers/schedule_provider.dart';
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../interceptor/http_interceptor.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:http/http.dart';
|
|
import 'package:http_interceptor/http_client_with_interceptor.dart';
|
|
|
|
const GET_PROJECTS = BASE_URL + 'Lists.svc/REST/GetProjectForDoctorAPP';
|
|
|
|
class ProjectsProvider with ChangeNotifier {
|
|
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
|
|
Locale _appLocale;
|
|
String currentLanguage = 'ar';
|
|
bool _isArabic = false;
|
|
|
|
Locale get appLocal => _appLocale;
|
|
|
|
bool get isArabic => _isArabic;
|
|
|
|
ProjectsProvider() {
|
|
loadSharedPrefLan();
|
|
}
|
|
|
|
void loadSharedPrefLan() async {
|
|
currentLanguage = await sharedPref.getString(APP_Language);
|
|
_appLocale = Locale(currentLanguage ?? 'ar');
|
|
_isArabic = currentLanguage != null
|
|
? currentLanguage == 'ar' ? true : false
|
|
: false;
|
|
notifyListeners();
|
|
}
|
|
|
|
void changeDirection(String lan) {
|
|
if (lan != "en" && currentLanguage != lan) {
|
|
_appLocale = Locale("ar");
|
|
_isArabic = true;
|
|
currentLanguage = 'ar';
|
|
sharedPref.setString(APP_Language, 'ar');
|
|
} else if (lan != "ar" && currentLanguage != lan) {
|
|
_appLocale = Locale("en");
|
|
_isArabic = false;
|
|
currentLanguage = 'en';
|
|
sharedPref.setString(APP_Language, 'en');
|
|
}
|
|
notifyListeners();
|
|
}
|
|
|
|
Client client =
|
|
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
|
|
|
|
Future<Map> getProjectsList() async {
|
|
const url = GET_PROJECTS;
|
|
var info = {
|
|
"LanguageID": 2,
|
|
"stamp": "2020-02-26T13:51:44.111Z",
|
|
"IPAdress": "11.11.11.11",
|
|
"VersionID": 1.2,
|
|
"Channel": 9,
|
|
"TokenID": "",
|
|
"SessionID": "i1UJwCTSqt",
|
|
"IsLoginForDoctorApp": true
|
|
};
|
|
try {
|
|
final response = await client.post(url, body: json.encode(info));
|
|
return Future.value(json.decode(response.body));
|
|
} catch (error) {
|
|
throw error;
|
|
// print('error');
|
|
}
|
|
}
|
|
}
|