-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add async-CustomInput
support
#182
Conversation
ad713ac |
input: (State) -> CustomInput, | ||
highlightColor: UIColor? = UIColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 1) | ||
) -> AnyRenderable { | ||
return CustomInputComponent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to change CustomInputComponent
to support this? Why can't we just return self
when state is nil
? At least I think this should be done the same way that we build boxes where sections and/or nodes are conditionally composed depending on a certain condition and here I think we could follow the same principle, if the state
is nil
it means there's no CustomInput
so we don't need a CustomInputComponent
but once that changes we can then build a CustomInputComponent
to display that input.
I'm not sure if I'm missing some detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state = nil
doesn't mean we don't use customInput
at all.
It's rather the same behavior as we already have: "Show customInput when user tapped"
On the contrary, when state
exists, customInput
shows immediately when re-rendered.
It also holds the same property "show customInput when user tapped" as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should rename method e.g. func customInput(immediatelyWhen:...)
so that "immediately" belongs to state existence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state = nil doesn't mean we don't use customInput at all.
It's rather the same behavior as we already have: "Show customInput when user tapped"
I'm a bit confused, in your example you tap Gender
and there's no input being presented, you display an activity indicator as accessory and after 1 sec. your state changes and then it shows the option picker, why do we need to have a custom input before the change of state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to have a custom input before the change of state
That's good question!
IIRC I tried the same approach by removing customInput
only when loading.
But this caused Bento diffing animation for the entire "gender cell" that I wanted to avoid.
So, keeping customInput
throughout the handling is (probably) required to avoid such animations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes it does that because we are swapping from one component to another one if we do that 😕
I don't see any way to avoid that animation but maybe @andersio has an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be some diffing optimization, but I think it's still OK to always keep customInput
during loading.
It might still be able to tap though (which will be a bug), I can add isEnabled
property to prevent that, so that we don't need to worry about removal animation of customInput
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(For sure diffing optimization will be more nice, but we won't probably invest too much here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#146 is meant to tackle that. But I'd be surprised that there is any deleting animation. It should be a subtle cross-fade.
In PR party, @andersio came up with an idea of showing loading indicator inside keyboard so that focus eligibility (keyboard switching) can still work and has a better user experience. While I agree on this UX improvement, this PR is still orthogonal that we want to have some functionality to present the keyboard immediately, e.g. SwiftUI's So, we concluded that this PR will be reviewed separately without considering about loading-keyboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
f789bcc Reverted example code. |
This PR is an experiment of asynchronously displaying
CustomInput
after cell tap.Example demo can be found in
SignUp
screen.This feature is needed when
OptionPicker
's data is not ready yet and requires async fetch beforeCustomInput
presentation.It is triggered by state change and
focusesOnFirstDisplay
is set.The implementation is complete, so please review and tell me this is the right way to go.
(Please don't review about example code. It will be deleted afterwards)
Changes
func customInputImmediately(when:input:)
focusesOnFirstDisplay
CustomInputComponent.ComponentView
to presentFocusToolbar
without back/forward buttons when it is not focus-eligible (due to asynchrony).Screencast
TODO