-
Notifications
You must be signed in to change notification settings - Fork 32
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
Issues/focusable support #232
Issues/focusable support #232
Conversation
label = "SystemInputViewFactory 1".desc() | ||
), | ||
InputWidgetGalleryScreen.InputInfo( | ||
id = SystemInputId, | ||
label = "SystemInputViewFactory 2".desc() | ||
), | ||
InputWidgetGalleryScreen.InputInfo( | ||
id = SystemInputId, | ||
label = "SystemInputViewFactory 3".desc() |
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 what here 3 same screens?
/* | ||
* Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ |
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.
copyright should be from first line of file
val getFocused: LiveData<Boolean> | ||
val setFocused: MutableLiveData<Boolean> |
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.
livedata is not callback, it should be just val focused: MutableLiveData<Boolean>
- and setting and getting allowed, also we can observe changes
override var hasNext: Boolean = false //TODO: Relocate in init(...)? | ||
override var hasPrev: Boolean = false //TODO: Relocate in init(...)? |
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.
it allow to change value from outside, not by our logic but just because someone write input(...).apply { hasNext = true }
and broke our logic
override fun textField( | ||
textField: UITextField, | ||
shouldChangeCharactersInRange: CValue<NSRange>, | ||
replacementString: String | ||
): Boolean { | ||
if (inputFormatter == null) { | ||
return true | ||
} | ||
val nsString = NSString.create(string = textField.text ?: "") | ||
val newText = nsString.stringByReplacingCharactersInRange( | ||
range = shouldChangeCharactersInRange, | ||
withString = replacementString | ||
) | ||
val unformattedText = inputFormatter.unformat(newText) | ||
|
||
textField.text = inputFormatter.format(unformattedText) | ||
textField.sendActionsForControlEvents(UIControlEventEditingChanged) | ||
return false | ||
} | ||
|
||
override fun textFieldDidBeginEditing(textField: UITextField) { | ||
getFocused.postValue(true) | ||
if (hasNext) { | ||
textField.returnKeyType = UIReturnKeyType.UIReturnKeyNext | ||
} | ||
//TODO: Work with accessory view here depending on keyboard type and previous button enabled? | ||
} | ||
|
||
override fun textFieldShouldReturn(textField: UITextField): Boolean { | ||
getFocused.postValue(false) | ||
return true | ||
} |
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.
we cant observe focused state without setting delegate?
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.
in same request used notification center, so we not set own delegate - https://github.com/icerockdev/moko-widgets/pull/180/files
var hasNext: Boolean | ||
var hasPrev: Boolean |
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.
i think it should be val to prevent invalid changes by developers outside of our focusable logic
).apply { | ||
[email protected](this) | ||
} |
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.
i think this search should be done automatic by default...can we got it?
No description provided.