From 2dd535465fe70689a8e22751db24e4b86809db35 Mon Sep 17 00:00:00 2001 From: jotaen4tinypilot <83721279+jotaen4tinypilot@users.noreply.github.com> Date: Thu, 24 Aug 2023 15:47:29 +0200 Subject: [PATCH] Add view mode to hide away menu and status bars (#1587) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of https://github.com/tiny-pilot/tinypilot/issues/728, stacked onto https://github.com/tiny-pilot/tinypilot/pull/1586. As demonstrated and discussed [in the original proof-of-concept branch](https://github.com/tiny-pilot/tinypilot/pull/1574), we want to hide the status bar and menu bar in the popup window [via a query parameter](https://github.com/tiny-pilot/tinypilot/pull/1574/files#diff-66e482e36d313dd641cd92c815c5fa30fb380bbaa601810827b30a5b84428856R351). So by appending `?viewMode=standalone` to the TinyPilot URL, this PR hides the status bar, the menu bar, and the on-screen keyboard. We will use this in a later PR, when adding the menu item for opening a “real” popup window. Screenshot 2023-08-23 at 18 38 09 The query parameter can also be used independent of the popup window, which e.g. allows for [the iframe use-case](https://github.com/tiny-pilot/tinypilot/issues/523). ## Notes - `prettier-ignore` is needed above ``, since Prettier cannot handle Jinja2 templates, and would enforce a pretty [bulky formatting otherwise](https://github.com/tiny-pilot/tinypilot/pull/1574/files#diff-a18b3b5de30df1bcf7531723d24c214d69b2acff3cd88540e1ff186409879b0aR81-R88). - I had to pull out a `--bar-padding` CSS variable in the `` component, so that we can dynamically override the value. I forgot that in the [earlier PR](https://github.com/tiny-pilot/tinypilot/pull/1583). - In `index.html`, I injected the `display: none` via a plain ` + {% endif %} diff --git a/app/views.py b/app/views.py index 39bd55ed5..a0748c36d 100644 --- a/app/views.py +++ b/app/views.py @@ -19,6 +19,7 @@ def index_get(): 'index.html', use_webrtc_remote_screen=use_webrtc, page_title_prefix=_page_title_prefix(), + is_standalone_mode=_is_standalone_mode(), custom_elements_files=find_files.custom_elements_files()) @@ -47,3 +48,7 @@ def _page_title_prefix(): if hostname.determine().lower() != _DEFAULT_HOSTNAME.lower(): return f'{hostname.determine()} - ' return '' + + +def _is_standalone_mode(): + return flask.request.args.get('viewMode') == 'standalone'