-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Allow setting the backing classes for UI elements #342
Conversation
This small change allows me to replace the implementation of the underlying Xamarin.Forms classes used by Fabulous.
@@ -75,7 +75,7 @@ module CodeGenerator = | |||
w | |||
|
|||
let generateCreateFunction (data: CreateData) (w: StringWriter) = | |||
w.printfn " static member val CreateFunc%s : (unit -> %s) = (fun () -> ViewBuilders.Create%s())" data.Name data.FullName data.Name | |||
w.printfn " static member val CreateFunc%s : (unit -> %s) = (fun () -> ViewBuilders.Create%s()) with get, set" data.Name data.FullName data.Name | |||
w.printfn "" | |||
w.printfn " static member Create%s () : %s =" data.Name data.FullName |
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.
If I understand correctly, you might want to extend this Create%s
method instead.
It's the one with the upcast.
Nevermind, just realized it's a concrete method and can't be overwritten. :)
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.
Yeah, I went with the public setter. I first tried adding a static extension method of the same name in the same namespace, but in my project and not in Fabulous, hoping that would override the default static methods in ViewBuilders(), but that didn't work so I went with the property setters.
Ok, I think it could be a good addition. Do you think you can add some documentation on it? |
Sure thing will add some docs. Thanks for the feedback! |
Retriggering CI |
Looks like that only retriggered AppVeyor. The Travis build link still says its from 8 hours ago. |
just needs some time. |
Awesome it worked :) |
Could you run |
Built and uploaded! |
Thanks! |
Awesome, looking forward to it 👍 |
MIght be good to add some docs for ViewProto too? I couldn't spot any on a quick glance |
@dsyme Were you thinking we should document each member in type ViewProtos() or just a doc for the type? I noticed some items are assigned in type ViewProtos(), but quite a few are left empty, such as ProtoContentPage and ProtoMasterDetailPage. ViewProtos members seem to only be called from internal Update methods in the generated |
Ah maybe it's not what I thought it was. If that's the case, it needs to be marked as Nevertheless, I think it would be doable to propose things like this let view model dispatch =
View.ContentPage(
content = View.StackLayout(
children = [
View.Label(text="Hello world")
]
)
)
type App() as app =
inherit Application()
ViewBuilders.DefaultLabel <- View.Label(fontFamily="Lobster-Regular")
let runner =
Program.mkProgram init update view
|> Program.runWithDynamicView app |
This small change allows setting ViewBuilders properties and enables me to replace the implementation of the underlying Xamarin.Forms classes used by Fabulous.
For example, if I need to override a virtual method on MasterDetailPage, this change enables running:
This will cause the MasterDetailPageWithoutToolbar class to be loaded when using the standard:
View.MasterDetailPage()