notification count

merge-requests/140/head
Sultan Khan 4 years ago
parent d2f391ab7f
commit 6e152951b4

@ -47,6 +47,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
int currentTab = 0; int currentTab = 0;
PageController pageController; PageController pageController;
ProjectViewModel projectProvider; ProjectViewModel projectProvider;
var notificationCount = '';
///inject the user data ///inject the user data
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject =
@ -87,33 +88,33 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
} }
//setState(() { //setState(() {
print("didChangeAppLifecycleState"); print("didChangeAppLifecycleState");
print('state = $state'); print('state = $state');
AppGlobal.context = context; AppGlobal.context = context;
if (state == AppLifecycleState.resumed) { if (state == AppLifecycleState.resumed) {
print(LandingPage.isOpenCallPage); print(LandingPage.isOpenCallPage);
if (LandingPage.isOpenCallPage) { if (LandingPage.isOpenCallPage) {
if (!isPageNavigated) { if (!isPageNavigated) {
isPageNavigated = true; isPageNavigated = true;
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => IncomingCall( builder: (context) => IncomingCall(
incomingCallData: LandingPage.incomingCallData))) incomingCallData: LandingPage.incomingCallData)))
.then((value) { .then((value) {
isPageNavigated = false; isPageNavigated = false;
}); });
}
} }
} }
}
if (state == AppLifecycleState.paused) { if (state == AppLifecycleState.paused) {
isPageNavigated = false; isPageNavigated = false;
} }
if (state == AppLifecycleState.inactive) { if (state == AppLifecycleState.inactive) {
isPageNavigated = false; isPageNavigated = false;
} }
//}); //});
} }
@ -128,8 +129,8 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
super.initState(); super.initState();
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
//setState(() { //setState(() {
AppGlobal.context = context; AppGlobal.context = context;
// }); // });
_requestIOSPermissions(); _requestIOSPermissions();
pageController = PageController(keepPage: true); pageController = PageController(keepPage: true);
_firebaseMessaging.setAutoInitEnabled(true); _firebaseMessaging.setAutoInitEnabled(true);
@ -140,7 +141,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
_firebaseMessaging.getToken().then((String token) { _firebaseMessaging.getToken().then((String token) {
sharedPref.setString(PUSH_TOKEN, token); sharedPref.setString(PUSH_TOKEN, token);
if (token != null && DEVICE_TOKEN =="") { if (token != null && DEVICE_TOKEN == "") {
DEVICE_TOKEN = token; DEVICE_TOKEN = token;
checkUserStatus(token); checkUserStatus(token);
} }
@ -344,34 +345,69 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
), ),
title: Text( title: Text(
getText(currentTab).toUpperCase(), getText(currentTab).toUpperCase(),
style: TextStyle(fontWeight: FontWeight.bold,color: Colors.white,fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'), style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'),
// bold: true, // bold: true,
// color: Colors.white, // color: Colors.white,
), ),
leading: Builder( leading: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return IconButton( return new Stack(
icon: Icon(Icons.menu), children: <Widget>[
color: Colors.white, IconButton(
onPressed: () => Scaffold.of(context).openDrawer(), icon: Icon(Icons.menu),
color: Colors.white,
onPressed: () => Scaffold.of(context).openDrawer(),
),
notificationCount != ''
? new Positioned(
right: 0,
top: 10,
child: new Container(
padding: EdgeInsets.all(4),
decoration: new BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
constraints: BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: new Text(
notificationCount,
style: new TextStyle(
color: Colors.white,
fontSize: 9,
),
textAlign: TextAlign.center,
),
),
)
: SizedBox()
],
); );
}, },
), ),
actions: [ actions: [
IconButton( IconButton(
//iconSize: 70, //iconSize: 70,
icon: Icon(projectViewModel.isLogin?Icons.settings : Icons.login,color: Colors.white,), icon: Icon(
onPressed: () { projectViewModel.isLogin ? Icons.settings : Icons.login,
if(projectViewModel.isLogin) color: Colors.white,
),
onPressed: () {
if (projectViewModel.isLogin)
Navigator.of(context).pushNamed(
SETTINGS,
);
else
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
SETTINGS , WELCOME_LOGIN,
); );
else }, //do something,
Navigator.of(context).pushNamed( )
WELCOME_LOGIN ,
);
}, //do something,
)
], ],
centerTitle: true, centerTitle: true,
), ),
@ -388,7 +424,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
), ),
MedicalProfilePage(), MedicalProfilePage(),
BookingOptions(), BookingOptions(),
MyFamily(isAppbarVisible:false), MyFamily(isAppbarVisible: false),
ToDo(), ToDo(),
], // Please do not remove the BookingOptions from this array ], // Please do not remove the BookingOptions from this array
), ),
@ -432,11 +468,17 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
if (await sharedPref.getObject(USER_PROFILE) != null) { if (await sharedPref.getObject(USER_PROFILE) != null) {
var data = var data =
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
if (data != null) if (data != null) {
authService authService
.registeredAuthenticatedUser(data, token, 0, 0) .registeredAuthenticatedUser(data, token, 0, 0)
.then((res) => {print(res)}); .then((res) => {print(res)});
authService.getDashboard().then((value) => {
setState(() {
notificationCount = value['List_PatientDashboard']
[0]['UnreadPatientNotificationCount'].toString();
})
});
}
} }
} }

