Skip to content

Commit

Permalink
feature: add choose doctor screen after searching by symptom
Browse files Browse the repository at this point in the history
  • Loading branch information
dungngminh committed Dec 20, 2021
1 parent b71b02a commit 3bffee7
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 125 deletions.
1 change: 1 addition & 0 deletions assets/lottie/happy.json

Large diffs are not rendered by default.

File renamed without changes.
4 changes: 4 additions & 0 deletions lib/data/models/specialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ class Specialization {
Specialization({
this.id,
required this.name,
this.description,
});

String? id;
late String name;
String? description;

Specialization.init();

factory Specialization.fromJson(Map<String, dynamic> json) => Specialization(
id: json["_id"],
name: json["name"],
description: json["description"],
);

Map<String, dynamic> toJson() => {
"_id": id,
"name": name,
"description": description,
};
}
65 changes: 65 additions & 0 deletions lib/modules/home/choose_doctor/choose_doctor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:happy_care/core/themes/colors.dart';
import 'package:happy_care/modules/home/choose_doctor/choose_doctor_controller.dart';
import 'package:happy_care/widgets/custom_card_scroll.dart';
import 'package:sizer/sizer.dart';

class ChooseDoctor extends GetView<ChooseDoctorController> {
ChooseDoctor({Key? key}) : super(key: key);

final specName = Get.arguments as String;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 0,
leading: IconButton(
onPressed: () => Get.back(),
icon: Icon(
Icons.arrow_back,
color: kMainColor,
size: 26,
),
),
centerTitle: true,
title: Text(
specName,
style: GoogleFonts.openSans(
color: kMainColor,
fontSize: 15.sp,
fontWeight: FontWeight.bold,
),
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Obx(
() => Stack(
children: <Widget>[
CustomCardScroll(
controller.currentPage.value,
controller.listDoctorInSpec,
),
Positioned.fill(
child: PageView.builder(
itemCount: controller.listDoctorInSpec.length,
controller: controller.pageController,
reverse: true,
itemBuilder: (context, index) {
return SizedBox();
},
),
)
],
),
),
],
),
);
}
}
9 changes: 9 additions & 0 deletions lib/modules/home/choose_doctor/choose_doctor_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:get/get.dart';
import 'package:happy_care/modules/home/choose_doctor/choose_doctor_controller.dart';

class ChooseDoctorBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut(() => ChooseDoctorController());
}
}
28 changes: 28 additions & 0 deletions lib/modules/home/choose_doctor/choose_doctor_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:happy_care/data/models/user.dart';
import 'package:happy_care/modules/main_screen/controller/doctor_controller.dart';

enum ChooseDoctorStatus { loading, done, error }

class ChooseDoctorController extends GetxController {
final DoctorController doctorController = Get.find();
final listDoctorInSpec = RxList(<User>[]);
late final PageController pageController;
final currentPage = 0.0.obs;

@override
void onInit() {
super.onInit();
final specName = Get.arguments as String;
print("specId" + specName);
listDoctorInSpec(doctorController.listDoctor
.where((doctor) => doctor.specializations!.first.contains(specName))
.toList());
pageController = PageController(initialPage: listDoctorInSpec.length - 1);
currentPage(listDoctorInSpec.length - 1.0);
pageController.addListener(() {
currentPage(pageController.page);
});
}
}
100 changes: 97 additions & 3 deletions lib/modules/home/finding_spec/finding_spec.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,106 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:happy_care/core/themes/colors.dart';
import 'package:happy_care/data/models/specialization.dart';
import 'package:happy_care/routes/app_pages.dart';
import 'package:sizer/sizer.dart';

class FindingSpecScreen extends StatelessWidget {
const FindingSpecScreen({ Key? key }) : super(key: key);
FindingSpecScreen({Key? key}) : super(key: key);

final List<Specialization> listSpecFound =
Get.arguments as List<Specialization>;

@override
Widget build(BuildContext context) {
return Scaffold(

body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IconButton(
onPressed: () => Get.back(),
icon: Icon(
Icons.arrow_back,
color: kMainColor,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Center(
child: Text(
"Kết quả tìm được từ triệu chứng của bạn",
style: GoogleFonts.openSans(
color: kMainColor,
fontSize: 13.sp,
fontWeight: FontWeight.w700,
),
),
),
),
SizedBox(height: 1.2.h),
Center(
child: Text(
"Đã tìm thấy ${listSpecFound.length} chuyên khoa bạn cần",
style: GoogleFonts.openSans(
color: kMainColor,
fontSize: 11.sp,
fontWeight: FontWeight.w700,
),
),
),
Divider(
color: kMainColor,
),
Expanded(
child: ListView.builder(
itemCount: listSpecFound.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(5.0),
child: ListTile(
onTap: () => Get.toNamed(
AppRoutes.rListDoctor,
arguments: listSpecFound[index].name,
),
title: Text(
listSpecFound[index].name,
style: GoogleFonts.openSans(
color: kMainColor,
fontWeight: FontWeight.w700,
),
),
subtitle: Text(
listSpecFound[index].description!,
style: GoogleFonts.openSans(
color: kMainColor,
),
),
leading: CircleAvatar(
radius: 30,
backgroundColor: kMainColor,
child: Padding(
padding: const EdgeInsets.all(2.0),
child: CircleAvatar(
radius: 30,
backgroundColor: Colors.white,
backgroundImage:
Image.asset("assets/images/doctor.png").image,
),
),
),
),
);
},
),
)
],
),
),
),
);
}
}
}
Loading

0 comments on commit 3bffee7

Please sign in to comment.