You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
healthcare-frontend/lib/dashboard.dart

512 lines
16 KiB

1 year ago
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:healthcare_user/emergency.dart';
import 'package:healthcare_user/invitations.dart';
import 'package:healthcare_user/medicines.dart';
import 'package:healthcare_user/my_health.dart';
import 'package:healthcare_user/prescriptions.dart';
import 'package:healthcare_user/reports.dart';
import 'package:healthcare_user/seekopinion.dart';
1 year ago
import 'package:healthcare_user/settings.dart';
import 'package:image_picker/image_picker.dart';
import 'package:carousel_slider/carousel_slider.dart';
1 year ago
import 'dart:ui' as ui;
import 'login.dart';
class Dashboard extends StatefulWidget {
const Dashboard({super.key});
@override
State<Dashboard> createState() => _DashboardState();
}
class _DashboardState extends State<Dashboard> {
int _selectedIndex = 0;
final List<String> imgList = [
'images/mobilebg.png',
'images/mobilebg2.png',
'images/mobilebg3.png'
1 year ago
];
final ImagePicker _picker = ImagePicker();
bool isTablet = false;
bool isPhone = true;
final double devicePixelRatio = ui.window.devicePixelRatio;
static final ui.Size size1 = ui.window.physicalSize;
final double width = size1.width;
final double height = size1.height;
devicedetection() {
if (devicePixelRatio < 2 && (width >= 1000 || height >= 1000)) {
isTablet = true;
isPhone = false;
} else if (devicePixelRatio == 2 && (width >= 1920 || height >= 1920)) {
isTablet = true;
isPhone = false;
} else {
isTablet = false;
isPhone = true;
}
}
List<String> images = [
"images/seekopinion.png",
"images/reports.png",
"images/prescriptions.png",
"images/medicines.png",
"images/invitations.png",
"images/emergency.png"
];
gridOntap(int ind){
if(ind==0){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SeekOpinion()),
);
}
else if(ind==1){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Reports()),
);
}
else if(ind==2){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Prescriptions()),
);
}
else if(ind==3){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Medicines()),
);
}
else if(ind==4){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Invitations()),
);
}
else if(ind==5){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Emergency()),
);
}
}
1 year ago
Widget _dashBoard() {
return Container(
color: Colors.white,
1 year ago
child: Column(
children: <Widget>[
CarouselSlider(
options: CarouselOptions(
1 year ago
height: MediaQuery.of(context).size.height * .250,
aspectRatio: 16 / 9,
viewportFraction: 0.8,
initialPage: 0,
enableInfiniteScroll: true,
reverse: false,
autoPlay: true,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.ease,
enlargeCenterPage: true,
enlargeFactor: 0.2,
scrollDirection: Axis.horizontal,
),
items: imgList.map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height * .250,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(0),
1 year ago
),
//color: Colors.red,
child: FittedBox(
child: Image(
image: AssetImage(i),
),
fit: BoxFit.fill,
));
},
);
}).toList(),
1 year ago
),
SizedBox(height: 5),
Expanded(child: Container(
padding: EdgeInsets.all(12.0),
child: GridView.builder(
itemCount: images.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 4.0,
mainAxisSpacing: 4.0,),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: (){
gridOntap(index);
},
child: Image.asset(images[index]),
);
},
)),)
1 year ago
],
),
);
}
@override
void initState() {
super.initState();
devicedetection();
}
showLogoutAlertDialog(context) {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('Do you really want to logout?'),
actions: <Widget>[
TextButton(
child: Text('No', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Yes', style: textButtonStyle()),
onPressed: () async {
await AppSettings.clearSharedPreferences();
await Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => Login()),
(Route<dynamic> route) => false,
);
},
),
]);
});
});
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
final shouldPop = await showDialog<bool>(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Do you want to exit app?',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: [
TextButton(
onPressed: () {
SystemNavigator.pop();
},
child: const Text('Yes',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: const Text('No',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
),
],
);
},
);
return shouldPop!;
1 year ago
},
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppSettings.appBar('Health Care'),
1 year ago
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: const BoxDecoration(
color: primaryColor,
),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .20,
height:
MediaQuery.of(context).size.height * .15,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: AssetImage(
"images/profile_pic.png"), // picked file
1 year ago
fit: BoxFit.cover)),
),
onTap: () {},
1 year ago
),
),
Text(
AppSettings.userName,
1 year ago
style: TextStyle(color: Colors.white, fontSize: 15),
),
Text(
AppSettings.phoneNumber,
1 year ago
style: TextStyle(color: Colors.white, fontSize: 15),
),
Text(
AppSettings.email,
1 year ago
style: TextStyle(color: Colors.white, fontSize: 15),
),
],
),
Container()
],
)),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('Edit Profile', style: TextStyle(color: primaryColor)),
],
),
onTap: () {},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('My Health', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MyHealth()),
);
},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('Report Myself', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('My Connections', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('My Medicine Timings', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('Update Pin', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('Update Mobile Number', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {},
1 year ago
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
Text('Update My Location', style: TextStyle(color: primaryColor)),
1 year ago
],
),
onTap: () {},
),
Divider(
color: Colors.grey,
),
ListTile(
title: Row(
children: const [
Image(
image: const AssetImage('images/01.png'),
1 year ago
height: 25,
width: 25,
fit: BoxFit.fill),
const SizedBox(
width: 10,
),
const SizedBox(
width: 10,
),
1 year ago
Text('Logout', style: TextStyle(color: primaryColor)),
],
),
onTap: () {},
1 year ago
),
1 year ago
],
),
),
body: _dashBoard(),
),
);
}
}