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

Unified safe area (insets) for Android and iOS #23811

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions demo/src/html/index.html.template
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@
}
#ha-launch-screen .ha-launch-screen-spacer-top {
flex: 1;
margin-top: calc( 2 * max(env(safe-area-inset-bottom), 48px) + 46px );
margin-top: calc( 2 * max(var(--safe-area-bottom), 48px) + 46px );
padding-top: 48px;
}
#ha-launch-screen .ha-launch-screen-spacer-bottom {
flex: 1;
padding-top: 48px;
}
.ohf-logo {
margin: max(env(safe-area-inset-bottom), 48px) 0;
margin: max(var(--safe-area-bottom), 48px) 0;
display: flex;
flex-direction: column;
align-items: center;
Expand Down
6 changes: 3 additions & 3 deletions hassio/src/dashboard/hassio-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class HassioDashboard extends LitElement {
}
ha-fab.non-tabs {
position: fixed;
right: calc(16px + env(safe-area-inset-right));
bottom: calc(16px + env(safe-area-inset-bottom));
inset-inline-end: calc(16px + env(safe-area-inset-right));
right: calc(16px + var(--safe-area-right));
bottom: calc(16px + var(--safe-area-bottom));
inset-inline-end: calc(16px + var(--safe-area-right));
inset-inline-start: initial;
z-index: 1;
}
Expand Down
2 changes: 1 addition & 1 deletion hassio/src/dialogs/network/dialog-hassio-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ export class DialogHassioNetwork
display: flex;
justify-content: space-between;
padding: 8px;
padding-bottom: max(env(safe-area-inset-bottom), 8px);
padding-bottom: max(var(--safe-area-bottom), 8px);
background-color: var(--mdc-theme-surface, #fff);
}
.warning {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ha-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class HaDialog extends DialogBase {
}
.mdc-dialog__actions {
justify-content: var(--justify-action-buttons, flex-end);
padding-bottom: max(env(safe-area-inset-bottom), 24px);
padding-bottom: max(var(--safe-area-bottom), 24px);
}
.mdc-dialog__actions span:nth-child(1) {
flex: var(--secondary-action-button-flex, unset);
Expand Down Expand Up @@ -120,7 +120,7 @@ export class HaDialog extends DialogBase {
:host([hideactions]) .mdc-dialog .mdc-dialog__content {
padding-bottom: max(
var(--dialog-content-padding, 24px),
env(safe-area-inset-bottom)
var(--safe-area-bottom)
);
}
.mdc-dialog .mdc-dialog__surface {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ha-md-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ export class HaMdDialog extends MdDialog {
@media all and (max-width: 450px), all and (max-height: 500px) {
:host(:not([type="alert"])) {
min-width: calc(
100vw - env(safe-area-inset-right) - env(safe-area-inset-left)
100vw - var(--safe-area-right) - var(--safe-area-left)
);
max-width: calc(
100vw - env(safe-area-inset-right) - env(safe-area-inset-left)
100vw - var(--safe-area-right) - var(--safe-area-left)
);
min-height: 100%;
max-height: 100%;
Expand Down
20 changes: 10 additions & 10 deletions src/components/ha-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,12 +875,12 @@ class HaSidebar extends SubscribeMixin(LitElement) {
);
font-size: 20px;
align-items: center;
padding-left: calc(4px + env(safe-area-inset-left));
padding-inline-start: calc(4px + env(safe-area-inset-left));
padding-left: calc(4px + var(--safe-area-left));
padding-inline-start: calc(4px + var(--safe-area-left));
padding-inline-end: initial;
}
:host([expanded]) .menu {
width: calc(256px + env(safe-area-inset-left));
width: calc(256px + var(--safe-area-left));
}
.menu ha-icon-button {
color: var(--sidebar-icon-color);
Expand Down Expand Up @@ -917,12 +917,12 @@ class HaSidebar extends SubscribeMixin(LitElement) {
box-sizing: border-box;
height: calc(100% - var(--header-height) - 132px);
height: calc(
100% - var(--header-height) - 132px - env(safe-area-inset-bottom)
100% - var(--header-height) - 132px - var(--safe-area-bottom)
);
overflow-x: hidden;
background: none;
margin-left: env(safe-area-inset-left);
margin-inline-start: env(safe-area-inset-left);
margin-left: var(--safe-area-left);
margin-inline-start: var(--safe-area-left);
margin-inline-end: initial;
}

Expand Down Expand Up @@ -1022,8 +1022,8 @@ class HaSidebar extends SubscribeMixin(LitElement) {
.notifications-container,
.configuration-container {
display: flex;
margin-left: env(safe-area-inset-left);
margin-inline-start: env(safe-area-inset-left);
margin-left: var(--safe-area-left);
margin-inline-start: var(--safe-area-left);
margin-inline-end: initial;
}
.notifications {
Expand All @@ -1034,8 +1034,8 @@ class HaSidebar extends SubscribeMixin(LitElement) {
flex: 1;
}
.profile {
margin-left: env(safe-area-inset-left);
margin-inline-start: env(safe-area-inset-left);
margin-left: var(--safe-area-left);
margin-inline-start: var(--safe-area-left);
margin-inline-end: initial;
}
.profile paper-icon-item {
Expand Down
12 changes: 6 additions & 6 deletions src/components/ha-toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class HaToast extends Snackbar {

.mdc-snackbar {
margin: 8px;
right: calc(8px + env(safe-area-inset-right));
bottom: calc(8px + env(safe-area-inset-bottom));
left: calc(8px + env(safe-area-inset-left));
right: calc(8px + var(--safe-area-right));
bottom: calc(8px + var(--safe-area-bottom));
left: calc(8px + var(--safe-area-left));
}

.mdc-snackbar__surface {
Expand All @@ -33,9 +33,9 @@ export class HaToast extends Snackbar {

@media all and (max-width: 450px), all and (max-height: 500px) {
.mdc-snackbar {
right: env(safe-area-inset-right);
bottom: env(safe-area-inset-bottom);
left: env(safe-area-inset-left);
right: var(--safe-area-right);
bottom: var(--safe-area-bottom);
left: var(--safe-area-left);
}
.mdc-snackbar__surface {
min-width: 100%;
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/more-info/controls/more-info-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ class MoreInfoUpdate extends LitElement {
position: sticky;
bottom: 0;
margin: 0 -24px 0 -24px;
margin-bottom: calc(-1 * max(env(safe-area-inset-bottom), 24px));
padding-bottom: env(safe-area-inset-bottom);
margin-bottom: calc(-1 * max(var(--safe-area-bottom), 24px));
padding-bottom: var(--safe-area-bottom);
box-sizing: border-box;
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/more-info/ha-more-info-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MoreInfoInfo extends LitElement {
flex-direction: column;
flex: 1;
padding: 24px;
padding-bottom: max(env(safe-area-inset-bottom), 24px);
padding-bottom: max(var(--safe-area-bottom), 24px);
}

[data-domain="camera"] .content {
Expand Down
10 changes: 5 additions & 5 deletions src/dialogs/notifications/notification-drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ export class HuiNotificationDrawer extends LitElement {
.notifications {
overflow-y: auto;
padding-top: 16px;
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
padding-inline-start: env(safe-area-inset-left);
padding-inline-end: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: var(--safe-area-left);
padding-right: var(--safe-area-right);
padding-inline-start: var(--safe-area-left);
padding-inline-end: var(--safe-area-right);
padding-bottom: var(--safe-area-bottom);
height: calc(100% - 1px - var(--header-height));
box-sizing: border-box;
background-color: var(--primary-background-color);
Expand Down
4 changes: 2 additions & 2 deletions src/html/index.html.template
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
}
#ha-launch-screen .ha-launch-screen-spacer-top {
flex: 1;
margin-top: calc( 2 * max(env(safe-area-inset-bottom), 48px) + 46px );
margin-top: calc( 2 * max(var(--safe-area-bottom), 48px) + 46px );
padding-top: 48px;
}
#ha-launch-screen .ha-launch-screen-spacer-bottom {
flex: 1;
padding-top: 48px;
}
.ohf-logo {
margin: max(env(safe-area-inset-bottom), 48px) 0;
margin: max(var(--safe-area-bottom), 48px) 0;
display: flex;
flex-direction: column;
align-items: center;
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/hass-subpage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ class HassSubpage extends LitElement {

#fab {
position: absolute;
right: calc(16px + env(safe-area-inset-right));
inset-inline-end: calc(16px + env(safe-area-inset-right));
right: calc(16px + var(--safe-area-right));
inset-inline-end: calc(16px + var(--safe-area-right));
inset-inline-start: initial;
bottom: calc(16px + env(safe-area-inset-bottom));
bottom: calc(16px + var(--safe-area-bottom));
z-index: 1;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
}
:host([narrow]) #fab.tabs {
bottom: calc(84px + env(safe-area-inset-bottom));
bottom: calc(84px + var(--safe-area-bottom));
}
#fab[is-wide] {
bottom: 24px;
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/hass-tabs-subpage-data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,10 @@ export class HaTabsSubpageDataTable extends KeyboardShortcutMixin(LitElement) {

ha-dialog {
--mdc-dialog-min-width: calc(
100vw - env(safe-area-inset-right) - env(safe-area-inset-left)
100vw - var(--safe-area-right) - var(--safe-area-left)
);
--mdc-dialog-max-width: calc(
100vw - env(safe-area-inset-right) - env(safe-area-inset-left)
100vw - var(--safe-area-right) - var(--safe-area-left)
);
--mdc-dialog-min-height: 100%;
--mdc-dialog-max-height: 100%;
Expand Down
28 changes: 12 additions & 16 deletions src/layouts/hass-tabs-subpage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class HassTabsSubpage extends LitElement {
z-index: 2;
font-size: 12px;
width: 100%;
padding-bottom: env(safe-area-inset-bottom);
padding-bottom: var(--safe-area-bottom);
}

#tabbar:not(.bottom-bar) {
Expand Down Expand Up @@ -311,45 +311,41 @@ class HassTabsSubpage extends LitElement {

.content {
position: relative;
width: calc(
100% - env(safe-area-inset-left) - env(safe-area-inset-right)
);
margin-left: env(safe-area-inset-left);
margin-right: env(safe-area-inset-right);
margin-inline-start: env(safe-area-inset-left);
margin-inline-end: env(safe-area-inset-right);
width: calc(100% - var(--safe-area-left) - var(--safe-area-right));
margin-left: var(--safe-area-left);
margin-right: var(--safe-area-right);
margin-inline-start: var(--safe-area-left);
margin-inline-end: var(--safe-area-right);
overflow: auto;
-webkit-overflow-scrolling: touch;
}

:host([narrow]) .content {
height: calc(100% - var(--header-height));
height: calc(
100% - var(--header-height) - env(safe-area-inset-bottom)
);
height: calc(100% - var(--header-height) - var(--safe-area-bottom));
}

:host([narrow]) .content.tabs {
height: calc(100% - 2 * var(--header-height));
height: calc(
100% - 2 * var(--header-height) - env(safe-area-inset-bottom)
100% - 2 * var(--header-height) - var(--safe-area-bottom)
);
}

#fab {
position: fixed;
right: calc(16px + env(safe-area-inset-right));
inset-inline-end: calc(16px + env(safe-area-inset-right));
right: calc(16px + var(--safe-area-right));
inset-inline-end: calc(16px + var(--safe-area-right));
inset-inline-start: initial;
bottom: calc(16px + env(safe-area-inset-bottom));
bottom: calc(16px + var(--safe-area-bottom));
z-index: 1;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
}
:host([narrow]) #fab.tabs {
bottom: calc(84px + env(safe-area-inset-bottom));
bottom: calc(84px + var(--safe-area-bottom));
}
#fab[is-wide] {
bottom: 24px;
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/home-assistant-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class HomeAssistantMain extends LitElement {
--mdc-top-app-bar-width: calc(100% - var(--mdc-drawer-width));
}
:host([expanded]) {
--mdc-drawer-width: calc(256px + env(safe-area-inset-left));
--mdc-drawer-width: calc(256px + var(--safe-area-left));
}
:host([modal]) {
--mdc-drawer-width: unset;
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/automation/ha-automation-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
}
ha-fab {
position: relative;
bottom: calc(-80px - env(safe-area-inset-bottom));
bottom: calc(-80px - var(--safe-area-bottom));
transition: bottom 0.3s;
}
ha-fab.dirty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class HaBackupOverviewBackups extends LitElement {
gap: 24px;
display: flex;
flex-direction: column;
margin-bottom: calc(72px + env(safe-area-inset-bottom));
margin-bottom: calc(72px + var(--safe-area-bottom));
}
.card-actions {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/core/ha-config-section-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class HaConfigSectionUpdates extends LitElement {
justify-content: space-between;
flex-direction: column;
display: flex;
margin-bottom: max(24px, env(safe-area-inset-bottom));
margin-bottom: max(24px, var(--safe-area-bottom));
}

.card-content {
Expand Down
4 changes: 2 additions & 2 deletions src/panels/config/core/ha-config-system-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class HaConfigSystemNavigation extends LitElement {
haStyle,
css`
:host(:not([narrow])) ha-card {
margin-bottom: max(24px, env(safe-area-inset-bottom));
margin-bottom: max(24px, var(--safe-area-bottom));
}

ha-config-section {
Expand All @@ -235,7 +235,7 @@ class HaConfigSystemNavigation extends LitElement {
ha-card {
overflow: hidden;
margin-bottom: 24px;
margin-bottom: max(24px, env(safe-area-inset-bottom));
margin-bottom: max(24px, var(--safe-area-bottom));
}

ha-card a {
Expand Down
6 changes: 3 additions & 3 deletions src/panels/config/dashboard/ha-config-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,10 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
haStyle,
css`
ha-card:last-child {
margin-bottom: env(safe-area-inset-bottom);
margin-bottom: var(--safe-area-bottom);
}
:host(:not([narrow])) ha-card:last-child {
margin-bottom: max(24px, env(safe-area-inset-bottom));
margin-bottom: max(24px, var(--safe-area-bottom));
}
ha-config-section {
margin: auto;
Expand Down Expand Up @@ -389,7 +389,7 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
}

ha-tip {
margin-bottom: max(env(safe-area-inset-bottom), 8px);
margin-bottom: max(var(--safe-area-bottom), 8px);
}

.new {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ class DialogMQTTDeviceDebugInfo extends LitElement {
@media all and (max-width: 450px), all and (max-height: 500px) {
ha-dialog {
--mdc-dialog-min-width: calc(
100vw - env(safe-area-inset-right) - env(safe-area-inset-left)
100vw - var(--safe-area-right) - var(--safe-area-left)
);
--mdc-dialog-max-width: calc(
100vw - env(safe-area-inset-right) - env(safe-area-inset-left)
100vw - var(--safe-area-right) - var(--safe-area-left)
);
}
}
Expand Down
Loading
Loading