Git Product home page Git Product logo

Comments (8)

TimLariviere avatar TimLariviere commented on May 27, 2024

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.

gaelian avatar gaelian commented on May 27, 2024

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.

TimLariviere avatar TimLariviere commented on May 27, 2024

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.

gaelian avatar gaelian commented on May 27, 2024

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.

TimLariviere avatar TimLariviere commented on May 27, 2024

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.

gaelian avatar gaelian commented on May 27, 2024

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.

DieselMeister avatar DieselMeister commented on May 27, 2024

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.
image

from fabulous.xamarinforms.

kaeedo avatar kaeedo commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.