Skip to content
Snippets Groups Projects
Commit 9b6fd322 authored by Mateusz Żebrak's avatar Mateusz Żebrak
Browse files

Get rid of unused ScreenBuilder type alias

parent f59f142d
No related branches found
No related tags found
2 merge requests!600v1.27.5.21 Release,!558Remove welcome profile from TUIWorld, set TUIWorld profile during CreateProfile wizard instead
......@@ -10,18 +10,20 @@ from clive.__private.ui.forms.create_profile.create_profile_form_screen import C
from clive.__private.ui.forms.create_profile.new_key_alias_form_screen import NewKeyAliasFormScreen
from clive.__private.ui.forms.create_profile.set_account_form_screen import SetAccountFormScreen
from clive.__private.ui.forms.create_profile.welcome_form_screen import CreateProfileWelcomeFormScreen
from clive.__private.ui.forms.form import Form, ScreenBuilder
from clive.__private.ui.forms.form import Form
if TYPE_CHECKING:
from collections.abc import Iterator
from clive.__private.ui.forms.form_screen import FormScreenBase
class CreateProfileForm(Form[CreateProfileContext]):
@property
def context(self) -> CreateProfileContext:
return self.__context
def register_screen_builders(self) -> Iterator[ScreenBuilder[CreateProfileContext]]:
def register_screen_builders(self) -> Iterator[type[FormScreenBase[CreateProfileContext]]]:
if not Profile.is_any_profile_saved():
yield CreateProfileWelcomeFormScreen
yield CreateProfileFormScreen
......
......@@ -4,14 +4,15 @@ import inspect
from abc import abstractmethod
from collections.abc import Callable, Iterator
from queue import Queue
from typing import Any
from typing import TYPE_CHECKING, Any
from clive.__private.core.commands.abc.command import Command
from clive.__private.core.contextual import ContextT, Contextual
from clive.__private.ui.clive_screen import CliveScreen
from clive.__private.ui.forms.form_screen import FormScreenBase
ScreenBuilder = Callable[["Form[ContextT]"], FormScreenBase[ContextT] | FormScreenBase[None]]
if TYPE_CHECKING:
from clive.__private.ui.forms.form_screen import FormScreenBase
PostAction = Command | Callable[[], Any]
......@@ -20,7 +21,7 @@ class Form(Contextual[ContextT], CliveScreen[None]):
def __init__(self) -> None:
self._current_screen_index = 0
self._screens: list[ScreenBuilder[ContextT]] = [*list(self.register_screen_builders())]
self._screens: list[type[FormScreenBase[ContextT]]] = [*list(self.register_screen_builders())]
assert len(self._screens) >= self.MINIMUM_SCREEN_COUNT, "Form must have at least 2 screens"
self._rebuild_context()
self._post_actions = Queue[PostAction]()
......@@ -28,11 +29,11 @@ class Form(Contextual[ContextT], CliveScreen[None]):
super().__init__()
@property
def screens(self) -> list[ScreenBuilder[ContextT]]:
def screens(self) -> list[type[FormScreenBase[ContextT]]]:
return self._screens
@property
def current_screen(self) -> ScreenBuilder[ContextT]:
def current_screen(self) -> type[FormScreenBase[ContextT]]:
return self._screens[self._current_screen_index]
def on_mount(self) -> None:
......@@ -67,7 +68,7 @@ class Form(Contextual[ContextT], CliveScreen[None]):
"""Create brand new fresh context."""
@abstractmethod
def register_screen_builders(self) -> Iterator[ScreenBuilder[ContextT]]:
def register_screen_builders(self) -> Iterator[type[FormScreenBase[ContextT]]]:
"""Return screens to display."""
def add_post_action(self, *actions: PostAction) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment