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

Questions about usage #21

Closed
frios opened this issue Feb 9, 2021 · 3 comments
Closed

Questions about usage #21

frios opened this issue Feb 9, 2021 · 3 comments

Comments

@frios
Copy link

frios commented Feb 9, 2021

Thank you for producing this component. I am finding it very useful, but I have a few issues that I hope you can help me resolve.

I have a “page-wide” disabled state that disallows any text field from receiving input unless a specific button is pressed. So upon display of the page, if the user taps on a text field, nothing happens. I do this by using the following code for each textfield on my page:

.disabled(editing ? false : true)

When I use your iPhoneNumberField, I notice a few things.

  1. When I first display the page, the text color is gray. I would prefer for it to be standard label color, so I used the modifiers
               .foregroundColor(.label)
               .placeholderColor(.label)

but they did not have any initial impact. If I navigate away from the page and them come back to it, the text is the correct label color.

  1. When i tap on the iPhoneNumberField it still gets input (and brings up a number keyboard) even though the field is supposed to be disabled.

  2. if I use the isEditing parameter and set it to my page-wide editing var then when the iPhoneNumberField is tapped, the state of the whole page editing is changed (which I understand)

So the questions I have are as follows:

  1. How can I totally disable the iPhoneNumberField so that it does not allow any input when my editing var is false?

  2. How can I set the text color to always show up in the standard label color?

Thank you for your help on these issues.

@MichealSBingham
Copy link

I have the same issue, the .disabled() modifier does not seem to work, have you found a solution?

@frios
Copy link
Author

frios commented Jun 18, 2021

Honestly, I just stopped using it.

@MojtabaHs
Copy link
Owner

  1. disabled modifier fixed in v0.6.2
  2. Unfortunately, Apple does not allow accessing the foregroundColor. But you can always customize almost anything in the field by accessing directly the underlying UIView:
            iPhoneNumberField(
                "Title",
                text: $text,
                isEditing: $isEditing,
                formatted: true) {
                    $0.numberPlaceholderColor = .red
                    $0.textColor = .label // <- Here
                    $0.numberPlaceholderColor = .label // <- Here
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants