NativeScript/NativeScript

Simplify passing Context from the showModal() method

Open

#6271 aperta il 14 set 2018

Vedi su GitHub
 (6 commenti) (0 reazioni) (1 assegnatario)TypeScript (1634 fork)batch import
featuregood first issuehacktoberfestmodal-page

Metriche repository

Star
 (23.592 star)
Metriche merge PR
 (Merge medio 11g) (13 PR mergiate in 30 g)

Descrizione

When using showModal() to show multiple modals with a new frame to navigate, context does not appear to be passed from page.showModal() function but from the frame.navigate() passed to it.

In the demo example, the second (context) parameter parameter of page.showModal is not passed to the modal page in navigation (excerpted from https://github.com/NativeScript/modal-navigation-demo/)

    const frame = new Frame();
    frame.navigate("modal/modal-page");    
    page.showModal(frame,
        "context", 
        () => console.log("home-page modal frame closed"),
        true);
    );

This results in the modal page having an empty args.context object, and not args.context = "context" as implied.

If a frame is supplied to page.showModal, the frame.navigate() must contain the context, e.g.:

   frame.navigate({moduleName: "modal/modal-page", context: "Context" });
   frame.navigate({moduleName: "modal/modal-page", context: { someContext: "Context", moreContext: "Context2" } });

then in the modal page the context is actually passed, e.g. args.context = "Context" or args.context.someContext = "Context"

Cross reference: https://github.com/NativeScript/modal-navigation-demo/issues/4

This problem appears in both iOS and Android in NativeScript 4.20.

I don't know if this is the new and desired behavior with frame-based modal navigation or if this is a bug in showModal(). At least it is something that should be marked as deprecated.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Guida contributor