Skip to content

2.1.0

Compare
Choose a tag to compare
@david-lev david-lev released this 25 Nov 21:28
· 43 commits to master since this release
92270c2

What's Changed

Update with pip: pip3 install -U pywa

  • [flows] adding CalendarPicker component
  • [flows] allow string concatenation with refs
  • [flows] adding support for math expressions
  • [flows] allowing to use condition in visible
  • [flows] new action: open url
  • [flows] new action: update data
  • [flows] init_value available outside form
  • [flows] allow to use screen/ref as shortcut for .ref_in(screen)
  • [flows] separating Action and adding on_unselect_action
from pywa.types.flows import *

FlowJSON(
    version="6.1",
    screens=[
        start := Screen(
            id="START",
            title="Start",
            layout=Layout(
                children=[
                    date_range := CalendarPicker(  # new component
                        name="date_range",
                        label={
                            "start-date": "Select start date",
                            "end-date": "Select end date",
                        },
                        mode=CalendarPickerMode.RANGE,
                    ),
                    ...,  # Footer with NavigateAction to `RESULT`
                ]
            ),
        ),
        Screen(
            id="RESULT",
            title="Result",
            layout=Layout(
                children=[
                    name := TextInput(
                        name="name",
                        label="Enter your name",
                        input_type=InputType.TEXT,
                    ),
                    birth_year := TextInput(
                        name="birth_year",
                        label="Enter birth year",
                        input_type=InputType.NUMBER,
                        init_value="1990",  # `init_value` outside Form
                    ),
                    TextBody(
                        # string concatenation with refs and math expressions
                        text=f"`'Hello, ' {name.ref} '. You are ' {2024 - birth_year.ref} ' years old.'`",
                        visible=birth_year.ref > 0,  # condition in `visible`
                    ),
                    OptIn(
                        name="rtd",
                        label="I read the docs",
                        on_click_action=OpenUrlAction(  # Open URL action
                            url="https://pywa.readthedocs.io",
                        ),
                    ),
                    Footer(
                        label="Done",
                        on_click_action=CompleteAction(  # `Action` is deprecated
                            payload={
                                "date_range": start/date_range.ref,  # using screen/ref as shortcut
                            },
                        ),
                    ),
                ],
            ),
        ),
    ],
)

Full Changelog: 2.0.5...2.1.0