Comments (5)
Hi Ben,
Fabulous works on top of Xamarin.Forms, so it could theoretically run anywhere XF is supported.
After looking at the documentation for XF/Share extensions, it seems to use the integration of Xamarin.Forms into a native view, aka "Native Forms".
Today, Fabulous doesn't support it as the program loop is tied to a Xamarin.Forms.Application instance which a share extension wouldn't have. That said, I have already validated that we can make Fabulous work against any XF control instead of just a Xamarin.Forms.Application. (see fabulous-dev/Fabulous#738 (comment))
Didn't had time to integrate that new feature for now, but if you want, you can make your own Fabulous Host
with a couple lines of code to see if you can write your share extension with Fabulous.
We would gladly accept a PR if that's the case.
For the modification, see this code:
https://github.com/fsprojects/Fabulous/blob/dda14abbf1d906de2fe576a4e7940bc94eb4df8c/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/Program.fs#L8-L18
Fabulous will consume the IHost
interface, so you can implement a XamarinFormsContentPageHost
that takes a ContentPage
instead of an Application
.
The GetRootView
and SetRootView
methods would get/set the Content
property.
Then you can write a few functions to be able to write |> Program.runContentPage ...
https://github.com/fsprojects/Fabulous/blob/dda14abbf1d906de2fe576a4e7940bc94eb4df8c/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/Program.fs#L53-L61
You would write your Fabulous app as usual, except for the App
class
module ShareExt =
type Model = ...
type Msg = ...
let init () = ...
let update msg model = ...
let view model dispatch =
View.Grid(...) // Here, make sure you don't use a Page but a Control directly since the parent will be a ContentPage
type MyShareExtContentPage() as this =
inherit Xamarin.Forms.ContentPage()
let runner =
XamarinFormsProgram.mkProgram init update view
|> XamarinFormsProgram.runContentPage this
Then in your share extension, you can write
member this.ViewDidLoad() =
global::Xamarin.Forms.Forms.Init()
let xfPage = new MyShareExtContentPage()
let newController = xfPage.CreateViewController()
this.PresentModalViewController(newController, false)
from fabulous.xamarinforms.
Thanks for the incredibly detailed response. I will try it out and submit a PR if it works as well as described.
from fabulous.xamarinforms.
I suggest having some documentation for running any XF component as a Fabulous program. Seems like a very useful thing to know.
from fabulous.xamarinforms.
I suggest having some documentation for running any XF component as a Fabulous program. Seems like a very useful thing to know.
It's not an official feature yet. Only something I know is possible for simple use cases.
We still need to change a few things inside Fabulous to fully support this.
For instance, currently, only one Fabulous program loop can be active at any single time in the whole application, thus preventing having multiple XF components using Fabulous inside a single app.
But it's a planned feature. Once we add it, the documentation will be available as well. :)
from fabulous.xamarinforms.
OK I understand. Well, looks like it works, I haven't done any dynamic views yet but static ones work.
from fabulous.xamarinforms.
Related Issues (19)
- Question: Can we have multiple windows? HOT 6
- GeastureRecognizers are not updated via UpdateIncremental on iOS HOT 4
- Cannot build default Android project from template HOT 4
- Question: Shell and BackButtonBehaviour/OnBackButtonPressed HOT 8
- Question: using Media.Plugin with Fabulous HOT 2
- [Bug] Reordering WebView in XamarinForms WPF sometimes loses the source HTML value
- Image rotation using Fabulous.XamarinForms.FFImageLoading? HOT 4
- Question: adding child views at runtime to FlexLayout or StackLayout? HOT 4
- Dynamically setting light/dark themes at runtime HOT 2
- [Bug] Getting error while trying to build project created from "fabulous-xf-app" template HOT 14
- AppLinkEntry support HOT 4
- [Experiment] New NavigationView with route-based navigation HOT 4
- Add support for Glide or Nuke Image caching library
- Add "maintenace mode only" message at the top of README
- Question: CollectionView items are not displayed on iOS (XF 5.0 bug) HOT 2
- SwipeItems not showing up correctly HOT 1
- Fabulous.XamarinForms.Templates references Fabulous.2.1.3 which is not released HOT 2
- ListView: disable animation when selectedItem changes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabulous.xamarinforms.