|
|
|
|
@ -74,6 +74,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
ApiConsts.selectedMemberType = MemberType.employee;
|
|
|
|
|
ApiConsts.ISDependetLogin = false;
|
|
|
|
|
// hmsApiAvailability = HmsApiAvailability();
|
|
|
|
|
// checkFirebaseToken();
|
|
|
|
|
@ -164,7 +165,15 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
|
|
|
|
|
void checkLoginInfo() async {
|
|
|
|
|
try {
|
|
|
|
|
loginInfo = await LoginApiClient().getMobileLoginInfoNEW(AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? "", Platform.isAndroid ? "android" : "ios");
|
|
|
|
|
loginInfo = await LoginApiClient().getMobileLoginInfoNEW(
|
|
|
|
|
AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? "",
|
|
|
|
|
Platform.isAndroid ? "android" : "ios",
|
|
|
|
|
memberType: ApiConsts.selectedMemberType.value,
|
|
|
|
|
);
|
|
|
|
|
if (ApiConsts.selectedMemberType.isDependent) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (loginInfo == null) {
|
|
|
|
|
await checkPrefs();
|
|
|
|
|
_autoLogin = false;
|
|
|
|
|
@ -285,7 +294,19 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onTabChanged(MemberType type) {
|
|
|
|
|
if (ApiConsts.selectedMemberType != type) {
|
|
|
|
|
setState(() {
|
|
|
|
|
ApiConsts.selectedMemberType = type;
|
|
|
|
|
});
|
|
|
|
|
checkLoginInfo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildTabSwitcher() {
|
|
|
|
|
bool isEmployee = ApiConsts.selectedMemberType == MemberType.employee;
|
|
|
|
|
bool isAr = AppState().isArabic(context);
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
height: 46,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
@ -298,9 +319,9 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: !ApiConsts.isDependetLogin ? Colors.white : Colors.transparent,
|
|
|
|
|
color: isEmployee ? Colors.white : Colors.transparent,
|
|
|
|
|
borderRadius: BorderRadius.circular(9),
|
|
|
|
|
boxShadow: !ApiConsts.isDependetLogin
|
|
|
|
|
boxShadow: isEmployee
|
|
|
|
|
? [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.black.withOpacity(0.06),
|
|
|
|
|
@ -311,24 +332,20 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: (AppState().isArabic(context) ? "المستخدم" : "Default User").toText14(
|
|
|
|
|
color: !ApiConsts.isDependetLogin ? MyColors.textMixColor : MyColors.grey70Color,
|
|
|
|
|
isBold: !ApiConsts.isDependetLogin,
|
|
|
|
|
child: (isAr ? "الموظف" : "Employee").toText14(
|
|
|
|
|
color: isEmployee ? MyColors.textMixColor : MyColors.grey70Color,
|
|
|
|
|
isBold: isEmployee,
|
|
|
|
|
),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
if (ApiConsts.isDependetLogin) {
|
|
|
|
|
setState(() {
|
|
|
|
|
ApiConsts.isDependetLogin = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
_onTabChanged(MemberType.employee);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: ApiConsts.isDependetLogin ? Colors.white : Colors.transparent,
|
|
|
|
|
color: !isEmployee ? Colors.white : Colors.transparent,
|
|
|
|
|
borderRadius: BorderRadius.circular(9),
|
|
|
|
|
boxShadow: ApiConsts.isDependetLogin
|
|
|
|
|
boxShadow: !isEmployee
|
|
|
|
|
? [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.black.withOpacity(0.06),
|
|
|
|
|
@ -339,16 +356,12 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: (AppState().isArabic(context) ? "التابع" : "Dependent").toText14(
|
|
|
|
|
color: ApiConsts.isDependetLogin ? MyColors.textMixColor : MyColors.grey70Color,
|
|
|
|
|
isBold: ApiConsts.isDependetLogin,
|
|
|
|
|
child: (isAr ? "التابع" : "Dependent").toText14(
|
|
|
|
|
color: !isEmployee ? MyColors.textMixColor : MyColors.grey70Color,
|
|
|
|
|
isBold: !isEmployee,
|
|
|
|
|
),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
if (!ApiConsts.isDependetLogin) {
|
|
|
|
|
setState(() {
|
|
|
|
|
ApiConsts.isDependetLogin = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
_onTabChanged(MemberType.dependent);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -607,7 +620,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
LocaleKeys.login.tr().toText24(isBold: true),
|
|
|
|
|
LocaleKeys.pleaseEnterLoginDetails.tr().toText16(),
|
|
|
|
|
16.height,
|
|
|
|
|
if (!ApiConsts.isDependetLogin) ...[
|
|
|
|
|
if (ApiConsts.selectedMemberType == MemberType.employee) ...[
|
|
|
|
|
InputWidget(LocaleKeys.username.tr(), "123456", username),
|
|
|
|
|
12.height,
|
|
|
|
|
InputWidget(LocaleKeys.password.tr(), "xxxxxx", password, isTextIsPassword: true),
|
|
|
|
|
|