Skip to content

Commit

Permalink
homescreen component updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelSena19 committed Jan 20, 2024
1 parent b46ccda commit dfae414
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 50 deletions.
1 change: 1 addition & 0 deletions assets/loading_animation.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ void main() async {
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(
DevicePreview(
enabled: true,
builder: (context) => const MyApp(),
)
// DevicePreview(
// enabled: true,
// builder: (context) =>
const MyApp(),
// )
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/providers/appointment_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class AppointmentProvider with ChangeNotifier {
'status': newAppointment.status,
});
getUserAppointments(newAppointment.patient);
notifyListeners();
} catch (error) {
rethrow;
}
Expand Down
1 change: 1 addition & 0 deletions lib/screens/apppointment_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class _AppointmentScreenState extends State<AppointmentScreen> {
height: 20,
),
SegmentedButton(
showSelectedIcon: false,
segments: const [
ButtonSegment(
value: FilterStatus.upcoming,
Expand Down
4 changes: 1 addition & 3 deletions lib/screens/calendar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class _CalendarScreenState extends State<CalendarScreen> {

List<dynamic> _getAppointmentsForDay(){
List<String> appointments = _events.value[_selectedDay] ?? [];
print('Appointments for $_selectedDay: $appointments');
return appointments;
}

Expand Down Expand Up @@ -65,8 +64,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
} else if (snapshot.hasError) {
showErrorDialog(context, '${snapshot.error}');
}
print('Appointments: $_appointments');
print('Events: ${_events.value}');

return ListView(
children: [
ValueListenableBuilder(
Expand Down
35 changes: 23 additions & 12 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:health_watch/providers/appointment_provider.dart';
import 'package:health_watch/providers/pharmacist_provider.dart';
import 'package:health_watch/providers/user_provider.dart';
import 'package:health_watch/screens/apppointment_screen.dart';
import 'package:health_watch/screens/loading_screen.dart';
// import 'package:health_watch/screens/chat_screen.dart';
import 'package:health_watch/screens/profile_screen.dart';
import 'package:health_watch/screens/search_screen.dart';
Expand Down Expand Up @@ -185,7 +186,7 @@ class _HomeScreenState extends State<HomeScreen> {
return ListTile(
contentPadding: EdgeInsets.zero,
leading: GestureDetector(
onTap: (){
onTap: () {
Scaffold.of(context).openDrawer();
},
child: ClipOval(
Expand Down Expand Up @@ -254,7 +255,7 @@ class _HomeScreenState extends State<HomeScreen> {
height: 20,
),
SizedBox(
height: 350,
height: 300,
child: PageView.builder(
padEnds: true,
pageSnapping: false,
Expand Down Expand Up @@ -282,9 +283,15 @@ class _HomeScreenState extends State<HomeScreen> {
const SizedBox(
height: 15,
),
const Text(
"Top Pharmacists",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Top Pharmacists",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
),
Icon(Icons.arrow_forward_ios)
],
),
FutureBuilder(
future: pharmacistProvider.getT5Pharmacists(),
Expand All @@ -296,13 +303,17 @@ class _HomeScreenState extends State<HomeScreen> {
}
List<PharmacistModel> t5Pharmacists =
pharmacistProvider.t5Pharmacists;
return Column(
children: List.generate(5, (index) {
final pharmacist = t5Pharmacists[index];
return DoctorCard(
pharmacist: pharmacist,
);
}),
return SizedBox(
height: 300,
child: ListView(
scrollDirection: Axis.horizontal,
children: List.generate(5, (index) {
final pharmacist = t5Pharmacists[index];
return DoctorCardSmall(
pharmacist: pharmacist,
);
}),
),
);
},
),
Expand Down
18 changes: 18 additions & 0 deletions lib/screens/loading_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

class LoadingScreen extends StatelessWidget {
const LoadingScreen({super.key});

@override
Widget build(BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Lottie.asset(
'assets/loading_animation.json',
repeat: true,
),
);
}
}
77 changes: 47 additions & 30 deletions lib/screens/search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SearchScreen extends StatefulWidget {
class _SearchScreenState extends State<SearchScreen> {
DateTime now = DateTime.now();
String patient = FirebaseAuth.instance.currentUser!.email.toString();
final SearchController controller = SearchController();

Future<void> loadData() async {}

Expand All @@ -45,36 +46,52 @@ class _SearchScreenState extends State<SearchScreen> {
child: ListView(
scrollDirection: Axis.vertical,
children: [
SearchAnchor(builder: (context, SearchController controller) {
return SearchBar(
controller: controller,
hintText: 'Search for pharmacists and pharmacies near you',
hintStyle: MaterialStateProperty.all(
const TextStyle(color: Colors.grey)),
elevation: MaterialStateProperty.all(1),
padding: const MaterialStatePropertyAll<EdgeInsets>(
EdgeInsets.symmetric(horizontal: 8)),
onTap: () {
controller.openView();
},
onChanged: (_) {
controller.openView();
},
leading: const Icon(Icons.search),
);
}, suggestionsBuilder: (context, SearchController controller) {
return List<ListTile>.generate(5, (int index) {
final String item = 'pharmacist ${index + 1}';
return ListTile(
title: Text(item),
onTap: () {
setState(() {
controller.closeView(item);
});
},
);
});
}),
// SearchAnchor(builder: (context, SearchController controller) {
// return SearchBar(
// controller: controller,
// hintText: 'Search for pharmacists and pharmacies near you',
// hintStyle: MaterialStateProperty.all(
// const TextStyle(color: Colors.grey)),
// elevation: MaterialStateProperty.all(1),
// padding: const MaterialStatePropertyAll<EdgeInsets>(
// EdgeInsets.symmetric(horizontal: 8)),
// onTap: () {
// controller.openView();
// },
// onChanged: (_) {
// controller.openView();
// },
// leading: const Icon(Icons.search),
// );
// }, suggestionsBuilder: (context, SearchController controller) {
// return List<ListTile>.generate(5, (int index) {
// final String item = 'pharmacist ${index + 1}';
// return ListTile(
// title: Text(item),
// onTap: () {
// setState(() {
// controller.closeView(item);
// });
// },
// );
// });
// }),
SearchBar(
controller: controller,
hintText: 'Search for pharmacists and pharmacies near you',
hintStyle: MaterialStateProperty.all(
const TextStyle(color: Colors.grey)),
elevation: MaterialStateProperty.all(1),
padding: const MaterialStatePropertyAll<EdgeInsets>(
EdgeInsets.symmetric(horizontal: 8)),
onTap: () {
controller.openView();
},
onChanged: (_) {
controller.openView();
},
leading: const Icon(Icons.search),
),
const SizedBox(
height: 10,
),
Expand Down
66 changes: 66 additions & 0 deletions lib/utilities/doctor_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,69 @@ class DoctorCard extends StatelessWidget {
);
}
}

class DoctorCardSmall extends StatelessWidget {
const DoctorCardSmall({super.key, required this.pharmacist});

final PharmacistModel pharmacist;

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
height: 230,
width: 220,
child: GestureDetector(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 220,
height: 220,
child: Image.asset(
"assets/user.jpg",
fit: BoxFit.fill,
),
),
Text(
'Dr. ${pharmacist.name}',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
Row(
children: [
const Icon(
Icons.local_hospital_outlined,
color: Colors.lightBlue,
),
Text(
pharmacist.pharmacy,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.grey,
),
),
],
),
],
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return PharmacistDetailsScreen(
pharmacist: pharmacist,
);
},
),
);
},
),
);
}
}
2 changes: 1 addition & 1 deletion lib/utilities/stack_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Widget stackWidget(String assetName, String text) {
child: Image(
image: AssetImage(assetName),
width: double.infinity,
height: 300,
height: 250,
fit: BoxFit.cover,
),
),
Expand Down

0 comments on commit dfae414

Please sign in to comment.