Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(recipients_app): Enable copy paste for OTP input #597

Merged
merged 7 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion recipients_app/lib/data/models/phone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion recipients_app/lib/data/models/phone.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions recipients_app/lib/view/widgets/welcome/otp_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ class _OtpInputState extends State<OtpInput> {
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
Expand Down Expand Up @@ -54,6 +72,7 @@ class _OtpInputState extends State<OtpInput> {
}
_checkCodeStatus();
},
isFirstField: true,
),
OtpInputField(
controller: digit2Controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,7 +45,7 @@ class OtpInputField extends StatelessWidget {
validator: null,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 1,
maxLength: isFirstField ? 6 : 1,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion recipients_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading