@blotch/angular-lynx-native 22.2.12 → 22.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/android/project.d.ts.map +1 -1
- package/dist/android/project.js +1 -0
- package/dist/ios/project.d.ts.map +1 -1
- package/dist/ios/project.js +3 -0
- package/dist/options.d.ts +8 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +1 -0
- package/package.json +1 -1
- package/templates/android/angular-lynx.properties +1 -0
- package/templates/android/app/build.gradle.kts +4 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +41 -19
- package/templates/ios/App/Info.plist +2 -0
- package/templates/ios/App/LynxViewController.swift +35 -11
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@ An ejected project (`ios/` or `android/` with a `.angular-lynx-ejected` marker,
|
|
|
15
15
|
|
|
16
16
|
## The shells
|
|
17
17
|
|
|
18
|
-
Both are one full-screen `LynxView` running `main.lynx.bundle`; Angular Router does all navigation inside it. Bundles and assets load from inside the app, so RSpeedy's default asset prefix (`/static/...`) works with no configuration. The `LynxView`
|
|
18
|
+
Both are one full-screen `LynxView` running `main.lynx.bundle`; Angular Router does all navigation inside it. Bundles and assets load from inside the app, so RSpeedy's default asset prefix (`/static/...`) works with no configuration. The `LynxView` fills the screen, under the status bar and the home indicator (`"edgeToEdge": false` in angular.json puts it inside the safe area instead). Lynx's own CSS `env(safe-area-inset-*)` is 0 there: Android never sets it, and the iOS shell creates its `LynxView` before the window is key, where Lynx reads it. The runtime gives every `env(safe-area-inset-*)` the insets the shell sends instead (see `safe-area-insets.ts` in the runtime), so they follow rotation. On Android the activity still pads the page for the keyboard, and the bottom inset is 0 while it's open.
|
|
19
19
|
|
|
20
|
-
Both send the same global props, which the runtime's services read: `platform`, `theme` (again whenever the phone switches between light and dark), `appLocale` (the phone's language as a BCP 47 tag), `isNotchScreen`, the safe-area insets `safeAreaTop`, `safeAreaBottom`, `safeAreaLeft` and `safeAreaRight
|
|
20
|
+
Both send the same global props, which the runtime's services read: `platform`, `theme` (again whenever the phone switches between light and dark), `appLocale` (the phone's language as a BCP 47 tag), `isNotchScreen`, `edgeToEdge`, the safe-area insets `safeAreaTop`, `safeAreaBottom`, `safeAreaLeft` and `safeAreaRight` (again whenever they change), `osVersion` (which Lynx leaves out of the main thread's `SystemInfo`), and the accessibility settings `reduceMotion`, `reduceTransparency` (iOS only) and `increaseContrast`, again whenever the user changes one. Android 12 and later also send `dynamicColors`, the wallpaper's Material 3 color roles in light and dark (`DynamicColors.kt`), again when the user changes their wallpaper or colors. Lynx Explorer sends `theme` and `isNotchScreen` too, but no `appLocale`, `osVersion` or accessibility settings. See [`templates/android/README.md`](templates/android/README.md) for the Android shell's details.
|
|
21
21
|
|
|
22
22
|
Both register the native modules the runtime's services call, which Lynx Explorer doesn't have: `AngularLynxWebAuth` (`WebAuthModule.swift`, `WebAuthModule.kt`) opens `LynxWebAuthSession`'s sign-in page, in `ASWebAuthenticationSession` on iOS and a Custom Tab on Android, and returns the URL it redirects to. `AngularLynxLocalStorage` (`LocalStorageModule.swift`, `LocalStorageModule.kt`) keeps `LynxLocalStorage`'s values in a `UserDefaults` suite and a `SharedPreferences` file of their own. `AngularLynxSecureStorage` (`SecureStorageModule.swift`, `SecureStorageModule.kt`) keeps `LynxSecureStorage`'s in the Keychain on iOS and, on Android, in `SharedPreferences`, each value encrypted with AES-GCM by an Android Keystore key, a file Auto Backup leaves out (`res/xml/backup_rules.xml`, `data_extraction_rules.xml`). Android also has `AngularLynxShell`, for the back button.
|
|
23
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAY9D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBAc9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,WAOtC,CAAC;AAEN,eAAO,MAAM,UAAU,GAAI,KAAK,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAY9D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBAc9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,WAOtC,CAAC;AAEN,eAAO,MAAM,UAAU,GAAI,KAAK,WAAW,KAAG,MAYhC,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAiBpD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW,KAAG,MAYjC,CAAC;AAEnB,2EAA2E;AAC3E,eAAO,MAAM,cAAc,GACzB,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAM,GAAG,SAaX,CAAC"}
|
package/dist/android/project.js
CHANGED
|
@@ -46,6 +46,7 @@ export const properties = (app) => [
|
|
|
46
46
|
`versionCode=${app.buildNumber}`,
|
|
47
47
|
`appName=${propertyValue(app.name)}`,
|
|
48
48
|
`screenOrientation=${SCREEN_ORIENTATIONS[app.orientation]}`,
|
|
49
|
+
`edgeToEdge=${app.edgeToEdge}`,
|
|
49
50
|
'',
|
|
50
51
|
].join('\n');
|
|
51
52
|
export const permissionEntries = (app) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/ios/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAiB9D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,iBA6B1B,CAAC;AAQF,eAAO,MAAM,QAAQ,GAAI,KAAK,WAAW,KAAG,MAY9B,CAAC;AAEf,eAAO,MAAM,gBAAgB,GAAI,KAAK,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/ios/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAiB9D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,iBA6B1B,CAAC;AAQF,eAAO,MAAM,QAAQ,GAAI,KAAK,WAAW,KAAG,MAY9B,CAAC;AAEf,eAAO,MAAM,gBAAgB,GAAI,KAAK,WAAW,KAAG,MA2CnD,CAAC"}
|
package/dist/ios/project.js
CHANGED
|
@@ -60,6 +60,9 @@ export const infoPlistEntries = (app) => {
|
|
|
60
60
|
lines.push('</array>');
|
|
61
61
|
};
|
|
62
62
|
array('UISupportedInterfaceOrientations', ORIENTATIONS[app.orientation]);
|
|
63
|
+
// Read by LynxViewController, which lays the LynxView out over the whole
|
|
64
|
+
// screen or inside the safe area.
|
|
65
|
+
lines.push('<key>AngularLynxEdgeToEdge</key>', app.edgeToEdge ? '<true/>' : '<false/>');
|
|
63
66
|
for (const [permission, reason] of Object.entries(app.permissions)) {
|
|
64
67
|
for (const key of PERMISSION_MAP[permission]
|
|
65
68
|
.ios) {
|
package/dist/options.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export type NativeAppOptions = {
|
|
|
19
19
|
/** The store build number (CFBundleVersion / versionCode). */
|
|
20
20
|
readonly buildNumber?: number;
|
|
21
21
|
readonly orientation?: Orientation;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the page fills the screen, under the status bar and the home
|
|
24
|
+
* indicator, with CSS `env(safe-area-inset-*)` carrying the insets, as
|
|
25
|
+
* Safari does for a page with `viewport-fit=cover`. Defaults to true; false
|
|
26
|
+
* lays the page out inside the safe area, with `env()` at 0.
|
|
27
|
+
*/
|
|
28
|
+
readonly edgeToEdge?: boolean;
|
|
22
29
|
/** Each permission the app uses, with the reason shown to the user. */
|
|
23
30
|
readonly permissions?: Partial<Record<Permission, string>>;
|
|
24
31
|
/** Custom URL schemes that open the app, e.g. `["myapp"]`. */
|
|
@@ -63,6 +70,7 @@ export type ResolvedApp = {
|
|
|
63
70
|
readonly version: string;
|
|
64
71
|
readonly buildNumber: number;
|
|
65
72
|
readonly orientation: Orientation;
|
|
73
|
+
readonly edgeToEdge: boolean;
|
|
66
74
|
readonly permissions: Partial<Record<Permission, string>>;
|
|
67
75
|
readonly deepLinkSchemes: readonly string[];
|
|
68
76
|
readonly icon?: string;
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,0E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,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAsB/C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,gBAAgB,EAC5B,UAAU;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3E,WAqFF,CAAC;AAUF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,OAWxC,CAAC"}
|
package/dist/options.js
CHANGED
package/package.json
CHANGED
|
@@ -53,6 +53,10 @@ android {
|
|
|
53
53
|
// portrait, sensorLandscape or unspecified (follows the device).
|
|
54
54
|
manifestPlaceholders["screenOrientation"] =
|
|
55
55
|
appConfig.getProperty("screenOrientation") ?: "portrait"
|
|
56
|
+
// Whether MainActivity draws the page under the system bars (see
|
|
57
|
+
// its insets listener). A properties file written before the option
|
|
58
|
+
// existed has no line for it, and gets the default.
|
|
59
|
+
resValue("bool", "edge_to_edge", appConfig.getProperty("edgeToEdge") ?: "true")
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
signingConfigs {
|
|
@@ -38,8 +38,13 @@ import com.lynx.xelement.XElementBehaviors
|
|
|
38
38
|
class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
39
39
|
private lateinit var lynxView: LynxView
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
//
|
|
41
|
+
// Whether the page draws under the system bars and the cutout:
|
|
42
|
+
// angular.json's edgeToEdge, which app/build.gradle.kts writes as a
|
|
43
|
+
// resource.
|
|
44
|
+
private val edgeToEdge by lazy { resources.getBoolean(R.bool.edge_to_edge) }
|
|
45
|
+
|
|
46
|
+
// The safe-area insets, and whether the screen has a cutout, as the
|
|
47
|
+
// window last reported them. Sent in the global props.
|
|
43
48
|
private var safeArea = Insets.NONE
|
|
44
49
|
private var hasCutout = false
|
|
45
50
|
|
|
@@ -104,26 +109,39 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
104
109
|
}
|
|
105
110
|
})
|
|
106
111
|
|
|
107
|
-
//
|
|
108
|
-
// camera cutout
|
|
109
|
-
//
|
|
110
|
-
//
|
|
112
|
+
// Draw the page under the status bar, the navigation bar and the
|
|
113
|
+
// camera cutout, as Safari does for a page with viewport-fit=cover,
|
|
114
|
+
// and let it pad itself with CSS env(safe-area-inset-*). Lynx never
|
|
115
|
+
// sets env() on Android, so the runtime gives every
|
|
116
|
+
// env(safe-area-inset-*) the safeArea* global props instead, as CSS
|
|
117
|
+
// variables on the page. With "edgeToEdge": false in angular.json
|
|
118
|
+
// the page sits inside the safe area, and the runtime keeps env() at
|
|
119
|
+
// 0. The iOS shell matches.
|
|
111
120
|
val container = FrameLayout(this)
|
|
112
121
|
container.addView(lynxView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
|
|
113
122
|
ViewCompat.setOnApplyWindowInsetsListener(container) { view, insets ->
|
|
114
|
-
val safe = insets.getInsets(
|
|
115
|
-
WindowInsetsCompat.Type.systemBars() or
|
|
116
|
-
WindowInsetsCompat.Type.displayCutout() or
|
|
117
|
-
WindowInsetsCompat.Type.ime(),
|
|
118
|
-
)
|
|
119
|
-
view.setPadding(safe.left, safe.top, safe.right, safe.bottom)
|
|
120
|
-
// The keyboard isn't part of the safe area, as on iOS.
|
|
121
123
|
val bars = insets.getInsets(
|
|
122
124
|
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout(),
|
|
123
125
|
)
|
|
126
|
+
val keyboard = insets.getInsets(WindowInsetsCompat.Type.ime())
|
|
127
|
+
val safe = if (edgeToEdge) {
|
|
128
|
+
// The keyboard still pushes the page up, so the input being
|
|
129
|
+
// typed into stays above it.
|
|
130
|
+
view.setPadding(0, 0, 0, keyboard.bottom)
|
|
131
|
+
// The part of the page the bars cover. While the keyboard is
|
|
132
|
+
// open the page ends at its top edge, above the navigation
|
|
133
|
+
// bar, so nothing covers the bottom.
|
|
134
|
+
Insets.of(bars.left, bars.top, bars.right, maxOf(0, bars.bottom - keyboard.bottom))
|
|
135
|
+
} else {
|
|
136
|
+
val padding = Insets.max(bars, keyboard)
|
|
137
|
+
view.setPadding(padding.left, padding.top, padding.right, padding.bottom)
|
|
138
|
+
// The window's insets, as before the option existed. The
|
|
139
|
+
// keyboard isn't part of the safe area, as on iOS.
|
|
140
|
+
bars
|
|
141
|
+
}
|
|
124
142
|
val cutout = insets.displayCutout != null
|
|
125
|
-
if (
|
|
126
|
-
safeArea =
|
|
143
|
+
if (safe != safeArea || cutout != hasCutout) {
|
|
144
|
+
safeArea = safe
|
|
127
145
|
hasCutout = cutout
|
|
128
146
|
lynxView.updateGlobalProps(globalProps(resources.configuration))
|
|
129
147
|
}
|
|
@@ -214,16 +232,20 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
214
232
|
* The global props the runtime reads: `theme` (LynxTheme), `isNotchScreen`
|
|
215
233
|
* (LynxSafeArea), `appLocale` (LynxLocale), the accessibility settings
|
|
216
234
|
* (LynxAccessibilitySettings) and `osVersion` (LynxSystemInfo), plus the
|
|
217
|
-
* safe-area insets in dp
|
|
218
|
-
*
|
|
219
|
-
* send the wallpaper's
|
|
220
|
-
* which iOS has no
|
|
235
|
+
* safe-area insets in dp and `edgeToEdge`, which env(safe-area-inset-*)
|
|
236
|
+
* reads. The iOS shell sends the same keys, and Lynx Explorer sends theme
|
|
237
|
+
* and isNotchScreen too. Android 12 and later also send the wallpaper's
|
|
238
|
+
* colors, `dynamicColors` (LynxTheme.dynamicColors), which iOS has no
|
|
239
|
+
* equivalent of.
|
|
221
240
|
*/
|
|
222
241
|
private fun globalProps(config: Configuration): Map<String, Any> {
|
|
223
242
|
val density = resources.displayMetrics.density
|
|
224
243
|
val night = config.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
|
225
244
|
val props = mutableMapOf<String, Any>(
|
|
226
245
|
"platform" to "android",
|
|
246
|
+
// Whether the page fills the screen. The runtime gives env() the
|
|
247
|
+
// insets below only then; otherwise the page is already inside them.
|
|
248
|
+
"edgeToEdge" to edgeToEdge,
|
|
227
249
|
"theme" to if (night) "Dark" else "Light",
|
|
228
250
|
"isNotchScreen" to hasCutout,
|
|
229
251
|
"safeAreaTop" to safeArea.top / density,
|
|
@@ -7,6 +7,13 @@ final class LynxViewController: UIViewController {
|
|
|
7
7
|
private var lynxView: LynxView?
|
|
8
8
|
private var lastViewport: CGRect = .zero
|
|
9
9
|
|
|
10
|
+
/// Whether the page fills the screen, under the status bar and the home
|
|
11
|
+
/// indicator: angular.json's `edgeToEdge`, which the generator writes into
|
|
12
|
+
/// Info.plist. A project generated before the option existed has no key,
|
|
13
|
+
/// and gets the default.
|
|
14
|
+
private let edgeToEdge =
|
|
15
|
+
Bundle.main.object(forInfoDictionaryKey: "AngularLynxEdgeToEdge") as? Bool ?? true
|
|
16
|
+
|
|
10
17
|
override func viewDidLoad() {
|
|
11
18
|
super.viewDidLoad()
|
|
12
19
|
view.backgroundColor = UIColor(named: "LaunchBackground") ?? .systemBackground
|
|
@@ -87,18 +94,31 @@ final class LynxViewController: UIViewController {
|
|
|
87
94
|
layoutLynxView()
|
|
88
95
|
}
|
|
89
96
|
|
|
90
|
-
///
|
|
91
|
-
///
|
|
92
|
-
///
|
|
97
|
+
/// The insets change once the view is in its window (they're 0 in
|
|
98
|
+
/// viewDidLoad, when the first global props go), and again on rotation.
|
|
99
|
+
/// An edge-to-edge LynxView keeps its frame when only they change, so
|
|
100
|
+
/// layoutLynxView wouldn't send them.
|
|
101
|
+
override func viewSafeAreaInsetsDidChange() {
|
|
102
|
+
super.viewSafeAreaInsetsDidChange()
|
|
103
|
+
lynxView?.updateGlobalProps(with: globalProps())
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// Lays the LynxView out over the whole screen, so the page draws under
|
|
107
|
+
/// the status bar and the home indicator, as Safari does for a page with
|
|
108
|
+
/// `viewport-fit=cover`, and pads itself with CSS env(safe-area-inset-*).
|
|
109
|
+
/// With `"edgeToEdge": false` in angular.json, it sits inside the safe area
|
|
110
|
+
/// instead, and nothing draws under the notch or the home indicator.
|
|
93
111
|
///
|
|
94
|
-
///
|
|
95
|
-
///
|
|
96
|
-
///
|
|
97
|
-
///
|
|
98
|
-
///
|
|
112
|
+
/// Lynx's own env(safe-area-inset-*) stays 0 here: Lynx reads it from the
|
|
113
|
+
/// key window when a LynxView is created, and viewDidLoad runs before
|
|
114
|
+
/// SceneDelegate makes the window key. It couldn't follow a rotation
|
|
115
|
+
/// anyway, as an element reads env() once. The runtime gives every
|
|
116
|
+
/// env(safe-area-inset-*) the safeArea* global props below instead, as CSS
|
|
117
|
+
/// variables on the page that restyle what reads them when they change, and
|
|
118
|
+
/// 0 when the LynxView is inside the safe area (see `edgeToEdge` there).
|
|
99
119
|
private func layoutLynxView() {
|
|
100
120
|
guard let lynxView else { return }
|
|
101
|
-
let frame = view.bounds.inset(by: view.safeAreaInsets)
|
|
121
|
+
let frame = edgeToEdge ? view.bounds : view.bounds.inset(by: view.safeAreaInsets)
|
|
102
122
|
guard frame != lastViewport else { return }
|
|
103
123
|
lastViewport = frame
|
|
104
124
|
lynxView.frame = frame
|
|
@@ -113,12 +133,16 @@ final class LynxViewController: UIViewController {
|
|
|
113
133
|
/// The global props the runtime reads: `theme` (LynxTheme), `isNotchScreen`
|
|
114
134
|
/// (LynxSafeArea), `appLocale` (LynxLocale), the accessibility settings
|
|
115
135
|
/// (LynxAccessibilitySettings) and `osVersion` (LynxSystemInfo), plus the
|
|
116
|
-
/// safe-area insets
|
|
117
|
-
/// Explorer sends theme and
|
|
136
|
+
/// safe-area insets and `edgeToEdge`, which env(safe-area-inset-*) reads.
|
|
137
|
+
/// The Android shell sends the same keys, and Lynx Explorer sends theme and
|
|
138
|
+
/// isNotchScreen too.
|
|
118
139
|
private func globalProps() -> LynxTemplateData {
|
|
119
140
|
let insets = view.safeAreaInsets
|
|
120
141
|
var props: [String: Any] = [
|
|
121
142
|
"platform": "ios",
|
|
143
|
+
// Whether the page fills the screen. The runtime gives env() the insets
|
|
144
|
+
// below only then; otherwise the page is already inside them.
|
|
145
|
+
"edgeToEdge": edgeToEdge,
|
|
122
146
|
"safeAreaTop": insets.top,
|
|
123
147
|
"safeAreaBottom": insets.bottom,
|
|
124
148
|
"safeAreaLeft": insets.left,
|