bugs solved and more fixes
This commit is contained in:
@@ -18,6 +18,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
|
||||
on<LoginRememberMeToggled>(_onRememberMeToggled);
|
||||
on<LoginEmailErrorToggled>(_onEmailErrorToggled);
|
||||
on<LoginPasswordErrorToggled>(_onPasswordErrorToggled);
|
||||
on<LoginReset>(_onReset);
|
||||
}
|
||||
|
||||
// ================= LOGIN SUBMITTED =================
|
||||
@@ -87,4 +88,11 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
|
||||
) {
|
||||
emit(state.copyWith(showPasswordError: event.show));
|
||||
}
|
||||
|
||||
void _onReset(
|
||||
LoginReset event,
|
||||
Emitter<LoginState> emit,
|
||||
) {
|
||||
emit(const LoginState());
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,10 @@ class LoginEmailErrorToggled extends LoginEvent {
|
||||
List<Object?> get props => [show];
|
||||
}
|
||||
|
||||
class LoginReset extends LoginEvent {
|
||||
const LoginReset();
|
||||
}
|
||||
|
||||
class LoginPasswordErrorToggled extends LoginEvent {
|
||||
final bool show;
|
||||
const LoginPasswordErrorToggled(this.show);
|
||||
|
||||
@@ -22,6 +22,12 @@ class _LoginPageState extends State<LoginPage> {
|
||||
final _emailFocusNode = FocusNode();
|
||||
final _passwordFocusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
context.read<LoginBloc>().add(const LoginReset());
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
@@ -32,9 +38,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
}
|
||||
|
||||
bool _isEmailValid(String email) {
|
||||
return RegExp(
|
||||
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
|
||||
.hasMatch(email);
|
||||
return RegExp(r'^[\w-\.]+@([\w-]+\.)+[a-zA-Z]{2,4}$').hasMatch(email);
|
||||
}
|
||||
|
||||
void _onLoginPressed(BuildContext context) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class ApiUrls {
|
||||
|
||||
// static const baseUrl = "https://devapi.citycards.betadelivery.com"; // Normal API
|
||||
static const baseUrl = "https://testingapi.citycards.betadelivery.com"; // Test API
|
||||
// static const baseUrl = "https://uatapi.citycard.betadelivery.com"; // Production Lvl API
|
||||
// static const baseUrl = "https://testingapi.citycards.betadelivery.com"; // Test API
|
||||
static const baseUrl = "https://uatapi.citycard.betadelivery.com"; // Production Lvl API
|
||||
|
||||
static const refreshToken = "$baseUrl/partner/auth/refresh";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import '../blocs/profile/profile_bloc.dart';
|
||||
import '../blocs/profile/profile_event.dart';
|
||||
import '../blocs/profile/profile_state.dart';
|
||||
import '../models/profile_model.dart'; // Import UserDetails model
|
||||
import '../../login/blocs/login/login_bloc.dart';
|
||||
|
||||
class ProfileScreen extends StatelessWidget {
|
||||
const ProfileScreen({super.key});
|
||||
@@ -192,6 +193,7 @@ class ProfileScreen extends StatelessWidget {
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
LocalPreference.clearAllExceptOnBoarding();
|
||||
context.read<LoginBloc>().add(const LoginReset());
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
AppRouter.login,
|
||||
|
||||
@@ -21,6 +21,7 @@ class SubmitQrCodeBloc
|
||||
SubmitQrCodeEventTriggered event,
|
||||
Emitter<SubmitQrCodeState> emit,
|
||||
) async {
|
||||
if (state is SubmitQrCodeLoading) return;
|
||||
if (event.qrCode.trim().isEmpty) {
|
||||
emit(const SubmitQrCodeFailure(
|
||||
errorMessage: 'QR code cannot be empty'));
|
||||
|
||||
@@ -24,6 +24,7 @@ class _QrScanScreenState extends State<QrScanScreen>
|
||||
late MobileScannerController _cameraController;
|
||||
final ValueNotifier<bool> _isTorchOn = ValueNotifier(false);
|
||||
bool _cameraAvailable = true;
|
||||
bool _isScanProcessing = false;
|
||||
|
||||
final sheetContentKey = GlobalKey();
|
||||
final ValueNotifier<double> sheetExtent = ValueNotifier(0.5);
|
||||
@@ -85,6 +86,7 @@ class _QrScanScreenState extends State<QrScanScreen>
|
||||
if (!mounted || !_cameraAvailable) return;
|
||||
|
||||
try {
|
||||
_isScanProcessing = false; // Reset flag when camera starts
|
||||
if (!_cameraController.value.isStarting) {
|
||||
await _cameraController.start();
|
||||
}
|
||||
@@ -179,22 +181,25 @@ class _QrScanScreenState extends State<QrScanScreen>
|
||||
|
||||
/// 📷 QR Scanner
|
||||
MobileScanner(
|
||||
controller: _cameraController,
|
||||
fit: BoxFit.cover,
|
||||
onDetect: (capture) {
|
||||
final barcode =
|
||||
capture.barcodes.first.rawValue ?? '';
|
||||
if (barcode.isNotEmpty &&
|
||||
state is! SubmitQrCodeLoading &&
|
||||
state is SubmitQrCodeInitial) {
|
||||
final extractedCode = _extractQrCode(barcode);
|
||||
_cameraController.stop();
|
||||
context.read<SubmitQrCodeBloc>().add(
|
||||
SubmitQrCodeEventTriggered(
|
||||
qrCode: extractedCode));
|
||||
}
|
||||
},
|
||||
),
|
||||
controller: _cameraController,
|
||||
fit: BoxFit.cover,
|
||||
onDetect: (capture) {
|
||||
if (_isScanProcessing) return;
|
||||
|
||||
final barcode =
|
||||
capture.barcodes.first.rawValue ?? '';
|
||||
if (barcode.isNotEmpty &&
|
||||
state is! SubmitQrCodeLoading &&
|
||||
state is SubmitQrCodeInitial) {
|
||||
_isScanProcessing = true;
|
||||
final extractedCode = _extractQrCode(barcode);
|
||||
_cameraController.stop();
|
||||
context.read<SubmitQrCodeBloc>().add(
|
||||
SubmitQrCodeEventTriggered(
|
||||
qrCode: extractedCode));
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
/// 🔲 Scanner Frame
|
||||
if (_cameraAvailable)
|
||||
|
||||
Reference in New Issue
Block a user