Commit 3d526459 authored by Boteju W.J.M.'s avatar Boteju W.J.M.

10/01

parent de6eccf5
Pipeline #2058 failed with stages
...@@ -22,7 +22,7 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -22,7 +22,7 @@ class _ProfilePageState extends State<ProfilePage> {
int sliderValue = 1; int sliderValue = 1;
static dynamic value = []; static dynamic value = [];
int walkingHrs, walkingMins, runningHrs, runningMins; int walkingHrs, walkingMins, runningHrs, runningMins, restingHrs, restingMins;
int totalActivityHrs = 0; int totalActivityHrs = 0;
int totalActivityMins = 0; int totalActivityMins = 0;
int _currentStrength; int _currentStrength;
...@@ -62,7 +62,7 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -62,7 +62,7 @@ class _ProfilePageState extends State<ProfilePage> {
finalDate = formattedDate.toString(); finalDate = formattedDate.toString();
dogBirthday = dogBirthdayAge.toString(); dogBirthday = dogBirthdayAge.toString();
globals.age = dogBirthdayAge; globals.age = dogBirthdayAge;
dogName= globals.dogName; dogName = globals.dogName;
}); });
getTotalWalkingMinutes(datee, dog); getTotalWalkingMinutes(datee, dog);
} }
...@@ -92,7 +92,7 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -92,7 +92,7 @@ class _ProfilePageState extends State<ProfilePage> {
} }
getTotalRunningMinutes(day, dog) async { getTotalRunningMinutes(day, dog) async {
print("Hereee in run"); print("In run");
SearchService.getTotalRunningMinutesPerDay(day, dog).then((responseBody) { SearchService.getTotalRunningMinutesPerDay(day, dog).then((responseBody) {
dynamic data = jsonDecode(responseBody); dynamic data = jsonDecode(responseBody);
setState(() { setState(() {
...@@ -118,6 +118,26 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -118,6 +118,26 @@ class _ProfilePageState extends State<ProfilePage> {
int totalTime = (totalActivityHrs * 60) + totalActivityMins; int totalTime = (totalActivityHrs * 60) + totalActivityMins;
compare(globals.dogBreed, totalTime); compare(globals.dogBreed, totalTime);
getTotalRestingMinutes(day, globals.dogId);
});
});
}
getTotalRestingMinutes(day, dog) async {
print("In Rest");
SearchService.getTotalRestingMinutesPerDay(day, dog).then((responseBody) {
dynamic data = jsonDecode(responseBody);
setState(() {
value = data[0]['minutes per day'];
print(value);
if (value != 0) {
value = value.toInt();
restingHrs = value ~/ 60;
restingMins = value % 60;
} else {
restingHrs = 0;
restingMins = 0;
}
}); });
}); });
} }
...@@ -134,11 +154,10 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -134,11 +154,10 @@ class _ProfilePageState extends State<ProfilePage> {
sliderValue = 3; sliderValue = 3;
} }
globals.status = data['status']; globals.status = data['status'];
status= globals.status; status = globals.status;
globals.sliderValue = sliderValue; globals.sliderValue = sliderValue;
loading = false; loading = false;
_showNotification(); _showNotification();
}); });
}); });
} }
...@@ -155,11 +174,10 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -155,11 +174,10 @@ class _ProfilePageState extends State<ProfilePage> {
fltrNotification.initialize(initilizationsSettings, fltrNotification.initialize(initilizationsSettings,
onSelectNotification: notificationSelected); onSelectNotification: notificationSelected);
getTotalActivityMinutesPerDay(globals.birthday, globals.dogId); getTotalActivityMinutesPerDay(globals.birthday, globals.dogId);
} }
Future _showNotification() async { Future _showNotification() async {
final String currentTimeZone = final String currentTimeZone =
await FlutterNativeTimezone.getLocalTimezone(); await FlutterNativeTimezone.getLocalTimezone();
tz.initializeTimeZones(); tz.initializeTimeZones();
...@@ -172,16 +190,23 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -172,16 +190,23 @@ class _ProfilePageState extends State<ProfilePage> {
var generalNotificationDetails = var generalNotificationDetails =
new NotificationDetails(android: androidDetails, iOS: iSODetails); new NotificationDetails(android: androidDetails, iOS: iSODetails);
// await fltrNotification.periodicallyShow(
// 1,
// 'Dog Status',
// "$dogName's activity level is $status",
// RepeatInterval.everyMinute,
// generalNotificationDetails,
// androidAllowWhileIdle: true);
await fltrNotification.periodicallyShow( await fltrNotification.periodicallyShow(
1, 1,
'Dog Status', 'Dog Status',
"$dogName's activity level is $status", "$dogName resting level is low",
RepeatInterval.everyMinute, RepeatInterval.everyMinute,
generalNotificationDetails, generalNotificationDetails,
androidAllowWhileIdle: true); androidAllowWhileIdle: true);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return loading return loading
...@@ -260,7 +285,8 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -260,7 +285,8 @@ class _ProfilePageState extends State<ProfilePage> {
TableRow( TableRow(
children: [ children: [
ProfileInfoBigCard( ProfileInfoBigCard(
firstText: "0 hrs 0 mins", firstText:
"$restingHrs hr $restingMins mins",
secondText: "Resting", secondText: "Resting",
activity: 3, activity: 3,
icon: Image.asset( icon: Image.asset(
...@@ -269,7 +295,7 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -269,7 +295,7 @@ class _ProfilePageState extends State<ProfilePage> {
), ),
), ),
ProfileInfoBigCard( ProfileInfoBigCard(
firstText: "0 hrs 0 mins", firstText: "",
activity: 4, activity: 4,
secondText: "Barking", secondText: "Barking",
icon: Image.asset( icon: Image.asset(
...@@ -292,7 +318,7 @@ class _ProfilePageState extends State<ProfilePage> { ...@@ -292,7 +318,7 @@ class _ProfilePageState extends State<ProfilePage> {
); );
} }
Future notificationSelected(String payload) async { Future notificationSelected(String payload) async {
showDialog( showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
......
...@@ -85,7 +85,6 @@ class SearchService { ...@@ -85,7 +85,6 @@ class SearchService {
body: body) body: body)
.then((http.Response response) { .then((http.Response response) {
return response; return response;
}); });
return response.body; return response.body;
...@@ -195,6 +194,22 @@ class SearchService { ...@@ -195,6 +194,22 @@ class SearchService {
return response.body; return response.body;
} }
static Future<String> getTotalRestingMinutesPerDay(day, dog) async {
String url = '$ip/getTotalMinutesPerDay';
var body = jsonEncode({"activity": 0, "dog": dog, "date": day});
http.Response response = await http
.post(url,
headers: {
"Content-Type": "application/json",
'authorization': basicAuth
},
body: body)
.then((http.Response response) {
return response;
});
return response.body;
}
static Future<String> getHighlightsPerDay(date) async { static Future<String> getHighlightsPerDay(date) async {
String url = '$ip/highlightsPerDay'; String url = '$ip/highlightsPerDay';
var body = jsonEncode( var body = jsonEncode(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment