Commit 1c336c23 authored by Nilupul Jayasekara's avatar Nilupul Jayasekara

finalize the main functionalities

parent d3d97f22
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- For apps with targetSDK=31 (Android 12) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<queries> <intent> <action android:name="android.intent.action.SENDTO" /> <data android:scheme="mailto" /> </intent> </queries>
<application
android:label="DiaBeta"
android:name="${applicationName}"
......
diabeta_app/assets/images/profile.png

8.69 KB | W: | H:

diabeta_app/assets/images/profile.png

78.2 KB | W: | H:

diabeta_app/assets/images/profile.png
diabeta_app/assets/images/profile.png
diabeta_app/assets/images/profile.png
diabeta_app/assets/images/profile.png
  • 2-up
  • Swipe
  • Onion skin
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/auth_screen.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';
......@@ -24,8 +24,7 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: kPrimaryColor,
),
home: LoginScreen(),
// home: _currentUser != null ? MainScreen() : const LoginScreen(),
home: _currentUser != null ? const AuthScreen() : const LoginScreen(),
);
}
}
class AccountInfo {
String? id;
String? uid;
String? fullname;
String? email;
String? mobile;
String? diabetesType;
String? gender;
DateTime? dob;
DateTime? yod;
AccountInfo({
this.id,
this.uid,
this.fullname,
this.email,
this.mobile,
this.diabetesType,
this.dob,
this.gender,
this.yod});
}
......@@ -23,7 +23,7 @@ class HealthQuestions {
question: "What is your hieght?",
type: QuesType.withSlider,
minValue: 1,
maxValue: 120,
maxValue: 200,
defaultValue: 20,
unit: "cm",
subText: "Your Height"),
......@@ -32,8 +32,8 @@ class HealthQuestions {
question: "What is your weight?",
type: QuesType.withSlider,
minValue: 1,
maxValue: 100,
defaultValue: 20,
maxValue: 200,
defaultValue: 60,
unit: "Kg",
subText: "Your Weight"),
DiabetesQues(
......@@ -143,7 +143,7 @@ class HealthQuestions {
type: QuesType.withSlider,
minValue: 80,
maxValue: 300,
defaultValue: 20,
defaultValue: 100,
unit: "mg/dL",
subText: "Your Cholesterol"),
DiabetesQues(
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/main_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:local_auth/local_auth.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AuthScreen extends StatefulWidget {
const AuthScreen({Key? key}) : super(key: key);
@override
State<AuthScreen> createState() => _AuthScreenState();
}
enum _SupportState {
unknown,
supported,
unsupported,
}
class _AuthScreenState extends State<AuthScreen> {
final LocalAuthentication auth = LocalAuthentication();
_SupportState _supportState = _SupportState.unknown;
bool? _canCheckBiometrics;
List<BiometricType>? _availableBiometrics;
String _authorized = 'Not Authorized';
bool _isAuthenticating = false;
bool isLoad = true;
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
Future<void> _authenticateWithBiometrics() async {
SharedPreferences prefs = await _prefs;
bool authenticated = false;
if (prefs.getBool("isAppLock") == null) {
prefs.setBool("isAppLock", false);
}
if (prefs.getBool("isAppLock")!) {
isLoad = false;
try {
setState(() {
_isAuthenticating = true;
_authorized = 'Authenticating';
});
authenticated = await auth.authenticate(
localizedReason: 'Scan your fingerprint to authenticate',
options: const AuthenticationOptions(
stickyAuth: true,
biometricOnly: true,
),
);
setState(() {
_isAuthenticating = false;
_authorized = 'Authenticating';
});
} on PlatformException catch (e) {
setState(() {
_isAuthenticating = false;
_authorized = 'Error - ${e.message}';
});
return;
}
if (!mounted) {
return;
}
if (authenticated) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const MainScreen()),
);
}
} else {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const MainScreen()),
);
}
}
@override
void initState() {
auth.isDeviceSupported().then(
(bool isSupported) => setState(() => _supportState = isSupported
? _SupportState.supported
: _SupportState.unsupported),
);
_authenticateWithBiometrics();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: isLoad
? Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Image.asset(
"assets/images/frontlogo.png",
width: 300,
height: 300,
),
),
const Center(
child: Text(
"DiaBeta",
style: TextStyle(fontSize: 36, color: Colors.teal),
),
),
],
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MainScreen()),
);
},
child: Padding(
padding: const EdgeInsets.only(bottom: 40),
child: Text(
"Continue",
style: TextStyle(
color: kPrimaryColor,
fontWeight: FontWeight.bold,
fontSize: 16),
),
),
),
],
)
: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Image.asset(
"assets/images/frontlogo.png",
width: 300,
height: 300,
),
),
const Center(
child: Text(
"DiaBeta Locked",
style: TextStyle(fontSize: 24, color: Colors.teal),
),
),
],
),
InkWell(
onTap: () {
_authenticateWithBiometrics();
},
child: Padding(
padding: const EdgeInsets.only(bottom: 40),
child: Text(
"Unlock",
style: TextStyle(
color: kPrimaryColor,
fontWeight: FontWeight.bold,
fontSize: 16),
),
),
),
],
),
);
}
}
......@@ -9,8 +9,10 @@ import 'package:diabeta_app/screens/reports/report_screen.dart';
import 'package:diabeta_app/services/diabates_predict_service.dart';
import 'package:diabeta_app/services/glucose_log_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import '../model/glucose_data.dart';
......@@ -27,9 +29,39 @@ class _DashboardScreenState extends State<DashboardScreen> {
List<SplineAreaWeightData> _chartData = <SplineAreaWeightData>[];
List<SplineAreaWeightData> _chartData1 = <SplineAreaWeightData>[];
final _currentUser = FirebaseAuth.instance.currentUser;
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
bool ismodelCalled = false;
int color = 0xFF34eb43;
void _changeGlucoseColor(int glucose) {
if (glucose > 315) {
setState(() {
color = 0xFFff0000;
});
} else if (glucose > 180) {
setState(() {
color = 0xFFfa5c5c;
});
} else if (glucose > 120) {
setState(() {
color = 0xFFff9d00;
});
} else if (glucose > 70) {
setState(() {
color = 0xFF34eb43;
});
} else if (glucose > 0) {
setState(() {
color = 0xFFff0000;
});
}
}
void getChartData() async {
List<SplineAreaWeightData> _data = <SplineAreaWeightData>[];
final SharedPreferences prefs = await _prefs;
var glucoseData = [];
List data = await GlucoseLogService.getRecordsByTimeFrame(
_currentUser!.uid, "This year",
......@@ -61,7 +93,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
}
});
if (lastDate != null) {
if (prefs.getBool("isForecast") == null) {
prefs.setBool("isForecast", true);
}
if (lastDate != null && prefs.getBool("isForecast")!) {
String futureData = await DiabatesPredictService.getFuturGlucoseLevel(
DateTime(lastDate!.year, lastDate!.month, lastDate!.day + 1),
glucoseData);
......@@ -113,6 +148,19 @@ class _DashboardScreenState extends State<DashboardScreen> {
void initState() {
//initialaizeLineChart();
getChartData();
DatabaseReference starCountRef = FirebaseDatabase.instance.ref('2/Glucose');
starCountRef.onValue.listen((DatabaseEvent event) {
final data = event.snapshot.value;
print(data);
if (mounted) {
setState(() {
if (data != 0 && !ismodelCalled) {
ismodelCalled = true;
showModelDialog(int.parse(data.toString()));
}
});
}
});
super.initState();
}
......@@ -127,7 +175,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const GlucoseLogScreen()),
).then((_) => setState(() {}));
);
},
child: const Icon(Icons.add)),
body: ListView(
......@@ -400,4 +448,173 @@ class _DashboardScreenState extends State<DashboardScreen> {
),
);
}
void showModelDialog(int glucose) async {
final SharedPreferences prefs = await _prefs;
if (prefs.getBool("isDiaBetaConnect") == null) {
prefs.setBool("isDiaBetaConnect", false);
} else {
if (prefs.getBool("isDiaBetaConnect")!) {
_changeGlucoseColor(glucose);
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return Container(
height: 500,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Column(
children: [
SizedBox(
height: 16,
),
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: () {
FirebaseDatabase.instance
.ref('2/Glucose')
.set(0)
.then((_) {
ismodelCalled = false;
Navigator.pop(context);
}).catchError((error) {});
},
),
const Text(
'Glucometer',
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
InkWell(
child: const Text(
'Done',
style: TextStyle(
fontSize: 16,
color: Colors.teal,
fontWeight: FontWeight.bold),
),
onTap: () {
setState(() {});
FirebaseDatabase.instance
.ref('2/Glucose')
.set(0)
.then((_) {
ismodelCalled = false;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GlucoseLogScreen(
glucose: glucose.toString(),
)),
);
}).catchError((error) {});
},
),
],
),
),
Divider(
color: kPrimaryColor,
),
Stack(
children: [
Center(
child: Image.asset(
"assets/images/glucometer.png",
width: 250,
height: 350,
),
),
Padding(
padding: const EdgeInsets.only(
top: 145,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Column(
children: [
Text(
"Glucose level",
),
SizedBox(
height: 16,
),
Text(
glucose.toString() + " mg/dL",
style: TextStyle(
fontSize: 26, color: Color(color)),
)
],
),
),
// SizedBox(
// height: 16,
// ),
// Padding(
// padding: const EdgeInsets.only(left: 100.0),
// child: Column(
// children: [
// Row(
// children: [
// Text(
// 'Heart rate : ',
// style: TextStyle(fontSize: 12),
// ),
// Text(
// "187.53 bpm",
// style: TextStyle(fontSize: 12),
// )
// ],
// ),
// Row(
// children: [
// Text(
// 'Oxygen level : ',
// style: TextStyle(fontSize: 12),
// ),
// Text(
// "97%",
// style: TextStyle(fontSize: 12),
// )
// ],
// ),
// ],
// ),
// )
],
),
)
],
),
],
),
);
}).whenComplete(_onBottomSheetClosed);
}
}
}
void _onBottomSheetClosed() {
FirebaseDatabase.instance.ref('2/Glucose').set(0).then((_) {
ismodelCalled = false;
}).catchError((error) {});
}
}
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/screens/main_screen.dart';
import 'package:diabeta_app/services/glucose_log_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
......@@ -11,8 +12,9 @@ import '../../../components/yes_no_model.dart';
class GlucoseLogScreen extends StatefulWidget {
final String title;
final String? glucose;
final LogEntry? logEntry;
const GlucoseLogScreen({Key? key, this.title = "", this.logEntry})
const GlucoseLogScreen({Key? key, this.title = "", this.logEntry, this.glucose})
: super(key: key);
@override
......@@ -55,20 +57,13 @@ class _GlucoseLogScreenState extends State<GlucoseLogScreen> {
@override
void initState() {
DatabaseReference starCountRef = FirebaseDatabase.instance.ref('2/Glucose');
starCountRef.onValue.listen((DatabaseEvent event) {
final data = event.snapshot.value;
print(data);
if (mounted) {
setState(() {
if (data != 0) {
_glucoseController.text = data.toString();
}
});
if(widget.glucose != null){
_glucoseController.text = widget.glucose!;
_changeGlucoseColor(int.parse(widget.glucose!));
}
});
if (widget.title != "") {
if (widget.logEntry!.glucoseLevel != null) {
_changeGlucoseColor(widget.logEntry!.glucoseLevel!.toInt());
_glucoseController.text = widget.logEntry!.glucoseLevel.toString();
}
if (widget.logEntry!.carbs != null) {
......@@ -244,15 +239,14 @@ class _GlucoseLogScreenState extends State<GlucoseLogScreen> {
? <Widget>[
IconButton(
onPressed: () async {
FirebaseDatabase.instance.ref('2/Glucose').set(0).then((_) {
// Data saved successfully!
}).catchError((error) {
// The write failed...
});
if (_formKey.currentState!.validate()) {
bool result = await _addRecord();
if (result) {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MainScreen()),
);
}
}
},
......
......@@ -404,6 +404,10 @@ class _FoodRecommendationScreenState extends State<FoodRecommendationScreen> {
clean_input += "notdesert ";
}
if(vegNonVeg == "Non Veg"){
vegNonVeg = "non";
}
clean_input += foodType+' ';
clean_input += vegNonVeg+ ' ';
......
......@@ -5,6 +5,7 @@ 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 'package:url_launcher/url_launcher.dart';
import 'diabetes/screens/quiz_screen1.dart';
......@@ -16,6 +17,12 @@ class HealthCheckScreen extends StatefulWidget {
}
class _HealthCheckScreenState extends State<HealthCheckScreen> {
Future<void> _launchUrl(_url) async {
if (!await launchUrl(Uri.parse(_url))) {
throw 'Could not launch $_url';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -43,14 +50,6 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
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),
......@@ -60,10 +59,18 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
const Text(
'Could You Have Prediabetes?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold),
fontSize: 18, fontWeight: FontWeight.bold),
),
Padding(
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const QuizScreen1()),
);
},
child: Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 16.0),
child: Container(
......@@ -83,20 +90,21 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
)),
),
),
),
const Text(
'Could You Have Type 2 Diabetes?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold),
fontSize: 18, fontWeight: FontWeight.bold),
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const QuizScreen()),
);
_launchUrl("https://diabeta.000webhostapp.com/educations.html");
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// const QuizScreen()),
// );
},
child: Padding(
padding: const EdgeInsets.only(
......@@ -121,7 +129,6 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
),
],
),
),
));
});
// showDialog(
......@@ -143,7 +150,8 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const HeartRiskScreen()),
MaterialPageRoute(
builder: (context) => const HeartRiskScreen()),
);
},
),
......@@ -167,7 +175,8 @@ class _HealthCheckScreenState extends State<HealthCheckScreen> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const KidneyRiskScreen()),
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';
import 'package:flutter/services.dart';
import 'package:local_auth/local_auth.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);
......@@ -13,19 +10,7 @@ class LoginScreen extends StatefulWidget {
State<LoginScreen> createState() => _LoginScreenState();
}
enum _SupportState {
unknown,
supported,
unsupported,
}
class _LoginScreenState extends State<LoginScreen> {
final LocalAuthentication auth = LocalAuthentication();
_SupportState _supportState = _SupportState.unknown;
bool? _canCheckBiometrics;
List<BiometricType>? _availableBiometrics;
String _authorized = 'Not Authorized';
bool _isAuthenticating = false;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController _userNameController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
......@@ -35,52 +20,6 @@ class _LoginScreenState extends State<LoginScreen> {
@override
void initState() {
super.initState();
auth.isDeviceSupported().then(
(bool isSupported) => setState(() => _supportState = isSupported
? _SupportState.supported
: _SupportState.unsupported),
);
_authenticateWithBiometrics();
}
Future<void> _authenticateWithBiometrics() async {
bool authenticated = false;
try {
setState(() {
_isAuthenticating = true;
_authorized = 'Authenticating';
});
authenticated = await auth.authenticate(
localizedReason:
'Scan your fingerprint to authenticate',
options: const AuthenticationOptions(
stickyAuth: true,
biometricOnly: true,
),
);
setState(() {
_isAuthenticating = false;
_authorized = 'Authenticating';
});
} on PlatformException catch (e) {
print(e);
setState(() {
_isAuthenticating = false;
_authorized = 'Error - ${e.message}';
});
return;
}
if (!mounted) {
return;
}
final String message = authenticated ? 'Authorized' : 'Not Authorized';
if(authenticated){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const MainScreen()),
);
}
}
@override
......@@ -96,7 +35,7 @@ class _LoginScreenState extends State<LoginScreen> {
child: Image.asset(
"assets/images/frontlogo.png",
width: 300,
height: 350,
height: 300,
),
),
const Center(
......@@ -176,20 +115,6 @@ class _LoginScreenState extends State<LoginScreen> {
if (_formKey.currentState!.validate()) {
_login();
}
// if (_userNameController.text == "amal" &&
// _passwordController.text == "1234") {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const MainScreen()),
// );
// } else {
// const snackBar = SnackBar(
// content: Text("Invalid username or password."),
// backgroundColor: Colors.red);
// ScaffoldMessenger.of(context)
// .showSnackBar(snackBar);
// }
},
child: const Text(
'Login',
......@@ -203,9 +128,7 @@ class _LoginScreenState extends State<LoginScreen> {
),
),
),
SizedBox(
height: 16,
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: Center(
......@@ -291,6 +214,9 @@ class _LoginScreenState extends State<LoginScreen> {
// );
// },
// ),
const SizedBox(
height: 24,
),
],
),
),
......
import 'package:diabeta_app/model/account_info.dart';
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';
......@@ -7,6 +8,7 @@ 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:diabeta_app/services/account_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../components/constants.dart';
......@@ -24,6 +26,21 @@ class _MainScreenState extends State<MainScreen> {
String period = "All records";
String _title = "DiaBeta";
final _currentUser = FirebaseAuth.instance.currentUser;
String fullname = "";
@override
void initState() {
getAccountInfo();
super.initState();
}
void getAccountInfo() async {
AccountInfo accountInfo =
await AccountService.getAccountInfoByID(_currentUser!.uid);
setState(() {
fullname = accountInfo.fullname ?? "";
});
}
@override
Widget build(BuildContext context) {
......@@ -100,7 +117,7 @@ class _MainScreenState extends State<MainScreen> {
Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
_currentUser!.displayName.toString(),
fullname,
style: const TextStyle(color: Colors.white),
),
),
......@@ -282,30 +299,23 @@ class _MainScreenState extends State<MainScreen> {
Navigator.pop(context);
},
),
ListTile(
title: Row(
children: const [
Icon(
Icons.exit_to_app,
color: kPrimaryColor,
),
SizedBox(
width: 8,
),
Text('Logout')
],
),
onTap: () async {
try {
await FirebaseAuth.instance.signOut();
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
);
} on FirebaseAuthException catch (e) {}
},
),
// ListTile(
// title: Row(
// children: const [
// Icon(
// Icons.exit_to_app,
// color: kPrimaryColor,
// ),
// SizedBox(
// width: 8,
// ),
// Text('Logout')
// ],
// ),
// onTap: () async {
// },
// ),
],
),
),
......@@ -335,7 +345,8 @@ class _MainScreenState extends State<MainScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
......@@ -373,6 +384,7 @@ class _MainScreenState extends State<MainScreen> {
],
),
),
),
const Divider(),
Container(
height: 32,
......
......@@ -46,7 +46,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
child: Image.asset(
"assets/images/frontlogo.png",
width: 300,
height: 350,
height: 300,
),
),
const Padding(
......
......@@ -73,8 +73,7 @@ class _ReminderDetailsState extends State<ReminderDetails> {
return Scaffold(
appBar: AppBar(
elevation: 0,
title: const Text("Reminder Details"),
centerTitle: true,
title: const Text("Add Reminder"),
leading: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
......@@ -119,15 +118,12 @@ class _ReminderDetailsState extends State<ReminderDetails> {
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(17.0),
padding: const EdgeInsets.all(16.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(
......
......@@ -33,8 +33,8 @@ class _ReportScreenState extends State<ReportScreen> {
List<SplineAreaWeightData> _chartGlucoseData = <SplineAreaWeightData>[];
List<SplineAreaWeightData> _chartCarbData = <SplineAreaWeightData>[];
final _currentUser = FirebaseAuth.instance.currentUser;
int _gselectedIndex = 0;
int _cselectedIndex = 0;
int _gselectedIndex = 2;
int _cselectedIndex = 2;
void getChartGlucoseDataByTimeFrame() async {
List<SplineAreaWeightData> _data = <SplineAreaWeightData>[];
......
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/model/account_info.dart';
import 'package:diabeta_app/services/account_service.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../login_screen.dart';
class AccountScreen extends StatefulWidget {
const AccountScreen({Key? key}) : super(key: key);
......@@ -9,6 +15,79 @@ class AccountScreen extends StatefulWidget {
}
class _AccountScreenState extends State<AccountScreen> {
String genderValue = "";
String diabetesValues = "";
DateTime? dobDate = null;
DateTime? yodDate = null;
TextEditingController _nameController = TextEditingController();
TextEditingController _emailController = TextEditingController();
TextEditingController _mobileController = TextEditingController();
final _currentUser = FirebaseAuth.instance.currentUser;
bool isAccountExist = false;
AccountInfo accountInfo = new AccountInfo();
var genders = [
'',
'Male',
'Female',
];
var diabetes = ['', 'Type 1', 'Type 2', 'Other'];
@override
void initState() {
getAccountInfo();
super.initState();
}
void getAccountInfo() async {
accountInfo = await AccountService.getAccountInfoByID(_currentUser!.uid);
if (accountInfo.email != null) {
isAccountExist = true;
}
_emailController.text = _currentUser!.email!;
_mobileController.text =
accountInfo.mobile != null ? accountInfo.mobile! : "";
_nameController.text =
accountInfo.fullname != null ? accountInfo.fullname! : "";
setState(() {
genderValue = accountInfo.gender != null ? accountInfo.gender! : "";
diabetesValues =
accountInfo.diabetesType != null ? accountInfo.diabetesType! : "";
yodDate = accountInfo.yod;
dobDate = accountInfo.dob;
});
}
Future pickDOBDate(BuildContext context) async {
FocusScope.of(context).requestFocus(FocusNode());
final initialDate = DateTime(1990);
final newDate = await showDatePicker(
context: context,
initialDate: initialDate,
firstDate: DateTime(DateTime.now().year - 50),
lastDate: DateTime(DateTime.now().year - 5));
if (newDate == null) return;
setState(() {
dobDate = newDate;
});
}
Future pickYODDate(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 - 50),
lastDate: DateTime.now());
if (newDate == null) return;
setState(() {
yodDate = newDate;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -17,11 +96,360 @@ class _AccountScreenState extends State<AccountScreen> {
elevation: 0,
backgroundColor: kPrimaryColor,
),
body: ListView(
body: SingleChildScrollView(
child: Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Account Info',
style: TextStyle(fontSize: 12, color: kPrimaryColor),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Full Name",
style: TextStyle(fontSize: 14),
),
Container(
width: 180,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey))),
child: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: TextFormField(
keyboardType: TextInputType.text,
controller: _nameController,
decoration: const InputDecoration(
border: InputBorder.none,
isDense: true,
isCollapsed: true),
),
),
),
],
),
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Email",
style: TextStyle(fontSize: 14),
),
Container(
width: 180,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey))),
child: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: TextFormField(
enabled: false,
style: const TextStyle(color: Colors.grey),
keyboardType: TextInputType.emailAddress,
controller: _emailController,
decoration: const InputDecoration(
border: InputBorder.none,
isDense: true,
isCollapsed: true),
),
),
),
],
),
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Mobile No",
style: TextStyle(fontSize: 14),
),
Container(
width: 180,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey))),
child: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: TextFormField(
keyboardType: TextInputType.number,
controller: _mobileController,
decoration: const InputDecoration(
border: InputBorder.none,
isDense: true,
isCollapsed: true),
),
),
),
],
),
),
],
),
),
Divider(),
SizedBox(
height: 24,
),
Text(
'Basic therapy info',
style: TextStyle(fontSize: 12, color: kPrimaryColor),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Diabetes Type",
style: TextStyle(fontSize: 14),
),
DropdownButton(
// Initial Value
value: diabetesValues,
isDense: true,
// Down Arrow Icon
icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: diabetes.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(items),
);
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
diabetesValues = newValue!;
});
},
),
],
),
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Gender",
style: TextStyle(fontSize: 14),
),
DropdownButton(
// Initial Value
value: genderValue,
isDense: true,
// Down Arrow Icon
icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: genders.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(items),
);
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
genderValue = newValue!;
});
},
),
],
),
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Date of birth",
style: TextStyle(fontSize: 14),
),
InkWell(
child: dobDate == null
? Text("Not Set")
: Text(DateFormat('MMMM dd, yyyy')
.format(dobDate!)),
onTap: () {
pickDOBDate(context);
},
)
],
),
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Year of diagnosis",
style: TextStyle(fontSize: 14),
),
InkWell(
child: yodDate == null
? Text("Not Set")
: Text(DateFormat('MMMM dd, yyyy')
.format(yodDate!)),
onTap: () {
pickYODDate(context);
},
)
],
),
),
],
),
),
Divider(),
Text(
"Sex, age and diabetes duration affect your metabolism.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
SizedBox(
height: 32,
),
ConstrainedBox(
constraints: const BoxConstraints.tightFor(
height: 35, width: double.infinity),
child: ElevatedButton(
onPressed: () async {
AccountInfo accountInfo1 = AccountInfo(
uid: _currentUser!.uid,
fullname: _nameController.text,
email: _emailController.text,
mobile: _mobileController.text,
diabetesType: diabetesValues,
dob: dobDate,
gender: genderValue,
yod: yodDate);
if (isAccountExist) {
bool result = await AccountService.editRecord(
accountInfo1, accountInfo.id);
if (result) {
const snackBar = SnackBar(
content:
Text("Account info updated successfully."),
backgroundColor: kPrimaryColor);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
} else {
String? id =
await AccountService.addRecord(accountInfo1);
if (id != null) {
const snackBar = SnackBar(
content: Text("Account info saved successfully."),
backgroundColor: kPrimaryColor);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
}
},
child: const Text(
'Save changes',
style: TextStyle(fontSize: 16),
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: kPrimaryColor,
),
),
),
SizedBox(
height: 16,
),
ConstrainedBox(
constraints: const BoxConstraints.tightFor(
height: 35, width: double.infinity),
child: ElevatedButton(
onPressed: () async {
try {
await FirebaseAuth.instance.signOut();
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const LoginScreen(),
),
);
} on FirebaseAuthException catch (e) {}
},
child: const Text(
'Logout',
style: TextStyle(fontSize: 16),
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: kSecondaryColor,
),
),
),
],
),
),
),
),
);
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class OtherSettingsScreen extends StatefulWidget {
const OtherSettingsScreen({Key? key}) : super(key: key);
......@@ -9,6 +10,34 @@ class OtherSettingsScreen extends StatefulWidget {
}
class _OtherSettingsScreenState extends State<OtherSettingsScreen> {
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
bool isAppLock = false;
bool isForecast = false;
bool isDiaBetaConnect = false;
@override
void initState() {
initializevalues();
super.initState();
}
Future<void> initializevalues() async {
final SharedPreferences prefs = await _prefs;
if (prefs.getBool("isForecast") == null) {
prefs.setBool("isForecast", false);
} else if (prefs.getBool("isAppLock") == null) {
prefs.setBool("isAppLock", false);
} else if (prefs.getBool("isDiaBetaConnect") == null) {
prefs.setBool("isDiaBetaConnect", false);
}
setState(() {
isForecast = prefs.getBool("isForecast")!;
isAppLock = prefs.getBool("isAppLock")!;
isDiaBetaConnect = prefs.getBool("isDiaBetaConnect")!;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -17,68 +46,329 @@ class _OtherSettingsScreenState extends State<OtherSettingsScreen> {
elevation: 0,
backgroundColor: kPrimaryColor,
),
body: ListView(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Padding(
// padding: const EdgeInsets.only(top: 16, right: 16),
// child: Image.asset(
// "assets/images/settings.png",
// width: 70,
// height: 70,
// ),
// ),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: const [
// Text(
// "No need to change these, ",
// style: TextStyle(color: Colors.grey),
// ),
// SizedBox(
// height: 4,
// ),
// Text(
// "but of course you can.",
// style: TextStyle(color: Colors.grey),
// )
// ],
// )
// ],
// ),
SizedBox(
height: 16,
),
Text(
'Privacy',
style: TextStyle(fontSize: 12, color: kPrimaryColor),
),
Divider(),
Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.only(left: 32, top:16, right: 16),
child: Image.asset(
"assets/images/settings.png",
width: 70,
height: 70,
Text(
"App Lock",
style: TextStyle(fontSize: 14),
),
],
),
Switch(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: isAppLock,
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
setState(() {
prefs
.setBool('isAppLock', value)
.then((bool success) {
isAppLock = value;
});
});
},
activeTrackColor: Colors.teal[300],
activeColor: kPrimaryColor,
),
],
),
),
],
),
Divider(),
Text(
"Require screen lock when you open the app.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const[
Text("No need to change these, ", style: TextStyle(color: Colors.grey),),
SizedBox(
height: 4,
height: 32,
),
Text(
'Your personal and medical data',
style: TextStyle(fontSize: 12, color: kPrimaryColor),
),
Divider(),
Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
"Export data",
style: TextStyle(fontSize: 14),
),
Text("but of course you can.",style: TextStyle(color: Colors.grey),)
],
)
),
],
),
),
],
),
Divider(),
Text(
"Export all your data in the app.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
Divider(),
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Container(
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(
Icons.settings,
size: 25,
color: kPrimaryColor,
Text(
"Forecast glucose level",
style: TextStyle(fontSize: 14),
),
],
),
Switch(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: isForecast,
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
setState(() {
prefs
.setBool('isForecast', value)
.then((bool success) {
isForecast = value;
});
});
},
activeTrackColor: Colors.teal[300],
activeColor: kPrimaryColor,
),
],
),
),
],
),
Divider(),
Text(
"Forecast your glucose level for next two days.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
Divider(),
Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
" Other settings",
"Connect DiaBeta device",
style: TextStyle(fontSize: 14),
),
],
),
Icon(
Icons.arrow_forward_ios,
size: 16,
color: kPrimaryColor,
)
Switch(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: isDiaBetaConnect,
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
setState(() {
prefs
.setBool('isDiaBetaConnect', value)
.then((bool success) {
isDiaBetaConnect = value;
});
});
},
activeTrackColor: Colors.teal[300],
activeColor: kPrimaryColor,
),
],
),
),
],
),
Divider(),
Text(
"Automatically connect to DiaBeta device",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
SizedBox(
height: 32,
),
Text(
'Account',
style: TextStyle(fontSize: 12, color: kPrimaryColor),
),
Divider(),
InkWell(
onTap: () {
showDeleteAccount();
},
child: Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
"Delete my account",
style: TextStyle(
fontSize: 14, color: Colors.redAccent),
),
],
),
],
),
),
],
),
),
Divider(),
Text(
"If you delete your account, your data will gone forever.",
style: TextStyle(fontSize: 12, color: Colors.grey),
)
],
),
),
);
}
void showDeleteAccount() {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return DeleteAccount();
},
);
}
}
class DeleteAccount extends StatelessWidget {
const DeleteAccount({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Container(
height: 400,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
'Are you sure?',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
Divider(),
const Text(
'Delete account?',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.redAccent),
),
Image.asset(
"assets/images/heart.jpg",
width: 100,
height: 150,
),
SizedBox(
width: double.infinity,
child: Text(
"We're so sad to see you go. Please be aware that by deleting your account, your data will be gone forever.",
),
),
SizedBox(
height: 30,
),
ConstrainedBox(
constraints: const BoxConstraints.tightFor(
height: 45, width: double.infinity),
child: ElevatedButton(
onPressed: () {},
child: const Text(
'Delete',
style: TextStyle(fontSize: 16),
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: Colors.redAccent,
),
),
),
SizedBox(
height: 16,
),
],
),
),
),
);
}
}
import 'package:diabeta_app/components/constants.dart';
import 'package:diabeta_app/screens/settings/account_screen.dart';
import 'package:diabeta_app/screens/settings/other_settings_screen.dart';
import 'package:diabeta_app/screens/settings/subscribe_screen.dart';
import 'package:smooth_star_rating_nsafe/smooth_star_rating.dart';
import 'package:flutter/material.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:share/share.dart';
class SettingsScreen extends StatefulWidget {
const SettingsScreen({Key? key}) : super(key: key);
......@@ -67,16 +71,25 @@ class _SettingsScreenState extends State<SettingsScreen> {
Divider(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SubscribeScreen()),
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"My subcription",
),
Text("Basic")
Text("PRO")
],
),
),
),
Divider(),
],
),
......@@ -87,11 +100,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
padding: const EdgeInsets.symmetric(horizontal: 20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const AccountScreen()),
);
showSupportFeedbackPage();
},
child: Container(
child: Row(
......@@ -123,18 +132,54 @@ class _SettingsScreenState extends State<SettingsScreen> {
],
),
Divider(),
// Column(
// children: [
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 20),
// child: InkWell(
// onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const AccountScreen()),
// );
// },
// child: Container(
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Row(
// children: [
// Icon(
// Icons.emoji_events,
// size: 25,
// color: kPrimaryColor,
// ),
// Text(
// " Challenges",
// style: TextStyle(fontSize: 14),
// ),
// ],
// ),
// Icon(
// Icons.arrow_forward_ios,
// size: 16,
// color: kPrimaryColor,
// )
// ],
// ),
// ),
// ),
// ),
// ],
// ),
// Divider(),
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const AccountScreen()),
);
},
onTap: () {},
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
......@@ -142,12 +187,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
Row(
children: [
Icon(
Icons.emoji_events,
Icons.class_,
size: 25,
color: kPrimaryColor,
),
Text(
" Challenges",
" User Manual",
style: TextStyle(fontSize: 14),
),
],
......@@ -171,11 +216,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
padding: const EdgeInsets.symmetric(horizontal: 20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const AccountScreen()),
);
showRecommendDiaBetaView();
},
child: Container(
child: Row(
......@@ -184,12 +225,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
Row(
children: [
Icon(
Icons.class_,
Icons.favorite,
size: 25,
color: kPrimaryColor,
),
Text(
" User Manual",
" Recommend DiaBeta",
style: TextStyle(fontSize: 14),
),
],
......@@ -216,7 +257,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const AccountScreen()),
builder: (context) => const OtherSettingsScreen()),
);
},
child: Container(
......@@ -226,12 +267,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
Row(
children: [
Icon(
Icons.favorite,
Icons.settings,
size: 25,
color: kPrimaryColor,
),
Text(
" Recommend DiaBeta",
" Other settings",
style: TextStyle(fontSize: 14),
),
],
......@@ -249,49 +290,219 @@ class _SettingsScreenState extends State<SettingsScreen> {
],
),
Divider(),
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const OtherSettingsScreen()),
],
);
},
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
}
void showSupportFeedbackPage() {
showDialog(
context: context,
builder: (context) {
return SupportDialog();
});
}
void showRecommendDiaBetaView() {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return RecommedDiaBeta();
});
}
}
class RecommedDiaBeta extends StatefulWidget {
const RecommedDiaBeta({Key? key}) : super(key: key);
@override
State<RecommedDiaBeta> createState() => _RecommedDiaBetaState();
}
class _RecommedDiaBetaState extends State<RecommedDiaBeta> {
@override
Widget build(BuildContext context) {
return Container(
height: 400,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 32),
child: Column(
children: [
Icon(
Icons.settings,
size: 25,
color: kPrimaryColor,
const Text(
'Like DiaBeta? Share the love!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: kPrimaryColor),
),
SizedBox(
height: 16,
),
Image.asset(
"assets/images/share.png",
width: 150,
height: 200,
),
SizedBox(
height: 16,
),
ConstrainedBox(
constraints: const BoxConstraints.tightFor(
height: 45, width: double.infinity),
child: ElevatedButton(
onPressed: () {
Share.share(
'Visit our website https://diabeta.000webhostapp.com/educations.html');
Navigator.pop(context);
},
child: const Text(
'Share with friends',
style: TextStyle(fontSize: 16),
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: kPrimaryColor,
),
Text(
" Other settings",
style: TextStyle(fontSize: 14),
),
),
SizedBox(
height: 16,
),
const Text(
'Thank you!',
style: TextStyle(fontSize: 14, color: kPrimaryColor),
),
],
),
Icon(
Icons.arrow_forward_ios,
size: 16,
),
);
}
}
class SupportDialog extends StatefulWidget {
const SupportDialog({Key? key}) : super(key: key);
@override
State<SupportDialog> createState() => _SupportDialogState();
}
class _SupportDialogState extends State<SupportDialog> {
double rating = 5;
TextEditingController _bodyController = TextEditingController();
Future<void> send() async {
final Email email = Email(
body: _bodyController.text + "\n User rating : " + rating.toString(),
subject: "DiaBeta Support and Feedback",
recipients: ["diabetasystem@gmail.com"],
);
String platformResponse;
try {
await FlutterEmailSender.send(email);
platformResponse = 'success';
} catch (error) {
print(error);
platformResponse = error.toString();
}
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return AlertDialog(
content: Container(
height: 370,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
'What is your rate?',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
SizedBox(
height: 8,
),
SmoothStarRating(
allowHalfRating: false,
onRatingChanged: (v) {
setState(() {
rating = v;
});
},
starCount: 5,
rating: rating,
size: 40.0,
filledIconData: Icons.star,
halfFilledIconData: Icons.star_half,
defaultIconData: Icons.star_border,
color: kPrimaryColor,
)
],
borderColor: kPrimaryColor,
spacing: 0.0),
SizedBox(
height: 32,
),
const Text(
'Please share your opinion?',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
SizedBox(
height: 16,
),
TextField(
controller: _bodyController,
maxLines: 6,
minLines: 5,
decoration: const InputDecoration(
filled: true,
fillColor: Colors.white,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: Colors.teal))),
),
SizedBox(
height: 16,
),
ConstrainedBox(
constraints: const BoxConstraints.tightFor(
height: 45, width: double.infinity),
child: ElevatedButton(
onPressed: () {
send();
},
child: const Text(
'Send',
style: TextStyle(fontSize: 16),
),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
elevation: 0,
primary: kPrimaryColor,
),
),
),
],
),
Divider(),
],
),
),
);
}
}
import 'package:flutter/material.dart';
class SubscribeScreen extends StatelessWidget {
const SubscribeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0.5,
centerTitle: true,
actions: [
IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
Icons.close,
color: Colors.black87,
size: 20,
))
],
title: const Text(
"Subscribe",
style: TextStyle(color: Colors.black87, fontSize: 16),
),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
SizedBox(
width: double.infinity,
child: const Text(
"Choose your favourite plan and do something good for you and your diabetes.",
textAlign: TextAlign.center,
),
),
Card()
],
),
),
),
);
}
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:diabeta_app/model/account_info.dart';
class AccountService {
static final CollectionReference _records =
FirebaseFirestore.instance.collection('account_info');
static Future<String> addRecord(AccountInfo accountInfo) {
return _records.add({
'uid': accountInfo.uid,
'fullname': accountInfo.fullname,
'email': accountInfo.email,
'mobile': accountInfo.mobile,
'diabetesType': accountInfo.diabetesType,
'gender': accountInfo.gender,
'dob': accountInfo.dob,
'yod': accountInfo.yod
}).then((value) {
return value.id;
}).catchError((error) {
return "";
});
}
static Future<bool> editRecord(AccountInfo accountInfo, String? id) {
return _records
.doc(id)
.update({
'fullname': accountInfo.fullname,
'email': accountInfo.email,
'mobile': accountInfo.mobile,
'diabetesType': accountInfo.diabetesType,
'gender': accountInfo.gender,
'dob': accountInfo.dob,
'yod': accountInfo.yod
})
.then((value) => true)
.catchError((error) => false);
}
static Future<AccountInfo> getAccountInfoByID(String id) async {
AccountInfo accountInfo = new AccountInfo();
await _records
.where("uid", isEqualTo: id)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
accountInfo = AccountInfo(
id: doc.id,
uid: doc["uid"],
dob: doc["dob"] !=null ? DateTime.parse(doc["dob"].toDate().toString()): null,
yod: doc["yod"] != null ? DateTime.parse(doc["yod"].toDate().toString()): null,
diabetesType: doc["diabetesType"],
email: doc["email"],
fullname: doc["fullname"],
gender: doc["gender"],
mobile: doc["mobile"],
);
});
}).catchError((error) {
print(error);
});
return accountInfo;
}
}
......@@ -265,6 +265,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.1"
flutter_email_sender:
dependency: "direct main"
description:
name: flutter_email_sender
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
flutter_lints:
dependency: "direct dev"
description:
......@@ -471,6 +478,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
outline_search_bar:
dependency: "direct main"
description:
......@@ -604,6 +618,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.27.5"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences:
dependency: "direct main"
description:
......@@ -672,6 +693,13 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
smooth_star_rating_nsafe:
dependency: "direct main"
description:
name: smooth_star_rating_nsafe
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0+1"
source_span:
dependency: transitive
description:
......@@ -742,6 +770,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.6"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.21"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
vector_math:
dependency: transitive
description:
......
......@@ -61,6 +61,10 @@ dependencies:
google_fonts: ^3.0.1
firebase_database: ^9.1.7
local_auth: ^2.1.2
smooth_star_rating_nsafe: 1.0.0+1
flutter_email_sender: ^5.1.0
share: ^2.0.4
url_launcher: ^6.1.6
dev_dependencies:
flutter_test:
......
......@@ -7,7 +7,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:diabeta_app/main.dart';
void main() {
......
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