Skip to content

Commit 110b727

Browse files
committed
Improve message rendering on webview (fix)
1 parent 1dba2de commit 110b727

File tree

8 files changed

+66
-13
lines changed

8 files changed

+66
-13
lines changed

android/app/capacitor.build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ android {
1010
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
1111
dependencies {
1212
implementation project(':capacitor-app')
13+
implementation project(':capacitor-keyboard')
1314
implementation project(':capacitor-push-notifications')
1415
implementation project(':capacitor-status-bar')
1516
implementation project(':capgo-capacitor-social-login')

android/capacitor.settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/
55
include ':capacitor-app'
66
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
77

8+
include ':capacitor-keyboard'
9+
project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android')
10+
811
include ':capacitor-push-notifications'
912
project(':capacitor-push-notifications').projectDir = new File('../node_modules/@capacitor/push-notifications/android')
1013

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"dependencies": {
3030
"@capacitor/app": "7.1.0",
3131
"@capacitor/core": "7.4.4",
32+
"@capacitor/keyboard": "7.0.3",
3233
"@capacitor/push-notifications": "7.0.3",
3334
"@capacitor/status-bar": "7.0.3",
3435
"@capgo/capacitor-social-login": "7.14.9",

web/components/page-base.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function PageBase(props: {
6666
<GoogleOneTapLogin className="fixed bottom-12 right-4 z-[1000]"/>
6767
<Col
6868
className={clsx(
69-
'pb-[58px] lg:pb-0', // bottom bar padding
69+
'pb-page-base lg:pb-0', // bottom bar padding
7070
'text-ink-1000 mx-auto min-h-screen w-full lg:grid lg:grid-cols-12'
7171
)}
7272
>

web/pages/_app.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {Capacitor} from '@capacitor/core'
1717
import {StatusBar} from '@capacitor/status-bar'
1818
import {App} from '@capacitor/app'
1919
import {useRouter} from "next/navigation";
20+
import {Keyboard} from "@capacitor/keyboard";
2021

2122
if (Capacitor.isNativePlatform()) {
2223
// Only runs on iOS/Android native
@@ -70,6 +71,19 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
7071
useHasLoaded()
7172
const router = useRouter()
7273

74+
useEffect(() => {
75+
if (!Capacitor.isNativePlatform()) return
76+
const onShow = () => document.body.classList.add('keyboard-open');
77+
const onHide = () => document.body.classList.remove('keyboard-open');
78+
79+
Keyboard.addListener('keyboardWillShow', onShow);
80+
Keyboard.addListener('keyboardWillHide', onHide);
81+
82+
return () => {
83+
Keyboard.removeAllListeners();
84+
};
85+
}, []);
86+
7387
useEffect(() => {
7488
initTracking()
7589

web/pages/messages/[channelId].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export const PrivateChat = (props: {
294294
</Modal>
295295
)}
296296
</Row>
297-
<Col className="relative h-[calc(100dvh-213px-env(safe-area-inset-bottom))] lg:h-[calc(100dvh-184px)] xl:px-0">
297+
<Col className="relative h-[calc(100dvh-210px-var(--hloss))] lg:h-[calc(100dvh-184px-var(--hloss))] xl:px-0">
298298
<div
299299
ref={outerDiv}
300300
className="relative h-full overflow-y-auto"

web/styles/globals.css

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,46 @@
55
:root {
66
/*--font-main: "Crimson Pro", "EB Garamond", Georgia, "Times New Roman", Times, serif;*/
77
--font-main: "Atkinson Hyperlegible Next", Georgia, "Times New Roman", Times, serif;
8+
--bnh: env(safe-area-inset-bottom); /* native bottom nav height */
9+
--tnh: env(safe-area-inset-top); /* native top nav height */
10+
--hloss: calc(var(--bnh) + var(--tnh)); /* mobile height loss due to native top and bottom bars */
11+
}
12+
13+
.safe-top {
14+
/*padding-top: calc(20px);*/
15+
padding-top: env(safe-area-inset-top);
16+
box-sizing: border-box; /* ensure padding doesn’t break layout */
17+
}
18+
19+
.safe-bottom {
20+
/*bottom: calc(48px);*/
21+
bottom: env(safe-area-inset-bottom);
22+
}
23+
24+
.keyboard-open .pb-page-base {
25+
padding-bottom: calc(61px);
26+
}
27+
28+
.pb-page-base {
29+
padding-bottom: calc(61px + env(safe-area-inset-bottom));
30+
/*bottom: calc(48px);*/
31+
/*padding-bottom: env(safe-area-inset-bottom);*/
32+
}
33+
34+
/* When keyboard is open, remove safe area offset */
35+
.keyboard-open .safe-bottom {
36+
bottom: 0;
37+
}
38+
39+
.keyboard-open {
40+
--bnh: 0;
41+
/*--tnh: 0;*/
42+
--hloss: var(--tnh);
43+
}
44+
45+
/* Replace default Tailwind behavior */
46+
.min-h-screen {
47+
min-height: calc(1dvh * 100 - var(--hloss));
848
}
949

1050
.main-font {
@@ -450,14 +490,3 @@ ol > li::marker {
450490
color: #374151; /* pick a visible color */
451491
}
452492

453-
.safe-top {
454-
/*padding-top: calc(20px);*/
455-
padding-top: env(safe-area-inset-top);
456-
box-sizing: border-box; /* ensure padding doesn’t break layout */
457-
}
458-
459-
.safe-bottom {
460-
/*bottom: calc(48px);*/
461-
bottom: env(safe-area-inset-bottom);
462-
}
463-

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,11 @@
11921192
dependencies:
11931193
tslib "^2.1.0"
11941194

1195+
"@capacitor/[email protected]":
1196+
version "7.0.3"
1197+
resolved "https://registry.yarnpkg.com/@capacitor/keyboard/-/keyboard-7.0.3.tgz#8e05a70a386479f0cd2778fbec1adda5f6e18cee"
1198+
integrity sha512-BIBKjmky5rOYNhvYhNeDi0MMvjwYZ6YF9JoCYcGKvKY+XLJKtezsEL78XfOlgWZBkbfR8uq3tzktY6PqgoYLKA==
1199+
11951200
"@capacitor/[email protected]":
11961201
version "7.0.3"
11971202
resolved "https://registry.yarnpkg.com/@capacitor/push-notifications/-/push-notifications-7.0.3.tgz#b053f5c8db8cc8ceddda8dd9a1c744a72113e202"

0 commit comments

Comments
 (0)