-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] Text Input #69
base: master
Are you sure you want to change the base?
[WIP] Text Input #69
Changes from 5 commits
d3ad852
806a20b
c3e1545
5ffa7de
59ec718
73c7d5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ _build | |
*.log | ||
*.install | ||
default.profraw | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
type t = CocoaTypes.view; | ||
|
||
[@noalloc] external make: unit => t = "ml_BriskTextInput_make"; | ||
|
||
[@noalloc] | ||
external setCallback: (t, unit => unit) => unit = "ml_BriskTextInput_setCallback"; | ||
|
||
let make = (~onChange=?, ()) => { | ||
let input = make(); | ||
|
||
switch (onChange) { | ||
| Some(callback) => | ||
setCallback( | ||
input, | ||
UIEventCallback.make(callback), | ||
) | ||
| None => () | ||
}; | ||
|
||
input; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
open Brisk; | ||
|
||
type attribute = [ Layout.style ]; | ||
|
||
type style = list(attribute); | ||
|
||
let component = nativeComponent("TextInput"); | ||
let make = (~style= [], ~callback=() => (), children) => | ||
component((_: Hooks.empty) => | ||
{ | ||
make: () => { | ||
let input = | ||
BriskTextInput.( | ||
make(~onChange=callback, ()) | ||
); | ||
}, | ||
configureInstance: (~isFirstRender as _, {view} as node) => { | ||
style | ||
|> List.iter(attribute => | ||
switch (attribute) { | ||
| #Layout.style => () | ||
} | ||
); | ||
node; | ||
}, | ||
children, | ||
} | ||
); | ||
|
||
let createElement = (~style=[], ~callback=?, ~children, ()) => | ||
element( | ||
make( | ||
~style, | ||
~callback?, | ||
listToElement(children) | ||
) | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@interface BriskTextInput : NSTextInputContext <NSTextInputClient> | ||
|
||
@end | ||
|
||
@implementation BriskTextInput | ||
|
||
@end | ||
|
||
NSTextInputContext *ml_BriskTextInput_make() { | ||
BriskTextInput *input = [BriskTextInput new]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So NSTextInputContext is actually a class and NSTextInputClient is a protocol. Should |
||
retainView(input); | ||
|
||
return input; | ||
} | ||
|
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.
just FYI - this doesn't do any magic. In this case the iter does nothing.
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.
Good to know, thanks. 😅
I have so many errors being thrown regarding
BriskTextInput.c
, I feel like once I get that ironed out I'll have a better way of understanding and implementing the component part.