Event - Screen Navigation

Description

Hello, I am facing some difficulty when i am trying to navigate some screens, suppose we have some mode to be set in out device and only one screen to show the parameters which is common for all modes, can we implement any kind of logic to use the same screen with all type of modes, the issue right now is if i give a DIR_LEFT event in the screen to navigate to one screen, and in a separate if statement if i give another DIR_LEFT navigation to a different screen from the same screen, it navigates only to the latest screen.

What MCU/Processor/Board and compiler are you using?

I am using Sensecap indicator D1s, specifically the ESP32-S3

What LVGL version are you using?

LVGL version 8.3

What do you want to achieve?

To know what kind of logic can be applied other than creating a duplicate screen with a different name.

What have you tried so far?

Tried some if statements, and if else statements, but in my code the if else statement is not working,

Code Snippet

void ui_event_screen_sensor(lv_event_t * e) {
  lv_event_code_t event_code = lv_event_get_code(e);
//   lv_obj_t *target = lv_event_get_target(e);
//   lv_obj_t * cur_screen = lv_scr_act();
    lv_indev_wait_release(lv_indev_get_act());
    if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT)
    {
        if (ui_screen_last == ui_ScreenMain);
        {
        _ui_screen_change(ui_Screen1, LV_SCR_LOAD_ANIM_MOVE_LEFT, 100, 0);
        }
        if (ui_screen_last == ui_ScreenMain);
        {
         _ui_screen_change(ui_Screen2, LV_SCR_LOAD_ANIM_MOVE_LEFT, 10000, 0);
        }
    } 
}

Completely lost in your idea. And when you use Squareline write into right forum…

Remove the semicolons from the if statement lines.

But you are aware that these 2 if statements are same, right?

Hey, sorry I couldn’t explain any better, And thankyou I will try in the squareline forum also.

When I remove the semicolons from the statement, the screen does not navigate when i swipe.

And sorry, i know the if statements are same, but for my use case, as I ,mentioned there are certain modes, and in each mode i am using the same Main screen, and only a secondary screen that changes with each mode. So while inside a mode i show a specific screen for the mode and the main screen which is common for all modes. Hope I am clear about the screens, Please point out if this method doesn’t work the way I think it will also.

Thank you for any help.

You write many words about modes , but in your showed code nothink .
For example you set global variable mode to actual destination mode then

    if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT)
    {
        if (mode==1)
        {
        _ui_screen_change(ui_Screen1, LV_SCR_LOAD_ANIM_MOVE_LEFT, 100, 0);
        }
        else if (mode==2)
        {
         _ui_screen_change(ui_Screen2, LV_SCR_LOAD_ANIM_MOVE_LEFT, 10000, 0);
        }
    }