fix: otp component
This commit is contained in:
parent
4b4b42beae
commit
7ec266cded
|
@ -1,4 +1,3 @@
|
|||
import 'package:cims_apps/application/component/button/button_view.dart';
|
||||
import 'package:cims_apps/application/component/otp/otp_viewmodel.dart';
|
||||
import 'package:cims_apps/application/component/text_caption/text_caption.dart';
|
||||
import 'package:cims_apps/application/theme/color_palette.dart';
|
||||
|
@ -61,12 +60,25 @@ class OtpView extends StatelessWidget {
|
|||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onCompleted: (pin) => provider.enableButton(),
|
||||
onChanged: (value) {
|
||||
if (provider.ctrlPin.length != 4) {
|
||||
provider.enableButton(isActive: false);
|
||||
}
|
||||
},
|
||||
),
|
||||
ButtonView(
|
||||
name: 'Verify',
|
||||
// disabled: !provider.buttonIsActive,
|
||||
// backgroundColor: ColorPalette.grey,
|
||||
onPressed: () {
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 32.0),
|
||||
width: SizeConfig.width,
|
||||
height: SizeConfig.height * .07,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: ColorPalette.primary,
|
||||
),
|
||||
onPressed: !provider.buttonIsActive
|
||||
? null
|
||||
: () {
|
||||
if (provider.formKey.currentState!.validate()) {
|
||||
final pin = provider.ctrlPin.text;
|
||||
provider.validateOtp(pin).then((value) {
|
||||
|
@ -80,6 +92,15 @@ class OtpView extends StatelessWidget {
|
|||
});
|
||||
}
|
||||
},
|
||||
child: const Text(
|
||||
'Verify',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
|
@ -106,7 +127,9 @@ class OtpView extends StatelessWidget {
|
|||
),
|
||||
_otpContent(context, provider),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
provider.ctrlPin.clear();
|
||||
},
|
||||
child: const Text(
|
||||
'Resend Code',
|
||||
style: TextStyle(
|
||||
|
|
|
@ -14,4 +14,9 @@ class OtpViewModel extends ChangeNotifier {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void enableButton({bool isActive = true}) {
|
||||
buttonIsActive = isActive;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user