diff --git a/recipients_app/lib/data/models/phone.dart b/recipients_app/lib/data/models/phone.dart index 23ce985c6..234bb7984 100644 --- a/recipients_app/lib/data/models/phone.dart +++ b/recipients_app/lib/data/models/phone.dart @@ -5,7 +5,7 @@ part "phone.g.dart"; @JsonSerializable() class Phone extends Equatable { - @JsonKey(name: "phone") + @JsonKey(name: "phone", defaultValue: 0) final int phoneNumber; const Phone(this.phoneNumber); diff --git a/recipients_app/lib/data/models/phone.g.dart b/recipients_app/lib/data/models/phone.g.dart index 8a0a81a8f..035247bac 100644 --- a/recipients_app/lib/data/models/phone.g.dart +++ b/recipients_app/lib/data/models/phone.g.dart @@ -7,7 +7,7 @@ part of 'phone.dart'; // ************************************************************************** Phone _$PhoneFromJson(Map json) => Phone( - json['phone'] as int, + json['phone'] as int? ?? 0, ); Map _$PhoneToJson(Phone instance) => { diff --git a/recipients_app/lib/view/widgets/welcome/otp_input.dart b/recipients_app/lib/view/widgets/welcome/otp_input.dart index 2c1633c01..d8413b032 100644 --- a/recipients_app/lib/view/widgets/welcome/otp_input.dart +++ b/recipients_app/lib/view/widgets/welcome/otp_input.dart @@ -27,6 +27,24 @@ class _OtpInputState extends State { digit4Controller = TextEditingController(); digit5Controller = TextEditingController(); digit6Controller = TextEditingController(); + + final controllers = [ + digit1Controller, + digit2Controller, + digit3Controller, + digit4Controller, + digit5Controller, + digit6Controller, + ]; + + digit1Controller.addListener(() { + final text = digit1Controller.text; + if (text.length > 1) { + for (int i = 0; i < text.length; i++) { + controllers[i].text = text[i]; + } + } + }); } @override @@ -54,6 +72,7 @@ class _OtpInputState extends State { } _checkCodeStatus(); }, + isFirstField: true, ), OtpInputField( controller: digit2Controller, diff --git a/recipients_app/lib/view/widgets/welcome/otp_input_field.dart b/recipients_app/lib/view/widgets/welcome/otp_input_field.dart index 372cf3d6c..95433649c 100644 --- a/recipients_app/lib/view/widgets/welcome/otp_input_field.dart +++ b/recipients_app/lib/view/widgets/welcome/otp_input_field.dart @@ -4,11 +4,13 @@ import "package:flutter/material.dart"; class OtpInputField extends StatelessWidget { final TextEditingController? controller; final Function(String?)? onChanged; + final bool isFirstField; const OtpInputField({ super.key, this.controller, this.onChanged, + this.isFirstField = false, }); @override @@ -43,7 +45,7 @@ class OtpInputField extends StatelessWidget { validator: null, textAlign: TextAlign.center, keyboardType: TextInputType.number, - maxLength: 1, + maxLength: isFirstField ? 6 : 1, ), ), ), diff --git a/recipients_app/pubspec.yaml b/recipients_app/pubspec.yaml index 6358f42e6..84166cb0c 100644 --- a/recipients_app/pubspec.yaml +++ b/recipients_app/pubspec.yaml @@ -2,7 +2,7 @@ name: app description: Social Income App publish_to: "none" -version: 1.1.8+20 +version: 1.1.8+22 environment: sdk: ">=3.1.0 <4.0.0"