How can we change to another Lens line programmatically?

Options
Jorge Costa
Jorge Costa Posts: 13 🔥
edited January 2023 in General #1

After my investigation, there are two ways to advance to go back or forward in Lens' line.

  1. Use LaunchData to send the line that we want to load.
  2. Enable the automaticallyConfiguresTouchHandler to true and let the user tap on the screen to go forward.

I want to jump to another line, using a custom SwiftUI Button, but applying the same lens with different LaunchData is not smooth; we see a white splash happening.

Is any way to achieve this?

Answers

  • stevenxu
    stevenxu Posts: 603 👻
    Options

    @Jorge Costa Thanks for submitting your question in our forum! I'm sharing this with our team now to take a look. Will get back to you as soon as we can.

  • stevenxu
    stevenxu Posts: 603 👻
    Options

    @Jorge Costa Could you explain in more details on what you mean by "Lens Line?" Not 100% we understand that.

  • ForumChris
    ForumChris Posts: 23 👻
    Options

    Hello @Jorge Costa , it sounds like you may benefit from Remote APIs

    With this setup, you could send a request from the Lens to the app, then within the app respond to the request with the new line to display once that SwiftUI Button is pressed. This way, the Lens will stay applied only once, but the information in the Lens can change via data you send in from the app.

  • Jorge Costa
    Jorge Costa Posts: 13 🔥
    Options

    @stevenxu with "Lens line" I mean a JSON file that we use on script to load and manage the lens state.

    "global.storyData = [
    {
    "line": 1,
    "text": " ",
    "background": "bg_Plain",
    "face": " ",
    "effects": "Character for Picker"
    },
    {
    "line": 2,
    "text": " ",
    "background": "bg_Plain",
    "face": " ",
    "effects": "pillow, Character for Picker, Picker with Face Inset"
    }
    ]"

    Tapping on the PreviewView updates the line we are on. I would like to implement that programmatically.

    @ForumChris thanks. I'll try that and let you now if it worked.