Skip to content
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

Add support for Window Controls Overlay #53

Merged
merged 9 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 11 additions & 0 deletions js/src/admin/components/PWAPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ export default class PWAPage extends ExtensionPage {
type: 'bool',
})}
</fieldset>
<fieldset>
{this.buildSettingComponent({
setting: 'askvortsov-pwa.windowControlsOverlay',
label: app.translator.trans('askvortsov-pwa.admin.pwa.other.windowControlsOverlay_label'),
help: app.translator.trans('askvortsov-pwa.admin.pwa.other.windowControlsOverlay_text', {
compatibilitylink: <a href="https://caniuse.com/mdn-api_windowcontrolsoverlay" tabindex="-1"/>,
learnlink: <a href="https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/window-controls-overlay" tabindex="-1"/>
}),
type: 'bool',
})}
</fieldset>
</fieldset>

{this.submitButton()}
Expand Down
6 changes: 6 additions & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ askvortsov-pwa:
push_notif_preference_default_to_email_text: If true, users will have push notifications enabled by default for all notification types where email notifications are enabled by default. If false, users will have push notifications disabled by default.
user_max_subscriptions_label: Max Push Subscriptions Per User
user_max_subscriptions_text: How many push subscriptions should each user be able to have at a time? When a user receives a push notification, each subscription will result in an API call. Each subscription typically corresponds to a browser the user has used.
windowControlsOverlay_label: Enable Window Controls Overlay?
windowControlsOverlay_text: |
If true, users will able to enable Window Controls Overlay to create an immersive, native-like experience. Window Controls Overlay enables or not depends on user's preference and browser's compatibility. You also should be sure you've done something to match this feature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be sure you've done something to match this feature.

What does that even mean or imply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it may not be described clearly. As the text mentioned, we must do something to adapt the UI changes.
Specifically speaking, after enabling this feature, the titlebar will disappear and only leave the three controls. Flarum doesn't do anything for that, so you'll have a bad window. For example:
Not adapted with Window Controls Overlay
Just like that. So you're needed to do is just write some CSS to "match this feature". For example (Please pay attention to the position changes of the elements on the titlebar):
Adapted
That's all. Since the description text is considered as incomprehensible, maybe it's necessary to rewrite it......If someone can provide help, I would be grateful.


See also: <compatibilitylink>The compatibility of Window Controls Overlay</compatibilitylink> & <learnlink>About Window Controls Overlay in Microsoft Learn</learnlink>

heading: Progressive Web App Configuration
text: Configure your Flarum site to run as a progressive web app! Please note that this doesn't automatically put your site in the app store. Instead, this means that users have an 'Add to Homescreen' option for your site. We provide some status checks, however, the best way to test this is to try and install it (search on google for instructions on how to install progressive web apps). Also, please keep in mind that 'install this PWA' popups are controlled by browsers, and cannot be triggered by developers/admins/programs. I recommend including instructions for how to install a PWA in your site's documentation.
status_check_heading: Status Check
Expand Down
5 changes: 5 additions & 0 deletions src/PWATrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ protected function buildManifest(): array
$manifest['short_name'] = $shortName;
}

$dispalyOverride = $settings->get('askvortsov-pwa.windowControlsOverlay');
if ($dispalyOverride) {
$manifest['display_override'] = ['window-controls-overlay'];
}

return $manifest;
}
}