File size: 917 Bytes
2a0825b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Navigation for the 4-step dictation wizard.

The UI is four ``gr.Group`` views stacked in one column; exactly one is visible
at a time. ``nav`` is the single source of truth for "show this step, hide the
rest" — handlers append its result to their outputs to move between steps. Kept
free of flat ``app`` imports so it can be imported both as ``wizard`` (Space
root) and ``space.wizard`` (repo root), and unit-tested without the app."""

import gradio as gr

# Order matters: it's the order the view Groups are created in build_ui and the
# order nav() returns visibility updates.
VIEWS = ("input", "listen", "upload", "results")


def nav(target: str) -> list:
    """Visibility updates for the four views; only ``target`` is shown."""
    if target not in VIEWS:
        raise ValueError(f"unknown view: {target!r} (expected one of {VIEWS})")
    return [gr.update(visible=(view == target)) for view in VIEWS]