Skip to content

Commit

Permalink
Added restart button on final page
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicLike committed Mar 13, 2023
1 parent 6880808 commit 13c3500
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
24 changes: 18 additions & 6 deletions openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,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 @@ -103,7 +103,10 @@ 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(
Expand All @@ -120,7 +123,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 @@ -132,7 +135,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 @@ -178,10 +181,19 @@ 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
21 changes: 20 additions & 1 deletion openandroidinstaller/views/success_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
# If not, see <https://www.gnu.org/licenses/>."""
# Author: Tobias Sterbak

from typing import Callable

import webbrowser
from loguru import logger
from flet import (
ElevatedButton,
Row,
Text,
Markdown,
icons,
)

from views import BaseView
Expand All @@ -28,8 +31,13 @@


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 @@ -69,5 +77,16 @@ def close_window(e):
)
]
),
Row(
[
ElevatedButton(
"Flash new device",
on_click=self.on_confirm,
icon=icons.RESTART_ALT,
disabled=False,
expand=True,
)
]
),
]
return self.view

0 comments on commit 13c3500

Please sign in to comment.