Skip to content

Added option for whether the system automatically enables the Return key #23

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions Sources/ResponsiveTextField/ResponsiveTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public struct ResponsiveTextField {
/// some external state.
let isSecure: Bool

/// Enables return key automatically.
let enablesReturnKeyAutomatically: Bool

/// Can be used to programatically control the text field's first responder state.
///
/// When the binding's wrapped value is set, it will cause the text field to try and become or resign first responder status
Expand Down Expand Up @@ -130,6 +133,7 @@ public struct ResponsiveTextField {
placeholder: String?,
text: Binding<String>,
isSecure: Bool = false,
enablesReturnKeyAutomatically: Bool = false,
adjustsFontForContentSizeCategory: Bool = true,
firstResponderDemand: Binding<FirstResponderDemand?>? = nil,
configuration: Configuration = .empty,
Expand All @@ -144,6 +148,7 @@ public struct ResponsiveTextField {
self.text = text
self.firstResponderDemand = firstResponderDemand
self.isSecure = isSecure
self.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically
self.configuration = configuration
self.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory
self.onFirstResponderStateChanged = onFirstResponderStateChanged
Expand Down Expand Up @@ -329,6 +334,7 @@ extension ResponsiveTextField: UIViewRepresentable {
textField.text = text.wrappedValue
textField.isEnabled = isEnabled
textField.isSecureTextEntry = isSecure
textField.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically
textField.font = font
textField.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory
textField.textColor = textColor
Expand Down Expand Up @@ -364,6 +370,7 @@ extension ResponsiveTextField: UIViewRepresentable {
public func updateUIView(_ uiView: UITextField, context: Context) {
uiView.isEnabled = isEnabled
uiView.isSecureTextEntry = isSecure
uiView.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically
uiView.returnKeyType = returnKeyType
uiView.text = text.wrappedValue
uiView.textColor = textColor
Expand Down
Loading