Merge branch 'replied_count' into 'development'

add badge on bottom bar in order to show number of un replied msg

See merge request Cloud_Solution/doctor_app_flutter!784
merge-requests/788/merge
Mohammad Aljammal 5 years ago
commit 4bfcca230e

@ -235,6 +235,7 @@ const GET_SICK_LEAVE_DOCTOR_APP = "Services/DoctorApplication.svc/REST/GetAllSic
const ADD_PATIENT_TO_DOCTOR = "LiveCareApi/DoctorApp/AssignPatientToDoctor"; const ADD_PATIENT_TO_DOCTOR = "LiveCareApi/DoctorApp/AssignPatientToDoctor";
const REMOVE_PATIENT_FROM_DOCTOR = "LiveCareApi/DoctorApp/BackPatientToQueue"; const REMOVE_PATIENT_FROM_DOCTOR = "LiveCareApi/DoctorApp/BackPatientToQueue";
const CREATE_DOCTOR_RESPONSE = "Services/DoctorApplication.svc/REST/CreateDoctorResponse"; const CREATE_DOCTOR_RESPONSE = "Services/DoctorApplication.svc/REST/CreateDoctorResponse";
const GET_DOCTOR_NOT_REPLIED_COUNTS = "Services/DoctorApplication.svc/REST/DoctorApp_GetDoctorNotRepliedCounts";
var selectedPatientType = 1; var selectedPatientType = 1;

