Comments (8)
Hello @gaelian
Unfortunately Shell is only partially supported in Fabulous for technical reasons, so I would recommend against using it for the moment.
Might be better in the upcoming MAUI rework.
Regarding your question, OnBackButtonPressed
is not supported.
You can use BackButtonBehavior
like you showed.
BackButtonBehavior
(called shellBackButtonBehavior
in Fabulous) is an attached property and so is defined on pages (ContentPage) like you did, instead of on the Shell directly.
shellBackButtonBehavior
takes a View.BackButtonBehavior()
value. You can find the various properties and events of BackButtonBehavior
as parameters of View.BackButtonBehavior()
.
e.g.
View.Shell(
items = [
View.ShellContent(
content = View.ContentPage(
shellBackButtonBehavior = View.BackButtonBehavior(
command = fun () -> dispatch BackButtonClicked
)
)
)
]
)
from fabulous.xamarinforms.
Hi @TimLariviere, I appreciate the quick response.
I have been looking quite intently at the Fabimals example app, do I understand correctly in that the workarounds displayed in the source for that app represent the partial support you allude to (e.g. Routes.fs, etc)? If so, I'm hoping that I can still make it work, as otherwise, Shell seems quite perfect for what I'm trying to do. Beyond what is shown in Fabimals, are there any other "gotchas" that one should be aware of when using Shell with Fabulous?
from fabulous.xamarinforms.
do I understand correctly in that the workarounds displayed in the source for that app represent the partial support you allude to (e.g. Routes.fs, etc)?
Yes. The thing with Shell is that it has its own routing mechanism that prevents Fabulous from knowing what's happening.
Shell instantiates the pages itself when you request to move a specific URL.
Also if you need to pass parameters to a page you're navigating to (e.g. user_detail?id=XYZ
), you'll need to use the QueryPropertyAttribute
on the page so XF can set the properties with the correct values (Id = XYZ
).
This is not possible in Fabulous by default since you don't have access to the real types.
Hence the need for a custom RoutingPage
class in the Fabimals sample.
This one simulates a dummy page where you can load Fabulous inside.
But it comes with its own set of limitations. For instance, once the page loaded, Fabulous won't be able to update it.
So if you're planning more than a "read-only" page, it won't work.
from fabulous.xamarinforms.
So if you're planning more than a "read-only" page, it won't work.
Ah, I see. That's very good to know. Yes, that's probably a show stopper on using Shell for me. Too bad. :(
But just out of interest, one more Shell question: I note in the Shell documentation they discuss efficient page loading. Is this something that Fabulous can or at some point will be able to take advantage of? Taking your previous example...
View.Shell(
items = [
View.ShellContent(
content = View.ContentPage(
shellBackButtonBehavior = View.BackButtonBehavior(
command = fun () -> dispatch BackButtonClicked
)
)
)
]
)
Is use of the content
argument able to lead to this efficient page loading feature?
from fabulous.xamarinforms.
Is use of the content argument able to lead to this efficient page loading feature?
Yes, it's already using it. content
maps directly to ShellContent.ContentTemplate
in reality.
So the page is only created when needed.
from fabulous.xamarinforms.
That's great. So wishing I could use Shell right now.
You're doing a great job with this stuff, Tim. I'm really liking Fabulous now that I'm somewhat past F# breaking my brain. I look forward to seeing the Xamarin guys hopefully making Shell more accessible to Fabulous in the future.
from fabulous.xamarinforms.
I you want to "hijack" the "hardware backbutton", you can use the navigating-event from the shell. If you don't want that the app will be closed und "e.Cancel()" to stop and implement a behaviour you want. The "e.Source" is something with "ShellXXXX.Pop" (Enum) in case you press the android back button. Don't know anything about iOS. But maybe you can uses this instead of the override backbutton thingy. At least it works for me.
For example here the back-button on an edit sub view.
from fabulous.xamarinforms.
Is there a way to "hijack" the back button behavior when NOT using a shell? i.e., just using a NavigationPage with a ContentPage child?
from fabulous.xamarinforms.
Related Issues (20)
- Question: Can we have multiple windows? HOT 6
- GeastureRecognizers are not updated via UpdateIncremental on iOS HOT 4
- Create iOS extensions with Fabulous HOT 5
- Cannot build default Android project from template HOT 4
- 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
- ImageButton CornerRadius property is an int not a float HOT 3
- 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.