Reactive Cards in summary,

Offline Banner
This commit is contained in:
Sewmina
2022-03-08 05:18:00 +05:30
parent 455483299f
commit c7c1495b92
2 changed files with 234 additions and 223 deletions

View File

@@ -55,6 +55,7 @@ Future<void> initUserData() async {
await initCacheDatabase();
await refreshUserData();
print('Initializing UserData...');
if(Platform.isAndroid || Platform.isIOS){
Connectivity().onConnectivityChanged.listen((result) {
offline = (result == ConnectivityResult.none);
if (!offline) {
@@ -62,6 +63,7 @@ Future<void> initUserData() async {
refreshUserData();
}
});
}
}
Future<void> refreshUserData() async {
@@ -180,14 +182,14 @@ Future<List<Category>> GetCategories(bool forceOffline) async {
//Validate device_id to check updates
bool catsUpdated = true;
try {
http.Response update_response = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/check_update.php'), body: <String, String>{"username": username, "device_id": android_id}));
final data = update_response.body.split(',');
catsUpdated = data[0] == '1';
} catch (e) {
print(e);
}
bool catsUpdated = false;
// try {
// http.Response update_response = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/check_update.php'), body: <String, String>{"username": username, "device_id": android_id}));
// final data = update_response.body.split(',');
// catsUpdated = data[0] == '1';
// } catch (e) {
// print(e);
// }
print("Need to update : ${!catsUpdated}");
@@ -243,15 +245,15 @@ Future<List<TaskType>> GetTaskTypes(bool forceOffline) async {
//Check if server got updated, If not go for cache
var android_id = await Settings.UUID();
bool updated = true;
try {
//Validate device_id to check updates
http.Response update_response = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/check_update.php'), body: <String, String>{"username": username, "device_id": android_id}));
final data = update_response.body.split(',');
updated = data[1] == '1';
} catch (e) {
print(e);
}
bool updated = false;
// try {
// //Validate device_id to check updates
// http.Response update_response = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/check_update.php'), body: <String, String>{"username": username, "device_id": android_id}));
// final data = update_response.body.split(',');
// updated = data[1] == '1';
// } catch (e) {
// print(e);
// }
print("Need to update : ${!updated}");
@@ -313,15 +315,15 @@ Future<List<Activity>> GetActivities(bool forceOffline) async {
//Check if server got updated, If not go for cache
var android_id = await Settings.UUID();
bool updated = true;
try {
//Validate device_id to check updates
http.Response update_response = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/check_update.php'), body: <String, String>{"username": username, "device_id": android_id}));
final data = update_response.body.split(',');
updated = data[2] == '1';
} catch (e) {
print(e);
}
bool updated = false;
// try {
// //Validate device_id to check updates
// http.Response update_response = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/check_update.php'), body: <String, String>{"username": username, "device_id": android_id}));
// final data = update_response.body.split(',');
// updated = data[2] == '1';
// } catch (e) {
// print(e);
// }
print("Need to update activities : ${!updated}");