Skip to content

Commit

Permalink
Fix #3516: delete Page.window.on_resize | deprecate Page.on_resize in…
Browse files Browse the repository at this point in the history
… favor of Page.on_resized
  • Loading branch information
ndonkoHenri committed Jun 22, 2024
1 parent c85c715 commit 2038493
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions sdk/python/packages/flet-core/src/flet_core/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ def __init__(self, page: "Page"):
self.page = page
self.__alignment = None
self.__on_event = EventHandler(lambda e: WindowEvent(e))
self.__on_resized = EventHandler(lambda e: WindowResizeEvent(e))
self.page._add_event_handler(
"window_event",
self.__on_event.get_handler(),
)
self.page._add_event_handler("resized", self.__on_resized.get_handler())

# bgcolor
@property
Expand Down Expand Up @@ -500,15 +498,6 @@ def on_event(self):
def on_event(self, handler: "Optional[Callable[[WindowEvent], None]]"):
self.__on_event.subscribe(handler)

# on_resize
@property
def on_resized(self):
return self.__on_resized

@on_resized.setter
def on_resized(self, handler: "Optional[Callable[[WindowReisizeEvent], None]]"):
self.__on_resized.subscribe(handler)


class Page(AdaptiveControl):
"""
Expand Down Expand Up @@ -589,6 +578,8 @@ def __init__(
"app_lifecycle_state_change",
self.__on_app_lifecycle_state_change.get_handler(),
)
self.__on_resized = EventHandler(lambda e: WindowResizeEvent(e))
self._add_event_handler("resized", self.__on_resized.get_handler())

self.__last_route = None

Expand Down Expand Up @@ -2750,23 +2741,31 @@ def on_close(self, handler: OptionalEventCallback):
# on_resize
@property
@deprecated(
reason="Use Page.window.on_resized instead.",
reason="Use Page.on_resized instead.",
version="0.23.0",
delete_version="0.26.0",
is_method=False,
)
def on_resize(self):
return self.__window.on_resized
return self.__on_resized

@on_resize.setter
@deprecated(
reason="Use Page.window.on_resized instead.",
reason="Use on_resized instead.",
version="0.23.0",
delete_version="0.26.0",
is_method=False,
)
def on_resize(self, handler: OptionalEventCallback):
self.__window.on_resized.subscribe(handler)
def on_resize(self, handler: "Optional[Callable[[WindowResizeEvent], None]]"):
self.__on_resized.subscribe(handler)

@property
def on_resized(self):
return self.__on_resized

@on_resize.setter
def on_resized(self, handler: "Optional[Callable[[WindowResizeEvent], None]]"):
self.__on_resized.subscribe(handler)

# on_platform_brightness_change
@property
Expand Down

0 comments on commit 2038493

Please sign in to comment.