Skip to content

Commit 17bca83

Browse files
committed
refactor: ui: Store Frame as a View attribute.
This commit stores the Fame widget of View as an attribute so that it can be easily manipulated for various purposes like overlaying widgets , adding padding, etc. Tests added.
1 parent 73ed8e9 commit 17bca83

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

tests/ui/test_ui.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ def test_set_footer_text_default(self, view: View, mocker: MockerFixture) -> Non
8282

8383
view.set_footer_text()
8484

85-
view._w.footer.set_text.assert_called_once_with(["some help text"])
85+
view.frame.footer.set_text.assert_called_once_with(["some help text"])
8686
view.controller.update_screen.assert_called_once_with()
8787

8888
def test_set_footer_text_specific_text(
8989
self, view: View, text: str = "blah"
9090
) -> None:
9191
view.set_footer_text([text])
9292

93-
view._w.footer.set_text.assert_called_once_with([text])
93+
view.frame.footer.set_text.assert_called_once_with([text])
9494
view.controller.update_screen.assert_called_once_with()
9595

9696
def test_set_footer_text_with_duration(
@@ -105,7 +105,7 @@ def test_set_footer_text_with_duration(
105105

106106
view.set_footer_text([custom_text], duration=duration)
107107

108-
view._w.footer.set_text.assert_has_calls(
108+
view.frame.footer.set_text.assert_has_calls(
109109
[mocker.call([custom_text]), mocker.call(["some help text"])]
110110
)
111111
mock_sleep.assert_called_once_with(duration)
@@ -226,6 +226,7 @@ def just_set_message_view(self: Any) -> None:
226226
frame.assert_called_once_with(
227227
view.body, col(), focus_part="body", footer=footer_view()
228228
)
229+
assert view.frame == frame()
229230
show_left_panel.assert_called_once_with(visible=True)
230231

231232
@pytest.mark.parametrize("autohide", [True, False])

zulipterminal/ui.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def set_footer_text(
107107
text = self.get_random_help()
108108
else:
109109
text = text_list
110-
self._w.footer.set_text(text)
111-
self._w.footer.set_attr_map({None: style})
110+
self.frame.footer.set_text(text)
111+
self.frame.footer.set_attr_map({None: style})
112112
self.controller.update_screen()
113113
if duration is not None:
114114
assert duration > 0
@@ -177,14 +177,14 @@ def main_window(self) -> Any:
177177
]
178178
)
179179

180-
w = urwid.Frame(
180+
self.frame = urwid.Frame(
181181
self.body, title_bar, focus_part="body", footer=self.footer_view()
182182
)
183183

184184
# Show left panel on startup in autohide mode
185185
self.show_left_panel(visible=True)
186186

187-
return w
187+
return self.frame
188188

189189
def show_left_panel(self, *, visible: bool) -> None:
190190
if not self.controller.autohide:

0 commit comments

Comments
 (0)