Commit d4b61b88 authored by Boteju W.J.M.'s avatar Boteju W.J.M.

@09/21@

parent 8cac7d60
Pipeline #1566 failed with stages
import 'package:flutter/material.dart';
class Background extends StatelessWidget {
class Background extends StatefulWidget {
final Widget child;
const Background({
Key key,
@required this.child,
}) : super(key: key);
@override
_BackgroundState createState() => _BackgroundState();
}
class _BackgroundState extends State<Background> {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
......@@ -17,22 +22,22 @@ class Background extends StatelessWidget {
alignment: Alignment.center,
children: <Widget>[
Positioned(
top: 0,
left: 0,
child: Image.asset(
"assets/images/main_top.png",
width: size.width * 0.35,
),
),
Positioned(
bottom: 0,
right: 0,
top: 50,
left: 25,
child: Image.asset(
"assets/images/login_bottom.png",
width: size.width * 0.4,
"assets/images/pawprint.png",
width: size.width * 0.25,
),
),
child,
// Positioned(
// bottom: 0,
// right: 0,
// // child: Image.asset(
// // "assets/images/login_bottom.png",
// // width: size.width * 0.4,
// // ),
// ),
widget.child,
],
),
);
......
import 'dart:convert';
import 'dart:developer';
import 'package:fitnessapp/Screens/WalkingPatternRecognition/service.dart';
import 'package:flutter/material.dart';
import 'package:fitnessapp/Screens/Login/components/background.dart';
import 'package:fitnessapp/Screens/Signup/signup_screen.dart';
......@@ -6,57 +10,99 @@ import 'package:fitnessapp/components/rounded_button.dart';
import 'package:fitnessapp/components/rounded_input_field.dart';
import 'package:fitnessapp/components/rounded_password_field.dart';
import 'package:flutter_svg/svg.dart';
import 'package:http/http.dart';
import '../../../loading.dart';
class Body extends StatelessWidget {
class Body extends StatefulWidget {
const Body({
Key key,
}) : super(key: key);
@override
_BodyState createState() => _BodyState();
}
class _BodyState extends State<Body> {
bool loading = false;
String token = '';
String username = '';
String password = '';
login() async {
SearchService.login(username, password).then((responseBody) {
dynamic data = jsonDecode(responseBody);
print(data);
setState(() {
token = data['token'];
if (token.length > 0) {
loading = false;
}
});
});
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Background(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"LOGIN",
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(height: size.height * 0.03),
SvgPicture.asset(
"assets/icons/login.svg",
height: size.height * 0.35,
),
SizedBox(height: size.height * 0.03),
RoundedInputField(
hintText: "Your Email",
onChanged: (value) {},
),
RoundedPasswordField(
onChanged: (value) {},
),
RoundedButton(
text: "LOGIN",
press: () {},
),
SizedBox(height: size.height * 0.03),
AlreadyHaveAnAccountCheck(
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return SignUpScreen();
return loading
? Loading()
: Background(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Text(
// "LOGIN",
// style: TextStyle(fontWeight: FontWeight.bold),
// ),
SizedBox(height: size.height * 0.1),
// SvgPicture.asset(
// "assets/icons/login.svg",
// height: size.height * 0.35,
// ),
SizedBox(height: 200),
RoundedInputField(
hintText: "Your Username",
onChanged: (value) {
setState(() {
username = value;
});
},
),
RoundedPasswordField(
onChanged: (value) {
setState(() {
password = value;
});
},
),
RoundedButton(
text: "LOGIN",
press: () {
setState(() {
loading = true;
});
this.login();
},
),
SizedBox(height: size.height * 0.03),
AlreadyHaveAnAccountCheck(
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return SignUpScreen();
},
),
);
},
),
);
},
],
),
),
],
),
),
);
);
}
}
......@@ -66,7 +66,7 @@ class _MainNavigationState extends State<MainNavigation>
height: MediaQuery.of(context).size.height - 80,
child: TabBarView(
controller: _tabController,
children: <Widget>[Home(), Home()],
children: <Widget>[Home(activityId: 1), Home(activityId: 2)],
),
)
],
......
......@@ -46,7 +46,7 @@ class _DailyDetailsScreenState extends State<DailyDetailsScreen> {
});
getActivityNameById();
getTotalMinutes(datee);
getHighlightsPerDay(datee);
// getHighlightsPerDay(datee);
}
getActivityNameById() async {
......@@ -77,6 +77,7 @@ class _DailyDetailsScreenState extends State<DailyDetailsScreen> {
}
getHighlightsPerDay(datee) async {
print(datee);
SearchService.getHighlightsPerDay(datee).then((responseBody) {
dynamic data = jsonDecode(responseBody);
setState(() {
......
import 'package:flutter/material.dart';
import 'Navigation.dart';
import 'package:fitnessapp/globals.dart' as globals;
class Home extends StatefulWidget {
Home({Key key, this.activityId}) : super(key: key);
final int activityId;
@override
_HomeState createState() => _HomeState();
_HomeState createState() => _HomeState(activityId);
}
class _HomeState extends State<Home> {
int activityId = 1;
_HomeState(this.activityId);
double left = 0;
double direction;
double MAX_LEFT = 0;
......@@ -14,6 +20,10 @@ class _HomeState extends State<Home> {
@override
void initState() {
super.initState();
setState(() {
globals.activityId = activityId;
});
}
@override
......
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:fitnessapp/globals.dart' as globals;
class SearchService {
static String ip = 'http://192.168.1.10:8000';
static String ip = 'http://192.168.1.2:8000';
static String username = 'Janadi';
static String password = 'janadi2.';
static String basicAuth =
'Basic ' + base64Encode(utf8.encode('$username:$password'));
//Get Readings Evey Minute
static Future<String> getCurrentActivity() async {
String url = '$ip/getCurrentActivity';
var body = jsonEncode({
"id": 1,
});
//Login
static Future<String> login(username, password) async {
String url = '$ip/auth/';
var body = jsonEncode({"username": username, "password": password});
http.Response response = await http
.post(url,
headers: {
"Content-Type": "application/json",
'authorization': basicAuth
},
body: body)
.then((http.Response response) {
......@@ -32,7 +30,7 @@ class SearchService {
static Future<String> getActivityNameById() async {
String url = '$ip/getActivityNameById';
var body = jsonEncode({
"id": 2,
"id": globals.activityId,
});
http.Response response = await http
.post(url,
......@@ -49,7 +47,8 @@ class SearchService {
static Future<String> getTotalMinutesPerDay(day) async {
String url = '$ip/getTotalMinutesPerDay';
var body = jsonEncode({"activity": 2, "dog": 1, "date": day});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "date": day});
http.Response response = await http
.post(url,
headers: {
......@@ -65,7 +64,8 @@ class SearchService {
static Future<String> getHighlightsPerDay(date) async {
String url = '$ip/highlightsPerDay';
var body = jsonEncode({"activity": 2, "dog": 1, "date": date});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "date": date});
http.Response response = await http
.post(url,
headers: {
......@@ -83,7 +83,8 @@ class SearchService {
static Future<String> getTotalMinutesPerWeek(formattedDate) async {
String url = '$ip/getTotalMinutesPerWeek';
var body = jsonEncode({"activity": 2, "dog": 1, "date": formattedDate});
var body = jsonEncode(
{"activity": globals.activityId, "dog": 1, "date": formattedDate});
http.Response response = await http
.post(url,
headers: {
......@@ -99,7 +100,8 @@ class SearchService {
static Future<String> getTotalMinutesPerDayInWeek(date) async {
String url = '$ip/getTotalMinutesPerDayInWeek';
var body = jsonEncode({"activity": 2, "dog": 1, "date": date});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "date": date});
http.Response response = await http
.post(url,
headers: {
......@@ -116,7 +118,8 @@ class SearchService {
static Future<String> getHighlightsPerWeek(date) async {
String url = '$ip/highlightsPerWeek';
var body = jsonEncode({"activity": 2, "dog": 1, "date": date});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "date": date});
http.Response response = await http
.post(url,
headers: {
......@@ -134,8 +137,12 @@ class SearchService {
static Future<String> getWeeklyDetailsInMonth(year, month) async {
String url = '$ip/getWeeklyDetailsInMonth';
var body =
jsonEncode({"activity": 2, "dog": 1, "year": year, "month": month});
var body = jsonEncode({
"activity": globals.activityId,
"dog": 1,
"year": year,
"month": month
});
http.Response response = await http
.post(url,
headers: {
......@@ -152,7 +159,8 @@ class SearchService {
static Future<String> getTotalMinutesPerMonth(month) async {
String url = '$ip/getTotalMinutesPerMonth';
var body = jsonEncode({"activity": 2, "dog": 1, "month": month});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "month": month});
http.Response response = await http
.post(url,
headers: {
......@@ -169,7 +177,8 @@ class SearchService {
static Future<String> getHighlightsPerMonth(month) async {
String url = '$ip/highlightsPerMonth';
var body = jsonEncode({"activity": 2, "dog": 1, "month": month});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "month": month});
http.Response response = await http
.post(url,
headers: {
......@@ -187,7 +196,8 @@ class SearchService {
static Future<String> getTotalMinutesPerYear(year) async {
String url = '$ip/getTotalMinutesPerYear';
var body = jsonEncode({"activity": 2, "dog": 1, "year": year});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "year": year});
http.Response response = await http
.post(url,
headers: {
......@@ -205,7 +215,7 @@ class SearchService {
static Future<String> getMonthlyDetailsInYear(year) async {
String url = '$ip/getMonthlyDetailsInYear';
var body = jsonEncode({
"activity": 2,
"activity": globals.activityId,
"dog": 1,
"year": year,
});
......@@ -225,7 +235,8 @@ class SearchService {
static Future<String> getHighlightsPerYear(year) async {
String url = '$ip/highlightsPerYear';
var body = jsonEncode({"activity": 2, "dog": 1, "year": year});
var body =
jsonEncode({"activity": globals.activityId, "dog": 1, "year": year});
http.Response response = await http
.post(url,
headers: {
......
import 'package:flutter/material.dart';
//const kPrimaryColor = Color(0xFF6F35A5);
const kPrimaryLightColor = Color(0xFFF1E6FF);
const kPrimaryLightColor = Color(0xF8FFEC);
const kTextColor = Color(0xFF1E2432);
const kTextMediumColor = Color(0xFF53627C);
const kTextLightColor = Color(0xFFACB1C0);
const kPrimaryColor = Color(0xFF0D8E53);
// const kPrimaryColor = Color(0xFF0D8E53);
const kPrimaryColor = Color(0xFF388E3C);
const kBackgroundColor = Color(0xFFFCFCFC);
const kInactiveChartColor = Color(0xFFEAECEF);
\ No newline at end of file
const kInactiveChartColor = Color(0xFFEAECEF);
library my_prj.globals;
int activityId;
import 'package:flutter/material.dart';
import 'package:fitnessapp/Screens/WalkingPatternRecognition/home_page.dart';
// import 'package:fitnessapp/Screens/Login/login_screen.dart';
import 'package:fitnessapp/constants.dart';
void main() => runApp(MyApp());
......@@ -8,7 +10,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Doggy App',
title: 'Dog Behavioural Monitoring System',
theme: ThemeData(
primaryColor: kPrimaryColor,
scaffoldBackgroundColor: Colors.white,
......
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