Merge issue 2.0

development_mirza
mirza.shafique 3 years ago
parent 45b5482b87
commit a0a162df4c

@ -1,16 +1,20 @@
import 'package:flutter/material.dart';
import 'package:hmg_nurses/ui/login/login_method_page.dart';
import 'package:hmg_nurses/ui/login/login_page.dart';
import 'package:hmg_nurses/ui/login/splash_page.dart';
class AppRoutes {
//Login
static const String splash = "/splash";
static const String registerSelection = "/registerSelection";
static const String loginVerifyAccount = "/loginVerifyAccount";
static const String loginMethodsPage = "/loginMethodsPage";
static const String login = "/login";
static final Map<String, WidgetBuilder> routes = {
//Login
splash: (BuildContext context) => SplashPage(),
// login: (BuildContext context) => LoginScreen(),
login: (BuildContext context) => const LoginPage(),
loginMethodsPage: (BuildContext context) => const LoginMethodsPage(),
};
}

@ -1,11 +1,12 @@
import 'dart:async';
import 'package:easy_localization/src/public_ext.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:hmg_nurses/classes/colors.dart';
import 'package:hmg_nurses/extensions/int_extensions.dart';
import 'package:hmg_nurses/extensions/string_extensions.dart';
import 'package:hmg_nurses/generated/locale_keys.g.dart';
import 'package:hmg_nurses/widgets/button/default_button.dart';
import 'package:hmg_nurses/widgets/otp_widget.dart';
@ -16,18 +17,13 @@ class OtpDialog {
final int? mobileNo;
final Function(String, TextEditingController _pinPutController) onSuccess;
final Function onFailure;
final BuildContext context;
final Function onResendCode;
int remainingTime = 120;
Future<Null>? timer;
static BuildContext? _context;
static bool? _loading;
OtpDialog(this.context, this.type, this.mobileNo, this.onSuccess, this.onFailure, {required this.onResendCode});
OtpDialog({required this.type, required this.mobileNo, required this.onSuccess, required this.onFailure, required this.onResendCode});
GlobalKey? verifyAccountForm = GlobalKey<FormState>();
@ -52,7 +48,6 @@ class OtpDialog {
// ProjectViewModel projectProvider;
String displayTime = '';
String? _code;
dynamic setState;
bool stopTimer = false;
@ -74,7 +69,7 @@ class OtpDialog {
}
return Container(
padding: EdgeInsets.all(21),
padding: const EdgeInsets.all(21),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@ -83,78 +78,73 @@ class OtpDialog {
type == 1
? "assets/images/login/verify_sms.svg"
: type == 2
? "assets/images/login/verify_whatsapp.svg"
: type == 3
? "assets/images/login/verify_face.svg"
: 'assets/images/login/verify_thumb.svg',
? "assets/images/login/verify_whatsapp.svg"
: type == 3
? "assets/images/login/verify_face.svg"
: 'assets/images/login/verify_thumb.svg',
height: 50,
width: 50,
),
12.height,
"LocaleKeys.otp.tr()".toText14(),
"LocaleKeys.verification.tr()".toText24(isBold: true),
LocaleKeys.otp.tr().toText14(),
LocaleKeys.verification.tr().toText24(isBold: true),
6.height,
("LocaleKeys.pleaseEnterTheVerificationCodeSentTo.tr()" + ' xxxxxxxx' + mobileNo.toString().substring(mobileNo.toString().length - 3)).toText16(),
('${LocaleKeys.pleaseEnterTheVerificationCodeSentTo.tr()} xxxxxxxx${mobileNo.toString().substring(mobileNo.toString().length - 3)}').toText16(),
18.height,
ValueListenableBuilder<String>(
builder: (BuildContext context, String value, Widget? child) {
// This builder will only get called when the _counter
// is updated.
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: OTPWidget(
autoFocus: true,
controller: _pinPutController,
defaultBorderColor: const Color(0xffD8D8D8),
maxLength: 4,
onTextChanged: (text) {},
pinBoxColor: Colors.white,
onDone: (code) => _onOtpCallBack(code, null),
textBorderColor: const Color(0xffD8D8D8),
pinBoxWidth: 60,
pinBoxHeight: 60,
pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor),
pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300),
pinBoxRadius: 10,
keyboardType: TextInputType.number,
),
Center(
child: OTPWidget(
autoFocus: true,
controller: _pinPutController,
defaultBorderColor: const Color(0xffD8D8D8),
maxLength: 4,
onTextChanged: (text) {},
pinBoxColor: Colors.white,
onDone: (code) => _onOtpCallBack(code, null),
textBorderColor: const Color(0xffD8D8D8),
pinBoxWidth: 60,
pinBoxHeight: 60,
pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor),
pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300),
pinBoxRadius: 10,
keyboardType: TextInputType.number,
),
),
10.height,
stopTimer
? Row(
children: [
Expanded(
child: "LocaleKeys.codeExpire.tr()".toText16(
color: MyColors.redColor,
),
),
12.width,
Image.asset(
"assets/icons/ic_alarm.png",
width: 20,
height: 20,
color: MyColors.redColor,
),
],
)
children: [
Expanded(
child: LocaleKeys.codeExpire.tr().toText16(
color: MyColors.redColor,
),
),
12.width,
Image.asset(
"assets/icons/ic_alarm.png",
width: 20,
height: 20,
color: MyColors.redColor,
),
],
)
: RichText(
text: TextSpan(
text: "LocaleKeys.theVerificationCodeWillExpireIn.tr()" + '\n',
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, letterSpacing: -0.48),
children: <TextSpan>[
TextSpan(
text: displayTime,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.textMixColor, letterSpacing: -0.48),
),
],
),
text: TextSpan(
text: '${LocaleKeys.theVerificationCodeWillExpireIn.tr()}\n',
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, letterSpacing: -0.48),
children: <TextSpan>[
TextSpan(
text: displayTime,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.textMixColor, letterSpacing: -0.48),
),
],
),
),
],
);
},
@ -162,8 +152,8 @@ class OtpDialog {
),
18.height,
DefaultButton(
stopTimer ? "LocaleKeys.resend.tr()" : "LocaleKeys.cancel.tr()",
() async {
stopTimer ? LocaleKeys.resend.tr() : LocaleKeys.cancel.tr(),
() async {
if (stopTimer) {
hideSMSBox(context);
onResendCode();
@ -176,9 +166,9 @@ class OtpDialog {
colors: stopTimer
? null
: [
MyColors.pinkDarkColor,
MyColors.pinkDarkColor,
],
MyColors.redColor,
MyColors.redColor,
],
),
],
),
@ -210,16 +200,6 @@ class OtpDialog {
);
}
// String validateCodeDigit(value) {
// if (value.isEmpty) {
// return ' ';
// } else if (value.length == 3) {
// print(value);
// } else {
// return null;
// }
// }
String getSecondsAsDigitalClock(int inputSeconds) {
int secNum = int.parse(inputSeconds.toString()); // don't forget the second param
int hours = (secNum / 3600).floor();
@ -227,9 +207,9 @@ class OtpDialog {
double seconds = secNum - hours * 3600 - minutes * 60;
String minutesString = "";
String secondsString = "";
minutesString = minutes < 10 ? "0" + minutes.toString() : minutes.toString();
secondsString = seconds < 10 ? "0" + seconds.toStringAsFixed(0) : seconds.toStringAsFixed(0);
return minutesString + ":" + secondsString;
minutesString = minutes < 10 ? "0$minutes" : minutes.toString();
secondsString = seconds < 10 ? "0${seconds.toStringAsFixed(0)}" : seconds.toStringAsFixed(0);
return "$minutesString:$secondsString";
}
void startTimer(setState) {
@ -269,4 +249,4 @@ class OtpDialog {
// // return null;
// // }
// }
}
}

@ -18,6 +18,8 @@ import 'generated/codegen_loader.g.dart';
late AppState appState;
GlobalKey<NavigatorState> navigatorKey = GlobalKey();
Logger logger = Logger(
// filter: null, // Use the default LogFilter (-> only log in debug mode)
printer: PrettyPrinter(
@ -82,6 +84,7 @@ class MyApp extends StatelessWidget {
) {
List<LocalizationsDelegate<dynamic>> delegates = context.localizationDelegates;
return MaterialApp(
key: navigatorKey,
theme: AppTheme.getTheme(
EasyLocalization.of(context)?.locale.languageCode == "ar",
),

@ -127,15 +127,15 @@ class LoginViewModel extends BaseViewModel {
startSMSService(AuthMethodTypes type, {isSilentLogin = false, required BuildContext context}) {
OtpDialog(
type: 1,
mobileNo: 0504278212,
onSuccess: (String otpCode, TextEditingController pinPut) {
Utils.showLoading();
//TODO: API CALL
// performDirectApiCall(_title, _icon, _flag, value);
},
onFailure: () => Navigator.pop(context),
onResendCode: () {})
.displayDialog(context);
type: 1,
mobileNo: 0504278212,
onSuccess: (String otpCode, TextEditingController pinPut) {
Utils.showLoading();
//TODO: API CALL
// performDirectApiCall(_title, _icon, _flag, value);
},
onFailure: () => Navigator.pop(context),
onResendCode: () {},
).displayDialog(context);
}
}

@ -179,6 +179,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
flutter_svg:
dependency: "direct main"
description:
@ -203,6 +210,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.1"
get_it:
dependency: "direct main"
description:
name: get_it
url: "https://pub.dartlang.org"
source: hosted
version: "7.2.0"
hexcolor:
dependency: "direct main"
description:
name: hexcolor
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
http:
dependency: "direct main"
description:
@ -245,6 +266,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
local_auth:
dependency: "direct main"
description:
name: local_auth
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
local_auth_android:
dependency: transitive
description:
name: local_auth_android
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.15"
local_auth_ios:
dependency: transitive
description:
name: local_auth_ios
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.10"
local_auth_platform_interface:
dependency: transitive
description:
name: local_auth_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
local_auth_windows:
dependency: transitive
description:
name: local_auth_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
logger:
dependency: "direct main"
description:

Loading…
Cancel
Save