Skip to content

Commit

Permalink
fix: linters, android handles all cases properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Dec 8, 2024
1 parent a33b455 commit 0cad973
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ fun getKeyboardTypeFromInputType(inputType: Int?): String {
return "default"
}

// Extract base input type class
val inputTypeClass = inputType and InputType.TYPE_MASK_CLASS
val inputTypeVariation = inputType and InputType.TYPE_MASK_VARIATION

// Check for special input types
return when {
// Check for numeric input types
inputType and InputType.TYPE_CLASS_NUMBER != 0 -> {
inputTypeVariation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS -> "email-address"
inputTypeVariation == InputType.TYPE_TEXT_VARIATION_URI -> "url"
inputTypeVariation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD -> "visible-password"

// Check for specific input type classes
inputTypeClass == InputType.TYPE_CLASS_NUMBER ->
when {
inputType and InputType.TYPE_NUMBER_FLAG_DECIMAL != 0 -> "decimal-pad"
inputType and INPUT_TYPE_KEYBOARD_NUMBERED != 0 -> "numeric"
else -> "number-pad"
}
}
// Check for email address type
inputType and InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != 0 -> "email-address"
(inputType and InputType.TYPE_NUMBER_FLAG_DECIMAL) != 0 &&
(inputType and InputType.TYPE_NUMBER_FLAG_SIGNED) == 0 -> "decimal-pad"

// Check for phone pad type
inputType and InputType.TYPE_CLASS_PHONE != 0 -> "phone-pad"
(inputType and InputType.TYPE_NUMBER_FLAG_SIGNED) != 0 -> "numeric"

// Check for URL type
inputType and InputType.TYPE_TEXT_VARIATION_URI != 0 -> "url"
else -> "number-pad"
}

// Check for visible password type
inputType and InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD != 0 -> "visible-password"
inputTypeClass == InputType.TYPE_CLASS_PHONE -> "phone-pad"
inputTypeClass == InputType.TYPE_CLASS_TEXT -> "default"

// Default case
else -> "default"
}
}


4 changes: 1 addition & 3 deletions ios/events/KeyboardEventEmitterPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public class KeyboardTypeConverter: NSObject {
}
}

public func buildEventParams(_ height: Double, _ duration: Int, _ responder: UIResponder?)
-> [AnyHashable: Any]
{
public func buildEventParams(_ height: Double, _ duration: Int, _ responder: UIResponder?) -> [AnyHashable: Any] {
var data = [AnyHashable: Any]()

data["height"] = height
Expand Down

0 comments on commit 0cad973

Please sign in to comment.