Skip to content

Commit

Permalink
ios status bar padding works
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Dec 26, 2024
1 parent a131c97 commit b9724be
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-clipboard')
implementation project(':capacitor-haptics')
implementation project(':capacitor-plugin-safe-area')

}

Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ project(':capacitor-clipboard').projectDir = new File('../node_modules/@capacito

include ':capacitor-haptics'
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')

include ':capacitor-plugin-safe-area'
project(':capacitor-plugin-safe-area').projectDir = new File('../node_modules/capacitor-plugin-safe-area/android')
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def capacitor_pods
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorClipboard', :path => '../../node_modules/@capacitor/clipboard'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
pod 'CapacitorPluginSafeArea', :path => '../../node_modules/capacitor-plugin-safe-area'
end

target 'App' do
Expand Down
8 changes: 7 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ PODS:
- CapacitorCordova (6.0.0)
- CapacitorHaptics (6.0.2):
- Capacitor
- CapacitorPluginSafeArea (3.0.4):
- Capacitor

DEPENDENCIES:
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
- "CapacitorClipboard (from `../../node_modules/@capacitor/clipboard`)"
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
- "CapacitorHaptics (from `../../node_modules/@capacitor/haptics`)"
- CapacitorPluginSafeArea (from `../../node_modules/capacitor-plugin-safe-area`)

EXTERNAL SOURCES:
Capacitor:
Expand All @@ -22,13 +25,16 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/ios"
CapacitorHaptics:
:path: "../../node_modules/@capacitor/haptics"
CapacitorPluginSafeArea:
:path: "../../node_modules/capacitor-plugin-safe-area"

SPEC CHECKSUMS:
Capacitor: 559d073c4ca6c27f8e7002c807eea94c3ba435a9
CapacitorClipboard: 55e0a514f1e97b1409d533266c119dcbff3e78c3
CapacitorCordova: 8c4bfdf69368512e85b1d8b724dd7546abeb30af
CapacitorHaptics: b53409aaca1203f79c6d0eb3ed5de40556339518
CapacitorPluginSafeArea: 237b6023aa7c3c1d4b245c12f73ae02e55093a50

PODFILE CHECKSUM: 76c1648fb6ed5cd9fba3d90514994da94e1cde2d
PODFILE CHECKSUM: fc2fb6bcae9257aa9abd8d6c141005bce765fe5c

COCOAPODS: 1.16.2
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@vueuse/core": "^10.9.0",
"axios": "^1.6.8",
"bech32": "^2.0.0",
"capacitor-plugin-safe-area": "^3.0.4",
"core-js": "^3.37.0",
"date-fns": "^3.6.0",
"light-bolt11-decoder": "^3.1.1",
Expand Down
24 changes: 24 additions & 0 deletions src/boot/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { copyToClipboard } from "quasar";
import { useUiStore } from "stores/ui";
import { Clipboard } from "@capacitor/clipboard";
import { SafeArea } from "capacitor-plugin-safe-area";

window.LOCALE = "en";
// window.EventHub = new Vue();
Expand Down Expand Up @@ -217,5 +218,28 @@ window.windowMixin = {
} else {
this.changeColor("monochrome");
}

// only for iOS
if (window.Capacitor && Capacitor.getPlatform() === "ios") {
SafeArea.getStatusBarHeight().then(({ statusBarHeight }) => {
document.documentElement.style.setProperty(
`--safe-area-inset-top`,
`${statusBarHeight}px`
);
});

SafeArea.removeAllListeners();

// when safe-area changed
SafeArea.addListener("safeAreaChanged", (data) => {
const { insets } = data;
for (const [key, value] of Object.entries(insets)) {
document.documentElement.style.setProperty(
`--safe-area-inset-${key}`,
`${value}px`
);
}
});
}
},
};
11 changes: 11 additions & 0 deletions src/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ body {
overscroll-behavior-y: contain;
}

body,
#q-app,
.q-drawer,
.q-layout,
.q-header,
.q-dialog__inner > div,
.q-notification {
margin-top: var(--safe-area-inset-top);
// margin-top: 100px; // for testing
}

.q-dialog__inner > div {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
Expand Down

0 comments on commit b9724be

Please sign in to comment.