@ng-native/router 0.15.0 → 0.16.0
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.
|
@@ -10,13 +10,27 @@
|
|
|
10
10
|
* Native bar button items would look truer to the platform and bring menus and system symbols
|
|
11
11
|
* with them, but they are data rather than views; they are a later opt-in.
|
|
12
12
|
*/
|
|
13
|
-
import { Component, ElementRef, computed, inject, input } from '@angular/core';
|
|
13
|
+
import { Component, ElementRef, computed, effect, inject, input } from '@angular/core';
|
|
14
|
+
import { HostEngine, nativePlatform } from '@ng-native/fabric';
|
|
14
15
|
import { ownHost } from "./own-host.js";
|
|
15
16
|
import { optionalBoolean } from "./transforms.js";
|
|
16
17
|
import * as i0 from "@angular/core";
|
|
18
|
+
/**
|
|
19
|
+
* A title item's least size on iOS, under any the app gives it. react-native-screens makes the
|
|
20
|
+
* item the bar's title view at its Yoga size, and UIKit lays out no title view of 0 by 0, so a
|
|
21
|
+
* `ui-host` sized to its SwiftUI content, which has no size until it is laid out, stayed 0 by 0.
|
|
22
|
+
*/
|
|
23
|
+
const TITLE_LEAST = { minWidth: 1, minHeight: 1 };
|
|
17
24
|
export class NativeHeaderItem {
|
|
18
25
|
constructor() {
|
|
19
|
-
|
|
26
|
+
const node = inject(ElementRef).nativeElement;
|
|
27
|
+
ownHost(node, this.constructor);
|
|
28
|
+
const engine = (node.host ?? inject(HostEngine));
|
|
29
|
+
if (nativePlatform() === 'ios') {
|
|
30
|
+
effect(() => {
|
|
31
|
+
engine.setDefaultStyle?.(node, this.slot() === 'center' ? TITLE_LEAST : undefined);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
20
34
|
}
|
|
21
35
|
/** Which slot to sit in. Native defaults to `left`. */
|
|
22
36
|
type = input(/* @ts-ignore */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-header-item.js","sourceRoot":"","sources":["../src/native-header-item.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;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G,IAAI,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5C,CAAC;6EAAC,CAAC;IACH,+DAA+D;IACtD,qBAAqB,GAAG,KAAK,CAAC,SAAS,6FAAI,SAAS,EAAE,eAAe,GAAG,CAAC;uGAzBvE,gBAAgB;2FAAhB,gBAAgB,udANjB,gBAAgB;;2FAMf,gBAAgB;kBAR5B,SAAS;mBAAC;oBACT,QAAQ,EAAE,oBAAoB;oBAC9B,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE;wBACJ,QAAQ,EAAE,QAAQ;wBAClB,yBAAyB,EAAE,yBAAyB;qBACrD;iBACF","sourcesContent":["/**\n * Anything Angular can render, placed in one of the navigation bar's slots.\n *\n * Commits as `RNSScreenStackHeaderSubview`, whose `type` picks the slot. A `right` item is the\n * usual \"Done\" or \"Edit\" button; `back` replaces the chevron, which needs\n * `backButtonInCustomView` on the header; `searchBar` expects a search bar rather than\n * arbitrary content.\n *\n * Press handling is the responder system, so a `pressable` inside one works like anywhere else.\n * Native bar button items would look truer to the platform and bring menus and system symbols\n * with them, but they are data rather than views; they are a later opt-in.\n */\nimport { Component, ElementRef, computed, effect, inject, input } from '@angular/core';\nimport { type Engine, type EngineNode, HostEngine, nativePlatform } from '@ng-native/fabric';\nimport { ownHost } from './own-host.ts';\nimport { optionalBoolean } from './transforms.ts';\n\n/**\n * The bar slots. `title` and `center` are the same place: iOS draws both as the title view, and\n * `title` is committed as `center`, the only spelling Android's header knows.\n */\nexport type HeaderItemType = 'back' | 'left' | 'center' | 'title' | 'right' | 'searchBar';\n\n/**\n * A title item's least size on iOS, under any the app gives it. react-native-screens makes the\n * item the bar's title view at its Yoga size, and UIKit lays out no title view of 0 by 0, so a\n * `ui-host` sized to its SwiftUI content, which has no size until it is laid out, stayed 0 by 0.\n */\nconst TITLE_LEAST = { minWidth: 1, minHeight: 1 } as const;\n\n@Component({\n selector: 'native-header-item',\n template: '<ng-content />',\n host: {\n '[type]': 'slot()',\n '[hidesSharedBackground]': 'hidesSharedBackground()',\n },\n})\nexport class NativeHeaderItem {\n constructor() {\n const node = inject(ElementRef).nativeElement as EngineNode;\n ownHost(node, this.constructor);\n const engine = (node.host ?? inject(HostEngine)) as Partial<Engine>;\n if (nativePlatform() === 'ios') {\n effect(() => {\n engine.setDefaultStyle?.(node, this.slot() === 'center' ? TITLE_LEAST : undefined);\n });\n }\n }\n\n /** Which slot to sit in. Native defaults to `left`. */\n readonly type = input<HeaderItemType>();\n\n /**\n * What reaches native. react-native-screens' spec lists `title`, and iOS takes it, but Android's\n * `ScreenStackHeaderSubviewManager` throws `Unknown type title` while mounting the item, which\n * takes the screen down with it: a page that worked on iOS crashed on Android as it opened.\n */\n protected readonly slot = computed(() => {\n const type = this.type();\n return type === 'title' ? 'center' : type;\n });\n /** Opt out of the bar's shared background behind this item. */\n readonly hidesSharedBackground = input(undefined, { transform: optionalBoolean });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "@angular/router over native navigation for Angular Native: stack and tab outlets, native headers and links.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ng-native/device": "0.
|
|
21
|
-
"@ng-native/fabric": "0.
|
|
20
|
+
"@ng-native/device": "0.16.0",
|
|
21
|
+
"@ng-native/fabric": "0.16.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@angular/common": "^22.0.0",
|