@ -16,6 +16,7 @@ class DoctorReplyService extends BaseService {
RequestDoctorReply _requestDoctorReply = RequestDoctorReply(); RequestDoctorReply _requestDoctorReply = RequestDoctorReply();
List<MyReferralPatientModel> _listMyReferralPatientModel = []; List<MyReferralPatientModel> _listMyReferralPatientModel = [];
List<MyReferralPatientModel> get listMyReferralPatientModel => _listMyReferralPatientModel; List<MyReferralPatientModel> get listMyReferralPatientModel => _listMyReferralPatientModel;
int notRepliedCount = 0;
Future getDoctorReply() async { Future getDoctorReply() async {
hasError = false; hasError = false;
@ -39,7 +40,23 @@ class DoctorReplyService extends BaseService {
CREATE_DOCTOR_RESPONSE, CREATE_DOCTOR_RESPONSE,
body: createDoctorResponseModel.toJson(), body: createDoctorResponseModel.toJson(),
onSuccess: (dynamic body, int statusCode) { onSuccess: (dynamic body, int statusCode) {
print("succsss"); },
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
);
}
Future getNotRepliedCount() async {
hasError = false;
await baseAppClient.post(
GET_DOCTOR_NOT_REPLIED_COUNTS,
body: {},
onSuccess: (dynamic body
, int statusCode) {
notRepliedCount = body["DoctorNotRepliedCounts"];
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
hasError = true; hasError = true;

@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart'; import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart';
import 'package:doctor_app_flutter/core/service/home/doctor_reply_service.dart';
import 'package:doctor_app_flutter/core/service/special_clinics/special_clinic_service.dart'; import 'package:doctor_app_flutter/core/service/special_clinics/special_clinic_service.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart';
@ -17,6 +18,7 @@ class DashboardViewModel extends BaseViewModel {
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
DashboardService _dashboardService = locator<DashboardService>(); DashboardService _dashboardService = locator<DashboardService>();
SpecialClinicsService _specialClinicsService = locator<SpecialClinicsService>(); SpecialClinicsService _specialClinicsService = locator<SpecialClinicsService>();
DoctorReplyService _doctorReplyService = locator<DoctorReplyService>();
List<DashboardModel> get dashboardItemsList => List<DashboardModel> get dashboardItemsList =>
_dashboardService.dashboardItemsList; _dashboardService.dashboardItemsList;
@ -24,6 +26,7 @@ class DashboardViewModel extends BaseViewModel {
bool get hasVirtualClinic => _dashboardService.hasVirtualClinic; bool get hasVirtualClinic => _dashboardService.hasVirtualClinic;
String get sServiceID => _dashboardService.sServiceID; String get sServiceID => _dashboardService.sServiceID;
int get notRepliedCount => _doctorReplyService.notRepliedCount;
List<GetSpecialClinicalCareListResponseModel> get specialClinicalCareList => _specialClinicsService.specialClinicalCareList; List<GetSpecialClinicalCareListResponseModel> get specialClinicalCareList => _specialClinicsService.specialClinicalCareList;
@ -114,4 +117,16 @@ class DashboardViewModel extends BaseViewModel {
return special; return special;
} }
Future getNotRepliedCount() async {
setState(ViewState.Busy);
await getDoctorProfile();
await _doctorReplyService.getNotRepliedCount();
if (_doctorReplyService.hasError) {
error = _doctorReplyService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
} }

@ -23,7 +23,6 @@ class DoctorReplayViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future createDoctorResponse( Future createDoctorResponse(
String response, ListGtMyPatientsQuestions model) async { String response, ListGtMyPatientsQuestions model) async {
await getDoctorProfile(); await getDoctorProfile();
@ -41,7 +40,10 @@ class DoctorReplayViewModel extends BaseViewModel {
if (_doctorReplyService.hasError) { if (_doctorReplyService.hasError) {
error = _doctorReplyService.error; error = _doctorReplyService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else {
setState(ViewState.Idle); setState(ViewState.Idle);
_doctorReplyService.getNotRepliedCount();
}
} }
} }

@ -72,6 +72,7 @@ class _HomeScreenState extends State<HomeScreen> {
await model.getDoctorProfile(isGetProfile: true); await model.getDoctorProfile(isGetProfile: true);
await model.checkDoctorHasLiveCare(); await model.checkDoctorHasLiveCare();
await model.getSpecialClinicalCareList(); await model.getSpecialClinicalCareList();
await model.getNotRepliedCount();
}, },
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,

@ -1,3 +1,4 @@
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';

@ -1,5 +1,11 @@
import 'package:badges/badges.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../locator.dart';
class BottomNavigationItem extends StatelessWidget { class BottomNavigationItem extends StatelessWidget {
final IconData icon; final IconData icon;
@ -19,6 +25,8 @@ class BottomNavigationItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
DashboardViewModel model = DashboardViewModel();
return Expanded( return Expanded(
child: SizedBox( child: SizedBox(
height: 70.0, height: 70.0,
@ -28,26 +36,51 @@ class BottomNavigationItem extends StatelessWidget {
highlightColor: Colors.transparent, highlightColor: Colors.transparent,
splashColor: Colors.transparent, splashColor: Colors.transparent,
onTap: () => changeIndex(currentIndex), onTap: () => changeIndex(currentIndex),
child: Column( child: Stack(
mainAxisSize: MainAxisSize.min, alignment: AlignmentDirectional.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: <Widget>[
SizedBox(height: 15,),
Container( Column(
child: Icon(currentIndex == index ? activeIcon : icon, mainAxisSize: MainAxisSize.min,
color: currentIndex == index mainAxisAlignment: MainAxisAlignment.center,
? Color(0xFF333C45) children: <Widget>[
: Theme.of(context).dividerColor, SizedBox(height: 15,),
size: 22.0), Container(
child: Icon(currentIndex == index ? activeIcon : icon,
color: currentIndex == index
? Color(0xFF333C45)
: Theme.of(context).dividerColor,
size: 22.0),
),
SizedBox(height: 5,),
Expanded(
child: Text(
name,
style: TextStyle(
color: currentIndex == index
? Theme.of(context).primaryColor
: Theme.of(context).dividerColor,
),
),
),
],
), ),
SizedBox(height: 5,), if(currentIndex == 3)
Expanded( Positioned(
child: Text( right: 18.0,
name, bottom: 40.0,
style: TextStyle( child: Badge(
color: currentIndex == index toAnimate: false,
? Theme.of(context).primaryColor position: BadgePosition.topEnd(),
: Theme.of(context).dividerColor, shape: BadgeShape.circle,
badgeColor: Colors.red[800],
borderRadius: BorderRadius.circular(8),
badgeContent: Container(
// padding: EdgeInsets.all(2.0),
child: Text(model.notRepliedCount.toString(),
style: TextStyle(
color: Colors.white, fontSize: 12.0)),
), ),
), ),
), ),

@ -96,6 +96,9 @@ dependencies:
# Html Editor Enhanced # Html Editor Enhanced
html_editor_enhanced: ^1.3.0 html_editor_enhanced: ^1.3.0
# Badges
badges: ^1.1.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter

Loading…
Cancel
Save