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}");

View File

@@ -369,7 +369,13 @@ class _MyHomePageState extends State<MyHomePage> {
Expanded(flex: 1,child: Container(),),
Expanded(flex: 2,child: Image(image: AssetImage('images/empty.png'))),
Expanded(flex:2,child: Text("Add your first activity to access Summary",style: TextStyle(color: Colors.grey, fontStyle: FontStyle.italic),))
]) :SingleChildScrollView(
]) :Column(
mainAxisSize: MainAxisSize.max,
children: [
if(User.offline)Expanded(flex:1,child: Container(width:1000,color: Colors.red,child: Align(alignment: Alignment.center,child: Text("Offline")))),
Expanded(
flex:50,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
@@ -492,7 +498,7 @@ class _MyHomePageState extends State<MyHomePage> {
)
: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [CircularProgressIndicator()])))),
Container(
height: 450,
height: (taskTypesData.length * 45).clamp(350, 1000).toDouble(),
padding: EdgeInsets.all(10),
child: Card(
elevation: 8,
@@ -532,7 +538,7 @@ class _MyHomePageState extends State<MyHomePage> {
)
])))),
Container(
height: 450,
height: (catsData.length * 45).clamp(350, 1000).toDouble(),
padding: EdgeInsets.all(10),
child: Card(
elevation: 8,
@@ -575,6 +581,9 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
),
],
),
),
);
}