Reactive Cards in summary,
Offline Banner
This commit is contained in:
@@ -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}");
|
||||
|
||||
|
||||
403
lib/main.dart
403
lib/main.dart
@@ -369,210 +369,219 @@ 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(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
children: [
|
||||
(false)
|
||||
? Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text("Good\nMorning!", style: TextStyle(fontSize: 23, fontStyle: FontStyle.italic)),
|
||||
Text(
|
||||
"12%",
|
||||
style: TextStyle(fontSize: 30),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(DateFormat("yy - MM-dd").format(DateTime.now())),
|
||||
Text(DateFormat("HH:mm").format(DateTime.now()), style: TextStyle(fontSize: 40)),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
Container(
|
||||
height: 300,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("Productivity", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text("Today : "),
|
||||
Text("${(productivityData.length > 0) ? productivityData[0].productivity.toStringAsFixed(1) : 'n/a'}%",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: (productivityData.length > 1)
|
||||
? ((productivityData[0].productivity > productivityData[1].productivity) ? Colors.lightGreenAccent : Colors.red)
|
||||
: Colors.white))
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Yesterday : "),
|
||||
Text("${(productivityData.length > 1) ? productivityData[1].productivity.toStringAsFixed(1) : 'n/a'}%", style: TextStyle(fontSize: 18))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: SfCartesianChart(
|
||||
// Initialize category axis
|
||||
primaryXAxis: CategoryAxis(),
|
||||
series: <LineSeries<ProductivityMapData, String>>[
|
||||
LineSeries<ProductivityMapData, String>(
|
||||
// Bind data source
|
||||
dataSource: productivityData.reversed.toList(),
|
||||
xValueMapper: (ProductivityMapData sales, _) => sales.day,
|
||||
yValueMapper: (ProductivityMapData sales, _) => sales.productivity,
|
||||
dataLabelMapper: (ProductivityMapData sales, _) => sales.productivity.toStringAsFixed(1) + "%",
|
||||
dataLabelSettings: DataLabelSettings(overflowMode: OverflowMode.hide, showZeroValue: false, isVisible: true),
|
||||
color: Colors.green)
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
height: 370,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: (!days.isEmpty)
|
||||
? Column(
|
||||
]) :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: [
|
||||
(false)
|
||||
? Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text("Good\nMorning!", style: TextStyle(fontSize: 23, fontStyle: FontStyle.italic)),
|
||||
Text(
|
||||
"12%",
|
||||
style: TextStyle(fontSize: 30),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Padding(padding: EdgeInsets.all(20), child: Text('Daily Briefing', style: TextStyle(fontWeight: FontWeight.bold))),
|
||||
dayPickerWidget(days, value: curDay, onChange: (_value) {
|
||||
print('new val : $_value');
|
||||
curDay = _value;
|
||||
setState(() {
|
||||
LoadStats();
|
||||
});
|
||||
}),
|
||||
]),
|
||||
Expanded(
|
||||
child: SfCircularChart(legend: Legend(isVisible: true), series: <CircularSeries>[
|
||||
// Render pie chart
|
||||
PieSeries<CatMapData, String>(
|
||||
dataSource: dailyData,
|
||||
pointColorMapper: (CatMapData data, _) => data.color,
|
||||
xValueMapper: (CatMapData data, _) => data.name,
|
||||
yValueMapper: (CatMapData data, _) => data.time,
|
||||
dataLabelMapper: (CatMapData sales, _) => MinutesToTimeString(sales.time),
|
||||
dataLabelSettings: DataLabelSettings(isVisible: true, useSeriesColor: true))
|
||||
]))
|
||||
Text(DateFormat("yy - MM-dd").format(DateTime.now())),
|
||||
Text(DateFormat("HH:mm").format(DateTime.now()), style: TextStyle(fontSize: 40)),
|
||||
],
|
||||
)
|
||||
: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [CircularProgressIndicator()])))),
|
||||
Container(
|
||||
height: 450,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 25),
|
||||
child: Column(children: [
|
||||
Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text("Task Types", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
DateTimeRange? value = await showDateRangePicker(context: context, firstDate: firstDay ?? DateTime.now(), lastDate: lastDay ?? DateTime.now());
|
||||
if (value != null) {
|
||||
taskTypeRange = value;
|
||||
}
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
Container(
|
||||
height: 300,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("Productivity", style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text("Today : "),
|
||||
Text("${(productivityData.length > 0) ? productivityData[0].productivity.toStringAsFixed(1) : 'n/a'}%",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: (productivityData.length > 1)
|
||||
? ((productivityData[0].productivity > productivityData[1].productivity) ? Colors.lightGreenAccent : Colors.red)
|
||||
: Colors.white))
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Yesterday : "),
|
||||
Text("${(productivityData.length > 1) ? productivityData[1].productivity.toStringAsFixed(1) : 'n/a'}%", style: TextStyle(fontSize: 18))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: SfCartesianChart(
|
||||
// Initialize category axis
|
||||
primaryXAxis: CategoryAxis(),
|
||||
series: <LineSeries<ProductivityMapData, String>>[
|
||||
LineSeries<ProductivityMapData, String>(
|
||||
// Bind data source
|
||||
dataSource: productivityData.reversed.toList(),
|
||||
xValueMapper: (ProductivityMapData sales, _) => sales.day,
|
||||
yValueMapper: (ProductivityMapData sales, _) => sales.productivity,
|
||||
dataLabelMapper: (ProductivityMapData sales, _) => sales.productivity.toStringAsFixed(1) + "%",
|
||||
dataLabelSettings: DataLabelSettings(overflowMode: OverflowMode.hide, showZeroValue: false, isVisible: true),
|
||||
color: Colors.green)
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
height: 370,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: (!days.isEmpty)
|
||||
? Column(
|
||||
children: [
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Padding(padding: EdgeInsets.all(20), child: Text('Daily Briefing', style: TextStyle(fontWeight: FontWeight.bold))),
|
||||
dayPickerWidget(days, value: curDay, onChange: (_value) {
|
||||
print('new val : $_value');
|
||||
curDay = _value;
|
||||
setState(() {
|
||||
LoadStats();
|
||||
});
|
||||
}),
|
||||
]),
|
||||
Expanded(
|
||||
child: SfCircularChart(legend: Legend(isVisible: true), series: <CircularSeries>[
|
||||
// Render pie chart
|
||||
PieSeries<CatMapData, String>(
|
||||
dataSource: dailyData,
|
||||
pointColorMapper: (CatMapData data, _) => data.color,
|
||||
xValueMapper: (CatMapData data, _) => data.name,
|
||||
yValueMapper: (CatMapData data, _) => data.time,
|
||||
dataLabelMapper: (CatMapData sales, _) => MinutesToTimeString(sales.time),
|
||||
dataLabelSettings: DataLabelSettings(isVisible: true, useSeriesColor: true))
|
||||
]))
|
||||
],
|
||||
)
|
||||
: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [CircularProgressIndicator()])))),
|
||||
Container(
|
||||
height: (taskTypesData.length * 45).clamp(350, 1000).toDouble(),
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 25),
|
||||
child: Column(children: [
|
||||
Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text("Task Types", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
DateTimeRange? value = await showDateRangePicker(context: context, firstDate: firstDay ?? DateTime.now(), lastDate: lastDay ?? DateTime.now());
|
||||
if (value != null) {
|
||||
taskTypeRange = value;
|
||||
}
|
||||
|
||||
LoadStats();
|
||||
},
|
||||
child: Text((taskTypeRange != null) ? (DateFormat("MM/dd").format(taskTypeRange!.start) + " - " + DateFormat("MM/dd").format(taskTypeRange!.end)) : 'n/a'),
|
||||
)
|
||||
]),
|
||||
Expanded(
|
||||
// maxHeight: 300,
|
||||
// maxWidth: 100,
|
||||
child: SfCartesianChart(primaryXAxis: CategoryAxis(),
|
||||
//primaryYAxis: NumericAxis(minimum: 0, maximum: 40, interval: 10),
|
||||
series: <ChartSeries<TaskTypeMapData, String>>[
|
||||
BarSeries<TaskTypeMapData, String>(
|
||||
dataSource: taskTypesData,
|
||||
xValueMapper: (TaskTypeMapData data, _) => data.task,
|
||||
yValueMapper: (TaskTypeMapData data, _) => data.time / 60,
|
||||
pointColorMapper: (TaskTypeMapData data, _) => data.color,
|
||||
dataLabelMapper: (TaskTypeMapData data, _) => MinutesToTimeString(data.time),
|
||||
dataLabelSettings: DataLabelSettings(isVisible: true),
|
||||
color: Color.fromRGBO(8, 142, 255, 1))
|
||||
LoadStats();
|
||||
},
|
||||
child: Text((taskTypeRange != null) ? (DateFormat("MM/dd").format(taskTypeRange!.start) + " - " + DateFormat("MM/dd").format(taskTypeRange!.end)) : 'n/a'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
])))),
|
||||
Container(
|
||||
height: 450,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 25),
|
||||
child: Column(children: [
|
||||
Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text("Categories", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
DateTimeRange? value = await showDateRangePicker(context: context, firstDate: firstDay ?? DateTime.now(), lastDate: lastDay ?? DateTime.now());
|
||||
if (value != null) {
|
||||
catsRange = value;
|
||||
}
|
||||
Expanded(
|
||||
// maxHeight: 300,
|
||||
// maxWidth: 100,
|
||||
child: SfCartesianChart(primaryXAxis: CategoryAxis(),
|
||||
//primaryYAxis: NumericAxis(minimum: 0, maximum: 40, interval: 10),
|
||||
series: <ChartSeries<TaskTypeMapData, String>>[
|
||||
BarSeries<TaskTypeMapData, String>(
|
||||
dataSource: taskTypesData,
|
||||
xValueMapper: (TaskTypeMapData data, _) => data.task,
|
||||
yValueMapper: (TaskTypeMapData data, _) => data.time / 60,
|
||||
pointColorMapper: (TaskTypeMapData data, _) => data.color,
|
||||
dataLabelMapper: (TaskTypeMapData data, _) => MinutesToTimeString(data.time),
|
||||
dataLabelSettings: DataLabelSettings(isVisible: true),
|
||||
color: Color.fromRGBO(8, 142, 255, 1))
|
||||
]),
|
||||
)
|
||||
])))),
|
||||
Container(
|
||||
height: (catsData.length * 45).clamp(350, 1000).toDouble(),
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Card(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.blueGrey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 25),
|
||||
child: Column(children: [
|
||||
Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
Text("Categories", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
DateTimeRange? value = await showDateRangePicker(context: context, firstDate: firstDay ?? DateTime.now(), lastDate: lastDay ?? DateTime.now());
|
||||
if (value != null) {
|
||||
catsRange = value;
|
||||
}
|
||||
|
||||
LoadStats();
|
||||
},
|
||||
child: Text((catsRange != null) ? (DateFormat("MM/dd").format(catsRange!.start) + " - " + DateFormat("MM/dd").format(catsRange!.end)) : 'n/a'),
|
||||
)
|
||||
]),
|
||||
Expanded(
|
||||
// maxHeight: 300,
|
||||
// maxWidth: 100,
|
||||
child: SfCartesianChart(primaryXAxis: CategoryAxis(),
|
||||
//primaryYAxis: NumericAxis(minimum: 0, maximum: 40, interval: 10),
|
||||
series: <ChartSeries<CatMapData, String>>[
|
||||
BarSeries<CatMapData, String>(
|
||||
dataSource: catsData,
|
||||
xValueMapper: (CatMapData data, _) => data.name,
|
||||
yValueMapper: (CatMapData data, _) => data.time / 60,
|
||||
pointColorMapper: (CatMapData data, _) => data.color,
|
||||
dataLabelMapper: (CatMapData data, _) => MinutesToTimeString(data.time),
|
||||
dataLabelSettings: DataLabelSettings(isVisible: true),
|
||||
color: Color.fromRGBO(8, 142, 255, 1))
|
||||
LoadStats();
|
||||
},
|
||||
child: Text((catsRange != null) ? (DateFormat("MM/dd").format(catsRange!.start) + " - " + DateFormat("MM/dd").format(catsRange!.end)) : 'n/a'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
])))),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
// maxHeight: 300,
|
||||
// maxWidth: 100,
|
||||
child: SfCartesianChart(primaryXAxis: CategoryAxis(),
|
||||
//primaryYAxis: NumericAxis(minimum: 0, maximum: 40, interval: 10),
|
||||
series: <ChartSeries<CatMapData, String>>[
|
||||
BarSeries<CatMapData, String>(
|
||||
dataSource: catsData,
|
||||
xValueMapper: (CatMapData data, _) => data.name,
|
||||
yValueMapper: (CatMapData data, _) => data.time / 60,
|
||||
pointColorMapper: (CatMapData data, _) => data.color,
|
||||
dataLabelMapper: (CatMapData data, _) => MinutesToTimeString(data.time),
|
||||
dataLabelSettings: DataLabelSettings(isVisible: true),
|
||||
color: Color.fromRGBO(8, 142, 255, 1))
|
||||
]),
|
||||
)
|
||||
])))),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user