@ -236,7 +236,43 @@ class _GeneralSettings extends State<GeneralSettings>
break; break;
case 1: case 1:
{ {
themeNotifier.setTheme(await getTheme(value)); themeNotifier.setTheme(ThemeData(
fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans',
primarySwatch: Colors.grey,
visualDensity: VisualDensity.adaptivePlatformDensity,
brightness: Brightness.light,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: ZoomPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
},
),
hintColor: Colors.grey[400],
cardColor: Colors.black,
buttonColor: Colors.grey[400],
disabledColor: Colors.grey[300],
errorColor: Color.fromRGBO(235, 80, 60, 1.0),
scaffoldBackgroundColor: Colors.grey,
textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5),
textSelectionHandleColor: Colors.grey,
canvasColor: Colors.white,
backgroundColor: Colors.grey,
highlightColor: Colors.grey[100].withOpacity(0.4),
splashColor: Colors.transparent,
primaryColor: Colors.grey,
bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)),
cursorColor: Colors.grey,
iconTheme: IconThemeData(),
appBarTheme: AppBarTheme(
color: Colors.grey,
brightness: Brightness.dark,
elevation: 10.0,
actionsIconTheme: IconThemeData(
color: Colors.grey,
),
),
));
Screen.setBrightness(1.0); Screen.setBrightness(1.0);
} }
break; break;
@ -257,7 +293,7 @@ class _GeneralSettings extends State<GeneralSettings>
} }
break; break;
} }
permission.setTheme(value); //permission.setTheme(value);
} }
setVibration(value){ setVibration(value){

@ -47,6 +47,7 @@ const LOGGED_IN_USER_URL =
const FORGOT_PATIENT_ID = const FORGOT_PATIENT_ID =
'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber'; 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
bool isLogin = false; bool isLogin = false;
@ -370,7 +371,8 @@ class AuthProvider with ChangeNotifier {
Future<Map> sendPatientIDSMS(mobileNo, context) async { Future<Map> sendPatientIDSMS(mobileNo, context) async {
Map<String, dynamic> request; Map<String, dynamic> request;
var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
Request req = appGlobal.getPublicRequest(); Request req = appGlobal.getPublicRequest();
request = { request = {
"LanguageID": languageID == 'ar' ? 1 : 2, "LanguageID": languageID == 'ar' ? 1 : 2,
@ -427,4 +429,31 @@ class AuthProvider with ChangeNotifier {
//return Future.value(error); //return Future.value(error);
} }
} }
Future<dynamic> getDashboard() async {
Map<String, dynamic> request = {};
request['VersionID'] = VERSION_ID;
request['Channel'] = CHANNEL;
request['IPAdress'] = IP_ADDRESS;
request['generalid'] = GENERAL_ID;
request['LanguageID'] = LANGUAGE_ID;
request['DeviceTypeID'] = DeviceTypeID;
request["PatientTypeID"] = 1;
request["PatientType"] = 1;
dynamic localRes;
try {
await new BaseAppClient().post(DASHBOARD,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
//return Future.value(error);
}
}
} }

@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/Request.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:localstorage/localstorage.dart'; import 'package:localstorage/localstorage.dart';
class PermissionService extends BaseService { class PermissionService extends BaseService {
@ -18,7 +19,12 @@ class PermissionService extends BaseService {
} }
isVibrationEnabled() { isVibrationEnabled() {
return storage.getItem('isVibration'); return storage.getItem('isVibration') ==null ? false :true;
}
vibrate(){
if(isVibrationEnabled() ==true){
HapticFeedback.vibrate();
}
} }

@ -90,7 +90,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: (){Feedback.wrapForTap(widget.onTap, context); if(permission.isVibrationEnabled()){ HapticFeedback.vibrate();}}, onTap: (){Feedback.wrapForTap(widget.onTap, context); permission.vibrate();},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -24,6 +24,6 @@ class DefaultButton extends StatelessWidget {
this.text, this.text,
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
), ),
onPressed: () =>{ this.onPress(), if(permission.isVibrationEnabled()){ HapticFeedback.vibrate()}})); onPressed: () =>{ this.onPress(), permission.vibrate()}));
} }
} }

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart';
@ -23,7 +24,7 @@ class _FloatingButtonState extends State<FloatingButton>
double _buttonSize = 1.0; double _buttonSize = 1.0;
AnimationController _animationController; AnimationController _animationController;
Animation _animation; Animation _animation;
PermissionService permission = new PermissionService();
@override @override
void initState() { void initState() {
_animationController = AnimationController( _animationController = AnimationController(
@ -62,7 +63,7 @@ class _FloatingButtonState extends State<FloatingButton>
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: Feedback.wrapForTap(widget.onTap, context), onTap:(){ Feedback.wrapForTap(widget.onTap, context); permission.vibrate();},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -1,5 +1,7 @@
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
enum MINI_BUTTON { Secondary, Primary } enum MINI_BUTTON { Secondary, Primary }
@ -30,7 +32,7 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
double _buttonSize = 1.0; double _buttonSize = 1.0;
AnimationController _animationController; AnimationController _animationController;
Animation _animation; Animation _animation;
PermissionService permission = new PermissionService();
@override @override
void initState() { void initState() {
_animationController = AnimationController( _animationController = AnimationController(
@ -85,7 +87,8 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: Feedback.wrapForTap(widget.onTap, context), // onTap: Feedback.wrapForTap(widget.onTap, context),
onTap: () =>{ widget.onTap(), permission.vibrate()},
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

@ -1,5 +1,7 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -51,7 +53,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
double _buttonSize = 1.0; double _buttonSize = 1.0;
AnimationController _animationController; AnimationController _animationController;
Animation _animation; Animation _animation;
PermissionService permission = new PermissionService();
double _rippleSize = 0.0; double _rippleSize = 0.0;
AnimationController _rippleController; AnimationController _rippleController;
Animation _rippleAnimation; Animation _rippleAnimation;
@ -142,7 +144,8 @@ class _SecondaryButtonState extends State<SecondaryButton>
onTapCancel: () { onTapCancel: () {
_animationController.forward(); _animationController.forward();
}, },
onTap: widget.disabled?null:Feedback.wrapForTap(widget.onTap, context), onTap: () =>{ widget.disabled ? null : widget.onTap(), permission.vibrate()},
// onTap: widget.disabled?null:Feedback.wrapForTap(widget.onTap, context),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,

Loading…
Cancel
Save