Commit 75a2b092 authored by Nilupul Jayasekara's avatar Nilupul Jayasekara

Merge branch 'IT19115894' into 'master'

It19115894

See merge request !6
parents 31f6db41 72e11618
No preview for this file type
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "diabeta-web",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
\ No newline at end of file
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
......@@ -22,11 +22,14 @@ if (flutterVersionName == null) {
}
apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......@@ -44,8 +47,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.diabeta_app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
minSdkVersion 21
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
......
{
"project_info": {
"project_number": "247730670466",
"firebase_url": "https://diabeta-e2bfe-default-rtdb.firebaseio.com",
"project_id": "diabeta-e2bfe",
"storage_bucket": "diabeta-e2bfe.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:247730670466:android:4348a6ed394223efa05d9b",
"android_client_info": {
"package_name": "com.example.diabeta_app"
}
},
"oauth_client": [
{
"client_id": "247730670466-ggtm24v92sj9b100iv4tdqe4m2sffj19.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA1ZrNeRH6i2FqLkWfQvdEBJR0glLmLqRU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "247730670466-ggtm24v92sj9b100iv4tdqe4m2sffj19.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "247730670466-tc414ncddkil5kqcqvqrsn7r4nlo2m9u.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.example.diabetaApp"
}
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.diabeta_app">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- For apps with targetSDK=31 (Android 12) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<application
android:label="diabeta_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<service
android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
<receiver
android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmBroadcastReceiver"
android:exported="false"/>
<receiver
android:name="dev.fluttercommunity.plus.androidalarmmanager.RebootBroadcastReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:exported="true"
......@@ -11,6 +30,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
......
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.31'
repositories {
google()
mavenCentral()
......@@ -7,6 +7,9 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.10'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
......
......@@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
......@@ -665,6 +665,11 @@ PODS:
- FirebaseCore (~> 8.0)
- GTMSessionFetcher/Core (~> 1.5)
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
- google_sign_in_ios (0.0.1):
- Flutter
- GoogleSignIn (~> 5.0)
......@@ -758,7 +763,14 @@ PODS:
- nanopb/encode (= 2.30908.0)
- nanopb/decode (2.30908.0)
- nanopb/encode (2.30908.0)
- path_provider_ios (0.0.1):
- Flutter
- printing (1.0.0):
- Flutter
- PromisesObjC (2.1.0)
- shared_preferences_ios (0.0.1):
- Flutter
- Toast (4.0.0)
DEPENDENCIES:
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
......@@ -766,7 +778,12 @@ DEPENDENCIES:
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- printing (from `.symlinks/plugins/printing/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
SPEC REPOS:
trunk:
......@@ -790,6 +807,7 @@ SPEC REPOS:
- Libuv-gRPC
- nanopb
- PromisesObjC
- Toast
EXTERNAL SOURCES:
cloud_firestore:
......@@ -802,8 +820,18 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_storage/ios"
Flutter:
:path: Flutter
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
google_sign_in_ios:
:path: ".symlinks/plugins/google_sign_in_ios/ios"
path_provider_ios:
:path: ".symlinks/plugins/path_provider_ios/ios"
printing:
:path: ".symlinks/plugins/printing/ios"
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"
SPEC CHECKSUMS:
abseil: ebe5b5529fb05d93a8bdb7951607be08b7fa71bc
......@@ -819,7 +847,9 @@ SPEC CHECKSUMS:
FirebaseCoreDiagnostics: 92e07a649aeb66352b319d43bdd2ee3942af84cb
FirebaseFirestore: d7023faff8e1b4fd69d0adbcf18e65129bc03842
FirebaseStorage: 8019af461599b2c3bc61c6a5dbdfa3d2de66a4d9
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
fluttertoast: 16fbe6039d06a763f3533670197d01fc73459037
google_sign_in_ios: ed71c0dbddfba8b1ea9aa210dbda695f46bf51bd
GoogleDataTransport: 629c20a4d363167143f30ea78320d5a7eb8bd940
GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213
......@@ -831,7 +861,11 @@ SPEC CHECKSUMS:
leveldb-library: 50c7b45cbd7bf543c81a468fe557a16ae3db8729
Libuv-gRPC: 55e51798e14ef436ad9bc45d12d43b77b49df378
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
printing: eafa00acb682c0ca029d4d98d0798f55a1e27102
PromisesObjC: 99b6f43f9e1044bd87a95a60beff28c2c44ddb72
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
PODFILE CHECKSUM: fe0e1ee7f3d1f7d00b11b474b62dd62134535aea
......
......@@ -361,7 +361,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
......@@ -438,7 +438,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
......@@ -487,7 +487,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
......
......@@ -7,6 +7,9 @@ import Flutter
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
......
......@@ -43,5 +43,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:247730670466:ios:b33e66d123772576a05d9b",
"FIREBASE_PROJECT_ID": "diabeta-e2bfe",
"GCM_SENDER_ID": "247730670466"
}
\ No newline at end of file
......@@ -21,12 +21,12 @@ class _CategoryCardState extends State<CategoryCard> {
child: Column(
children: [
Container(
height: 150,
height: MediaQuery.of(context).size.height/5,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(widget.imgPath),
fit: BoxFit.fill,
fit: BoxFit.fitWidth,
alignment: Alignment.topCenter,
),
borderRadius: const BorderRadius.only(
......
import 'package:flutter/material.dart';
const kPrimaryColor = Colors.teal;
const text_style =
TextStyle(color: Colors.black, fontSize: 12, fontWeight: FontWeight.normal);
const kSecondaryColor = Color(0xFFFF7F50);
enum QuesType{
enum QuesType {
withTwoButton,
withThreeButton,
withSlider,
......@@ -18,7 +21,7 @@ const mealTimeList = [
'Fasting'
];
IconData getMealIconByName (String name){
IconData getMealIconByName(String name) {
switch (name) {
case 'Breakfast':
return Icons.free_breakfast;
......@@ -36,5 +39,5 @@ IconData getMealIconByName (String name){
return Icons.no_meals;
default:
return Icons.abc;
}
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/diabetes/screens/quiz_screen1.dart';
import 'package:flutter/material.dart';
import '../screens/diabetes/screens/quiz_screen.dart';
class DiabetesTestType extends StatelessWidget {
final BuildContext buildContext;
const DiabetesTestType({ Key? key , required this.buildContext}) : super(key: key);
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text(
'Select Diabetes Test',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
content:Container(
//height: 50,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(onPressed: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const QuizScreen()),
);
}, child: Text("Test 1")),
TextButton(onPressed: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const QuizScreen1()),
);
}, child: Text("Test 2")),
],
),
),
);
}
}
\ No newline at end of file
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/log_count.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class MenuCard extends StatefulWidget {
const MenuCard({Key? key}) : super(key: key);
MenuCard({Key? key, required this.logCount}) : super(key: key);
LogCount logCount;
@override
State<MenuCard> createState() => _MenuCardState();
}
......@@ -16,10 +19,19 @@ class _MenuCardState extends State<MenuCard> {
height: 100,
width: double.infinity,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: <Color>[
kPrimaryColor,
// Color.fromARGB(255, 96, 207, 92),
Color.fromARGB(255, 2, 102, 93),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.teal[200],
),
child: getWidgetByIndex(0),
child: getWidgetByIndex(widget.logCount.index),
),
);
}
......@@ -34,11 +46,27 @@ class _MenuCardState extends State<MenuCard> {
const SizedBox(
height: 16,
),
Text('LATEST CHECK 09/05/2022 12:47 PM'),
Text(
'LATEST CHECK ' +
DateFormat('MM/dd/yyyy')
.format(widget.logCount.dateTime ?? DateTime.now()) +
' ' +
DateFormat.jm()
.format(widget.logCount.dateTime ?? DateTime.now()),
style: const TextStyle(
color: Colors.white,
),
),
const SizedBox(
height: 20,
),
const Text('WEEKLY ENTRIES', style: TextStyle(fontWeight: FontWeight.bold,),),
const Text(
'WEEKLY ENTRIES',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 20,
),
......@@ -49,56 +77,317 @@ class _MenuCardState extends State<MenuCard> {
children: [
Column(
children: [
const Text('In Range'),
const Text(
'In Range',
style: const TextStyle(
color: Colors.white,
),
),
Row(
children: [
Icon(
Icons.thumb_up,
size: 30,
color: Colors.green[900],
color: Colors.white,
),
Text(
'2',
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.bold),
widget.logCount.inrange.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
),
Column(
children: [
const Text(
'Below',
style: const TextStyle(
color: Colors.white,
),
),
Row(
children: [
const Icon(
Icons.arrow_downward,
size: 30,
color: kSecondaryColor,
),
Text(
widget.logCount.below.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
),
Column(
children: [
const Text(
'Above',
style: const TextStyle(
color: Colors.white,
),
),
Row(
children: [
const Icon(
Icons.arrow_upward,
size: 30,
color: kSecondaryColor,
),
Text(
widget.logCount.above.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
)
],
),
),
],
);
case 1:
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
height: 16,
),
Text(
'LATEST CHECK ' +
DateFormat('MM/dd/yyyy')
.format(widget.logCount.dateTime ?? DateTime.now()) +
' ' +
DateFormat.jm()
.format(widget.logCount.dateTime ?? DateTime.now()),
style: TextStyle(
color: Colors.white,
),
),
const SizedBox(
height: 20,
),
const Text(
'MONTHLY ENTRIES',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 36),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
const Text('Below'),
const Text(
'In Range',
style: TextStyle(
color: Colors.white,
),
),
Row(
children: [
Icon(
Icons.thumb_up,
size: 30,
color: Colors.white,
),
Text(
widget.logCount.inrange.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
),
Column(
children: [
const Text(
'Below',
style: TextStyle(
color: Colors.white,
),
),
Row(
children: [
const Icon(
Icons.arrow_downward,
size: 30,
color: Colors.red,
color: kSecondaryColor,
),
Text(
'0',
widget.logCount.below.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
),
Column(
children: [
const Text(
'Above',
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.bold),
color: Colors.white,
),
),
Row(
children: [
const Icon(
Icons.arrow_upward,
size: 30,
color: kSecondaryColor,
),
Text(
widget.logCount.above.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
)
],
),
),
],
);
case 2:
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
height: 16,
),
Text(
'LATEST CHECK ' +
DateFormat('MM/dd/yyyy')
.format(widget.logCount.dateTime ?? DateTime.now()) +
' ' +
DateFormat.jm()
.format(widget.logCount.dateTime ?? DateTime.now()),
style: TextStyle(
color: Colors.white,
),
),
const SizedBox(
height: 20,
),
const Text(
'YEARLY ENTRIES',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 36),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
const Text('Above'),
const Text(
'In Range',
style: TextStyle(
color: Colors.white,
),
),
Row(
children: [
Icon(
Icons.arrow_upward,
Icons.thumb_up,
size: 30,
color: Colors.red,
color: Colors.white,
),
Text(
'6',
widget.logCount.inrange.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
),
Column(
children: [
const Text(
'Below',
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.bold),
color: Colors.white,
),
),
Row(
children: [
const Icon(
Icons.arrow_downward,
size: 30,
color: kSecondaryColor,
),
Text(
widget.logCount.below.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
],
),
Column(
children: [
const Text(
'Above',
style: TextStyle(
color: Colors.white,
),
),
Row(
children: [
const Icon(
Icons.arrow_upward,
size: 30,
color: kSecondaryColor,
),
Text(
widget.logCount.above.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
),
......
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyD5IRuR9PAvwRZzbUcLlRXr7iSkHjEobcs',
appId: '1:247730670466:web:5d195e3ccf6f9a05a05d9b',
messagingSenderId: '247730670466',
projectId: 'diabeta-e2bfe',
authDomain: 'diabeta-e2bfe.firebaseapp.com',
databaseURL: 'https://diabeta-e2bfe-default-rtdb.firebaseio.com',
storageBucket: 'diabeta-e2bfe.appspot.com',
measurementId: 'G-HVPDDELR0B',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyA1ZrNeRH6i2FqLkWfQvdEBJR0glLmLqRU',
appId: '1:247730670466:android:4348a6ed394223efa05d9b',
messagingSenderId: '247730670466',
projectId: 'diabeta-e2bfe',
databaseURL: 'https://diabeta-e2bfe-default-rtdb.firebaseio.com',
storageBucket: 'diabeta-e2bfe.appspot.com',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyBcQtXDuf_2PfRMyMWRkfrSgHlaQF2oNwc',
appId: '1:247730670466:ios:b33e66d123772576a05d9b',
messagingSenderId: '247730670466',
projectId: 'diabeta-e2bfe',
databaseURL: 'https://diabeta-e2bfe-default-rtdb.firebaseio.com',
storageBucket: 'diabeta-e2bfe.appspot.com',
iosClientId: '247730670466-tc414ncddkil5kqcqvqrsn7r4nlo2m9u.apps.googleusercontent.com',
iosBundleId: 'com.example.diabetaApp',
);
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/login_screen.dart';
import 'package:diabeta_app/screens/main_screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
......@@ -13,14 +14,17 @@ void main() async{
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
var _currentUser = FirebaseAuth.instance.currentUser;
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: kPrimaryColor,
),
home: const LoginScreen(),
home: _currentUser!= null? MainScreen(): const LoginScreen(),
);
}
}
......
class ReceivedNotification {
ReceivedNotification({
required this.id,
required this.title,
required this.body,
required this.payload,
});
final int id;
final String? title;
final String? body;
final String? payload;
}
\ No newline at end of file
import '../components/constants.dart';
import 'diabetes_ques.dart';
class DiabetesQuizAns{
final int qno;
final String answer;
class DiabeticQuestions{
static List sampleQuiz1 =<DiabetesQues>[
DiabetesQues(qno: 1, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 2, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 25, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 3, question: "What is your hieght?", type: QuesType.withSlider, minValue: 1, maxValue: 200, defaultValue: 150, unit: "cm", subText: "Your Height"),
DiabetesQues(qno: 4, question: "What is your weight?", type: QuesType.withSlider, minValue: 1, maxValue: 200, defaultValue: 70, unit: "Kg", subText: "Your Weight"),
DiabetesQues(qno: 5, question: "Select your blood glucose?", type: QuesType.withSlider, minValue: 1, maxValue: 300, defaultValue: 80, unit: "mg/dL", subText: "Your Blood Pressure"),
DiabetesQues(qno: 6, question: "Select your blood pressure?", type: QuesType.withSlider, minValue: 1, maxValue: 200, defaultValue: 120, unit: "mmHg", subText: "Your Blood Pressure"),
DiabetesQues(qno: 7, question: "Select your insulin level?", type: QuesType.withSlider, minValue: 1, maxValue: 200, defaultValue: 20, unit: "muU/ml", subText: "Your Insulin"),
DiabetesQues(qno: 8, question: "Select your skin thickness?", type: QuesType.withSlider, minValue: 1, maxValue: 50, defaultValue: 20, unit: "mm", subText: "Your Skin Thickness"),
];
DiabetesQuizAns({required this.qno, required this.answer});
static List sampleQuiz2 =<DiabetesQues>[
DiabetesQues(qno: 1, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 2, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 3, question: "Do you have Polyuria?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img: "poliyuria.png", des: 'Polyuria is defined as the frequent passage of large volumes of urine – more than 3 litres a day compared to the normal daily urine output in adults of about 1 to 2 litres.'),
DiabetesQues(qno: 4, question: "Do you have Polydipsia?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img: "polydipsia.png", des: "Polydipsia is the term given to excessive thirst and is one of the initial symptoms of diabetes. It is also usually accompanied by temporary or prolonged dryness of the mouth."),
DiabetesQues(qno: 5, question: "Have you had sudden weight loss?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img:"suddenweightloss.png", des:'Sudden weight loss is a noticeable drop in body weight that occurs even if the person is not trying to lose weight.'),
DiabetesQues(qno: 6, question: "Do you feel Irritability?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img:"irritability.png", des:"Irritability involves feelings of anger or frustration that often arise over even the smallest of things."),
DiabetesQues(qno: 7, question: "Do you have Delayed Healing?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img:"delayedhealing.png", des:" Delayed wound healing is when it takes longer than normal for a wound to heal."),
DiabetesQues(qno: 8, question: "Do you have Partial Paresis?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img:"partialparalisis.png", des: "Partial or incomplete paralysis is when you still have some feeling in, and possibly control over, your paralyzed muscles."),
DiabetesQues(qno: 9, question: "Do you have Alopecia?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img:"alpecia.png", des: " Alopecia areata occurs when the immune system attacks hair follicles and may be brought on by severe stress. The main symptom is hair loss."),
DiabetesQues(qno: 10, question: "Do you have Visual Blurring?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img:"blurredvision.png", des:"Blurred vision refers to a lack of sharpness of vision resulting in the inability to see fine detail."),
];
}
\ No newline at end of file
import '../components/constants.dart';
import 'diabetes_ques.dart';
class DiabeticQuestions{
static List sampleQuiz1 =<DiabetesQues>[
DiabetesQues(qno: 1, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 2, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 3, question: "What is your hieght?", type: QuesType.withSlider, minValue: 1, maxValue: 120, defaultValue: 20, unit: "cm", subText: "Your Height"),
DiabetesQues(qno: 4, question: "What is your weight?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "Kg", subText: "Your Weight"),
DiabetesQues(qno: 5, question: "Select your blood pressure level?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "mmHg", subText: "Your Blood Pressure"),
DiabetesQues(qno: 6, question: "Select your insulin level?", type: QuesType.withSlider, minValue: 1, maxValue: 200, defaultValue: 20, unit: "muU/ml", subText: "Your Insulin"),
];
static List sampleQuiz2 =<DiabetesQues>[
DiabetesQues(qno: 1, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 2, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 3, question: "Do you have Polyuria?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img: "poliyuria.png", des: 'Polyuria is defined as the frequent passage of large volumes of urine – more than 3 litres a day compared to the normal daily urine output in adults of about 1 to 2 litres.'),
DiabetesQues(qno: 4, question: "Do you have Polydipsia?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0, img: "polydipsia.png", des: "Polydipsia is the term given to excessive thirst and is one of the initial symptoms of diabetes. It is also usually accompanied by temporary or prolonged dryness of the mouth."),
DiabetesQues(qno: 5, question: "Have you had sudden weight loss?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 6, question: "Do you feel Irritability?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 7, question: "Do you have Delayed Healing?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 8, question: "Do you have Partial Paresis?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 9, question: "Do you have Alopecia?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 10, question: "Do you have Visual Blurring?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
];
}
\ No newline at end of file
class Exercise{
final String lifestyle, activity, category, diabetes;
Exercise({
required this.lifestyle,
required this.activity,
required this.category,
required this.diabetes
});
}
\ No newline at end of file
import '../components/constants.dart';
import 'diabetes_ques.dart';
class HealthQuestions{
static List kidneyQuiz =<DiabetesQues>[
DiabetesQues(qno: 1, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 2, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 3, question: "What is your hieght?", type: QuesType.withSlider, minValue: 1, maxValue: 120, defaultValue: 20, unit: "cm", subText: "Your Height"),
DiabetesQues(qno: 4, question: "What is your weight?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "Kg", subText: "Your Weight"),
DiabetesQues(qno: 5, question: "Are you taking medicines to any disease?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 6, question: "Has any one in your family had kidney transplant, had kidney failure or been on diagnosis?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 7, question: "Have your urine amount decreased?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 8, question: "Are you having diabetes?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
];
static List eyeQuiz =<DiabetesQues>[
DiabetesQues(qno: 1, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 2, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 3, question: "Select your blood pressure level?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "mmHg", subText: "Your Blood Pressure"),
DiabetesQues(qno: 4, question: "Have you ever had an eye injury or eye surgery?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 5, question: "Have you noticed a changes in your vision over the last 12 months?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 6, question: "Do you have persistent pain in or around the eye?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 7, question: "Are you having diabetes?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
];
static List heartQuiz =<DiabetesQues>[
DiabetesQues(qno: 1, question: "How old are you?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "years", subText: "Your Age"),
DiabetesQues(qno: 2, question: "What is your gender?", type: QuesType.withTwoButton, options: ["Male", "Female"], defaultValue: 0),
DiabetesQues(qno: 3, question: "Select your blood pressure level?", type: QuesType.withSlider, minValue: 1, maxValue: 100, defaultValue: 20, unit: "mmHg", subText: "Your Blood Pressure"),
DiabetesQues(qno: 4, question: "Have you ever had an eye injury or eye surgery?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 5, question: "Have you noticed a changes in your vision over the last 12 months?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 6, question: "Do you have persistent pain in or around the eye?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
DiabetesQues(qno: 7, question: "Are you having diabetes?", type: QuesType.withTwoButton, options: ["Yes", "No"], defaultValue: 0),
];
}
\ No newline at end of file
class LogCount{
final String type;
late DateTime? dateTime;
late int index;
late int inrange;
late int below;
late int above;
LogCount({required this.dateTime, required this.index, required this.type, required this.inrange, required this.below, required this.above});
}
\ No newline at end of file
......@@ -2,8 +2,11 @@ import 'package:card_swiper/card_swiper.dart';
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/components/log_card.dart';
import 'package:diabeta_app/components/menu_card.dart';
import 'package:diabeta_app/model/log_count.dart';
import 'package:diabeta_app/screens/diabetes/screens/glucose_log_screen.dart';
import 'package:diabeta_app/screens/reports/report_screen.dart';
import 'package:diabeta_app/services/glucose_log_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
......@@ -17,29 +20,51 @@ class DashboardScreen extends StatefulWidget {
class _DashboardScreenState extends State<DashboardScreen> {
var glucoseData = <GlucoseData>[];
var entryCountList = <LogCount>[];
late ChartSeriesController _chartSeriesController;
List<SplineAreaWeightData> _chartData = <SplineAreaWeightData>[];
final _currentUser = FirebaseAuth.instance.currentUser;
void initialaizeLineChart() async {
print("Helo");
List data = await GlucoseLogService.getLast10GlucoseRecords('001');
var gdata = <GlucoseData>[];
void getChartData() async {
List<SplineAreaWeightData> _data = <SplineAreaWeightData>[];
List data = await GlucoseLogService.getLast10GlucoseRecords(_currentUser!.uid);
data.forEach((element) {
gdata.add(GlucoseData(
_data.add(SplineAreaWeightData(
DateFormat('MMM d').format(element.dateTime).toString(),
element.glucoseLevel));
});
entryCountList =
await GlucoseLogService.getRecordsCountByTimeFrame(_currentUser!.uid);
setState(() {
glucoseData = gdata;
_chartData = _data;
});
}
// void initialaizeLineChart() async {
// List data = await GlucoseLogService.getLast10GlucoseRecords('001');
// var gdata = <GlucoseData>[];
// data.forEach((element) {
// gdata.add(GlucoseData(
// DateFormat('MMM d').format(element.dateTime).toString(),
// element.glucoseLevel));
// });
// entryCountList = await GlucoseLogService.getRecordsCountByTimeFrame('001');
// setState(() {
// glucoseData = gdata;
// });
// }
@override
void initState() {
initialaizeLineChart();
//initialaizeLineChart();
getChartData();
super.initState();
}
@override
Widget build(BuildContext context) {
var width = MediaQuery.of(context).size.width;
return Scaffold(
floatingActionButton: FloatingActionButton(
backgroundColor: kSecondaryColor,
......@@ -52,23 +77,27 @@ class _DashboardScreenState extends State<DashboardScreen> {
child: const Icon(Icons.add)),
body: ListView(
children: [
Center(
child: Container(
color: Colors.teal[100],
height: 200,
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <LineSeries<GlucoseData, String>>[
LineSeries<GlucoseData, String>(
dataSource: glucoseData,
dataLabelSettings: const DataLabelSettings(
isVisible: true,
textStyle: TextStyle(color: kSecondaryColor)),
xValueMapper: (GlucoseData sales, _) => sales.date,
yValueMapper: (GlucoseData sales, _) => sales.sales),
],
),
),
// Center(
// child: Container(
// color: Colors.teal[100],
// height: 200,
// child: SfCartesianChart(
// primaryXAxis: CategoryAxis(),
// series: <LineSeries<GlucoseData, String>>[
// LineSeries<GlucoseData, String>(
// dataSource: glucoseData,
// dataLabelSettings: const DataLabelSettings(
// isVisible: true,
// textStyle: TextStyle(color: kSecondaryColor)),
// xValueMapper: (GlucoseData sales, _) => sales.date,
// yValueMapper: (GlucoseData sales, _) => sales.sales),
// ],
// ),
// ),
// ),
Padding(
padding: const EdgeInsets.all(8.0),
child: ChartCard(width, "Blood Glucose", _chartData),
),
Container(
height: 200,
......@@ -81,18 +110,24 @@ class _DashboardScreenState extends State<DashboardScreen> {
autoplayDelay: 8000,
onIndexChanged: (index) {},
layout: SwiperLayout.STACK,
pagination: const SwiperPagination(),
pagination: const SwiperPagination(
builder: DotSwiperPaginationBuilder(
color: Colors.grey, activeColor: Colors.white)),
itemBuilder: (BuildContext context, int index) {
return MenuCard();
return entryCountList.length > index
? MenuCard(
logCount: entryCountList.elementAt(index),
)
: Container();
},
),
),
FutureBuilder(
future: GlucoseLogService.getLast10Records('001'),
future: GlucoseLogService.getLast10Records(_currentUser!.uid),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
int length = snapshot.data!.length;
return ListView(
return length >0 ? ListView(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
children: List.generate(
......@@ -117,6 +152,17 @@ class _DashboardScreenState extends State<DashboardScreen> {
);
},
),
): Padding(
padding: const EdgeInsets.only(top: 50.0),
child: Column(
children: [
Container(child: Center(child: Text(" No records, yet.")),),
SizedBox(
height: 8,
),
Container(child: Center(child: Text(" Add your first record.")),),
],
),
);
} else {
return const Center(
......@@ -129,6 +175,131 @@ class _DashboardScreenState extends State<DashboardScreen> {
),
);
}
Container ChartCard(
double width, String title, List<SplineAreaWeightData> chartData) {
return Container(
height: 250,
width: width - 20,
margin: const EdgeInsets.only(top: 20.0),
// width: size.width * 0.85,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: <Color>[
kPrimaryColor,
// Color.fromARGB(255, 96, 207, 92),
Color.fromARGB(255, 2, 102, 93),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
// color: Colors.red[800],
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.4),
blurRadius: 10.0, // soften the shadow
spreadRadius: 1.0, //extend the shadow
)
],
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'Glucose Level',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 17),
),
SizedBox(
height: 10,
),
Container(
height: 200,
child: _chartData.isEmpty
? const Center(
child: Text("No data to display.", style: TextStyle(color: Colors.white),))
: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enablePinching: true,
enableDoubleTapZooming: true,
enablePanning: true,
),
enableAxisAnimation: true,
legend: Legend(isVisible: false, opacity: 0.7),
// title: ChartTitle(text: 'Inflation rate'),
plotAreaBorderWidth: 0,
primaryXAxis: CategoryAxis(
axisLine: AxisLine(
color: Colors.white,
width: 2,
),
labelStyle: TextStyle(color: Colors.white),
isVisible: true,
// maximumLabels: 5,
// interval: 1,
majorGridLines: const MajorGridLines(width: 0),
edgeLabelPlacement: EdgeLabelPlacement.shift),
primaryYAxis: NumericAxis(
axisLine: AxisLine(
color: Colors.white,
width: 2,
),
labelStyle: TextStyle(color: Colors.white),
isVisible: true,
labelFormat: '{value}',
// axisLine: const AxisLine(width: 0),
majorTickLines: const MajorTickLines(size: 0)),
series: <ChartSeries>[
SplineAreaSeries<SplineAreaWeightData, String>(
// animationDuration: 100,
markerSettings: MarkerSettings(
isVisible: true,
borderColor: Colors.white,
height: 4,
width: 4),
// gradient: LinearGradient(
// colors: <Color>[
// Colors.white.withAlpha(100),
// Colors.white.withAlpha(10),
// ],
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// ),
onRendererCreated:
(ChartSeriesController controller) {
_chartSeriesController = controller;
// setState(() {
// _chartSeriesController = controller;
// });
},
enableTooltip: true,
dataSource: _chartData,
borderColor: Colors.white,
splineType: SplineType.natural,
color: Colors.transparent,
borderWidth: 3,
name: 'mg/dL',
xValueMapper: (SplineAreaWeightData data, _) =>
data.title,
yValueMapper: (SplineAreaWeightData data, _) =>
data.value,
)
],
tooltipBehavior: TooltipBehavior(enable: true),
),
),
],
),
),
);
}
}
class GlucoseData {
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/diabetes_ques.dart';
import 'package:diabeta_app/model/diabetes_questions.dart';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:flutter/material.dart';
class QCard extends StatefulWidget {
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/diabetes_ques.dart';
import 'package:diabeta_app/model/diabetes_questions.dart';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:flutter/material.dart';
class QCard1 extends StatefulWidget {
......@@ -84,12 +84,16 @@ class _QCardState extends State<QCard1> {
): Container(),
widget.ques.qno == DiabeticQuestions.sampleQuiz2.length ?
Padding(
padding: const EdgeInsets.only(top: 100.0),
padding: const EdgeInsets.only(top: 30.0),
child: Center(
child: InkWell(
onTap: (){
widget.callBack();
},
child: InkWell(
onTap: () async{
widget.callBack();
},
child: Container(
decoration: BoxDecoration(
color: kSecondaryColor,
......@@ -102,6 +106,7 @@ class _QCardState extends State<QCard1> {
),
),
),
),
):Container(),
],
),
......@@ -178,14 +183,14 @@ class _QCardState extends State<QCard1> {
InkWell(
onTap: () {
setState(() {
_currentValue = 0;
_currentValue = 1;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue != 1.0 ? kPrimaryColor : Colors.white,
_currentValue == 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
......@@ -197,7 +202,7 @@ class _QCardState extends State<QCard1> {
widget.ques.options![0],
style: TextStyle(
fontSize: 16,
color: _currentValue != 1
color: _currentValue == 1
? Colors.white
: Colors.black),
),
......@@ -209,14 +214,14 @@ class _QCardState extends State<QCard1> {
InkWell(
onTap: () {
setState(() {
_currentValue = 1;
_currentValue = 0;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue == 1.0 ? kPrimaryColor : Colors.white,
_currentValue != 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
......@@ -228,12 +233,12 @@ class _QCardState extends State<QCard1> {
widget.ques.options![1],
style: TextStyle(
fontSize: 16,
color: _currentValue == 1
color: _currentValue != 1
? Colors.white
: Colors.black),
),
)),
)
),
],
)
]);
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/diabetes_ques.dart';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:flutter/material.dart';
class QHealthCard extends StatefulWidget {
const QHealthCard({Key? key, required this.ques, required this.callBack})
: super(key: key);
final DiabetesQues ques;
final Function() callBack;
@override
State<QHealthCard> createState() => _QCardState();
}
class _QCardState extends State<QHealthCard> {
double _currentValue = 0;
void setAnswer(){
HealthQuestions.kidneyQuiz[widget.ques.qno-1].defaultValue = _currentValue;
}
@override
void initState() {
_currentValue = widget.ques.defaultValue!;
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
height: 300,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
widget.ques.qno.toString(),
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
),
const Text(" of "),
Text(HealthQuestions.kidneyQuiz.length.toString())
],
),
const SizedBox(
height: 20,
),
Text(
widget.ques.question,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
getRandomWidget(widget.ques.type),
const SizedBox(
height: 16,
),
widget.ques.img != null ? Image.asset(
"assets/images/"+widget.ques.img!,
width: 80,
height: 80,
): Container(),
widget.ques.des != null ? Text(
widget.ques.des!
): Container(),
widget.ques.qno == HealthQuestions.kidneyQuiz.length ?
Padding(
padding: const EdgeInsets.only(top: 100.0),
child: Center(
child: InkWell(
onTap: (){
widget.callBack();
},
child: InkWell(
onTap: () async{
widget.callBack();
},
child: Container(
decoration: BoxDecoration(
color: kSecondaryColor,
border: Border.all(color: kSecondaryColor),
borderRadius: const BorderRadius.all(Radius.circular(20))
),
height: 40,
width: 120,
child: const Center(child: Text('Predict', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),)),
),
),
),
),
):Container(),
],
),
),
),
);
}
Widget getRandomWidget(QuesType quesType) {
switch (quesType) {
case QuesType.withSlider:
return Column(children: <Widget>[
const SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.ques.subText!),
Row(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(20))),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(_currentValue.toStringAsFixed(0)),
),
),
Text(" " + widget.ques.unit!)
],
)
],
),
SliderTheme(
data: SliderTheme.of(context).copyWith(
trackShape: CustomTrackShape(),
trackHeight: 16,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 12.0),
),
child: Slider(
value: _currentValue,
max: widget.ques.maxValue!,
min: widget.ques.minValue!,
activeColor: kPrimaryColor,
label: _currentValue.round().toString(),
onChanged: (double value) {
setState(() {
_currentValue = value;
setAnswer();
});
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.ques.minValue.toString()),
Text(widget.ques.maxValue.toString()),
],
),
]);
case QuesType.withTwoButton:
return Column(children: <Widget>[
const SizedBox(
height: 16,
),
Row(
children: [
InkWell(
onTap: () {
setState(() {
_currentValue = 1;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue == 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(10))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
widget.ques.options![0],
style: TextStyle(
fontSize: 16,
color: _currentValue == 1
? Colors.white
: Colors.black),
),
)),
),
const SizedBox(
width: 8,
),
InkWell(
onTap: () {
setState(() {
_currentValue = 0;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue != 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(10))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
widget.ques.options![1],
style: TextStyle(
fontSize: 16,
color: _currentValue != 1
? Colors.white
: Colors.black),
),
)),
),
],
)
]);
default:
return const Text("");
}
}
}
class CustomTrackShape extends RoundedRectSliderTrackShape {
@override
Rect getPreferredRect({
required RenderBox parentBox,
Offset offset = Offset.zero,
required SliderThemeData sliderTheme,
bool isEnabled = false,
bool isDiscrete = false,
}) {
final double? trackHeight = sliderTheme.trackHeight;
final double trackLeft = offset.dx;
final double trackTop =
offset.dy + (parentBox.size.height - trackHeight!) / 2;
final double trackWidth = parentBox.size.width;
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/diabetes_ques.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:flutter/material.dart';
class QHealth1Card extends StatefulWidget {
const QHealth1Card({Key? key, required this.ques, required this.callBack})
: super(key: key);
final DiabetesQues ques;
final Function() callBack;
@override
State<QHealth1Card> createState() => _QCardState();
}
class _QCardState extends State<QHealth1Card> {
double _currentValue = 0;
void setAnswer(){
HealthQuestions.eyeQuiz[widget.ques.qno-1].defaultValue = _currentValue;
}
@override
void initState() {
_currentValue = widget.ques.defaultValue!;
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
height: 300,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
widget.ques.qno.toString(),
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
),
const Text(" of "),
Text(HealthQuestions.eyeQuiz.length.toString())
],
),
const SizedBox(
height: 20,
),
Text(
widget.ques.question,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
getRandomWidget(widget.ques.type),
const SizedBox(
height: 16,
),
widget.ques.img != null ? Image.asset(
"assets/images/"+widget.ques.img!,
width: 80,
height: 80,
): Container(),
widget.ques.des != null ? Text(
widget.ques.des!
): Container(),
widget.ques.qno == HealthQuestions.eyeQuiz.length ?
Padding(
padding: const EdgeInsets.only(top: 100.0),
child: Center(
child: InkWell(
onTap: (){
widget.callBack();
},
child: InkWell(
onTap: () async{
widget.callBack();
},
child: Container(
decoration: BoxDecoration(
color: kSecondaryColor,
border: Border.all(color: kSecondaryColor),
borderRadius: const BorderRadius.all(Radius.circular(20))
),
height: 40,
width: 120,
child: const Center(child: Text('Predict', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),)),
),
),
),
),
):Container(),
],
),
),
),
);
}
Widget getRandomWidget(QuesType quesType) {
switch (quesType) {
case QuesType.withSlider:
return Column(children: <Widget>[
const SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.ques.subText!),
Row(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(20))),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(_currentValue.toStringAsFixed(0)),
),
),
Text(" " + widget.ques.unit!)
],
)
],
),
SliderTheme(
data: SliderTheme.of(context).copyWith(
trackShape: CustomTrackShape(),
trackHeight: 16,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 12.0),
),
child: Slider(
value: _currentValue,
max: widget.ques.maxValue!,
min: widget.ques.minValue!,
activeColor: kPrimaryColor,
label: _currentValue.round().toString(),
onChanged: (double value) {
setState(() {
_currentValue = value;
setAnswer();
});
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.ques.minValue.toString()),
Text(widget.ques.maxValue.toString()),
],
),
]);
case QuesType.withTwoButton:
return Column(children: <Widget>[
const SizedBox(
height: 16,
),
Row(
children: [
InkWell(
onTap: () {
setState(() {
_currentValue = 1;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue == 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(10))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
widget.ques.options![0],
style: TextStyle(
fontSize: 16,
color: _currentValue == 1
? Colors.white
: Colors.black),
),
)),
),
const SizedBox(
width: 8,
),
InkWell(
onTap: () {
setState(() {
_currentValue = 0;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue != 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(10))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
widget.ques.options![1],
style: TextStyle(
fontSize: 16,
color: _currentValue != 1
? Colors.white
: Colors.black),
),
)),
),
],
)
]);
default:
return const Text("");
}
}
}
class CustomTrackShape extends RoundedRectSliderTrackShape {
@override
Rect getPreferredRect({
required RenderBox parentBox,
Offset offset = Offset.zero,
required SliderThemeData sliderTheme,
bool isEnabled = false,
bool isDiscrete = false,
}) {
final double? trackHeight = sliderTheme.trackHeight;
final double trackLeft = offset.dx;
final double trackTop =
offset.dy + (parentBox.size.height - trackHeight!) / 2;
final double trackWidth = parentBox.size.width;
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/diabetes_ques.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:flutter/material.dart';
class QHealth3Card extends StatefulWidget {
const QHealth3Card({Key? key, required this.ques, required this.callBack})
: super(key: key);
final DiabetesQues ques;
final Function() callBack;
@override
State<QHealth3Card> createState() => _QCardState();
}
class _QCardState extends State<QHealth3Card> {
double _currentValue = 0;
void setAnswer(){
HealthQuestions.heartQuiz[widget.ques.qno-1].defaultValue = _currentValue;
}
@override
void initState() {
_currentValue = widget.ques.defaultValue!;
super.initState();
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
height: 300,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
widget.ques.qno.toString(),
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
),
const Text(" of "),
Text(HealthQuestions.heartQuiz.length.toString())
],
),
const SizedBox(
height: 20,
),
Text(
widget.ques.question,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
getRandomWidget(widget.ques.type),
const SizedBox(
height: 16,
),
widget.ques.img != null ? Image.asset(
"assets/images/"+widget.ques.img!,
width: 80,
height: 80,
): Container(),
widget.ques.des != null ? Text(
widget.ques.des!
): Container(),
widget.ques.qno == HealthQuestions.heartQuiz.length ?
Padding(
padding: const EdgeInsets.only(top: 100.0),
child: Center(
child: InkWell(
onTap: (){
widget.callBack();
},
child: InkWell(
onTap: () async{
widget.callBack();
},
child: Container(
decoration: BoxDecoration(
color: kSecondaryColor,
border: Border.all(color: kSecondaryColor),
borderRadius: const BorderRadius.all(Radius.circular(20))
),
height: 40,
width: 120,
child: const Center(child: Text('Predict', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold),)),
),
),
),
),
):Container(),
],
),
),
),
);
}
Widget getRandomWidget(QuesType quesType) {
switch (quesType) {
case QuesType.withSlider:
return Column(children: <Widget>[
const SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.ques.subText!),
Row(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(20))),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(_currentValue.toStringAsFixed(0)),
),
),
Text(" " + widget.ques.unit!)
],
)
],
),
SliderTheme(
data: SliderTheme.of(context).copyWith(
trackShape: CustomTrackShape(),
trackHeight: 16,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 12.0),
),
child: Slider(
value: _currentValue,
max: widget.ques.maxValue!,
min: widget.ques.minValue!,
activeColor: kPrimaryColor,
label: _currentValue.round().toString(),
onChanged: (double value) {
setState(() {
_currentValue = value;
setAnswer();
});
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.ques.minValue.toString()),
Text(widget.ques.maxValue.toString()),
],
),
]);
case QuesType.withTwoButton:
return Column(children: <Widget>[
const SizedBox(
height: 16,
),
Row(
children: [
InkWell(
onTap: () {
setState(() {
_currentValue = 1;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue == 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(10))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
widget.ques.options![0],
style: TextStyle(
fontSize: 16,
color: _currentValue == 1
? Colors.white
: Colors.black),
),
)),
),
const SizedBox(
width: 8,
),
InkWell(
onTap: () {
setState(() {
_currentValue = 0;
setAnswer();
});
},
child: Container(
decoration: BoxDecoration(
color:
_currentValue != 1.0 ? kPrimaryColor : Colors.white,
border: Border.all(
color: kPrimaryColor,
),
borderRadius:
const BorderRadius.all(Radius.circular(10))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
widget.ques.options![1],
style: TextStyle(
fontSize: 16,
color: _currentValue != 1
? Colors.white
: Colors.black),
),
)),
),
],
)
]);
default:
return const Text("");
}
}
}
class CustomTrackShape extends RoundedRectSliderTrackShape {
@override
Rect getPreferredRect({
required RenderBox parentBox,
Offset offset = Offset.zero,
required SliderThemeData sliderTheme,
bool isEnabled = false,
bool isDiscrete = false,
}) {
final double? trackHeight = sliderTheme.trackHeight;
final double trackLeft = offset.dx;
final double trackTop =
offset.dy + (parentBox.size.height - trackHeight!) / 2;
final double trackWidth = parentBox.size.width;
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
}
}
......@@ -2,10 +2,10 @@ import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/log_entry.dart';
import 'package:diabeta_app/screens/diabetes/components/b_card.dart';
import 'package:diabeta_app/services/glucose_log_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../../../components/yes_no_model.dart';
class GlucoseLogScreen extends StatefulWidget {
......@@ -24,6 +24,7 @@ class _GlucoseLogScreenState extends State<GlucoseLogScreen> {
final TextEditingController _carbsController = TextEditingController();
final TextEditingController _insulinController = TextEditingController();
final TextEditingController _pillController = TextEditingController();
final _currentUser = FirebaseAuth.instance.currentUser;
int selectedIndex = 0;
DateTime date = DateTime.now();
......@@ -85,7 +86,7 @@ class _GlucoseLogScreenState extends State<GlucoseLogScreen> {
insulinType: null,
pillType: null,
mealType: mealTimeList[selectedIndex],
userId: '001');
userId: _currentUser!.uid);
String result = await GlucoseLogService.addRecord(logEntry);
return result != "";
......@@ -111,7 +112,7 @@ class _GlucoseLogScreenState extends State<GlucoseLogScreen> {
insulinType: null,
pillType: null,
mealType: mealTimeList[selectedIndex],
userId: '001');
userId: _currentUser!.uid);
return await GlucoseLogService.editRecord(logEntry, widget.logEntry!.id);
}
......
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../../../components/log_card.dart';
import '../../../services/glucose_log_service.dart';
import 'glucose_log_screen.dart';
class LogbookScreen extends StatefulWidget {
const LogbookScreen({Key? key}) : super(key: key);
LogbookScreen({Key? key, required this.period}) : super(key: key);
String period = "This year";
@override
State<LogbookScreen> createState() => _LogbookScreenState();
}
class _LogbookScreenState extends State<LogbookScreen> {
final _currentUser = FirebaseAuth.instance.currentUser;
@override
Widget build(BuildContext context) {
return Container(
child: FutureBuilder(
future: GlucoseLogService.getAllRecords('001'),
future: GlucoseLogService.getRecordsByTimeFrame(_currentUser!.uid, widget.period),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
int length = snapshot.data!.length;
return ListView(
return length>0 ? ListView(
shrinkWrap: true,
children: List.generate(length, (index) {
return Center(
......@@ -41,7 +44,7 @@ class _LogbookScreenState extends State<LogbookScreen> {
),
);
}),
);
): Container(child: Center(child: Text("No data to display."),),);
} else {
return const Center(
child: CircularProgressIndicator(),
......
import 'dart:typed_data';
import 'package:diabeta_app/services/glucose_log_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import "package:flutter/material.dart";
import 'package:intl/intl.dart';
import 'package:pdf/pdf.dart';
import 'package:printing/printing.dart';
import 'package:pdf/widgets.dart' as pw;
class PrintLogScreen extends StatelessWidget {
PrintLogScreen({Key? key, required this.period}) : super(key: key);
String period;
final _currentUser = FirebaseAuth.instance.currentUser;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Logbook")),
body: PdfPreview(
build: (format) => _generatePdf(format),
),
);
}
Future<Uint8List> _generatePdf(PdfPageFormat format) async {
final pdf = pw.Document(version: PdfVersion.pdf_1_5, compress: true);
var list = await GlucoseLogService.getRecordsByTimeFrame(_currentUser!.uid, period);
pdf.addPage(pw.MultiPage(
pageFormat: format,
maxPages: 20,
build: (pw.Context context) {
return getBarcodes(list);
}));
return pdf.save();
}
List<pw.Widget> getBarcodes(var list) {
List<pw.Widget> barcodeList = [];
barcodeList.add(pw.Table(
columnWidths: {
0: const pw.FlexColumnWidth(3),
1: const pw.FlexColumnWidth(3),
2: const pw.FlexColumnWidth(2),
3: const pw.FlexColumnWidth(2),
4: const pw.FlexColumnWidth(2),
5: const pw.FlexColumnWidth(2),
},
border: pw.TableBorder.all(width: 1.0, color: PdfColors.teal),
children: [
pw.TableRow(children: [
pw.Text(
"Date",
textScaleFactor: 1.5,
textAlign: pw.TextAlign.center,
),
pw.Text(
"Time",
textScaleFactor: 1.5,
textAlign: pw.TextAlign.center,
),
pw.Text("Glucose", textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
pw.Text("Carbs",textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
pw.Text("Insulin",textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
pw.Text("Pill",textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
]),
],
));
list.forEach((entry) => barcodeList.add(pw.Table(
columnWidths: {
0: const pw.FlexColumnWidth(3),
1: const pw.FlexColumnWidth(3),
2: const pw.FlexColumnWidth(2),
3: const pw.FlexColumnWidth(2),
4: const pw.FlexColumnWidth(2),
5: const pw.FlexColumnWidth(2),
},
border: pw.TableBorder.all(width: 1.0, color: PdfColors.teal),
children: [
pw.TableRow(children: [
pw.Text(
DateFormat('yyyy. MM. dd').format(entry.dateTime).toString(),
textAlign: pw.TextAlign.center,
textScaleFactor: 1.5,
),
pw.Text(
formatTimeOfDay(TimeOfDay.fromDateTime(entry.dateTime))
.toString(),
textAlign: pw.TextAlign.center,
textScaleFactor: 1.5,
),
pw.Text(entry.glucoseLevel == null ? "":entry.glucoseLevel.toString() ,textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
pw.Text(entry.carbs == null ? "":entry.carbs.toString(),textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
pw.Text(entry.insulin == null ? "":entry.insulin.toString(),textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
pw.Text(entry.pill == null ? "":entry.pill.toString(),textAlign: pw.TextAlign.center, textScaleFactor: 1.5),
]),
],
)));
return barcodeList;
}
String formatTimeOfDay(TimeOfDay tod) {
final now = DateTime.now();
final dt = DateTime(now.year, now.month, now.day, tod.hour, tod.minute);
final format = DateFormat.jm(); //"6:00 AM"
return format.format(dt);
}
}
// ignore_for_file: public_member_api_docs
import 'dart:typed_data';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
class PrintScreen extends StatelessWidget {
const PrintScreen({Key? key, required this.comment, required this.prediction, required this.riskScore}) : super(key: key);
final String comment;
final bool prediction;
final double riskScore;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Prediction Result")),
body: PdfPreview(
build: (format) => _generatePdf(format),
),
);
}
Future<Uint8List> _generatePdf(PdfPageFormat format) async {
final pdf = pw.Document(version: PdfVersion.pdf_1_5, compress: true);
pdf.addPage(
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (context) {
return pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Container(
width: double.infinity,
color: PdfColors.teal100,
child: pw.Padding(
padding: const pw.EdgeInsets.all(8),
child: pw.Text("Diabetes Prediction Result",
style: pw.TextStyle(
fontSize: 24, fontWeight: pw.FontWeight.bold)),
),
),
pw.SizedBox(height: 24),
pw.Text("1. " + DiabeticQuestions.sampleQuiz1[0].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
DiabeticQuestions.sampleQuiz1[0].defaultValue == 0
? " Male"
: " Female",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("2. " + DiabeticQuestions.sampleQuiz1[1].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
DiabeticQuestions.sampleQuiz1[1].defaultValue
.toStringAsFixed(0) +
" years",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("3. " + DiabeticQuestions.sampleQuiz1[2].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
(DiabeticQuestions.sampleQuiz1[2].defaultValue / 100.00)
.toStringAsFixed(2) +
" m",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("4. " + DiabeticQuestions.sampleQuiz1[3].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
(DiabeticQuestions.sampleQuiz1[3].defaultValue)
.toStringAsFixed(0) +
" Kg",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("5. " + DiabeticQuestions.sampleQuiz1[4].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
(DiabeticQuestions.sampleQuiz1[4].defaultValue)
.toStringAsFixed(0) +
" mg/dL",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("6. " + DiabeticQuestions.sampleQuiz1[5].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
(DiabeticQuestions.sampleQuiz1[5].defaultValue)
.toStringAsFixed(0) +
" mmHg",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("7. " + DiabeticQuestions.sampleQuiz1[6].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
(DiabeticQuestions.sampleQuiz1[6].defaultValue)
.toStringAsFixed(0) +
" muU/ml",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 8),
pw.Text("8. " + DiabeticQuestions.sampleQuiz1[7].question,
style: const pw.TextStyle(fontSize: 18)),
pw.SizedBox(height: 4),
pw.Text(
" " +
(DiabeticQuestions.sampleQuiz1[7].defaultValue)
.toStringAsFixed(0) +
" mm",
style:
const pw.TextStyle(fontSize: 18, color: PdfColors.teal)),
pw.SizedBox(height: 18),
pw.Container(
color: PdfColors.teal100,
child: pw.Padding(
padding: const pw.EdgeInsets.all(8),
child: pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Text("Test Result",
style: pw.TextStyle(
fontSize: 20, fontWeight: pw.FontWeight.bold)),
pw.SizedBox(height: 8),
pw.Row(children: [
pw.Text("Diabetes Status : ",
style: const pw.TextStyle(
fontSize: 18,
)),
prediction ? pw.Text("Positive",
style: pw.TextStyle(
fontSize: 18,
fontWeight: pw.FontWeight.bold,
color: PdfColors.red900
)):pw.Text("Negative",
style: pw.TextStyle(
fontSize: 18,
fontWeight: pw.FontWeight.bold,
color: PdfColors.green900
))
]),
pw.SizedBox(height: 4),
pw.Row(children: [
pw.Text("Risk Score : ",
style: const pw.TextStyle(
fontSize: 18,
)),
pw.Text(riskScore.toStringAsFixed(2)+ "%",
style: const pw.TextStyle(
fontSize: 18,
))
]),
pw.SizedBox(height: 8),
pw.Text("Comment : ",
style: const pw.TextStyle(
fontSize: 18,
)),
pw.SizedBox(height: 4),
pw.Text(comment,
style: const pw.TextStyle(
fontSize: 18,
))
],
),
),
),
],
);
},
),
);
return pdf.save();
}
}
// ignore_for_file: public_member_api_docs
import 'dart:typed_data';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
class PrintScreen1 extends StatelessWidget {
const PrintScreen1(
{Key? key,
required this.comment,
required this.prediction,
required this.riskScore})
: super(key: key);
final String comment;
final bool prediction;
final double riskScore;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Prediction Result")),
body: PdfPreview(
build: (format) => _generatePdf(format),
),
);
}
Future<Uint8List> _generatePdf(PdfPageFormat format) async {
final pdf = pw.Document(version: PdfVersion.pdf_1_5, compress: true);
pdf.addPage(
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (context) {
return pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Container(
width: double.infinity,
color: PdfColors.teal100,
child: pw.Padding(
padding: const pw.EdgeInsets.all(8),
child: pw.Text("Prediabetes Prediction Result",
style: pw.TextStyle(
fontSize: 24, fontWeight: pw.FontWeight.bold)),
),
),
pw.SizedBox(height: 24),
pw.Row(children: [
pw.Text("1. " + DiabeticQuestions.sampleQuiz2[0].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[0].defaultValue == 1
? " Male"
: " Female",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("2. " + DiabeticQuestions.sampleQuiz2[1].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
" " +
DiabeticQuestions.sampleQuiz2[1].defaultValue
.toStringAsFixed(0) +
" years",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("3. " + DiabeticQuestions.sampleQuiz2[2].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[2].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 8),
pw.Row(children: [
pw.Text("4. " + DiabeticQuestions.sampleQuiz2[3].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[3].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("5. " + DiabeticQuestions.sampleQuiz2[4].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[4].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("6. " + DiabeticQuestions.sampleQuiz2[5].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[5].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("7. " + DiabeticQuestions.sampleQuiz2[6].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[6].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("8. " + DiabeticQuestions.sampleQuiz2[7].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[7].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("9. " + DiabeticQuestions.sampleQuiz2[8].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[8].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 12),
pw.Row(children: [
pw.Text("10. " + DiabeticQuestions.sampleQuiz2[9].question,
style: const pw.TextStyle(fontSize: 18)),
pw.Text(
DiabeticQuestions.sampleQuiz2[9].defaultValue == 1
? " Yes"
: " No",
style: const pw.TextStyle(
fontSize: 18, color: PdfColors.teal)),
]),
pw.SizedBox(height: 20),
pw.Container(
color: PdfColors.teal100,
child: pw.Padding(
padding: const pw.EdgeInsets.all(8),
child: pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: [
pw.Text("Test Result",
style: pw.TextStyle(
fontSize: 20, fontWeight: pw.FontWeight.bold)),
pw.SizedBox(height: 8),
pw.Row(children: [
pw.Text("Diabetes Status : ",
style: const pw.TextStyle(
fontSize: 18,
)),
prediction
? pw.Text("Positive",
style: pw.TextStyle(
fontSize: 18,
fontWeight: pw.FontWeight.bold,
color: PdfColors.red900))
: pw.Text("Negative",
style: pw.TextStyle(
fontSize: 18,
fontWeight: pw.FontWeight.bold,
color: PdfColors.green900))
]),
pw.SizedBox(height: 4),
pw.Row(children: [
pw.Text("Risk Score : ",
style: const pw.TextStyle(
fontSize: 18,
)),
pw.Text(riskScore.toStringAsFixed(2) + "%",
style: const pw.TextStyle(
fontSize: 18,
))
]),
pw.SizedBox(height: 8),
pw.Text("Comment : ",
style: const pw.TextStyle(
fontSize: 18,
)),
pw.SizedBox(height: 4),
pw.Text(comment,
style: const pw.TextStyle(
fontSize: 18,
))
],
),
),
),
],
);
},
),
);
return pdf.save();
}
}
import 'dart:convert';
import 'package:diabeta_app/components/constants.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card.dart';
import 'package:diabeta_app/screens/diabetes/screens/print_screen.dart';
import 'package:flutter/material.dart';
import 'package:loading_animations/loading_animations.dart';
import '../../../model/diabetes_questions.dart';
import '../../../model/diabetes_ques_ans.dart';
import '../../../services/diabates_predict_service.dart';
import '../components/q_card.dart';
class QuizScreen extends StatefulWidget {
const QuizScreen({Key? key}) : super(key: key);
......@@ -15,11 +17,28 @@ class QuizScreen extends StatefulWidget {
class _QuizScreenState extends State<QuizScreen> {
bool isLoading = false;
bool isResult = false;
bool isPositive = false;
double riskScore = 0;
final String positiveMsg ="Based on your score, you are likely to have diabetes. Seeing your doctor is the critical next step to determining if you have diabetes.";
final negativeMsg = "Based on your risk score, your diabetes risk is low, continue having a healty life style.";
void setResult(){
void setResult() async {
setState(() {
isLoading = true;
});
String result = await DiabatesPredictService.getDiabatesPrediction();
setState(() {
riskScore = jsonDecode(result)['probability'] * 100;
if (jsonDecode(result)['result'] == 0) {
isPositive = false;
} else {
isPositive = true;
}
isResult = true;
});
}
@override
......@@ -27,9 +46,8 @@ class _QuizScreenState extends State<QuizScreen> {
return Scaffold(
backgroundColor: Colors.teal[100],
appBar: AppBar(
title: const Text("Diabetes Prediction"),
title: const Text("Diabates Prediction"),
centerTitle: true,
backgroundColor: kPrimaryColor,
),
body: !isLoading
? Container(
......@@ -43,11 +61,14 @@ class _QuizScreenState extends State<QuizScreen> {
layout: SwiperLayout.STACK,
pagination: const SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
return QCard(ques: DiabeticQuestions.sampleQuiz1[index], callBack: setResult);
return QCard(
ques: DiabeticQuestions.sampleQuiz1[index],
callBack: setResult);
},
),
)
: Column(
: !isResult
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LoadingFlipping.circle(
......@@ -62,6 +83,121 @@ class _QuizScreenState extends State<QuizScreen> {
),
const Text('Loading result...')
],
)
: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 50),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset:
const Offset(0, 3), // changes position of shadow
),
],
),
height: 400,
width: 600,
child: Column(
children: [
Image.asset(
"assets/images/diabetsresult.png",
width: 200,
height: 180,
),
Padding(
padding:
const EdgeInsets.only(bottom: 16.0, left: 24),
child: Row(
children: [
const Text(
"Your Risk Score : ",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
riskScore <= 50
? Text(
riskScore.toStringAsFixed(2) + "%",
style: const TextStyle(
color: kPrimaryColor,
fontSize: 18,
fontWeight: FontWeight.bold),
)
: Text(
riskScore.toStringAsFixed(2) + "%",
style: TextStyle(
color: Colors.red[400],
fontSize: 18,
fontWeight: FontWeight.bold),
)
],
),
),
isPositive
? Padding(
padding:
const EdgeInsets.only(left: 24.0, right: 24.0),
child: Text(
positiveMsg
),
)
: Padding(
padding:
const EdgeInsets.only(left: 24.0, right: 24.0),
child: Text(
negativeMsg
),
),
const SizedBox(
height: 20,
),
Padding(
padding:
const EdgeInsets.only(left: 24.0, right: 24.0),
child: Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 16.0),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PrintScreen(
prediction: isPositive,
riskScore: riskScore,
comment: isPositive ? positiveMsg : negativeMsg,
)),
);
},
child: Container(
height: 40,
width: 150,
decoration: const BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
child: const Center(
child: Text(
'DOWNLOAD',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
),
),
),
)
],
),
),
),
);
}
......
import 'dart:convert';
import 'package:diabeta_app/components/constants.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card1.dart';
import 'package:diabeta_app/screens/diabetes/screens/print_screen1.dart';
import 'package:flutter/material.dart';
import 'package:loading_animations/loading_animations.dart';
import '../../../model/diabetes_questions.dart';
import '../../../model/diabetes_ques_ans.dart';
import '../../../services/diabates_predict_service.dart';
class QuizScreen1 extends StatefulWidget {
const QuizScreen1({Key? key}) : super(key: key);
......@@ -16,11 +18,30 @@ class QuizScreen1 extends StatefulWidget {
class _QuizScreenState extends State<QuizScreen1> {
bool isLoading = false;
bool isResult = false;
bool isPositive = false;
double riskScore = 0;
void setResult(){
String positiveMsg =
"Based on your score, you are likely to have prediabetes. Seeing your doctor is the critical next step to determining if you have prediabetes.";
String negativeMsg =
"Based on your risk score, your prediabetes risk is low, continue having a healty life style.";
void setResult() async {
setState(() {
isLoading = true;
});
String result = await DiabatesPredictService.getPrediabatesPrediction();
setState(() {
riskScore = jsonDecode(result)['probability'] * 100;
if (jsonDecode(result)['result'] == 0) {
isPositive = false;
} else {
isPositive = true;
}
isResult = true;
});
}
@override
......@@ -28,7 +49,7 @@ class _QuizScreenState extends State<QuizScreen1> {
return Scaffold(
backgroundColor: Colors.teal[100],
appBar: AppBar(
title: const Text("Diabetes Prediction"),
title: const Text("Prediabates Prediction"),
centerTitle: true,
backgroundColor: kPrimaryColor,
),
......@@ -44,11 +65,14 @@ class _QuizScreenState extends State<QuizScreen1> {
layout: SwiperLayout.STACK,
pagination: const SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
return QCard1(ques: DiabeticQuestions.sampleQuiz2[index], callBack: setResult);
return QCard1(
ques: DiabeticQuestions.sampleQuiz2[index],
callBack: setResult);
},
),
)
: Column(
: !isResult
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LoadingFlipping.circle(
......@@ -63,6 +87,118 @@ class _QuizScreenState extends State<QuizScreen1> {
),
const Text('Loading result...')
],
)
: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 50),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset:
const Offset(0, 3), // changes position of shadow
),
],
),
height: 400,
width: 600,
child: Column(
children: [
Image.asset(
"assets/images/diabetsresult.png",
width: 200,
height: 180,
),
Padding(
padding:
const EdgeInsets.only(bottom: 16.0, left: 24),
child: Row(
children: [
const Text(
"Your Risk Score : ",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
riskScore <= 50
? Text(
riskScore.toString() + "%",
style: const TextStyle(
color: kPrimaryColor,
fontSize: 18,
fontWeight: FontWeight.bold),
)
: Text(
riskScore.toString() + "%",
style: TextStyle(
color: Colors.red[400],
fontSize: 18,
fontWeight: FontWeight.bold),
)
],
),
),
isPositive
? Padding(
padding: const EdgeInsets.only(
left: 24.0, right: 24.0),
child: Text(positiveMsg),
)
: Padding(
padding: const EdgeInsets.only(
left: 24.0, right: 24.0),
child: Text(negativeMsg),
),
const SizedBox(
height: 20,
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PrintScreen1(
prediction: isPositive,
riskScore: riskScore,
comment: isPositive
? positiveMsg
: negativeMsg,
)),
);
},
child: Padding(
padding:
const EdgeInsets.only(left: 24.0, right: 24.0),
child: Padding(
padding:
const EdgeInsets.only(top: 8.0, bottom: 16.0),
child: Container(
height: 40,
width: 150,
decoration: const BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
child: const Center(
child: Text(
'DOWNLOAD',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
),
),
),
),
],
),
),
),
);
}
......
import 'package:diabeta_app/model/exercise_cal.dart';
import 'package:diabeta_app/screens/exercise/components/exercise_cal_card.dart';
import 'package:diabeta_app/screens/food/components/food_cal_card.dart';
import 'package:diabeta_app/services/exercise_calc_service.dart';
import 'package:diabeta_app/services/exercise_service.dart';
import 'package:diabeta_app/services/food_calc_service.dart';
import "package:flutter/material.dart";
import 'package:outline_search_bar/outline_search_bar.dart';
......@@ -45,7 +45,7 @@ class _ExersiceCalculatorScreenState extends State<ExersiceCalculatorScreen> {
),
_query != ""
? FutureBuilder(
future: ExerciseCalcService.getExerciseDetails(_query),
future: ExerciseService.getExerciseDetails(_query),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
int length = snapshot.data!.length;
......@@ -72,10 +72,10 @@ class _ExersiceCalculatorScreenState extends State<ExersiceCalculatorScreen> {
),
Container(
height: 150,
width: 150,
width: 170,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/search.jpg"),
image: AssetImage("assets/images/search.png"),
fit: BoxFit.fill,
alignment: Alignment.topCenter,
),
......@@ -85,6 +85,9 @@ class _ExersiceCalculatorScreenState extends State<ExersiceCalculatorScreen> {
),
child: Center(),
),
const SizedBox(
height: 16,
),
const Text("Search for exercises", style: TextStyle(fontSize: 16, color: Colors.black38),)
],
),
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/exercise/exercise_calculator_screen.dart';
import 'package:diabeta_app/screens/food/food_calculator_screen.dart';
import 'package:diabeta_app/screens/food/food_recommendation_screen.dart';
import 'package:diabeta_app/screens/exercise/exercise_recommendation_screen.dart';
import 'package:flutter/material.dart';
class ExerciseMainScreen extends StatefulWidget {
......@@ -33,9 +32,9 @@ class _ExerciseMainScreenState extends State<ExerciseMainScreen> {
},
child: Container(
decoration: BoxDecoration(
border: const Border(
top: BorderSide(width: 1, color: Colors.white),
right: BorderSide(width: 1, color: Colors.white)),
// border: const Border(
// top: BorderSide(width: 1, color: Colors.white),
// right: BorderSide(width: 1, color: Colors.white)),
color: selectedIndex == 0 ? Colors.teal[300] : kPrimaryColor,
),
height: 50,
......@@ -54,8 +53,8 @@ class _ExerciseMainScreenState extends State<ExerciseMainScreen> {
},
child: Container(
decoration: BoxDecoration(
border: const Border(
top: BorderSide(width: 1, color: Colors.white)),
// border: const Border(
// top: BorderSide(width: 1, color: Colors.white)),
color: selectedIndex == 1 ? Colors.teal[300] : kPrimaryColor,
),
height: 50,
......@@ -69,7 +68,7 @@ class _ExerciseMainScreenState extends State<ExerciseMainScreen> {
),
selectedIndex == 0 ?
const ExersiceCalculatorScreen():
const FoodRecommendationScreen()
const ExerciseRecommendationScreen()
],
);
}
......
import 'dart:convert';
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/exercise.dart';
import 'package:diabeta_app/services/exercise_service.dart';
import 'package:flutter/material.dart';
import 'package:dropdown_button2/dropdown_button2.dart';
class ExerciseRecommendationScreen extends StatefulWidget {
const ExerciseRecommendationScreen({Key? key}) : super(key: key);
@override
State<ExerciseRecommendationScreen> createState() =>
_ExerciseRecommendationScreenState();
}
class _ExerciseRecommendationScreenState
extends State<ExerciseRecommendationScreen> {
final List<String> diabetesList = [
'Prediabetes',
'Diabetes',
];
bool isLoading = false;
final List<String> lifeStyleList = ['Yoga', 'Gym'];
final List<String> activityList = [
'Sedentary',
'Light Exercise',
'Moderate Exercise',
'Very Active',
];
List<String> categoryList = [];
final List<String> categoryList1 = [
'Cardio',
'Legs+Abs',
'Upper',
'Stretching '
];
final List<String> categoryList2 = [
'Cardio',
'Yoga_Poses',
'Meditation',
'Stretching '
];
String lifestyle = "", activity = "", category = "", diabetes = "";
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Life Style :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: lifeStyleList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select life style.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
if (value == "Gym") {
setState(() {
categoryList = categoryList1;
});
} else {
setState(() {
categoryList = categoryList2;
});
}
},
onSaved: (value) {
lifestyle = value.toString();
},
),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Category :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: categoryList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select category.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
},
onSaved: (value) {
category = value.toString();
},
),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Activity Level :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: activityList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select activity level.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
},
onSaved: (value) {
activity = value.toString().replaceAll(' ', '');
},
),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Diabetes Type :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: diabetesList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select diabetes type.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
},
onSaved: (value) {
diabetes = value.toString();
},
),
const SizedBox(
height: 24,
),
!isLoading
? InkWell(
onTap: () async {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
setState(() {
isLoading = true;
});
Exercise exercise = Exercise(
lifestyle: lifestyle,
activity: activity,
category: category,
diabetes: diabetes);
var list = await ExerciseService
.getExerciseRecommendationList(exercise);
if (list == "") {
setState(() {
isLoading = false;
});
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text("Exercises not found."),
duration: Duration(milliseconds: 2000),
));
} else {
if (jsonDecode(list).length > 0) {
setState(() {
isLoading = false;
});
showBottomSheet(jsonDecode(list));
}
}
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: kPrimaryColor,
),
height: 45,
width: double.infinity,
child: const Center(
child: Text(
"GENERATE",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16),
)),
),
)
: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.teal[200],
),
height: 45,
width: double.infinity,
child: const Center(
child: Text(
"GENERATING...",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16),
)),
),
],
),
),
],
),
);
}
void showBottomSheet(var exercises) {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Container(
height: 500,
decoration: BoxDecoration(
color: Colors.teal[100],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Column(
children: [
Container(
decoration: const BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
height: 50,
width: double.infinity,
child: const Center(
child: Text(
"Exercises",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white),
)),
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("1. " + exercises[0]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("2. " + exercises[1]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("3. " + exercises[2]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("4. " + exercises[3]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("5. " + exercises[4]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("6. " + exercises[5]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("7. " + exercises[6]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("8. " + exercises[7]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("9. " + exercises[8]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("10. " + exercises[9]),
),
const Divider(),
],
),
],
),
);
},
);
},
);
}
}
......@@ -70,10 +70,10 @@ class _FoodCalculatorScreenState extends State<FoodCalculatorScreen> {
),
Container(
height: 150,
width: 150,
width: 170,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/search.jpg"),
image: AssetImage("assets/images/search.png"),
fit: BoxFit.fill,
alignment: Alignment.topCenter,
),
......@@ -83,6 +83,9 @@ class _FoodCalculatorScreenState extends State<FoodCalculatorScreen> {
),
child: Center(),
),
const SizedBox(
height: 16,
),
const Text("Search for foods", style: TextStyle(fontSize: 16, color: Colors.black38),)
],
),
......
......@@ -35,9 +35,9 @@ class _FoodMainScreenState extends State<FoodMainScreen> {
},
child: Container(
decoration: BoxDecoration(
border: const Border(
top: BorderSide(width: 1, color: Colors.white),
right: BorderSide(width: 1, color: Colors.white)),
// border: const Border(
// top: BorderSide(width: 1, color: Colors.white),
// right: BorderSide(width: 1, color: Colors.white)),
color: selectedIndex == 0 ? Colors.teal[300] : kPrimaryColor,
),
height: 50,
......@@ -56,8 +56,8 @@ class _FoodMainScreenState extends State<FoodMainScreen> {
},
child: Container(
decoration: BoxDecoration(
border: const Border(
top: BorderSide(width: 1, color: Colors.white)),
// border: const Border(
// top: BorderSide(width: 1, color: Colors.white)),
color: selectedIndex == 1 ? Colors.teal[300] : kPrimaryColor,
),
height: 50,
......
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import '../../components/constants.dart';
class FoodRecommendationScreen extends StatefulWidget {
const FoodRecommendationScreen({ Key? key }) : super(key: key);
......@@ -8,10 +10,480 @@ class FoodRecommendationScreen extends StatefulWidget {
}
class _FoodRecommendationScreenState extends State<FoodRecommendationScreen> {
final List<String> diabetesList = [ ];
bool isLoading = false;
final List<String> lifeStyleList = [];
final List<String> activityList = [
];
List<String> categoryList = [];
final List<String> categoryList1 = [
];
final List<String> categoryList2 = [
];
String lifestyle = "", activity = "", category = "", diabetes = "";
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Container(
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Food Type :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: lifeStyleList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select life style.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
if (value == "Gym") {
setState(() {
categoryList = categoryList1;
});
} else {
setState(() {
categoryList = categoryList2;
});
}
},
onSaved: (value) {
lifestyle = value.toString();
},
),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Food Category :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: categoryList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select category.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
},
onSaved: (value) {
category = value.toString();
},
),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Veg or Non Veg :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: activityList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select activity level.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
},
onSaved: (value) {
activity = value.toString().replaceAll(' ', '');
},
),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text("Select Diabetes Type :"),
),
const SizedBox(height: 8),
DropdownButtonFormField2(
decoration: InputDecoration(
//Add isDense true and zero Padding.
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
isDense: true,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
),
//Add more decoration as you want here
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
),
isExpanded: true,
hint: const Text(
'',
style: TextStyle(fontSize: 14),
),
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
iconSize: 30,
buttonHeight: 40,
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
items: diabetesList
.map((item) => DropdownMenuItem<String>(
value: item,
child: Text(
item,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
validator: (value) {
if (value == null) {
return 'Please select diabetes type.';
}
},
onChanged: (value) {
//Do something when changing the item if you want.
},
onSaved: (value) {
diabetes = value.toString();
},
),
const SizedBox(
height: 24,
),
!isLoading
? InkWell(
onTap: () async {
// if (_formKey.currentState!.validate()) {
// _formKey.currentState!.save();
// setState(() {
// isLoading = true;
// });
// Exercise exercise = Exercise(
// lifestyle: lifestyle,
// activity: activity,
// category: category,
// diabetes: diabetes);
// var list = await ExerciseService
// .getExerciseRecommendationList(exercise);
// if (list == "") {
// setState(() {
// isLoading = false;
// });
// ScaffoldMessenger.of(context)
// .showSnackBar(const SnackBar(
// content: Text("Exercises not found."),
// duration: Duration(milliseconds: 2000),
// ));
// } else {
// if (jsonDecode(list).length > 0) {
// setState(() {
// isLoading = false;
// });
// showBottomSheet(jsonDecode(list));
// }
// }
// }
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: kPrimaryColor,
),
height: 45,
width: double.infinity,
child: const Center(
child: Text(
"GENERATE",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16),
)),
),
)
: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.teal[200],
),
height: 45,
width: double.infinity,
child: const Center(
child: Text(
"GENERATING...",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16),
)),
),
],
),
),
],
),
);
}
void showBottomSheet(var exercises) {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Container(
height: 500,
decoration: BoxDecoration(
color: Colors.teal[100],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Column(
children: [
Container(
decoration: const BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
height: 50,
width: double.infinity,
child: const Center(
child: Text(
"Exercises",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white),
)),
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("1. " + exercises[0]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("2. " + exercises[1]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("3. " + exercises[2]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("4. " + exercises[3]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("5. " + exercises[4]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("6. " + exercises[5]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("7. " + exercises[6]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("8. " + exercises[7]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("9. " + exercises[8]),
),
const Divider(),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text("10. " + exercises[9]),
),
const Divider(),
],
),
],
),
);
},
);
},
);
}
}
\ No newline at end of file
import 'package:diabeta_app/components/constants.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card_health1.dart';
import 'package:flutter/material.dart';
import 'package:loading_animations/loading_animations.dart';
import '../../model/diabetes_ques_ans.dart';
import '../../services/health_predict_service.dart';
class EyeRiskScreen extends StatefulWidget {
const EyeRiskScreen({Key? key}) : super(key: key);
@override
State<EyeRiskScreen> createState() => _EyeRiskScreenState();
}
class _EyeRiskScreenState extends State<EyeRiskScreen> {
bool isLoading = false;
void setResult(){
var result = HealthPredictService.getEyePrediction();
print(result);
setState(() {
isLoading = true;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.teal[100],
appBar: AppBar(
title: const Text("Eye Risk Prediction"),
centerTitle: true,
backgroundColor: kPrimaryColor,
),
body: !isLoading
? Container(
height: 500,
child: Swiper(
loop: false,
itemCount: HealthQuestions.eyeQuiz.length,
itemHeight: 400.0,
itemWidth: 600,
onIndexChanged: (index) {},
layout: SwiperLayout.STACK,
pagination: const SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
return QHealth1Card(ques: HealthQuestions.eyeQuiz[index], callBack: setResult);
},
),
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LoadingFlipping.circle(
borderColor: kPrimaryColor,
// borderSize: 3.0,
size: 60.0,
backgroundColor: kPrimaryColor,
duration: const Duration(milliseconds: 2000),
),
const SizedBox(
height: 8,
),
const Text('Loading result...')
],
),
);
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card_health3.dart';
import 'package:flutter/material.dart';
import 'package:loading_animations/loading_animations.dart';
import '../../model/diabetes_ques_ans.dart';
import '../../services/health_predict_service.dart';
class HeartRiskScreen extends StatefulWidget {
const HeartRiskScreen({Key? key}) : super(key: key);
@override
State<HeartRiskScreen> createState() => _HeartRiskScreenState();
}
class _HeartRiskScreenState extends State<HeartRiskScreen> {
bool isLoading = false;
void setResult(){
var result = HealthPredictService.getHeartPrediction();
setState(() {
isLoading = true;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.teal[100],
appBar: AppBar(
title: const Text("Heart Risk Prediction"),
centerTitle: true,
backgroundColor: kPrimaryColor,
),
body: !isLoading
? Container(
height: 500,
child: Swiper(
loop: false,
itemCount: HealthQuestions.heartQuiz.length,
itemHeight: 400.0,
itemWidth: 600,
onIndexChanged: (index) {},
layout: SwiperLayout.STACK,
pagination: const SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
return QHealth3Card(ques: HealthQuestions.heartQuiz[index], callBack: setResult);
},
),
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LoadingFlipping.circle(
borderColor: kPrimaryColor,
// borderSize: 3.0,
size: 60.0,
backgroundColor: kPrimaryColor,
duration: const Duration(milliseconds: 2000),
),
const SizedBox(
height: 8,
),
const Text('Loading result...')
],
),
);
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card.dart';
import 'package:diabeta_app/screens/diabetes/components/q_card_health.dart';
import 'package:diabeta_app/services/health_predict_service.dart';
import 'package:flutter/material.dart';
import 'package:loading_animations/loading_animations.dart';
import '../../model/diabetes_ques_ans.dart';
class KidneyRiskScreen extends StatefulWidget {
const KidneyRiskScreen({Key? key}) : super(key: key);
@override
State<KidneyRiskScreen> createState() => _KidneyRiskScreenState();
}
class _KidneyRiskScreenState extends State<KidneyRiskScreen> {
bool isLoading = false;
void setResult(){
var result = HealthPredictService.getKidneyPrediction();
setState(() {
isLoading = true;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.teal[100],
appBar: AppBar(
title: const Text("Kidney Risk Prediction"),
centerTitle: true,
backgroundColor: kPrimaryColor,
),
body: !isLoading
? Container(
height: 500,
child: Swiper(
loop: false,
itemCount: HealthQuestions.kidneyQuiz.length,
itemHeight: 400.0,
itemWidth: 600,
onIndexChanged: (index) {},
layout: SwiperLayout.STACK,
pagination: const SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
return QHealthCard(ques: HealthQuestions.kidneyQuiz[index], callBack: setResult);
},
),
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LoadingFlipping.circle(
borderColor: kPrimaryColor,
// borderSize: 3.0,
size: 60.0,
backgroundColor: kPrimaryColor,
duration: const Duration(milliseconds: 2000),
),
const SizedBox(
height: 8,
),
const Text('Loading result...')
],
),
);
}
}
import 'package:diabeta_app/components/category_card.dart';
import 'package:diabeta_app/components/diabetes_test_type.dart';
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/diabetes/screens/quiz_screen.dart';
import 'package:diabeta_app/screens/health/eye_risk_screen.dart';
import 'package:diabeta_app/screens/health/heart_risk_screen.dart';
import 'package:diabeta_app/screens/health/kidney_risk_screen.dart';
import 'package:flutter/material.dart';
import 'diabetes/screens/quiz_screen1.dart';
class HealthCheckScreen extends StatefulWidget {
const HealthCheckScreen({Key? key}) : super(key: key);
......@@ -26,11 +31,104 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
imgPath: "assets/images/diabetes.jpeg",
),
onTap: () {
showDialog(
showModalBottomSheet(
context: context,
builder: (BuildContext buildContext) => (DiabetesTestType(
buildContext: context,)),
backgroundColor: Colors.transparent,
builder: (context) {
return Container(
height: 300,
decoration: BoxDecoration(
color: Colors.teal[100],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const QuizScreen1()),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32, vertical: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Could You Have Prediabetes?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 16.0),
child: Container(
height: 40,
width: 200,
decoration: const BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
child: const Center(
child: Text(
'TAKE THE TEST',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white),
)),
),
),
const Text(
'Could You Have Type 2 Diabetes?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold),
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const QuizScreen()),
);
},
child: Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 16.0),
child: Container(
height: 40,
width: 200,
decoration: const BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
child: const Center(
child: Text(
'TAKE THE TEST',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white),
)),
),
),
),
],
),
),
));
});
// showDialog(
// context: context,
// builder: (BuildContext buildContext) => (DiabetesTestType(
// buildContext: context,)),
// );
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => const QuizScreen()),
......@@ -45,7 +143,7 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const QuizScreen()),
MaterialPageRoute(builder: (context) => const HeartRiskScreen()),
);
},
),
......@@ -57,7 +155,7 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const QuizScreen()),
MaterialPageRoute(builder: (context) => const EyeRiskScreen()),
);
},
),
......@@ -69,7 +167,7 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const QuizScreen()),
MaterialPageRoute(builder: (context) => const KidneyRiskScreen()),
);
},
),
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/main_screen.dart';
import 'package:diabeta_app/screens/register_screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class LoginScreen extends StatefulWidget {
......@@ -10,11 +12,17 @@ class LoginScreen extends StatefulWidget {
}
class _LoginScreenState extends State<LoginScreen> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController _userNameController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
get kPrimaryColor => null;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return SafeArea(
......@@ -40,13 +48,21 @@ class _LoginScreenState extends State<LoginScreen> {
const SizedBox(
height: 30,
),
Column(
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: TextField(
child: TextFormField(
validator: (String? value) {
if (value!.isEmpty) {
return 'Please enter your email.';
}
return null;
},
controller: _userNameController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.email),
......@@ -54,9 +70,9 @@ class _LoginScreenState extends State<LoginScreen> {
borderRadius:
BorderRadius.all(Radius.circular(30))),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 10, vertical: 12),
labelText: 'Username',
contentPadding: EdgeInsets.symmetric(
horizontal: 10, vertical: 12),
labelText: 'Email',
),
),
),
......@@ -65,14 +81,20 @@ class _LoginScreenState extends State<LoginScreen> {
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: TextField(
child: TextFormField(
obscureText: true,
validator: (String? value) {
if (value!.isEmpty) {
return 'Please enter your password.';
}
return null;
},
controller: _passwordController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.lock),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 10, vertical: 12),
contentPadding: EdgeInsets.symmetric(
horizontal: 10, vertical: 12),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30))),
......@@ -91,13 +113,16 @@ class _LoginScreenState extends State<LoginScreen> {
constraints: const BoxConstraints.tightFor(height: 45),
child: ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_login();
}
// if (_userNameController.text == "amal" &&
// _passwordController.text == "1234") {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MainScreen()),
);
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const MainScreen()),
// );
// } else {
// const snackBar = SnackBar(
// content: Text("Invalid username or password."),
......@@ -118,36 +143,72 @@ class _LoginScreenState extends State<LoginScreen> {
),
),
),
SizedBox(
height: 16,
),
const Padding(
padding: EdgeInsets.symmetric(vertical:8.0),
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Center(
child: Text(
"- or -",
style: TextStyle(fontSize: 14, color: Colors.black),
"Forgot password?",
style: TextStyle(fontSize: 14, color: Colors.teal),
)),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40,
),
child: ConstrainedBox(
constraints: const BoxConstraints.tightFor(height: 40),
child: ElevatedButton(
onPressed: () {
},
child: const Text(
'Register',
style: TextStyle(fontSize: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Don't have an account,",
style: TextStyle(
fontSize: 14,
color: Colors.teal,
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: kSecondaryColor,
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const RegisterScreen()),
);
},
child: Text(
" Sign Up",
style: TextStyle(
fontSize: 14,
color: Colors.teal,
fontWeight: FontWeight.bold),
),
),
],
),
// Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 40,
// ),
// child: ConstrainedBox(
// constraints: const BoxConstraints.tightFor(height: 40),
// child: ElevatedButton(
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const RegisterScreen()),
// );
// },
// child: const Text(
// 'Register',
// style: TextStyle(fontSize: 16),
// ),
// style: ElevatedButton.styleFrom(
// shape: const StadiumBorder(),
// elevation: 0,
// primary: kSecondaryColor,
// ),
// ),
// ),
// ),
// FutureBuilder(
// future: Authentication.initializeFirebase(context),
// builder: (context, snapshot) {
......@@ -172,10 +233,31 @@ class _LoginScreenState extends State<LoginScreen> {
// ),
],
),
),
],
),
),
),
);
}
Future<void> _login() async {
try {
UserCredential userCredential = await FirebaseAuth.instance
.signInWithEmailAndPassword(
email: _userNameController.text.toString(),
password: _passwordController.text.toString());
if (userCredential.user != null) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const MainScreen()),
);
}
} on FirebaseAuthException catch (e) {
const snackBar = SnackBar(
content: Text("Invalid username or password."),
backgroundColor: Colors.red);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
}
}
import 'package:diabeta_app/screens/diabetes/screens/logbook_screen.dart';
import 'package:diabeta_app/screens/diabetes/screens/print_log_screen.dart';
import 'package:diabeta_app/screens/exercise/exercise_main_screen.dart';
import 'package:diabeta_app/screens/food/food_main_screen.dart';
import 'package:diabeta_app/screens/health_check_screen.dart';
import 'package:diabeta_app/screens/dashboard_screen.dart';
import 'package:diabeta_app/screens/reminders/reminder_screen.dart';
import 'package:diabeta_app/screens/reports/report_screen.dart';
import 'package:diabeta_app/screens/settings/settings_screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../components/constants.dart';
import 'login_screen.dart';
......@@ -18,27 +21,58 @@ class MainScreen extends StatefulWidget {
class _MainScreenState extends State<MainScreen> {
int _selectedIndex = 0;
String period = "All records";
String _title = "DiaBeta";
static const List<Widget> _widgetOptions = <Widget>[
DashboardScreen(),
LogbookScreen(),
HealthCheckScreen(),
FoodMainScreen(),
ExerciseMainScreen(),
ReminderScreen(),
SettingsScreen()
];
final _currentUser = FirebaseAuth.instance.currentUser;
@override
Widget build(BuildContext context) {
List<Widget> _widgetOptions = <Widget>[
const DashboardScreen(),
LogbookScreen(period: period),
const HealthCheckScreen(),
const FoodMainScreen(),
const ExerciseMainScreen(),
const ReminderScreen(),
const ReportScreen(),
const SettingsScreen()
];
void setPeriodForLogbook(String p) {
setState(() {
period = p;
});
}
return Scaffold(
appBar: AppBar(
title: Text(_title),
backgroundColor: kPrimaryColor,
elevation: 0,
actions: [
IconButton(icon: const Icon(Icons.notifications), onPressed: (){},)
actions: _title != "Logbook"
? [
IconButton(
icon: const Icon(Icons.notifications),
onPressed: () {},
),
]
: [
IconButton(
icon: const Icon(Icons.filter_alt),
onPressed: () {
showBottomSheet(setPeriodForLogbook, period);
},
),
IconButton(
icon: const Icon(Icons.share),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PrintLogScreen(period: period)),
);
},
)
],
),
body: _widgetOptions.elementAt(_selectedIndex),
......@@ -54,27 +88,28 @@ class _MainScreenState extends State<MainScreen> {
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
Padding(
children: [
const Padding(
padding: EdgeInsets.all(4.0),
child: CircleAvatar(
backgroundImage: AssetImage('assets/images/profile.png'),
backgroundImage:
AssetImage('assets/images/profile.png'),
radius: 30,
),
),
Padding(
padding: EdgeInsets.all(4.0),
padding: const EdgeInsets.all(4.0),
child: Text(
"Robert Steve",
style: TextStyle(color: Colors.white),
_currentUser!.displayName.toString(),
style: const TextStyle(color: Colors.white),
),
),
Padding(
padding: EdgeInsets.symmetric(
padding: const EdgeInsets.symmetric(
horizontal: 4.0,
),
child: Text("roberts@gmail.com",
style: TextStyle(color: Colors.white)),
child: Text(_currentUser!.email.toString(),
style: const TextStyle(color: Colors.white)),
),
],
),
......@@ -205,6 +240,27 @@ class _MainScreenState extends State<MainScreen> {
Navigator.pop(context);
},
),
ListTile(
title: Row(
children: const [
Icon(
Icons.timeline,
color: kPrimaryColor,
),
SizedBox(
width: 8,
),
Text('Report')
],
),
onTap: () {
setState(() {
_selectedIndex = 6;
_title = "Reports";
});
Navigator.pop(context);
},
),
ListTile(
title: Row(
children: const [
......@@ -220,7 +276,7 @@ class _MainScreenState extends State<MainScreen> {
),
onTap: () {
setState(() {
_selectedIndex = 6;
_selectedIndex = 7;
_title = "Settings";
});
Navigator.pop(context);
......@@ -239,12 +295,15 @@ class _MainScreenState extends State<MainScreen> {
Text('Logout')
],
),
onTap: () {
onTap: () async {
try {
await FirebaseAuth.instance.signOut();
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
);
} on FirebaseAuthException catch (e) {}
},
),
],
......@@ -253,4 +312,226 @@ class _MainScreenState extends State<MainScreen> {
),
);
}
void showBottomSheet(Function(String) callBack, String p) {
String period = p;
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return StatefulBuilder(builder: (context, setState) {
return Container(
height: 350,
decoration: BoxDecoration(
color: Colors.teal[100],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 0, vertical: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
child: const Text(
'Close',
style: TextStyle(
fontSize: 16,
color: Colors.teal,
fontWeight: FontWeight.bold),
),
onTap: () {
Navigator.pop(context);
},
),
const Text(
'Filter',
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
InkWell(
child: const Text(
'Done',
style: TextStyle(
fontSize: 16,
color: Colors.teal,
fontWeight: FontWeight.bold),
),
onTap: () {
callBack(period);
Navigator.pop(context);
},
),
],
),
),
const Divider(),
Container(
height: 32,
width: double.infinity,
color: Colors.teal[200],
child: const Padding(
padding: EdgeInsets.only(top: 4.0, left: 4),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Period',
style: TextStyle(
fontSize: 18,
),
),
),
),
),
const Divider(),
InkWell(
onTap: () {
setState(() {
period = "This week";
});
},
child: Container(
height: 32,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.only(top: 4.0, left: 4),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
const Text(
'This week',
style: TextStyle(
fontSize: 16,
),
),
period == "This week"
? const Icon(Icons.done)
: Container()
],
),
),
),
),
),
const Divider(),
InkWell(
onTap: () {
setState(() {
period = "This month";
});
},
child: Container(
height: 32,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.only(top: 4.0, left: 4),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
const Text(
'This month',
style: TextStyle(
fontSize: 16,
),
),
period == "This month"
? const Icon(Icons.done)
: Container()
],
),
),
),
),
),
const Divider(),
InkWell(
onTap: () {
setState(() {
period = "This year";
});
},
child: Container(
height: 32,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.only(top: 4.0, left: 4),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
const Text(
'This year',
style: TextStyle(
fontSize: 16,
),
),
period == "This year"
? const Icon(Icons.done)
: Container()
],
),
),
),
),
),
const Divider(),
InkWell(
onTap: () {
setState(() {
period = "All records";
});
},
child: Container(
height: 32,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.only(top: 4.0, left: 4),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
const Text(
'All records',
style: TextStyle(
fontSize: 16,
),
),
period == "All records"
? const Icon(Icons.done)
: Container()
],
),
),
),
),
),
const Divider(),
],
),
));
});
});
}
}
import 'package:diabeta_app/screens/login_screen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class RegisterScreen extends StatefulWidget {
const RegisterScreen({Key? key}) : super(key: key);
@override
State<RegisterScreen> createState() => _RegisterScreenState();
}
class _RegisterScreenState extends State<RegisterScreen> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController _nameController = TextEditingController();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
bool _success = false;
String _userEmail = "";
get kPrimaryColor => null;
@override
void dispose() {
_emailController.dispose();
_nameController.dispose();
_passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 100,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"Sign Up",
style: TextStyle(fontSize: 40, color: Colors.teal),
),
),
const SizedBox(
height: 30,
),
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: TextFormField(
validator: (String? value) {
if (value!.isEmpty) {
return 'Please enter your full name';
}
return null;
},
controller: _nameController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.person),
isDense: true,
contentPadding: EdgeInsets.symmetric(
horizontal: 10, vertical: 12),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30))),
labelText: 'Full Name',
),
),
),
const SizedBox(
height: 14,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: TextFormField(
controller: _emailController,
validator: (String? value) {
if (value!.isEmpty) {
return 'Please enter your email';
}
return null;
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.email),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30))),
isDense: true,
contentPadding: EdgeInsets.symmetric(
horizontal: 10, vertical: 12),
labelText: 'Email',
),
),
),
const SizedBox(
height: 14,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: TextFormField(
obscureText: true,
validator: (String? value) {
if (value!.isEmpty) {
return 'Please enter a password';
}
return null;
},
controller: _passwordController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.lock),
isDense: true,
contentPadding: EdgeInsets.symmetric(
horizontal: 10, vertical: 12),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30))),
labelText: 'Password',
),
),
),
const SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40,
),
child: ConstrainedBox(
constraints: const BoxConstraints.tightFor(height: 45),
child: ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_register();
}
// if (_userNameController.text == "amal" &&
// _passwordController.text == "1234") {
// } else {
// const snackBar = SnackBar(
// content: Text("Invalid username or password."),
// backgroundColor: Colors.red);
// ScaffoldMessenger.of(context)
// .showSnackBar(snackBar);
// }
},
child: const Text(
'Register',
style: TextStyle(fontSize: 16),
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: kPrimaryColor,
),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Already have an account?",
style: TextStyle(fontSize: 14, color: Colors.black),
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen()),
);
},
child: const Text(
" Login",
style: TextStyle(
fontSize: 14,
color: Colors.teal,
fontWeight: FontWeight.bold),
),
)
],
),
),
// FutureBuilder(
// future: Authentication.initializeFirebase(context),
// builder: (context, snapshot) {
// if (snapshot.hasError) {
// return const Text('Error initializing Firebase');
// } else if (snapshot.connectionState ==
// ConnectionState.done) {
// return const Padding(
// padding: EdgeInsets.symmetric(horizontal: 40),
// child: GoogleSignInButton(),
// );
// }
// return Container(
// width: 20,
// child: const CircularProgressIndicator(
// valueColor: AlwaysStoppedAnimation<Color>(
// Colors.blue,
// ),
// ),
// );
// },
// ),
],
),
),
],
),
),
),
);
}
void _register() async {
try {
UserCredential userCredential = await FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: _emailController.text.toString(),
password: _passwordController.text.toString());
User? user = userCredential.user;
if(user != null){
user.updateDisplayName(_nameController.text.toString());
}
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
const snackBar = SnackBar(
content: Text("The password provided is too weak."),
backgroundColor: Colors.red);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
} else if (e.code == 'email-already-in-use') {
const snackBar = SnackBar(
content: Text("The account already exists for that email."),
backgroundColor: Colors.red);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
} catch (e) {
print(e);
}
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/ReceivedNotification.dart';
import 'package:diabeta_app/services/data_store.dart';
import 'package:diabeta_app/services/local_notification_service.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
class ReminderDetails extends StatefulWidget {
final String? activity;
final String? dateTime;
const ReminderDetails({Key? key, this.activity, this.dateTime})
: super(key: key);
@override
_ReminderDetailsState createState() => _ReminderDetailsState();
}
class _ReminderDetailsState extends State<ReminderDetails> {
late final LocalNotificationService service;
DateTime pickedDate = DateTime.now();
String notificationBody = '';
DateTime date = DateTime.now();
TimeOfDay time = TimeOfDay.now();
@override
void initState() {
service = LocalNotificationService();
service.intialize();
if (widget.activity != null && widget.dateTime != null) {
notificationBody = widget.activity.toString();
pickedDate = DateTime.parse(widget.dateTime.toString());
date = DateTime.parse(widget.dateTime.toString());
time = TimeOfDay.fromDateTime(DateTime.parse(widget.dateTime.toString()));
}
listenToNotification();
super.initState();
}
Future pickDate(BuildContext context) async {
FocusScope.of(context).requestFocus(FocusNode());
final initialDate = DateTime.now();
final newDate = await showDatePicker(
context: context,
initialDate: initialDate,
firstDate: DateTime(DateTime.now().year - 5),
lastDate: DateTime(DateTime.now().year + 5));
if (newDate == null) return;
setState(() {
print(newDate);
date = newDate;
});
}
Future pickTime(BuildContext context, DateTime date) async {
final TimeOfDay? result =
await showTimePicker(context: context, initialTime: TimeOfDay.now());
if (result != null) {
setState(() {
print(result);
time = result;
});
}
}
String formatTimeOfDay(TimeOfDay tod) {
final now = DateTime.now();
final dt = DateTime(now.year, now.month, now.day, tod.hour, tod.minute);
final format = DateFormat.jm(); //"6:00 AM"
return format.format(dt);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
title: const Text("Reminder Details"),
centerTitle: true,
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Navigator.pop(context);
},
),
actions: (<Widget>[
IconButton(
onPressed: () async {
date = DateTime(
date.year, date.month, date.day, time.hour, time.minute);
try {
await service.setScheduledNotification(
id: 0,
body: notificationBody ?? widget.activity ?? 'Not Found',
dateAndTime: date,
);
ReceivedNotification receivedNotification =
new ReceivedNotification(
id: 0,
title: "Diabeta Activity",
body: notificationBody,
payload: date.toString());
// await DataStore.shared.setReminderList(receivedNotification);
Navigator.pop(context, receivedNotification);
} catch (e) {
print(e);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Enter Valid Date"),
duration: Duration(milliseconds: 2000),
));
// Fluttertoast.showToast(
// msg: "Enter Valid Date",
// backgroundColor: Color.fromARGB(255, 77, 77, 77),
// textColor: Colors.white,
// fontSize: 15.0);
}
},
icon: const Icon(Icons.done),
),
]),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(17.0),
child: Center(
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 40,
),
Padding(
padding: EdgeInsets.only(left: 12.0, bottom: 0),
child: Text(
"Title",
textAlign: TextAlign.start,
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: TextFormField(
decoration: InputDecoration(
// border: OutlineInputBorder(),
// labelText: 'Title',
),
initialValue: widget.activity ?? '',
// controller: TextEditingController(text: widget.activity ?? ''),
onChanged: (value) {
setState(() {
print(value);
notificationBody = value;
});
},
),
),
SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: 1.5, color: Colors.grey[300]!),
)),
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: const [
FaIcon(FontAwesomeIcons.calendar,
color: kPrimaryColor),
SizedBox(
width: 8,
),
Text('Date'),
],
),
InkWell(
child: Text(DateFormat('MMMM dd, yyyy').format(date)),
onTap: () {
pickDate(context);
},
)
],
),
),
),
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: 1.5, color: Colors.grey[300]!),
)),
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: const [
FaIcon(FontAwesomeIcons.clock,
color: kPrimaryColor),
SizedBox(
width: 8,
),
Text('Time'),
],
),
InkWell(
child: Text(formatTimeOfDay(time)),
onTap: () {
pickTime(context, date);
},
)
],
),
),
),
const SizedBox(
height: 10,
),
// ElevatedButton(
// onPressed: () async {
// date = DateTime(date.year, date.month, date.day, time.hour,
// time.minute);
// try {
// await service.setScheduledNotification(
// id: 0,
// body:
// notificationBody ?? widget.activity ?? 'Not Found',
// dateAndTime: date,
// );
// ReceivedNotification receivedNotification =
// new ReceivedNotification(
// id: 0,
// title: "Diabeta Activity",
// body: notificationBody,
// payload: date.toString());
// // await DataStore.shared.setReminderList(receivedNotification);
// Navigator.pop(context, receivedNotification);
// } catch (e) {
// print(e);
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
// content: Text("Enter Valid Date"),
// duration: Duration(milliseconds: 2000),
// ));
// // Fluttertoast.showToast(
// // msg: "Enter Valid Date",
// // backgroundColor: Color.fromARGB(255, 77, 77, 77),
// // textColor: Colors.white,
// // fontSize: 15.0);
// }
// },
// child: const Text('Save Reminder'),
// ),
],
),
),
),
),
);
}
void listenToNotification() =>
service.onNotificationClick.stream.listen(onNoticationListener);
void onNoticationListener(String? payload) {
if (payload != null && payload.isNotEmpty) {
print('payload $payload');
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: ((context) => SecondScreen(payload: payload))));
}
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/reminders/reminder_details.dart';
import 'package:diabeta_app/services/data_store.dart';
import 'package:diabeta_app/services/local_notification_service.dart';
import 'package:flutter/material.dart';
class ReminderScreen extends StatefulWidget {
const ReminderScreen({ Key? key }) : super(key: key);
const ReminderScreen({Key? key}) : super(key: key);
@override
State<ReminderScreen> createState() => _ReminderScreenState();
}
class _ReminderScreenState extends State<ReminderScreen> {
late final LocalNotificationService service;
DateTime pickedDate = DateTime.now();
String notificationBody = '';
List<dynamic> reminderList = [];
@override
void initState() {
service = LocalNotificationService();
service.intialize();
listenToNotification();
super.initState();
DataStore.shared.getReminderList().then((value) {
setState(() {
reminderList = value;
});
});
}
@override
Widget build(BuildContext context) {
return Container(
return Scaffold(
body: Stack(
children: [
Scaffold(
floatingActionButton: FloatingActionButton(
backgroundColor: kSecondaryColor,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReminderDetails()))
.then((payload) {
if (payload != null) {
DataStore.shared.setReminderList(payload);
DataStore.shared.getReminderList().then((value) {
setState(() {
reminderList = value;
});
});
}
// DataStore.shared.getReminderList().then((value) {
// setState(() {
// reminderList = value;
// });
// });
});
},
child: const Icon(Icons.add)),
body: Padding(
padding:
const EdgeInsets.only(top: 17.0, left: 17.0, right: 17.0),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// const Text(
// 'This is a demo of how to use local notifications in Flutter.',
// style: TextStyle(fontSize: 20),
// ),
Expanded(
child: ListView.builder(
shrinkWrap: true,
// physics: ,
itemBuilder: (context, index) {
return Center(
child: Card(
child: ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ReminderDetails(
activity:
reminderList[index]
["body"],
dateTime: reminderList[
index]
["payload"]))).then(
(payload) {
if (payload != null) {
reminderList.removeAt(index);
reminderList.add({
"id": payload.id,
"body": payload.body,
"payload": payload.payload,
"title": payload.title,
});
DataStore.shared.setReminderFullList(
reminderList);
DataStore.shared
.getReminderList()
.then((value) {
setState(() {
reminderList = value;
});
});
}
});
},
leading:
CircleAvatar(child: Icon(Icons.alarm)),
title: Text(
reminderList[index]["body"].toString()),
subtitle: Text(reminderList[index]
["payload"]
.toString()
.substring(0, 16)),
trailing: GestureDetector(
onTap: () async {
print(index);
reminderList.removeAt(index);
await DataStore.shared
.setReminderFullList(reminderList);
setState(() {});
},
child: CircleAvatar(
child: Icon(
Icons.close,
color: Colors.white,
size: 15,
),
radius: 10,
backgroundColor: Colors.red[800],
),
)),
),
);
},
itemCount: reminderList.length),
)
],
),
),
),
),
// Padding(
// padding: const EdgeInsets.only(bottom: 12.0),
// child: Align(
// alignment: Alignment.bottomRight,
// heightFactor: 130.0,
// widthFactor: 130.0,
// child: ElevatedButton(
// style: ElevatedButton.styleFrom(
// shape: const CircleBorder(),
// backgroundColor: kSecondaryColor),
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => ReminderDetails()))
// .then((payload) {
// if (payload != null) {
// DataStore.shared.setReminderList(payload);
// DataStore.shared.getReminderList().then((value) {
// setState(() {
// reminderList = value;
// });
// });
// }
// // DataStore.shared.getReminderList().then((value) {
// // setState(() {
// // reminderList = value;
// // });
// // });
// });
// },
// child: Padding(
// padding: const EdgeInsets.all(10.0),
// child: const Icon(Icons.add, size: 30.0),
// ),
// ),
// ),
// ),
],
),
);
}
void listenToNotification() =>
service.onNotificationClick.stream.listen(onNoticationListener);
void onNoticationListener(String? payload) {
if (payload != null && payload.isNotEmpty) {
print('payload $payload');
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: ((context) => SecondScreen(payload: payload))));
}
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import '../../services/glucose_log_service.dart';
class SplineAreaWeightData {
// SplineAreaData(this.year, this.y1, this.y2);
// final double year;
// final double y1;
// final double y2;
SplineAreaWeightData(this.title, this.value);
final String title;
final double value;
}
class ReportScreen extends StatefulWidget {
const ReportScreen({Key? key}) : super(key: key);
@override
State<ReportScreen> createState() => _ReportScreenState();
}
class _ReportScreenState extends State<ReportScreen> {
late ChartSeriesController _chartSeriesController;
List<SplineAreaWeightData> _chartGlucoseData = <SplineAreaWeightData>[];
List<SplineAreaWeightData> _chartCarbData = <SplineAreaWeightData>[];
final _currentUser = FirebaseAuth.instance.currentUser;
int _gselectedIndex = 0;
int _cselectedIndex = 0;
void getChartGlucoseDataByTimeFrame() async {
List<SplineAreaWeightData> _data = <SplineAreaWeightData>[];
String period = "This week";
if (_gselectedIndex == 1) {
period = "This month";
} else if (_gselectedIndex == 2) {
period = "This year";
}
List data = await GlucoseLogService.getRecordsByTimeFrame(
_currentUser!.uid, period,
isDecending: false);
data.forEach((element) {
if (element.glucoseLevel != null) {
_data.add(SplineAreaWeightData(
DateFormat('MMM d').format(element.dateTime).toString(),
element.glucoseLevel));
}
});
setState(() {
_chartGlucoseData = _data;
});
}
void getChartCarbsDataByTimeFrame() async {
List<SplineAreaWeightData> _data = <SplineAreaWeightData>[];
String period = "This week";
if (_cselectedIndex == 1) {
period = "This month";
} else if (_cselectedIndex == 2) {
period = "This year";
}
List data = await GlucoseLogService.getRecordsByTimeFrame(_currentUser!.uid, period, isDecending: false);
data.forEach((element) {
if (element.carbs != null) {
_data.add(SplineAreaWeightData(
DateFormat('MMM d').format(element.dateTime).toString(),
element.carbs));
}
});
setState(() {
_chartCarbData = _data;
});
}
@override
void initState() {
getChartGlucoseDataByTimeFrame();
getChartCarbsDataByTimeFrame();
}
@override
Widget build(BuildContext context) {
var width = MediaQuery.of(context).size.width;
var height = MediaQuery.of(context).size.height;
return SingleChildScrollView(
child: Container(
child: Center(
child: Column(
children: [
SizedBox(
height: 30,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
InkWell(
onTap: (() {
setState(() {
_gselectedIndex = 0;
getChartGlucoseDataByTimeFrame();
});
}),
child: Container(
width: (MediaQuery.of(context).size.width - 16) / 3,
decoration: BoxDecoration(
color: _gselectedIndex != 0
? kPrimaryColor
: Colors.teal[300]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"WEEK",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
),
InkWell(
onTap: (() {
setState(() {
_gselectedIndex = 1;
getChartGlucoseDataByTimeFrame();
});
}),
child: Container(
width: (MediaQuery.of(context).size.width - 16) / 3,
decoration: BoxDecoration(
color: _gselectedIndex != 1
? kPrimaryColor
: Colors.teal[300]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"MONTH",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
),
InkWell(
onTap: (() {
setState(() {
_gselectedIndex = 2;
getChartGlucoseDataByTimeFrame();
});
}),
child: Container(
width: (MediaQuery.of(context).size.width - 16) / 3,
decoration: BoxDecoration(
color: _gselectedIndex != 2
? kPrimaryColor
: Colors.teal[300]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"YEAR",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
)
],
),
),
ChartCard(width, "Glucose", "mg/dL", _chartGlucoseData),
SizedBox(
height: 30,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: [
InkWell(
onTap: (() {
setState(() {
_cselectedIndex = 0;
getChartCarbsDataByTimeFrame();
});
}),
child: Container(
width: (MediaQuery.of(context).size.width - 16) / 3,
decoration: BoxDecoration(
color: _cselectedIndex != 0
? kPrimaryColor
: Colors.teal[300]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"WEEK",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
),
InkWell(
onTap: (() {
setState(() {
_cselectedIndex = 1;
getChartCarbsDataByTimeFrame();
});
}),
child: Container(
width: (MediaQuery.of(context).size.width - 16) / 3,
decoration: BoxDecoration(
color: _cselectedIndex != 1
? kPrimaryColor
: Colors.teal[300]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"MONTH",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
),
InkWell(
onTap: (() {
setState(() {
_cselectedIndex = 2;
getChartCarbsDataByTimeFrame();
});
}),
child: Container(
width: (MediaQuery.of(context).size.width - 16) / 3,
decoration: BoxDecoration(
color: _cselectedIndex != 2
? kPrimaryColor
: Colors.teal[300]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"YEAR",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
)
],
),
),
ChartCard(width, "Carbohydrates", "grams", _chartCarbData),
//ChartCard(width, "","mg/dL", _chartCarbData),
],
),
),
),
);
}
Container ChartCard(double width, String title, String unit,
List<SplineAreaWeightData> chartData) {
return Container(
height: 380,
width: width - 20,
margin: const EdgeInsets.only(top: 20.0),
// width: size.width * 0.85,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: <Color>[
kPrimaryColor,
// Color.fromARGB(255, 96, 207, 92),
Color.fromARGB(255, 2, 102, 93),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
// color: Colors.red[800],
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.4),
blurRadius: 10.0, // soften the shadow
spreadRadius: 1.0, //extend the shadow
)
],
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
title,
textAlign: TextAlign.center,
style: GoogleFonts.dmSans(
textStyle: const TextStyle(
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.normal),
),
),
const SizedBox(
height: 10,
),
Container(
height: 320,
child: chartData.isEmpty
? const Center(
child: Text(
"No data to display.",
style: TextStyle(color: Colors.white),
))
: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enablePinching: true,
enableDoubleTapZooming: true,
enablePanning: true,
),
enableAxisAnimation: true,
legend: Legend(isVisible: false, opacity: 0.7),
// title: ChartTitle(text: 'Inflation rate'),
plotAreaBorderWidth: 0,
primaryXAxis: CategoryAxis(
axisLine: AxisLine(
color: Colors.white,
width: 2,
),
labelStyle: TextStyle(color: Colors.white),
isVisible: true,
// maximumLabels: 5,
// interval: 1,
majorGridLines: const MajorGridLines(width: 0),
edgeLabelPlacement: EdgeLabelPlacement.shift),
primaryYAxis: NumericAxis(
axisLine: AxisLine(
color: Colors.white,
width: 2,
),
labelStyle: TextStyle(color: Colors.white),
isVisible: true,
labelFormat: '{value}',
// axisLine: const AxisLine(width: 0),
majorTickLines: const MajorTickLines(size: 0)),
series: <ChartSeries>[
SplineAreaSeries<SplineAreaWeightData, String>(
// animationDuration: 100,
markerSettings: MarkerSettings(
isVisible: true,
borderColor: Colors.white,
height: 4,
width: 4),
// gradient: LinearGradient(
// colors: <Color>[
// Colors.white.withAlpha(100),
// Colors.white.withAlpha(10),
// ],
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// ),
onRendererCreated:
(ChartSeriesController controller) {
_chartSeriesController = controller;
// setState(() {
// _chartSeriesController = controller;
// });
},
enableTooltip: true,
dataSource: chartData,
borderColor: Colors.white,
splineType: SplineType.natural,
color: Colors.transparent,
borderWidth: 3,
name: unit,
xValueMapper: (SplineAreaWeightData data, _) =>
data.title,
yValueMapper: (SplineAreaWeightData data, _) =>
data.value,
)
],
tooltipBehavior: TooltipBehavior(enable: true),
),
),
],
),
),
);
}
}
import 'dart:convert';
import 'package:diabeta_app/model/ReceivedNotification.dart';
import 'package:shared_preferences/shared_preferences.dart';
class DataStore {
DataStore._privateConstructor();
static final DataStore _instance = DataStore._privateConstructor();
static DataStore get shared => _instance;
static final Future<SharedPreferences> _store = SharedPreferences.getInstance();
List<dynamic> _reminders = [];
Future clearAll() async {
final SharedPreferences store = await _store;
_reminders = [];
await store.clear();
}
Future<List<dynamic>> getReminderList() async {
final SharedPreferences store = await _store;
List<dynamic> _reminders = jsonDecode(store.getString("reminders") ?? '[]');
print("_reminders");
print(_reminders);
return _reminders;
}
setReminderList(ReceivedNotification value) {
_store.then((store) {
_reminders = jsonDecode(store.getString("reminders") ?? '[]');
_reminders.insert(0, {
"id": value.id,
"body": value.body,
"payload": value.payload,
"title": value.title,
});
String newReminders = jsonEncode(_reminders);
print("newReminders");
print(newReminders);
store.setString("reminders", newReminders);
});
}
setReminderFullList(List<dynamic> value) {
_store.then((store) {
String newReminders = jsonEncode(value);
print("newReminders");
print(newReminders);
store.setString("reminders", newReminders);
});
}
}
import 'dart:convert';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:dio/dio.dart';
class DiabatesPredictService {
static String api_url = "https://diabeta-backend.herokuapp.com";
static Future<String> getPrediabatesPrediction() async {
var data = {
"Age": DiabeticQuestions.sampleQuiz2[0].defaultValue,
"Gender": DiabeticQuestions.sampleQuiz2[1].defaultValue,
"Polyuria": DiabeticQuestions.sampleQuiz2[2].defaultValue,
"Polydipsia": DiabeticQuestions.sampleQuiz2[3].defaultValue,
"SuddenWeightLoss": DiabeticQuestions.sampleQuiz2[5].defaultValue,
"Irritability": DiabeticQuestions.sampleQuiz2[6].defaultValue,
"DelayedHealing": DiabeticQuestions.sampleQuiz2[7].defaultValue,
"PartialParesis": DiabeticQuestions.sampleQuiz2[4].defaultValue,
"Alopecia": DiabeticQuestions.sampleQuiz2[8].defaultValue,
"VisualBlurring": DiabeticQuestions.sampleQuiz2[9].defaultValue
};
var response = await Dio().post(api_url + "/prediabetes/predict",
options: Options(
headers: {"Content-Type": "application/json"},
),
data: jsonEncode(data));
return response.data;
}
static Future<String> getDiabatesPrediction() async {
double weight = DiabeticQuestions.sampleQuiz1[3].defaultValue;
double hieght = DiabeticQuestions.sampleQuiz1[2].defaultValue/100.0;
double bmi = weight/ (hieght * hieght);
var data = {
"Age": DiabeticQuestions.sampleQuiz1[1].defaultValue,
"Glucose": DiabeticQuestions.sampleQuiz1[4].defaultValue,
"BloodPressure": DiabeticQuestions.sampleQuiz1[5].defaultValue,
"Insulin": DiabeticQuestions.sampleQuiz1[6].defaultValue,
"SkinThickness": DiabeticQuestions.sampleQuiz1[7].defaultValue,
"BMI": bmi
};
var response = await Dio().post(api_url + "/diabetes/predict",
options: Options(
headers: {"Content-Type": "application/json"},
),
data: jsonEncode(data));
return response.data;
}
}
import 'dart:convert';
import 'package:diabeta_app/model/exercise.dart';
import 'package:diabeta_app/model/exercise_cal.dart';
import 'package:dio/dio.dart';
class ExerciseCalcService {
class ExerciseService {
static const String _APP_ID = "01e29302";
static const String _API_KEY = "0a2220fadb63fd55438ec22af43f3767";
static String api_url = "https://diabeta-backend.herokuapp.com";
static Future<List<ExerciseCal>> getExerciseDetails(String query) async {
String api_url = 'https://trackapi.nutritionix.com/v2/natural/exercise';
......@@ -35,8 +37,7 @@ class ExerciseCalcService {
exercise: item["user_input"],
calories: item["nf_calories"],
duration: item["duration_min"],
met: item["met"]
);
met: item["met"]);
exerciseList.add(exerciseCal);
}
......@@ -45,4 +46,40 @@ class ExerciseCalcService {
}
return exerciseList;
}
static Future<String> getExerciseRecommendationList(Exercise exercise) async {
String prediabetes="", diabetes="";
if(exercise.diabetes == "Prediabetes"){
prediabetes = "prediabetic";
}else if(exercise.diabetes == "Diabetes"){
prediabetes = "prediabetic";
diabetes = "diabetic";
}else if(exercise.diabetes == "None"){
prediabetes = "nonprediabetic";
diabetes = "nondiabetic";
}
print(exercise.lifestyle.toLowerCase());
print(exercise.category.toLowerCase());
print(exercise.activity.toLowerCase());
print(prediabetes);
print(diabetes);
var data = {
"Lifestyle": exercise.lifestyle.toLowerCase(),
"Category": exercise.category.toLowerCase(),
"Activity-level": exercise.activity.toLowerCase(),
"PreDiabetic": prediabetes,
"Diabetic": diabetes
};
var response = await Dio().post(api_url + "/exercise/recommendation",
options: Options(
headers: {"Content-Type": "application/json"},
),
data: jsonEncode(data));
print(response.data);
return response.data;
}
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:diabeta_app/model/log_count.dart';
import 'package:diabeta_app/model/log_entry.dart';
class GlucoseLogService {
......@@ -97,11 +98,11 @@ class GlucoseLogService {
return recordList;
}
static Future<List<LogEntry>> getAllRecords(String accountId) async {
static Future<List<LogEntry>> getAllRecords(String accountId, bool descending) async {
List<LogEntry> recordList = [];
await _records
.where("userId", isEqualTo: accountId)
.orderBy("dateTime", descending: true)
.orderBy("dateTime", descending: descending)
.get()
.then((QuerySnapshot querySnapshot) {
for (var doc in querySnapshot.docs) {
......@@ -131,4 +132,190 @@ class GlucoseLogService {
.then((value) => true)
.catchError((error) => false);
}
static Future<List<LogCount>> getRecordsCountByTimeFrame(
String accountId) async {
List<LogCount> recordList = [];
bool isFinalGlucoseLog = false;
DateTime now = DateTime.now();
int currentDay = now.weekday;
DateTime firstDayOfWeek = now.subtract(Duration(days: currentDay));
LogCount weeklyCount =
LogCount(dateTime: null, index: 0, type: "weekly", inrange: 0, below: 0, above: 0);
LogCount monthlyCount =
LogCount(dateTime: null, index: 1,type: "monthly", inrange: 0, below: 0, above: 0);
LogCount yearlyCount =
LogCount(dateTime: null, index: 2, type: "yearly", inrange: 0, below: 0, above: 0);
await _records
.where("userId", isEqualTo: accountId)
.orderBy("dateTime", descending: true)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
if (doc["glucoseLevel"] != null && !isFinalGlucoseLog) {
weeklyCount.dateTime = DateTime.parse(doc["dateTime"].toDate().toString());
monthlyCount.dateTime = DateTime.parse(doc["dateTime"].toDate().toString());
yearlyCount.dateTime = DateTime.parse(doc["dateTime"].toDate().toString());
isFinalGlucoseLog = true;
}
if (DateTime.parse(doc["dateTime"].toDate().toString())
.isAfter(Timestamp.fromDate(firstDayOfWeek).toDate())) {
if (doc["glucoseLevel"] != null) {
if (doc["glucoseLevel"] > 120) {
weeklyCount.above += 1;
} else if (doc["glucoseLevel"] > 70) {
weeklyCount.inrange += 1;
} else {
weeklyCount.below += 1;
}
}
}
if (DateTime.parse(doc["dateTime"].toDate().toString()).isAfter(
Timestamp.fromDate(DateTime(now.year, now.month, 1)).toDate())) {
if (doc["glucoseLevel"] != null) {
if (doc["glucoseLevel"] > 120) {
monthlyCount.above += 1;
} else if (doc["glucoseLevel"] > 70) {
monthlyCount.inrange += 1;
} else {
monthlyCount.below += 1;
}
}
}
if (DateTime.parse(doc["dateTime"].toDate().toString())
.isAfter(Timestamp.fromDate(DateTime(now.year, 1, 1)).toDate())) {
if (doc["glucoseLevel"] != null) {
if (doc["glucoseLevel"] > 120) {
yearlyCount.above += 1;
} else if (doc["glucoseLevel"] > 70) {
yearlyCount.inrange += 1;
} else {
yearlyCount.below += 1;
}
}
}
});
recordList.add(weeklyCount);
recordList.add(monthlyCount);
recordList.add(yearlyCount);
}).catchError((error) {
print(error);
});
return recordList;
}
static Future<List<LogEntry>> getRecordsByTimeFrame(
String accountId, String period, {bool isDecending = true}) async {
List<LogEntry> recordList = [];
DateTime date = DateTime.now();
if (period == "This week") {
DateTime now = DateTime.now();
int currentDay = now.weekday;
DateTime firstDayOfWeek = now.subtract(Duration(days: currentDay));
await _records
.where("userId", isEqualTo: accountId)
.where("dateTime",
isGreaterThanOrEqualTo: Timestamp.fromDate(firstDayOfWeek))
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
LogEntry account = LogEntry(
id: doc.id,
dateTime: DateTime.parse(doc["dateTime"].toDate().toString()),
glucoseLevel: doc["glucoseLevel"],
carbs: doc["carbs"],
insulin: doc["insulin"],
pill: doc["pill"],
insulinType: doc["insulinType"],
pillType: doc["pillType"],
mealType: doc["mealType"],
userId: doc["userId"]);
recordList.add(account);
});
}).catchError((error) {
print(error);
});
} else if (period == "This month") {
DateTime now = DateTime.now();
await _records
.where("userId", isEqualTo: accountId)
.where("dateTime",
isGreaterThanOrEqualTo:
Timestamp.fromDate(DateTime(now.year, now.month, 1)))
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
LogEntry account = LogEntry(
id: doc.id,
dateTime: DateTime.parse(doc["dateTime"].toDate().toString()),
glucoseLevel: doc["glucoseLevel"],
carbs: doc["carbs"],
insulin: doc["insulin"],
pill: doc["pill"],
insulinType: doc["insulinType"],
pillType: doc["pillType"],
mealType: doc["mealType"],
userId: doc["userId"]);
recordList.add(account);
});
}).catchError((error) {
print(error);
});
} else if (period == "This year") {
DateTime now = DateTime.now();
await _records
.where("userId", isEqualTo: accountId)
.where("dateTime",
isGreaterThanOrEqualTo:
Timestamp.fromDate(DateTime(now.year, 1, 1)))
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
LogEntry account = LogEntry(
id: doc.id,
dateTime: DateTime.parse(doc["dateTime"].toDate().toString()),
glucoseLevel: doc["glucoseLevel"],
carbs: doc["carbs"],
insulin: doc["insulin"],
pill: doc["pill"],
insulinType: doc["insulinType"],
pillType: doc["pillType"],
mealType: doc["mealType"],
userId: doc["userId"]);
recordList.add(account);
});
}).catchError((error) {
print(error);
});
} else if (period == "All records") {
await _records
.where("userId", isEqualTo: accountId)
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
LogEntry account = LogEntry(
id: doc.id,
dateTime: DateTime.parse(doc["dateTime"].toDate().toString()),
glucoseLevel: doc["glucoseLevel"],
carbs: doc["carbs"],
insulin: doc["insulin"],
pill: doc["pill"],
insulinType: doc["insulinType"],
pillType: doc["pillType"],
mealType: doc["mealType"],
userId: doc["userId"]);
recordList.add(account);
});
}).catchError((error) {
print(error);
});
}
return recordList;
}
}
import 'dart:convert';
import 'package:diabeta_app/model/diabetes_ques_ans.dart';
import 'package:diabeta_app/model/health_ques_ans.dart';
import 'package:dio/dio.dart';
class HealthPredictService {
static String api_url = "https://diabeta-backend.herokuapp.com";
static Future<String> getHeartPrediction() async {
var data = {
"Age": HealthQuestions.heartQuiz[0].defaultValue,
};
var response = await Dio().post(api_url + "/heart/predict",
options: Options(
headers: {"Content-Type": "application/json"},
),
data: jsonEncode(data));
return response.data;
}
static Future<String> getEyePrediction() async {
var data = {
"Age": HealthQuestions.eyeQuiz[0].defaultValue,
};
var response = await Dio().post(api_url + "/eye/predict",
options: Options(
headers: {"Content-Type": "application/json"},
),
data: jsonEncode(data));
return response.data;
}
static Future<String> getKidneyPrediction() async {
var data = {
"Age": HealthQuestions.kidneyQuiz[0].defaultValue,
};
var response = await Dio().post(api_url + "/kidney/predict",
options: Options(
headers: {"Content-Type": "application/json"},
),
data: jsonEncode(data));
return response.data;
}
}
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:rxdart/subjects.dart';
import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest.dart' as tz;
class LocalNotificationService {
LocalNotificationService();
final _localNotificationService = FlutterLocalNotificationsPlugin();
final BehaviorSubject<String?> onNotificationClick = BehaviorSubject();
Future<void> intialize() async {
tz.initializeTimeZones();
const AndroidInitializationSettings androidInitializationSettings =
AndroidInitializationSettings('@drawable/ic_stat_android');
// IOSInitializationSettings iosInitializationSettings =
// IOSInitializationSettings(
// requestAlertPermission: true,
// requestBadgePermission: true,
// requestSoundPermission: true,
// onDidReceiveLocalNotification: onDidReceiveLocalNotification,
// );
final InitializationSettings settings = InitializationSettings(
android: androidInitializationSettings,
//iOS: iosInitializationSettings,
);
await _localNotificationService.initialize(
settings,
//onSelectNotification: onSelectNotification,
);
}
Future<NotificationDetails> _notificationDetails() async {
const AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails('channel_id', 'channel_name',
channelDescription: 'description',
importance: Importance.max,
priority: Priority.max,
playSound: true);
// const IOSNotificationDetails iosNotificationDetails =
// IOSNotificationDetails();
return const NotificationDetails(
android: androidNotificationDetails,
// iOS: iosNotificationDetails,
);
}
Future<void> showNotification({
required int id,
required String title,
required String body,
}) async {
final details = await _notificationDetails();
await _localNotificationService.show(id, title, body, details);
}
Future<void> showScheduledNotification(
{required int id,
required String title,
required String body,
required int seconds}) async {
final details = await _notificationDetails();
await _localNotificationService.zonedSchedule(
id,
title,
body,
tz.TZDateTime.from(
DateTime.now().add(Duration(seconds: seconds)),
tz.local,
),
details,
androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
);
}
Future<void> setScheduledNotification(
{required int id,
required String body,
required DateTime dateAndTime}) async {
final details = await _notificationDetails();
print(DateTime.now().add(Duration(seconds: 5)));
await _localNotificationService.zonedSchedule(
id,
"Diabeta Activity Reminder",
body,
tz.TZDateTime.from(
dateAndTime,
tz.local,
),
details,
androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
);
}
// Future<void> setScheduledDailyNotification(
// {required int id,
// required String body,
// required DateTime dateAndTime}) async {
// final details = await _notificationDetails();
// print(DateTime.now().add(Duration(seconds: 5)));
// await _localNotificationService.showDailyAtTime(
// id,
// "Diabeta Activity Reminder",
// body,
// Time(dateAndTime.hour,dateAndTime.minute, dateAndTime.second),
// details,
// );
// }
Future<void> setScheduledDailyNotification(
{required int id,
required String body,
required DateTime dateAndTime}) async {
final details = await _notificationDetails();
print(DateTime.now().add(Duration(seconds: 5)));
await _localNotificationService.periodicallyShow(
id,
"Diabeta Activity Reminder",
body,
RepeatInterval.daily,
details,
androidAllowWhileIdle: true,
);
}
Future<void> setScheduledWeeklyNotification(
{required int id,
required String body,
required DateTime dateAndTime}) async {
final details = await _notificationDetails();
print(DateTime.now().add(Duration(seconds: 5)));
await _localNotificationService.periodicallyShow(
id,
"Diabeta Activity Reminder",
body,
RepeatInterval.weekly,
details,
androidAllowWhileIdle: true,
);
}
Future<void> setScheduledMinutelyNotification(
{required int id,
required String body,
required DateTime dateAndTime}) async {
final details = await _notificationDetails();
print(DateTime.now().add(Duration(seconds: 5)));
await _localNotificationService.periodicallyShow(
id,
"Diabeta Activity Reminder",
body,
RepeatInterval.everyMinute,
details,
androidAllowWhileIdle: true,
);
}
Future<void> showNotificationWithPayload(
{required int id,
required String title,
required String body,
required String payload}) async {
final details = await _notificationDetails();
await _localNotificationService.show(id, title, body, details,
payload: payload);
}
void onDidReceiveLocalNotification(
int id, String? title, String? body, String? payload) {
print('id $id');
}
void onSelectNotification(String? payload) {
print('payload $payload');
if (payload != null && payload.isNotEmpty) {
onNotificationClick.add(payload);
}
}
}
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.1"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
barcode:
dependency: transitive
description:
name: barcode
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.3"
boolean_selector:
dependency: transitive
description:
......@@ -28,7 +49,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
charcode:
dependency: transitive
description:
......@@ -42,7 +63,7 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
cloud_firestore:
dependency: "direct main"
description:
......@@ -70,7 +91,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
......@@ -78,6 +106,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
dbus:
dependency: transitive
description:
name: dbus
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.8"
dio:
dependency: "direct main"
description:
......@@ -85,6 +120,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.6"
dropdown_button2:
dependency: "direct main"
description:
name: dropdown_button2
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
equatable:
dependency: transitive
description:
......@@ -98,7 +140,21 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.4"
firebase_auth:
dependency: "direct main"
description:
......@@ -174,6 +230,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_datetime_picker:
dependency: "direct main"
description:
name: flutter_datetime_picker
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.1"
flutter_lints:
dependency: "direct dev"
description:
......@@ -181,6 +244,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "10.0.0"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
......@@ -191,6 +275,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
url: "https://pub.dartlang.org"
source: hosted
version: "8.0.9"
font_awesome_flutter:
dependency: "direct main"
description:
......@@ -198,6 +289,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "10.1.0"
google_fonts:
dependency: "direct main"
description:
name: google_fonts
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
google_sign_in:
dependency: "direct main"
description:
......@@ -247,6 +345,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
intl:
dependency: "direct main"
description:
......@@ -260,7 +365,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
lints:
dependency: transitive
description:
......@@ -281,21 +386,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
outline_search_bar:
dependency: "direct main"
description:
......@@ -309,7 +414,84 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.2"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.20"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.7"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
pdf:
dependency: "direct main"
description:
name: pdf
url: "https://pub.dartlang.org"
source: hosted
version: "3.8.3"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
......@@ -317,6 +499,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
printing:
dependency: "direct main"
description:
name: printing
url: "https://pub.dartlang.org"
source: hosted
version: "5.9.3"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
qr:
dependency: transitive
description:
name: qr
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
quiver:
dependency: transitive
description:
......@@ -324,6 +527,69 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1+1"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.5"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.15"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
simple_text_field:
dependency: transitive
description:
......@@ -342,7 +608,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
......@@ -363,7 +629,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
syncfusion_flutter_charts:
dependency: "direct main"
description:
......@@ -384,14 +650,21 @@ packages:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
version: "0.4.12"
timezone:
dependency: "direct main"
description:
name: timezone
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.0"
typed_data:
dependency: transitive
description:
......@@ -405,7 +678,28 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+2"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
sdks:
dart: ">=2.16.0 <3.0.0"
flutter: ">=2.8.0"
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
......@@ -49,6 +49,16 @@ dependencies:
loading_animations: ^2.2.0
outline_search_bar: ^2.3.0
dio: ^4.0.6
dropdown_button2: ^1.8.1
timezone: ^0.8.0
rxdart: ^0.27.4
flutter_datetime_picker: ^1.5.1
fluttertoast: ^8.0.8
shared_preferences: ^2.0.15
flutter_local_notifications: ^10.0.0
pdf: ^3.8.3
printing: ^5.9.3
google_fonts: ^3.0.1
dev_dependencies:
flutter_test:
......
......@@ -25,22 +25,15 @@ def predict_diabetes():
data["Gender"],
data["Polyuria"],
data["Polydipsia"],
data["PartialParesis"],
data["SuddenWeightLoss"],
data["Weakness"],
data["Polyphagia"],
data["GenitalThrush"],
data["VisualBlurring"],
data["Itching"],
data["Irritability"],
data["DelayedHealing"],
data["PartialParesis"],
data["MuscleStiffness"],
data["Alopecia"],
data["Obesity"],
data["VisualBlurring"],
]
data = np.array([data_array])
print(data)
prediction = classifier.predict(data)
return str(prediction)
......
import pandas as pd
import pickle
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.ensemble import RandomForestClassifier
df=pd.read_csv('diabetes_data_upload.csv')
df['Gender'] = df['Gender'].map({'Male': 1, 'Female': 0})
df['Polyuria'] = df['Polyuria'].map({'Yes': 1, 'No': 0})
df['Polydipsia'] = df['Polydipsia'].map({'Yes': 1, 'No': 0})
df['sudden weight loss'] = df['sudden weight loss'].map({'Yes': 1, 'No': 0})
df['weakness'] = df['weakness'].map({'Yes': 1, 'No': 0})
df['Polyphagia'] = df['Polyphagia'].map({'Yes': 1, 'No': 0})
df['Genital thrush'] = df['Genital thrush'].map({'Yes': 1, 'No': 0})
df['visual blurring'] = df['visual blurring'].map({'Yes': 1, 'No': 0})
df['Itching'] = df['Itching'].map({'Yes': 1, 'No': 0})
df['Irritability'] = df['Irritability'].map({'Yes': 1, 'No': 0})
df['delayed healing'] = df['delayed healing'].map({'Yes': 1, 'No': 0})
df['partial paresis'] = df['partial paresis'].map({'Yes': 1, 'No': 0})
df['muscle stiffness'] = df['muscle stiffness'].map({'Yes': 1, 'No': 0})
df['Alopecia'] = df['Alopecia'].map({'Yes': 1, 'No': 0})
df['Obesity'] = df['Obesity'].map({'Yes': 1, 'No': 0})
df['class'] = df['class'].map({'Positive': 1, 'Negative': 0})
for column in df.columns.drop(['Age','Gender','class']):
df[column]= df[column].replace({'No':0 , 'Yes': 1})
df['class'] = df ['class'].replace({'Positive':1,'Negative':0 })
df['Gender'] = df ['Gender'].replace({'Female':0,'Male':1 })
# Model Building
X = df.drop(['class'], axis='columns')
y = df['class']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=50, stratify=y)
X_fs = X[['Age', 'Gender','Polyuria', 'Polydipsia','partial paresis','sudden weight loss','Irritability', 'delayed healing','Alopecia','visual blurring']]
X_train, X_test, y_train, y_test = train_test_split(X_fs, y, test_size = 0.2,stratify=y, random_state = 1234)
#Standadize Data
ss = StandardScaler()
X_train = ss.fit_transform(X_train)
X_test = ss.transform(X_test)
# Creating Random Forest Model
rf = RandomForestClassifier(criterion='gini',n_estimators=100)
......
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