Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelSena19 committed Jan 17, 2024
1 parent 7ab4772 commit 87e17bf
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 56 deletions.
8 changes: 7 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:device_preview/device_preview.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
Expand All @@ -24,7 +25,12 @@ void main() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
runApp(
DevicePreview(
enabled: true,
builder: (context) => const MyApp(),
)
);
}

class MyApp extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/user_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UserProvider with ChangeNotifier {
gender: 'gender',
healthConditions: 'healthConditions',
height: 'height',
imagePath: 'imagePath',
imagePath: 'https://th.bing.com/th/id/R.e62421c9ba5aeb764163aaccd64a9583?rik=DzXjlnhTgV5CvA&riu=http%3a%2f%2fcdn.onlinewebfonts.com%2fsvg%2fimg_210318.png&ehk=952QCsChZS0znBch2iju8Vc%2fS2aIXvqX%2f0zrwkjJ3GA%3d&risl=&pid=ImgRaw&r=0',
month: 'month',
username: 'username',
weight: 'weight',
Expand Down
4 changes: 3 additions & 1 deletion lib/screens/apppointment_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ class _AppointmentScreenState extends State<AppointmentScreen> {
children: [
Expanded(
child: OutlinedButton(
onPressed: () {},
onPressed: () {
appointmentProvider.updateStatus(schedule, 'canceled');
},
child: const Text(
'Cancel',
style: TextStyle(
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class _ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: appbarWidget('Chats'),
appBar: appbarWidget('Chats', Colors.transparent),
drawer: drawerWidget(context),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
Expand Down
129 changes: 78 additions & 51 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@ class _HomeScreenState extends State<HomeScreen> {
super.initState();
appointmentProvider =
Provider.of<AppointmentProvider>(context, listen: false);
appointmentProvider.getUserAppointments(_email);
userProvider = Provider.of<UserProvider>(context, listen: false);
userProvider.getUserData(_email);
pharmacistProvider =
Provider.of<PharmacistProvider>(context, listen: false);
pharmacistProvider.getPharmacists();
pharmacistProvider.getT5Pharmacists();
}

@override
Expand All @@ -131,11 +127,6 @@ class _HomeScreenState extends State<HomeScreen> {

@override
Widget build(BuildContext context) {
List<AppointmentModel> appointments = appointmentProvider.appointments;
UserModel user = userProvider.user;
List<AppointmentModel> filteredAppointments =
appointmentProvider.filterAppointments(appointments, 'upcoming');
List<PharmacistModel> t5Pharmacists = pharmacistProvider.t5Pharmacists;
List<Widget> stacks = [
Padding(
padding: const EdgeInsets.only(right: 20),
Expand Down Expand Up @@ -181,49 +172,83 @@ class _HomeScreenState extends State<HomeScreen> {
child: ListView(
scrollDirection: Axis.vertical,
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: ClipOval(
child: Image.network(
user.imagePath,
width: 50,
height: 50,
fit: BoxFit.cover,
),
),
title: Text(
introText(),
style: const TextStyle(
fontSize: 15,
color: Colors.blueGrey,
),
),
subtitle: Text(
user.username,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.lightBlue,
),
),
trailing: const IconButton(
icon: Icon(
Icons.notifications_none,
color: Colors.black,
size: 30,
),
onPressed: null,
),
),
const SizedBox(
height: 5,
FutureBuilder(
future: userProvider.getUserData(_email),
builder: (context, snapshot) {
if (snapshot.hasError) {
showErrorDialog(context, 'Error: ${snapshot.error}');
} else if (snapshot.connectionState ==
ConnectionState.waiting) {
return const SizedBox();
} else {
final UserModel user = userProvider.user;
return ListTile(
contentPadding: EdgeInsets.zero,
leading: GestureDetector(
onTap: (){
Scaffold.of(context).openDrawer();
},
child: ClipOval(
child: Image.network(
user.imagePath,
width: 50,
height: 50,
fit: BoxFit.cover,
),
),
),
title: Text(
introText(),
style: const TextStyle(
fontSize: 15,
color: Colors.blueGrey,
),
),
subtitle: Text(
user.username,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.lightBlue,
),
),
trailing: const IconButton(
icon: Icon(
Icons.notifications_none,
color: Colors.black,
size: 30,
),
onPressed: null,
),
);
}
return const SizedBox(
height: 5,
);
},
),
Text(
'You have ${filteredAppointments.length} upcoming appointments',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
),
FutureBuilder(
future: appointmentProvider.getUserAppointments(_email),
builder: (context, snapshot) {
if (snapshot.hasError) {
showErrorDialog(context, '${snapshot.error}');
} else if (snapshot.connectionState ==
ConnectionState.waiting) {
return const SizedBox();
}
List<AppointmentModel> appointments =
appointmentProvider.appointments;
List<AppointmentModel> filteredAppointments =
appointmentProvider.filterAppointments(
appointments, 'upcoming');
return Text(
'You have ${filteredAppointments.length} upcoming ${filteredAppointments.length == 1 ? 'appointment' : 'appointments'}',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
),
);
},
),
const SizedBox(
height: 20,
Expand Down Expand Up @@ -269,6 +294,8 @@ class _HomeScreenState extends State<HomeScreen> {
} else if (snapshot.hasError) {
showErrorDialog(context, '${snapshot.error}');
}
List<PharmacistModel> t5Pharmacists =
pharmacistProvider.t5Pharmacists;
return Column(
children: List.generate(5, (index) {
final pharmacist = t5Pharmacists[index];
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/pharmacist_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _PharmacistDetailsScreenState extends State<PharmacistDetailsScreen> {
}

return Scaffold(
appBar: appbarWidget("Pharmacist Details", Colors.transparent),
appBar: appbarWidget("Pharmacist Details", Colors.lightBlue),
body: ListView(
scrollDirection: Axis.vertical,
children: [
Expand Down

0 comments on commit 87e17bf

Please sign in to comment.