Skip to content

Commit d3750e0

Browse files
committed
Refactor: Streamline AppTimer and Verify OTP UI
- Removed unused `formKey` from `VerifyOTPScreen`. - Simplified `AppTimer` widget by removing `onTick` and `textStyle` parameters. - Updated `VerifyOTPState`'s `isValid` getter to include email validation.
1 parent a5934fa commit d3750e0

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

apps/app_core/lib/modules/verify_otp/bloc/verify_otp_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class VerifyOTPState extends Equatable {
3434
final LengthValidator otp;
3535
final String errorMessage;
3636

37-
bool get isValid => otp.isValid;
37+
bool get isValid => otp.isValid && email.isValid;
3838

3939
@override
4040
List<Object> get props => [statusForResendOTP, email, otp, errorMessage, statusForVerifyOTP];

apps/app_core/lib/modules/verify_otp/screens/verify_otp_screen.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class VerifyOTPScreen extends StatefulWidget implements AutoRouteWrapper {
3737
}
3838

3939
class _VerifyOTPScreenState extends State<VerifyOTPScreen> with TickerProviderStateMixin {
40-
late final GlobalKey<FormState> formKey;
41-
4240
Timer? _timer;
4341
int _secondsRemaining = 30;
4442
bool _isTimerRunning = true;
@@ -51,7 +49,6 @@ class _VerifyOTPScreenState extends State<VerifyOTPScreen> with TickerProviderSt
5149

5250
@override
5351
void initState() {
54-
formKey = GlobalKey<FormState>();
5552
_startTimer();
5653
super.initState();
5754
}
@@ -157,7 +154,7 @@ class _VerifyOTPScreenState extends State<VerifyOTPScreen> with TickerProviderSt
157154
),
158155
),
159156
VSpace.xsmall8(),
160-
if (_isTimerRunning) AppTimer(seconds: 30, onTick: (remaining) {}, onFinished: () {}),
157+
if (_isTimerRunning) AppTimer(seconds: 30, onFinished: () {}),
161158
VSpace.small12(),
162159
Row(
163160
mainAxisAlignment: MainAxisAlignment.center,

packages/app_ui/lib/src/widgets/molecules/app_timer.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ import 'package:app_ui/app_ui.dart';
44
import 'package:flutter/material.dart';
55

66
class AppTimer extends StatefulWidget {
7-
const AppTimer({required this.seconds, super.key, this.onTick, this.onFinished, this.textStyle});
7+
const AppTimer({required this.seconds, super.key, this.onFinished});
88
final int seconds;
9-
final void Function(int secondsRemaining)? onTick;
9+
1010
final VoidCallback? onFinished;
11-
final TextStyle? textStyle;
1211

1312
@override
1413
State<AppTimer> createState() => _AppTimerState();
1514
}
1615

17-
class _AppTimerState extends State<AppTimer> with TickerProviderStateMixin {
16+
class _AppTimerState extends State<AppTimer> {
1817
late int _secondsRemaining;
1918
Timer? _timer;
2019

@@ -42,7 +41,6 @@ class _AppTimerState extends State<AppTimer> with TickerProviderStateMixin {
4241
setState(() {
4342
_secondsRemaining--;
4443
});
45-
if (widget.onTick != null) widget.onTick?.call(_secondsRemaining);
4644
} else {
4745
timer.cancel();
4846
if (widget.onFinished != null) widget.onFinished?.call();
@@ -59,9 +57,6 @@ class _AppTimerState extends State<AppTimer> with TickerProviderStateMixin {
5957
@override
6058
Widget build(BuildContext context) {
6159
final timerText = '00:${_secondsRemaining.toString().padLeft(2, '0')}';
62-
return AppText(
63-
text: timerText,
64-
style: widget.textStyle ?? context.textTheme?.sSemiBold.copyWith(color: context.colorScheme.primary400),
65-
);
60+
return AppText(text: timerText, style: context.textTheme?.sSemiBold.copyWith(color: context.colorScheme.primary400));
6661
}
6762
}

0 commit comments

Comments
 (0)