Skip to content

WIP: Restart button #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
PLATFORM = sys.platform
# Define asset paths
CONFIG_PATH = (
Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "configs"]))).resolve()
Path(__file__).parent.joinpath(
Path(os.sep.join(["assets", "configs"]))).resolve()
)
BIN_PATH = Path(__file__).parent.joinpath(Path("bin")).resolve()

Expand All @@ -75,7 +76,7 @@ def __init__(self, state: AppState):
self.view = Column(expand=True, width=1200)

# create default starter views
welcome_view = WelcomeView(
self.welcome_view = WelcomeView(
on_confirm=self.to_next_view,
state=self.state,
)
Expand All @@ -102,14 +103,19 @@ def __init__(self, state: AppState):
)

# create the final success view
self.final_view = SuccessView(state=self.state)
self.success_view = SuccessView(
on_confirm=self.restart,
state=self.state,
)

# initialize the addon view
self.select_addon_view = AddonsView(
on_confirm=self.to_next_view, state=self.state
on_confirm=self.to_next_view,
state=self.state
)
self.install_addons_view = InstallAddonsView(
on_confirm=self.to_next_view, state=self.state
on_confirm=self.to_next_view,
state=self.state
)

# attach some views to the state to modify and reuse later
Expand All @@ -119,7 +125,7 @@ def __init__(self, state: AppState):
select_files_view,
requirements_view,
start_view,
welcome_view,
self.welcome_view,
]
)
self.state.add_addon_views(
Expand All @@ -131,7 +137,7 @@ def __init__(self, state: AppState):
# final default views, ordered to allow to pop
self.state.add_final_default_views(
views=[
self.final_view,
self.success_view,
self.install_view,
]
)
Expand Down Expand Up @@ -177,10 +183,20 @@ def to_next_view(self, e):

# else:
# # display the final view
# self.view.controls.append(self.final_view)
# self.view.controls.append(self.success_view)
logger.info("Confirmed and moved to next step.")
self.view.update()

def restart(self, e):
"""Method to display the first view."""
self.welcome_view.init_visuals()
# clear the current view
self.view.controls = []
# retrieve the new view and update
self.view.controls.append(self.welcome_view)
logger.info("Restart.")
self.view.update()


def configure(page: Page):
"""Configure the application."""
Expand Down Expand Up @@ -219,7 +235,8 @@ def log_version_infos(bin_path):


def main(page: Page, test: bool = False, test_config: str = "sargo"):
logger.info(f"Running OpenAndroidInstaller version '{VERSION}' on '{PLATFORM}'.")
logger.info(
f"Running OpenAndroidInstaller version '{VERSION}' on '{PLATFORM}'.")
log_version_infos(bin_path=BIN_PATH)
logger.info(100 * "-")

Expand All @@ -234,7 +251,8 @@ def main(page: Page, test: bool = False, test_config: str = "sargo"):
leading_width=56,
toolbar_height=72,
elevation=0,
title=Text(f"OpenAndroidInstaller version {VERSION}", style="displaySmall"),
title=Text(
f"OpenAndroidInstaller version {VERSION}", style="displaySmall"),
center_title=False,
bgcolor="#00d886",
actions=[
Expand Down
15 changes: 14 additions & 1 deletion openandroidinstaller/views/success_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# If not, see <https://www.gnu.org/licenses/>."""
# Author: Tobias Sterbak

from typing import Callable
from loguru import logger
from flet import (
ElevatedButton,
Expand All @@ -22,15 +23,21 @@
from styles import (
Text,
Markdown,
icons,
)
from views import BaseView
from app_state import AppState
from widgets import get_title


class SuccessView(BaseView):
def __init__(self, state: AppState):
def __init__(
self,
state: AppState,
on_confirm: Callable,
):
super().__init__(state=state, image="success.png")
self.on_confirm = on_confirm

def build(
self,
Expand Down Expand Up @@ -66,6 +73,12 @@ def close_window(e):
"Finish and close",
expand=True,
on_click=close_window,
),
ElevatedButton(
"Finish and close",
on_click=close_window,
icon=icons.EXIT_TO_APP_OUTLINED,
expand=True,
)
]
),
Expand Down