@ng-native/components 0.28.0 → 0.30.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.
- package/README.md +2 -2
- package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +116 -11
- package/dist/activity-indicator.js +3 -3
- package/dist/animated-style.js +3 -3
- package/dist/animations-web.js +3 -3
- package/dist/animations.js +3 -3
- package/dist/content-container.js +3 -3
- package/dist/context-menu.js +3 -3
- package/dist/drag-and-drop.js +6 -6
- package/dist/gestures-web.js +6 -6
- package/dist/gestures.js +6 -6
- package/dist/gradient-text.d.ts +1 -1
- package/dist/gradient-text.js +4 -4
- package/dist/gradient-text.js.map +1 -1
- package/dist/image-background.js +3 -3
- package/dist/image.js +3 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/input-accessory-view.js +3 -3
- package/dist/keyboard-avoiding-view.js +3 -3
- package/dist/keyboard-dock.js +15 -15
- package/dist/markdown-blocks.d.ts +2 -1
- package/dist/markdown-blocks.js +22 -18
- package/dist/markdown-blocks.js.map +1 -1
- package/dist/markdown-columns.js +3 -3
- package/dist/markdown-stream.js +8 -5
- package/dist/markdown-stream.js.map +1 -1
- package/dist/markdown.js +5 -5
- package/dist/markdown.js.map +1 -1
- package/dist/menu.d.ts +11 -5
- package/dist/menu.js +24 -44
- package/dist/menu.js.map +1 -1
- package/dist/modal.js +8 -3
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +25 -3
- package/dist/native-button.js +102 -8
- package/dist/native-button.js.map +1 -1
- package/dist/native-gesture.js +3 -3
- package/dist/native-ref.js +3 -3
- package/dist/press-menu.d.ts +38 -8
- package/dist/press-menu.js +80 -19
- package/dist/press-menu.js.map +1 -1
- package/dist/pressable.js +14 -13
- package/dist/pressable.js.map +1 -1
- package/dist/reanimated-web.js +6 -6
- package/dist/reanimated.js +6 -6
- package/dist/refresh-control.js +3 -3
- package/dist/safe-area-provider.js +3 -3
- package/dist/safe-area-view.js +3 -3
- package/dist/scroll-view-props.js +3 -3
- package/dist/scroll-view.d.ts +3 -1
- package/dist/scroll-view.js +10 -5
- package/dist/scroll-view.js.map +1 -1
- package/dist/section-list.d.ts +4 -4
- package/dist/section-list.js +37 -34
- package/dist/section-list.js.map +1 -1
- package/dist/shortcut.js +3 -3
- package/dist/sidebar-item.js +3 -3
- package/dist/sidebar-section.d.ts +12 -5
- package/dist/sidebar-section.js +32 -12
- package/dist/sidebar-section.js.map +1 -1
- package/dist/sidebar.d.ts +11 -3
- package/dist/sidebar.js +18 -8
- package/dist/sidebar.js.map +1 -1
- package/dist/split-view.d.ts +23 -2
- package/dist/split-view.js +36 -9
- package/dist/split-view.js.map +1 -1
- package/dist/stand-ins/animations.js +3 -3
- package/dist/sticky-headers.d.ts +19 -0
- package/dist/sticky-headers.js +67 -10
- package/dist/sticky-headers.js.map +1 -1
- package/dist/sticky-rows.d.ts +13 -11
- package/dist/sticky-rows.js +35 -21
- package/dist/sticky-rows.js.map +1 -1
- package/dist/svg-icon.d.ts +16 -2
- package/dist/svg-icon.js +19 -3
- package/dist/svg-icon.js.map +1 -1
- package/dist/switch.js +3 -3
- package/dist/template-slot.js +3 -3
- package/dist/text-input.js +3 -3
- package/dist/text.js +3 -3
- package/dist/touchable-opacity.js +3 -3
- package/dist/tray-icon.d.ts +7 -1
- package/dist/tray-icon.js +17 -5
- package/dist/tray-icon.js.map +1 -1
- package/dist/view-base.d.ts +18 -2
- package/dist/view-base.js +42 -10
- package/dist/view-base.js.map +1 -1
- package/dist/view.js +3 -3
- package/dist/virtual-list-layout.d.ts +5 -0
- package/dist/virtual-list-layout.js.map +1 -1
- package/dist/virtual-list-num-columns.d.ts +8 -4
- package/dist/virtual-list-num-columns.js +13 -5
- package/dist/virtual-list-num-columns.js.map +1 -1
- package/dist/virtual-list-sticky-level.d.ts +0 -6
- package/dist/virtual-list-sticky-level.js +5 -29
- package/dist/virtual-list-sticky-level.js.map +1 -1
- package/dist/virtual-list.d.ts +72 -11
- package/dist/virtual-list.js +285 -74
- package/dist/virtual-list.js.map +1 -1
- package/dist/visual-effect.d.ts +37 -0
- package/dist/visual-effect.js +60 -0
- package/dist/visual-effect.js.map +1 -0
- package/dist/worklet-scroll.js +3 -3
- package/dist/worklet-style.js +3 -3
- package/dist/written-props.js +9 -0
- package/dist/written-props.js.map +1 -1
- package/ios/NgNativeButtonComponentView.mm +8 -4
- package/ios/NgNativeButtonMetrics.h +9 -2
- package/ios/NgNativeButtonMetrics.mm +33 -4
- package/ios/NgNativeButtonShadowNode.h +2 -0
- package/ios/NgNativeButtonShadowNode.mm +5 -1
- package/ios/NgNativeComponents.podspec +2 -2
- package/ios/NgNativeKeyboardFocus.h +21 -0
- package/ios/NgNativeKeyboardFocus.mm +28 -0
- package/ios/NgNativeKeyboardFocusModule.mm +203 -0
- package/ios/NgNativeMenus.mm +62 -2
- package/ios/NgNativePressMenu.h +36 -0
- package/ios/NgNativePressMenu.mm +79 -0
- package/ios/NgNativeViewBinder.h +5 -0
- package/ios/NgNativeViewBinder.mm +31 -4
- package/package.json +6 -6
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ViewBase } from './view-base.ts';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/** One of AppKit's materials, by the name of its `NSVisualEffectMaterial` case. */
|
|
4
|
+
export type VisualEffectMaterial = 'sidebar' | 'window-background' | 'under-window-background' | 'content-background' | 'under-page-background' | 'header-view' | 'titlebar' | 'menu' | 'popover' | 'sheet' | 'hud-window' | 'full-screen-ui' | 'tooltip' | 'selection';
|
|
5
|
+
/** What the material blurs: the desktop and windows behind the window, or the window's own content. */
|
|
6
|
+
export type VisualEffectBlendingMode = 'behind-window' | 'within-window';
|
|
7
|
+
/** Whether the material looks active: as its window does, always, or never. */
|
|
8
|
+
export type VisualEffectState = 'follows-window' | 'active' | 'inactive';
|
|
9
|
+
/**
|
|
10
|
+
* A view in one of the system's translucent materials, behind its children:
|
|
11
|
+
*
|
|
12
|
+
* <visual-effect class="backdrop" material="sidebar">...</visual-effect>
|
|
13
|
+
*
|
|
14
|
+
* With `behind-window` blending, the default, macOS draws what is behind the window through it,
|
|
15
|
+
* blurred and tinted, as a source list's sidebar does, and with `within-window` the window's own
|
|
16
|
+
* content under it. It lays out and takes styles as a `<view>` does, and its `border-radius`
|
|
17
|
+
* rounds the material. Elsewhere it is a plain view: give it a `background-color` for Linux, iOS
|
|
18
|
+
* and Android.
|
|
19
|
+
*/
|
|
20
|
+
export declare class VisualEffect extends ViewBase {
|
|
21
|
+
/**
|
|
22
|
+
* Whether the desktop host draws the material here, rather than a plain view. Where it does, an
|
|
23
|
+
* input left unset commits `null`, so one taken away goes back to the host's default rather than
|
|
24
|
+
* keeping the value it had; elsewhere none of them is committed.
|
|
25
|
+
*/
|
|
26
|
+
protected readonly drawn: boolean;
|
|
27
|
+
/** The material. Defaults to `sidebar`. */
|
|
28
|
+
readonly material: import("@angular/core").InputSignal<VisualEffectMaterial | undefined>;
|
|
29
|
+
/** What the material blurs. Defaults to `behind-window`. */
|
|
30
|
+
readonly blendingMode: import("@angular/core").InputSignal<VisualEffectBlendingMode | undefined>;
|
|
31
|
+
/** Whether it looks active. Defaults to `follows-window`. */
|
|
32
|
+
readonly state: import("@angular/core").InputSignal<VisualEffectState | undefined>;
|
|
33
|
+
/** A selection material drawn in the accent colour, as a source list's focused selection is. */
|
|
34
|
+
readonly emphasized: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<VisualEffect, never>;
|
|
36
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<VisualEffect, "visual-effect", never, { "material": { "alias": "material"; "required": false; "isSignal": true; }; "blendingMode": { "alias": "blendingMode"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "emphasized": { "alias": "emphasized"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Directive, input } from '@angular/core';
|
|
2
|
+
import { registerViewName } from '@ng-native/fabric';
|
|
3
|
+
import { hostDraws } from "./split-view.js";
|
|
4
|
+
import { optionalBoolean } from "./transforms.js";
|
|
5
|
+
import { ViewBase } from "./view-base.js";
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/**
|
|
8
|
+
* On macOS an NSVisualEffectView behind the element's children, drawn by the desktop host. On
|
|
9
|
+
* Linux, iOS and Android a plain view, whose own background shows.
|
|
10
|
+
*/
|
|
11
|
+
registerViewName('visual-effect', {
|
|
12
|
+
ios: 'View',
|
|
13
|
+
android: 'View',
|
|
14
|
+
macos: 'NgNativeVisualEffect',
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* A view in one of the system's translucent materials, behind its children:
|
|
18
|
+
*
|
|
19
|
+
* <visual-effect class="backdrop" material="sidebar">...</visual-effect>
|
|
20
|
+
*
|
|
21
|
+
* With `behind-window` blending, the default, macOS draws what is behind the window through it,
|
|
22
|
+
* blurred and tinted, as a source list's sidebar does, and with `within-window` the window's own
|
|
23
|
+
* content under it. It lays out and takes styles as a `<view>` does, and its `border-radius`
|
|
24
|
+
* rounds the material. Elsewhere it is a plain view: give it a `background-color` for Linux, iOS
|
|
25
|
+
* and Android.
|
|
26
|
+
*/
|
|
27
|
+
export class VisualEffect extends ViewBase {
|
|
28
|
+
/**
|
|
29
|
+
* Whether the desktop host draws the material here, rather than a plain view. Where it does, an
|
|
30
|
+
* input left unset commits `null`, so one taken away goes back to the host's default rather than
|
|
31
|
+
* keeping the value it had; elsewhere none of them is committed.
|
|
32
|
+
*/
|
|
33
|
+
drawn = hostDraws('visual-effect');
|
|
34
|
+
/** The material. Defaults to `sidebar`. */
|
|
35
|
+
material = input(/* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [undefined, { debugName: "material" }] : /* istanbul ignore next */ []));
|
|
37
|
+
/** What the material blurs. Defaults to `behind-window`. */
|
|
38
|
+
blendingMode = input(/* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [undefined, { debugName: "blendingMode" }] : /* istanbul ignore next */ []));
|
|
40
|
+
/** Whether it looks active. Defaults to `follows-window`. */
|
|
41
|
+
state = input(/* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [undefined, { debugName: "state" }] : /* istanbul ignore next */ []));
|
|
43
|
+
/** A selection material drawn in the accent colour, as a source list's focused selection is. */
|
|
44
|
+
emphasized = input(undefined, { ...(ngDevMode ? { debugName: "emphasized" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
45
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: VisualEffect, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
46
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.0", type: VisualEffect, isStandalone: true, selector: "visual-effect", inputs: { material: { classPropertyName: "material", publicName: "material", isSignal: true, isRequired: false, transformFunction: null }, blendingMode: { classPropertyName: "blendingMode", publicName: "blendingMode", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, emphasized: { classPropertyName: "emphasized", publicName: "emphasized", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "material": "drawn ? (material() ?? null) : undefined", "blendingMode": "drawn ? (blendingMode() ?? null) : undefined", "state": "drawn ? (state() ?? null) : undefined", "emphasized": "drawn ? (emphasized() ?? null) : undefined" } }, usesInheritance: true, ngImport: i0 });
|
|
47
|
+
}
|
|
48
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: VisualEffect, decorators: [{
|
|
49
|
+
type: Directive,
|
|
50
|
+
args: [{
|
|
51
|
+
selector: 'visual-effect',
|
|
52
|
+
host: {
|
|
53
|
+
'[material]': 'drawn ? (material() ?? null) : undefined',
|
|
54
|
+
'[blendingMode]': 'drawn ? (blendingMode() ?? null) : undefined',
|
|
55
|
+
'[state]': 'drawn ? (state() ?? null) : undefined',
|
|
56
|
+
'[emphasized]': 'drawn ? (emphasized() ?? null) : undefined',
|
|
57
|
+
},
|
|
58
|
+
}]
|
|
59
|
+
}], propDecorators: { material: [{ type: i0.Input, args: [{ isSignal: true, alias: "material", required: false }] }], blendingMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "blendingMode", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], emphasized: [{ type: i0.Input, args: [{ isSignal: true, alias: "emphasized", required: false }] }] } });
|
|
60
|
+
//# sourceMappingURL=visual-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-effect.js","sourceRoot":"","sources":["../src/visual-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;GAGG;AACH,gBAAgB,CAAC,eAAe,EAAE;IAChC,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,sBAAsB;CAC9B,CAAC,CAAC;AAyBH;;;;;;;;;;GAUG;AAUH,MAAM,OAAO,YAAa,SAAQ,QAAQ;IACxC;;;;OAIG;IACgB,KAAK,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;IAEtD,2CAA2C;IAClC,QAAQ,GAAG,KAAK;4FAAwB,CAAC;IAClD,4DAA4D;IACnD,YAAY,GAAG,KAAK;gGAA4B,CAAC;IAC1D,6DAA6D;IACpD,KAAK,GAAG,KAAK;yFAAqB,CAAC;IAC5C,gGAAgG;IACvF,UAAU,GAAG,KAAK,CAAC,SAAS,kFAAI,SAAS,EAAE,eAAe,GAAG,CAAC;uGAf5D,YAAY;2FAAZ,YAAY;;2FAAZ,YAAY;kBATxB,SAAS;mBAAC;oBACT,QAAQ,EAAE,eAAe;oBACzB,IAAI,EAAE;wBACJ,YAAY,EAAE,0CAA0C;wBACxD,gBAAgB,EAAE,8CAA8C;wBAChE,SAAS,EAAE,uCAAuC;wBAClD,cAAc,EAAE,4CAA4C;qBAC7D;iBACF","sourcesContent":["import { Directive, input } from '@angular/core';\nimport { registerViewName } from '@ng-native/fabric';\nimport { hostDraws } from './split-view.ts';\nimport { optionalBoolean } from './transforms.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * On macOS an NSVisualEffectView behind the element's children, drawn by the desktop host. On\n * Linux, iOS and Android a plain view, whose own background shows.\n */\nregisterViewName('visual-effect', {\n ios: 'View',\n android: 'View',\n macos: 'NgNativeVisualEffect',\n});\n\n/** One of AppKit's materials, by the name of its `NSVisualEffectMaterial` case. */\nexport type VisualEffectMaterial =\n | 'sidebar'\n | 'window-background'\n | 'under-window-background'\n | 'content-background'\n | 'under-page-background'\n | 'header-view'\n | 'titlebar'\n | 'menu'\n | 'popover'\n | 'sheet'\n | 'hud-window'\n | 'full-screen-ui'\n | 'tooltip'\n | 'selection';\n\n/** What the material blurs: the desktop and windows behind the window, or the window's own content. */\nexport type VisualEffectBlendingMode = 'behind-window' | 'within-window';\n\n/** Whether the material looks active: as its window does, always, or never. */\nexport type VisualEffectState = 'follows-window' | 'active' | 'inactive';\n\n/**\n * A view in one of the system's translucent materials, behind its children:\n *\n * <visual-effect class=\"backdrop\" material=\"sidebar\">...</visual-effect>\n *\n * With `behind-window` blending, the default, macOS draws what is behind the window through it,\n * blurred and tinted, as a source list's sidebar does, and with `within-window` the window's own\n * content under it. It lays out and takes styles as a `<view>` does, and its `border-radius`\n * rounds the material. Elsewhere it is a plain view: give it a `background-color` for Linux, iOS\n * and Android.\n */\n@Directive({\n selector: 'visual-effect',\n host: {\n '[material]': 'drawn ? (material() ?? null) : undefined',\n '[blendingMode]': 'drawn ? (blendingMode() ?? null) : undefined',\n '[state]': 'drawn ? (state() ?? null) : undefined',\n '[emphasized]': 'drawn ? (emphasized() ?? null) : undefined',\n },\n})\nexport class VisualEffect extends ViewBase {\n /**\n * Whether the desktop host draws the material here, rather than a plain view. Where it does, an\n * input left unset commits `null`, so one taken away goes back to the host's default rather than\n * keeping the value it had; elsewhere none of them is committed.\n */\n protected readonly drawn = hostDraws('visual-effect');\n\n /** The material. Defaults to `sidebar`. */\n readonly material = input<VisualEffectMaterial>();\n /** What the material blurs. Defaults to `behind-window`. */\n readonly blendingMode = input<VisualEffectBlendingMode>();\n /** Whether it looks active. Defaults to `follows-window`. */\n readonly state = input<VisualEffectState>();\n /** A selection material drawn in the accent colour, as a source list's focused selection is. */\n readonly emphasized = input(undefined, { transform: optionalBoolean });\n}\n"]}
|
package/dist/worklet-scroll.js
CHANGED
|
@@ -39,10 +39,10 @@ export class WorkletScrollBase {
|
|
|
39
39
|
}, { injector: this.injector });
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
43
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.
|
|
42
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: WorkletScrollBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
43
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.0", type: WorkletScrollBase, isStandalone: true, selector: "[workletScroll]", inputs: { workletScroll: { classPropertyName: "workletScroll", publicName: "workletScroll", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
44
44
|
}
|
|
45
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
45
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: WorkletScrollBase, decorators: [{
|
|
46
46
|
type: Directive,
|
|
47
47
|
args: [{ selector: '[workletScroll]' }]
|
|
48
48
|
}], ctorParameters: () => [], propDecorators: { workletScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "workletScroll", required: true }] }] } });
|
package/dist/worklet-style.js
CHANGED
|
@@ -51,10 +51,10 @@ export class WorkletStyleBase {
|
|
|
51
51
|
this.drawn = { ...this.drawn, ...props };
|
|
52
52
|
this.engine.setUiThreadProps(this.node, this.drawn);
|
|
53
53
|
}
|
|
54
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
55
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.
|
|
54
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: WorkletStyleBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
55
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.0", type: WorkletStyleBase, isStandalone: true, selector: "[workletStyle]", inputs: { workletStyle: { classPropertyName: "workletStyle", publicName: "workletStyle", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
56
56
|
}
|
|
57
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: WorkletStyleBase, decorators: [{
|
|
58
58
|
type: Directive,
|
|
59
59
|
args: [{ selector: '[workletStyle]' }]
|
|
60
60
|
}], ctorParameters: () => [], propDecorators: { workletStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "workletStyle", required: true }] }] } });
|
package/dist/written-props.js
CHANGED
|
@@ -65,6 +65,7 @@ export const WRITTEN_PROPS = [
|
|
|
65
65
|
'contentInset',
|
|
66
66
|
'contentInsetAdjustmentBehavior',
|
|
67
67
|
'contentOffset',
|
|
68
|
+
'contentStyle',
|
|
68
69
|
'contextMenu',
|
|
69
70
|
'contextMenuHidden',
|
|
70
71
|
'controlSize',
|
|
@@ -95,6 +96,7 @@ export const WRITTEN_PROPS = [
|
|
|
95
96
|
'hidesWhenStopped',
|
|
96
97
|
'hitSlop',
|
|
97
98
|
'horizontal',
|
|
99
|
+
'iconImage',
|
|
98
100
|
'importantForAutofill',
|
|
99
101
|
'indeterminate',
|
|
100
102
|
'indicatorStyle',
|
|
@@ -194,6 +196,8 @@ export const WRITTEN_PROPS = [
|
|
|
194
196
|
'tintColor',
|
|
195
197
|
'title',
|
|
196
198
|
'titleColor',
|
|
199
|
+
'toggleButton',
|
|
200
|
+
'tooltip',
|
|
197
201
|
'trackColorForFalse',
|
|
198
202
|
'trackColorForTrue',
|
|
199
203
|
'trackTintColor',
|
|
@@ -204,5 +208,10 @@ export const WRITTEN_PROPS = [
|
|
|
204
208
|
'visible',
|
|
205
209
|
'zIndex',
|
|
206
210
|
'zoomScale',
|
|
211
|
+
// <visual-effect>'s, on a desktop host.
|
|
212
|
+
'blendingMode',
|
|
213
|
+
'emphasized',
|
|
214
|
+
'material',
|
|
215
|
+
'state',
|
|
207
216
|
];
|
|
208
217
|
//# sourceMappingURL=written-props.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"written-props.js","sourceRoot":"","sources":["../src/written-props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,sBAAsB;IACtB,0BAA0B;IAC1B,0BAA0B;IAC1B,6BAA6B;IAC7B,mBAAmB;IACnB,kCAAkC;IAClC,sBAAsB;IACtB,oBAAoB;IACpB,yBAAyB;IACzB,uBAAuB;IACvB,gCAAgC;IAChC,oBAAoB;IACpB,yBAAyB;IACzB,uBAAuB;IACvB,uBAAuB;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,kBAAkB;IAClB,MAAM;IACN,sBAAsB;IACtB,WAAW;IACX,yBAAyB;IACzB,yBAAyB;IACzB,UAAU;IACV,0BAA0B;IAC1B,gCAAgC;IAChC,qBAAqB;IACrB,eAAe;IACf,IAAI;IACJ,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,cAAc;IACd,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,aAAa;IACb,sBAAsB;IACtB,eAAe;IACf,mBAAmB;IACnB,yBAAyB;IACzB,oBAAoB;IACpB,6BAA6B;IAC7B,YAAY;IACZ,uBAAuB;IACvB,gCAAgC;IAChC,cAAc;IACd,YAAY;IACZ,kBAAkB;IAClB,eAAe;IACf,MAAM;IACN,MAAM;IACN,eAAe;IACf,qBAAqB;IACrB,uBAAuB;IACvB,yBAAyB;IACzB,cAAc;IACd,iBAAiB;IACjB,mBAAmB;IACnB,YAAY;IACZ,UAAU;IACV,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,oBAAoB;IACpB,UAAU;IACV,oBAAoB;IACpB,sBAAsB;IACtB,gCAAgC;IAChC,8BAA8B;IAC9B,MAAM;IACN,mBAAmB;IACnB,aAAa;IACb,iBAAiB;IACjB,WAAW;IACX,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,QAAQ;IACR,YAAY;IACZ,sBAAsB;IACtB,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,SAAS;IACT,QAAQ;IACR,MAAM;IACN,WAAW;IACX,mBAAmB;IACnB,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,OAAO;IACP,YAAY;IACZ,oBAAoB;IACpB,mBAAmB;IACnB,gBAAgB;IAChB,WAAW;IACX,aAAa;IACb,uBAAuB;IACvB,OAAO;IACP,SAAS;IACT,QAAQ;IACR,WAAW;
|
|
1
|
+
{"version":3,"file":"written-props.js","sourceRoot":"","sources":["../src/written-props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAA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ACjB,gBAAgB;IAChB,WAAW;IACX,OAAO;IACP,YAAY;IACZ,cAAc;IACd,SAAS;IACT,oBAAoB;IACpB,mBAAmB;IACnB,gBAAgB;IAChB,WAAW;IACX,aAAa;IACb,uBAAuB;IACvB,OAAO;IACP,SAAS;IACT,QAAQ;IACR,WAAW;IACX,wCAAwC;IACxC,cAAc;IACd,YAAY;IACZ,UAAU;IACV,OAAO;CACR,CAAC","sourcesContent":["/**\n * Every prop the components send through a host binding or a write from code, under the native\n * view's own name, which is often not the name of any input. `native-props.test.ts` holds it to\n * the sources.\n */\nexport const WRITTEN_PROPS: readonly string[] = [\n 'accessibilityActions',\n 'accessibilityColumnCount',\n 'accessibilityDescribedBy',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityIgnoresInvertColors',\n 'accessibilityInvalid',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityLanguage',\n 'accessibilityLargeContentTitle',\n 'accessibilityLevel',\n 'accessibilityLiveRegion',\n 'accessibilityPosInSet',\n 'accessibilityRequired',\n 'accessibilityRespondsToUserInteraction',\n 'accessibilityRole',\n 'accessibilityRowCount',\n 'accessibilitySetSize',\n 'accessibilityShowsLargeContentViewer',\n 'accessibilityState',\n 'accessibilityValue',\n 'accessibilityViewIsModal',\n 'accessible',\n 'adjustsFontSizeToFit',\n 'allowFontScaling',\n 'allowSwipeDismissal',\n 'anchor',\n 'alwaysBounceHorizontal',\n 'alwaysBounceVertical',\n 'android_hyphenationFrequency',\n 'animating',\n 'animationType',\n 'autoCapitalize',\n 'autoComplete',\n 'autoCorrect',\n 'autoFocus',\n 'automaticallyAdjustContentInsets',\n 'automaticallyAdjustKeyboardInsets',\n 'automaticallyAdjustsScrollIndicatorInsets',\n 'autosaveName',\n 'backgroundColor',\n 'badge',\n 'blurRadius',\n 'bounces',\n 'bouncesZoom',\n 'canCancelContentTouches',\n 'capInsets',\n 'caretHidden',\n 'centerContent',\n 'clearButtonMode',\n 'clearTextOnFocus',\n 'collapsable',\n 'collapsableChildren',\n 'collapsed',\n 'collapsible',\n 'color',\n 'colors',\n 'contentInset',\n 'contentInsetAdjustmentBehavior',\n 'contentOffset',\n 'contentStyle',\n 'contextMenu',\n 'contextMenuHidden',\n 'controlSize',\n 'cursorColor',\n 'dataDetectorType',\n 'dataDetectorTypes',\n 'decelerationRate',\n 'defaultSource',\n 'directionalLockEnabled',\n 'disableFullscreenUI',\n 'disableIntervalMomentum',\n 'disabled',\n 'dragItem',\n 'drawable',\n 'dynamicTypeRamp',\n 'edges',\n 'editable',\n 'ellipsizeMode',\n 'enabled',\n 'enablesReturnKeyAutomatically',\n 'endFillColor',\n 'fadeDuration',\n 'fadingEdgeLength',\n 'fileDrop',\n 'flexDirection',\n 'focusable',\n 'hardwareAccelerated',\n 'hidesWhenStopped',\n 'hitSlop',\n 'horizontal',\n 'iconImage',\n 'importantForAutofill',\n 'indeterminate',\n 'indicatorStyle',\n 'inlineImageLeft',\n 'inlineImagePadding',\n 'inputAccessoryViewID',\n 'isHighlighted',\n 'isPressable',\n 'keyboardAppearance',\n 'keyboardDismissMode',\n 'keyboardType',\n 'kind',\n 'label',\n 'lineBreakStrategyIOS',\n 'loadingIndicatorSource',\n 'maintainVisibleContentPosition',\n 'maxFontSizeMultiplier',\n 'maxLength',\n 'maximumZoomScale',\n 'minimumFontScale',\n 'minimumZoomScale',\n 'mode',\n 'mostRecentEventCount',\n 'multiline',\n 'nativeBackgroundAndroid',\n 'nativeForegroundAndroid',\n 'nativeID',\n 'navigationBarTranslucent',\n 'needsOffscreenAlphaCompositing',\n 'nestedScrollEnabled',\n 'numberOfLines',\n 'on',\n 'onTintColor',\n 'overScrollMode',\n 'pagingEnabled',\n 'paneMaxWidth',\n 'paneMinWidth',\n 'passwordRules',\n 'persistentScrollbar',\n 'pinchGestureEnabled',\n 'placeholder',\n 'placeholderTextColor',\n 'pointerEvents',\n 'presentationStyle',\n 'progressBackgroundColor',\n 'progressViewOffset',\n 'progressiveRenderingEnabled',\n 'refreshing',\n 'removeClippedSubviews',\n 'renderToHardwareTextureAndroid',\n 'resizeMethod',\n 'resizeMode',\n 'resizeMultiplier',\n 'returnKeyType',\n 'role',\n 'rows',\n 'scrollEnabled',\n 'scrollEventThrottle',\n 'scrollIndicatorInsets',\n 'scrollToOverflowEnabled',\n 'scrollsToTop',\n 'secureTextEntry',\n 'selectTextOnFocus',\n 'selectable',\n 'selected',\n 'selection',\n 'selectionColor',\n 'selectionHandleColor',\n 'sendMomentumEvents',\n 'sfSymbol',\n 'shouldRasterizeIOS',\n 'showSoftInputOnFocus',\n 'showsHorizontalScrollIndicator',\n 'showsVerticalScrollIndicator',\n 'size',\n 'smartInsertDelete',\n 'smartQuotes',\n 'snapToAlignment',\n 'snapToEnd',\n 'snapToInterval',\n 'snapToOffsets',\n 'snapToStart',\n 'source',\n 'spellCheck',\n 'statusBarTranslucent',\n 'styleAttr',\n 'submitBehavior',\n 'supportedOrientations',\n 'svgIcon',\n 'testID',\n 'text',\n 'textAlign',\n 'textAlignVertical',\n 'textBreakStrategy',\n 'textContentType',\n 'thumbTintColor',\n 'tintColor',\n 'title',\n 'titleColor',\n 'toggleButton',\n 'tooltip',\n 'trackColorForFalse',\n 'trackColorForTrue',\n 'trackTintColor',\n 'transform',\n 'transparent',\n 'underlineColorAndroid',\n 'value',\n 'visible',\n 'zIndex',\n 'zoomScale',\n // <visual-effect>'s, on a desktop host.\n 'blendingMode',\n 'emphasized',\n 'material',\n 'state',\n];\n"]}
|
|
@@ -11,8 +11,10 @@ using namespace facebook::react;
|
|
|
11
11
|
`<native-button>` on iOS: a UIButton drawn from a button configuration, the glass ones on iOS 26
|
|
12
12
|
and later. `kind` picks the style (`default` the prominent one, `destructive` in red, `plain`
|
|
13
13
|
borderless, anything else the plain push button), `controlSize` UIButton's own size with the
|
|
14
|
-
metrics the shadow node measures with, and a tap sends `topButtonPress`. The
|
|
15
|
-
|
|
14
|
+
metrics the shadow node measures with, and a tap sends `topButtonPress`. The picture before the
|
|
15
|
+
title is the SF Symbol, or else `iconImage`, an icon's SVG markup drawn as a PNG, tinted as the
|
|
16
|
+
title is. The title follows the user's text size: the button is configured again as it changes,
|
|
17
|
+
and React Native measures it again.
|
|
16
18
|
Return and Escape press no button on iOS: `default` and `cancel` are only styles there.
|
|
17
19
|
*/
|
|
18
20
|
@interface NgNativeButtonComponentView : RCTViewComponentView
|
|
@@ -78,7 +80,8 @@ static UIButtonConfiguration *configurationForKind(NSString *kind)
|
|
|
78
80
|
const auto &newProps = static_cast<const NgNativeButtonProps &>(*props);
|
|
79
81
|
const auto &previous = static_cast<const NgNativeButtonProps &>(*_props);
|
|
80
82
|
BOOL changed = newProps.title != previous.title || newProps.kind != previous.kind ||
|
|
81
|
-
newProps.controlSize != previous.controlSize || newProps.sfSymbol != previous.sfSymbol
|
|
83
|
+
newProps.controlSize != previous.controlSize || newProps.sfSymbol != previous.sfSymbol ||
|
|
84
|
+
newProps.iconImage != previous.iconImage;
|
|
82
85
|
[super updateProps:props oldProps:oldProps];
|
|
83
86
|
if (changed) {
|
|
84
87
|
[self ngn_configureWith:newProps];
|
|
@@ -95,7 +98,8 @@ static UIButtonConfiguration *configurationForKind(NSString *kind)
|
|
|
95
98
|
configuration.contentInsets = NgNativeButtonInsets(controlSize);
|
|
96
99
|
configuration.title = string(props.title);
|
|
97
100
|
configuration.titleLineBreakMode = NSLineBreakByTruncatingTail;
|
|
98
|
-
configuration.image = NgNativeButtonSymbol(string(props.sfSymbol), controlSize)
|
|
101
|
+
configuration.image = NgNativeButtonSymbol(string(props.sfSymbol), controlSize)
|
|
102
|
+
?: NgNativeButtonImage(string(props.iconImage), controlSize);
|
|
99
103
|
configuration.imagePadding = NgNativeButtonImagePadding;
|
|
100
104
|
UIFont *font = NgNativeButtonFont(controlSize);
|
|
101
105
|
configuration.titleTextAttributesTransformer = ^NSDictionary<NSAttributedStringKey, id> *(
|
|
@@ -22,7 +22,14 @@ extern const CGFloat NgNativeButtonImagePadding;
|
|
|
22
22
|
// The symbol drawn beside the title, or nil for none or a name the OS lacks.
|
|
23
23
|
UIImage *_Nullable NgNativeButtonSymbol(NSString *sfSymbol, NSString *controlSize);
|
|
24
24
|
|
|
25
|
-
// The
|
|
26
|
-
|
|
25
|
+
// The side of an icon image drawn beside the title, in points: a symbol's height in the title's font.
|
|
26
|
+
CGFloat NgNativeButtonImageSide(NSString *controlSize);
|
|
27
|
+
|
|
28
|
+
// An icon image from a PNG `data:` URI, a template image `NgNativeButtonImageSide` square that the
|
|
29
|
+
// button tints as it does a symbol, or nil for none or data that is no image.
|
|
30
|
+
UIImage *_Nullable NgNativeButtonImage(NSString *uri, NSString *controlSize);
|
|
31
|
+
|
|
32
|
+
// The button's natural size: one line of title, the symbol or else an icon image, and the insets.
|
|
33
|
+
CGSize NgNativeButtonNaturalSize(NSString *title, NSString *controlSize, NSString *sfSymbol, BOOL hasImage);
|
|
27
34
|
|
|
28
35
|
NS_ASSUME_NONNULL_END
|
|
@@ -52,16 +52,45 @@ UIImage *_Nullable NgNativeButtonSymbol(NSString *sfSymbol, NSString *controlSiz
|
|
|
52
52
|
return [UIImage systemImageNamed:sfSymbol withConfiguration:configuration];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
CGFloat NgNativeButtonImageSide(NSString *controlSize)
|
|
56
|
+
{
|
|
57
|
+
return round(NgNativeButtonFont(controlSize).pointSize * 1.2);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
UIImage *_Nullable NgNativeButtonImage(NSString *uri, NSString *controlSize)
|
|
61
|
+
{
|
|
62
|
+
NSRange comma = [uri rangeOfString:@";base64,"];
|
|
63
|
+
if (![uri hasPrefix:@"data:"] || comma.location == NSNotFound) {
|
|
64
|
+
return nil;
|
|
65
|
+
}
|
|
66
|
+
NSData *data = [[NSData alloc] initWithBase64EncodedString:[uri substringFromIndex:NSMaxRange(comma)]
|
|
67
|
+
options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
|
68
|
+
UIImage *decoded = data != nil ? [UIImage imageWithData:data] : nil;
|
|
69
|
+
CGImageRef pixels = decoded.CGImage;
|
|
70
|
+
if (pixels == NULL) {
|
|
71
|
+
return nil;
|
|
72
|
+
}
|
|
73
|
+
// Its pixels to a point chosen so that it is the side square, whatever size it was drawn at.
|
|
74
|
+
CGFloat longest = MAX(CGImageGetWidth(pixels), CGImageGetHeight(pixels));
|
|
75
|
+
UIImage *sized = [UIImage imageWithCGImage:pixels
|
|
76
|
+
scale:longest / NgNativeButtonImageSide(controlSize)
|
|
77
|
+
orientation:UIImageOrientationUp];
|
|
78
|
+
return [sized imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
CGSize NgNativeButtonNaturalSize(NSString *title, NSString *controlSize, NSString *sfSymbol, BOOL hasImage)
|
|
56
82
|
{
|
|
57
83
|
UIFont *font = NgNativeButtonFont(controlSize);
|
|
58
84
|
CGSize text = title.length > 0 ? [title sizeWithAttributes:@{NSFontAttributeName : font}] : CGSizeZero;
|
|
59
85
|
CGFloat width = ceil(text.width);
|
|
60
86
|
CGFloat height = ceil(MAX(text.height, font.lineHeight));
|
|
61
87
|
UIImage *symbol = NgNativeButtonSymbol(sfSymbol, controlSize);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
CGSize picture = symbol != nil ? symbol.size
|
|
89
|
+
: hasImage ? CGSizeMake(NgNativeButtonImageSide(controlSize), NgNativeButtonImageSide(controlSize))
|
|
90
|
+
: CGSizeZero;
|
|
91
|
+
if (picture.width > 0) {
|
|
92
|
+
width += ceil(picture.width) + (title.length > 0 ? NgNativeButtonImagePadding : 0);
|
|
93
|
+
height = MAX(height, ceil(picture.height));
|
|
65
94
|
}
|
|
66
95
|
NSDirectionalEdgeInsets insets = NgNativeButtonInsets(controlSize);
|
|
67
96
|
return CGSizeMake(width + insets.leading + insets.trailing, height + insets.top + insets.bottom);
|
|
@@ -30,6 +30,8 @@ class NgNativeButtonProps final : public ViewProps {
|
|
|
30
30
|
// `mini`, `small`, `regular` or `large`; empty is `regular`.
|
|
31
31
|
std::string controlSize{};
|
|
32
32
|
std::string sfSymbol{};
|
|
33
|
+
// An icon's SVG markup drawn as a PNG, as a `data:` URI, which a symbol wins over.
|
|
34
|
+
std::string iconImage{};
|
|
33
35
|
bool enabled{true};
|
|
34
36
|
};
|
|
35
37
|
|
|
@@ -18,6 +18,7 @@ NgNativeButtonProps::NgNativeButtonProps(
|
|
|
18
18
|
kind(convertRawProp(context, rawProps, "kind", sourceProps.kind, {})),
|
|
19
19
|
controlSize(convertRawProp(context, rawProps, "controlSize", sourceProps.controlSize, {})),
|
|
20
20
|
sfSymbol(convertRawProp(context, rawProps, "sfSymbol", sourceProps.sfSymbol, {})),
|
|
21
|
+
iconImage(convertRawProp(context, rawProps, "iconImage", sourceProps.iconImage, {})),
|
|
21
22
|
enabled(convertRawProp(context, rawProps, "enabled", sourceProps.enabled, true))
|
|
22
23
|
{
|
|
23
24
|
}
|
|
@@ -32,7 +33,10 @@ Size NgNativeButtonShadowNode::measureContent(
|
|
|
32
33
|
const LayoutConstraints &layoutConstraints) const
|
|
33
34
|
{
|
|
34
35
|
const auto &props = getConcreteProps();
|
|
35
|
-
|
|
36
|
+
NSString *controlSize = string(props.controlSize);
|
|
37
|
+
// Room is kept for an image only when the button can decode it, as NgNativeButtonComponentView does.
|
|
38
|
+
BOOL hasImage = !props.iconImage.empty() && NgNativeButtonImage(string(props.iconImage), controlSize) != nil;
|
|
39
|
+
CGSize size = NgNativeButtonNaturalSize(string(props.title), controlSize, string(props.sfSymbol), hasImage);
|
|
36
40
|
// A narrower box truncates the title rather than wrapping it.
|
|
37
41
|
return layoutConstraints.clamp({.width = (Float)size.width, .height = (Float)size.height});
|
|
38
42
|
}
|
|
@@ -15,9 +15,9 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.description = package['description']
|
|
16
16
|
s.license = package['license']
|
|
17
17
|
s.author = 'Angular Native'
|
|
18
|
-
s.homepage = 'https://github.com/
|
|
18
|
+
s.homepage = 'https://github.com/coralogix/ng-native'
|
|
19
19
|
s.platforms = { :ios => '16.4' }
|
|
20
|
-
s.source = { git: 'https://github.com/
|
|
20
|
+
s.source = { git: 'https://github.com/coralogix/ng-native.git' }
|
|
21
21
|
s.static_framework = true
|
|
22
22
|
|
|
23
23
|
s.source_files = '**/*.{h,mm}'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// What an iPad's hardware keyboard can focus among React Native's views, which take no part in
|
|
2
|
+
// UIKit's focus system on their own: React Native's iOS props have no `focusable`. A view that
|
|
3
|
+
// commits `focusable: true` is reported by react tag (the NgNativeKeyboardFocus module); the hooks
|
|
4
|
+
// on RCTViewComponentView let it be focused, draw the focus halo, and press it on Space and Return
|
|
5
|
+
// with the touch a tap would send. The parts here run without React Native.
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
// Whether the view with react tag `tag` takes the keyboard's focus. Forgotten as React Native
|
|
13
|
+
// recycles the view. Main thread.
|
|
14
|
+
void NgNativeSetKeyboardFocusable(NSInteger tag, BOOL focusable);
|
|
15
|
+
BOOL NgNativeKeyboardFocusable(NSInteger tag);
|
|
16
|
+
|
|
17
|
+
// Whether `key`, with `modifiers` held, presses the focused view: Space, Return or the keypad's
|
|
18
|
+
// Enter, with nothing held but Caps Lock.
|
|
19
|
+
BOOL NgNativeKeyPresses(UIKeyboardHIDUsage key, UIKeyModifierFlags modifiers);
|
|
20
|
+
|
|
21
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#import "NgNativeKeyboardFocus.h"
|
|
2
|
+
|
|
3
|
+
static NSMutableSet<NSNumber *> *focusableTags(void)
|
|
4
|
+
{
|
|
5
|
+
static NSMutableSet<NSNumber *> *tags = [NSMutableSet set];
|
|
6
|
+
return tags;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
void NgNativeSetKeyboardFocusable(NSInteger tag, BOOL focusable)
|
|
10
|
+
{
|
|
11
|
+
if (focusable) {
|
|
12
|
+
[focusableTags() addObject:@(tag)];
|
|
13
|
+
} else {
|
|
14
|
+
[focusableTags() removeObject:@(tag)];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
BOOL NgNativeKeyboardFocusable(NSInteger tag)
|
|
19
|
+
{
|
|
20
|
+
return [focusableTags() containsObject:@(tag)];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
BOOL NgNativeKeyPresses(UIKeyboardHIDUsage key, UIKeyModifierFlags modifiers)
|
|
24
|
+
{
|
|
25
|
+
BOOL pressing = key == UIKeyboardHIDUsageKeyboardSpacebar || key == UIKeyboardHIDUsageKeyboardReturnOrEnter ||
|
|
26
|
+
key == UIKeyboardHIDUsageKeypadEnter;
|
|
27
|
+
return pressing && (modifiers & ~(UIKeyModifierAlphaShift | UIKeyModifierNumericPad)) == 0;
|
|
28
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
The iPad hardware keyboard's focus on React Native's views (NgNativeKeyboardFocus.h).
|
|
3
|
+
|
|
4
|
+
- `setFocusable(tag, focusable)`: the view with that react tag commits `focusable`. Sent by
|
|
5
|
+
`@ng-native/components` once the view is committed.
|
|
6
|
+
|
|
7
|
+
The first call installs hooks on RCTViewComponentView. A view reported focusable, shown, taking
|
|
8
|
+
touches and not disabled answers `canBecomeFocused`, draws UIKit's focus halo in its corners, and
|
|
9
|
+
while focused takes Space and Return: the press sends the touch start and end a tap at its middle
|
|
10
|
+
would, so whatever presses on a tap (a pressable, its press menu) presses here too. A recycled
|
|
11
|
+
view is forgotten.
|
|
12
|
+
*/
|
|
13
|
+
#import <React/RCTBridgeModule.h>
|
|
14
|
+
#import <React/RCTConversions.h>
|
|
15
|
+
#import <React/RCTRootComponentView.h>
|
|
16
|
+
#import <React/RCTViewComponentView.h>
|
|
17
|
+
|
|
18
|
+
#import "NgNativeKeyboardFocus.h"
|
|
19
|
+
#import "NgNativeResponderHooks.h"
|
|
20
|
+
|
|
21
|
+
#include <react/renderer/components/view/TouchEvent.h>
|
|
22
|
+
|
|
23
|
+
using namespace facebook::react;
|
|
24
|
+
|
|
25
|
+
// The touch a keyboard press stands for, told apart from a finger's.
|
|
26
|
+
static const int kKeyboardTouch = 0x4b4559;
|
|
27
|
+
|
|
28
|
+
// The view a held Space or Return is pressing, and the key that started it, until that key is let go.
|
|
29
|
+
static __weak RCTViewComponentView *pressing;
|
|
30
|
+
static UIKeyboardHIDUsage pressingKey;
|
|
31
|
+
|
|
32
|
+
@interface RCTViewComponentView (NgNativeKeyboardFocus)
|
|
33
|
+
- (BOOL)ngn_takesKeyboardFocus;
|
|
34
|
+
- (void)ngn_sendKeyboardTouch:(int)phase;
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
@implementation RCTViewComponentView (NgNativeKeyboardFocus)
|
|
38
|
+
|
|
39
|
+
- (BOOL)ngn_takesKeyboardFocus
|
|
40
|
+
{
|
|
41
|
+
if (!NgNativeKeyboardFocusable(self.tag) || self.hidden || !self.userInteractionEnabled) {
|
|
42
|
+
return NO;
|
|
43
|
+
}
|
|
44
|
+
return !(_props && _props->accessibilityState && _props->accessibilityState->disabled);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 0 starts, 1 ends and 2 cancels the touch, at the view's middle.
|
|
48
|
+
- (void)ngn_sendKeyboardTouch:(int)phase
|
|
49
|
+
{
|
|
50
|
+
if (!_eventEmitter) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
UIView *root = self;
|
|
54
|
+
while (root.superview != nil && ![root isKindOfClass:[RCTRootComponentView class]]) {
|
|
55
|
+
root = root.superview;
|
|
56
|
+
}
|
|
57
|
+
CGPoint middle = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
|
|
58
|
+
Touch touch{};
|
|
59
|
+
touch.offsetPoint = RCTPointFromCGPoint(middle);
|
|
60
|
+
touch.pagePoint = RCTPointFromCGPoint([self convertPoint:middle toView:root]);
|
|
61
|
+
touch.screenPoint = RCTPointFromCGPoint([self convertPoint:middle toView:nil]);
|
|
62
|
+
touch.identifier = kKeyboardTouch;
|
|
63
|
+
touch.target = (Tag)self.tag;
|
|
64
|
+
NSTimeInterval now = CACurrentMediaTime();
|
|
65
|
+
touch.timestamp = (Float)now;
|
|
66
|
+
touch.timeStamp = RCTHighResTimeStampFromSeconds(now);
|
|
67
|
+
TouchEvent event;
|
|
68
|
+
event.changedTouches.insert(touch);
|
|
69
|
+
if (phase == 0) {
|
|
70
|
+
event.touches.insert(touch);
|
|
71
|
+
event.targetTouches.insert(touch);
|
|
72
|
+
_eventEmitter->onTouchStart(event);
|
|
73
|
+
} else if (phase == 1) {
|
|
74
|
+
_eventEmitter->onTouchEnd(event);
|
|
75
|
+
} else {
|
|
76
|
+
_eventEmitter->onTouchCancel(event);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@end
|
|
81
|
+
|
|
82
|
+
// The key among `presses` that presses the focused view, or 0 for none.
|
|
83
|
+
static UIKeyboardHIDUsage keyPressingView(NSSet<UIPress *> *presses)
|
|
84
|
+
{
|
|
85
|
+
for (UIPress *press in presses) {
|
|
86
|
+
if (press.key != nil && NgNativeKeyPresses(press.key.keyCode, press.key.modifierFlags)) {
|
|
87
|
+
return press.key.keyCode;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return (UIKeyboardHIDUsage)0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Whether `presses` let go of `key`, whatever is held with it now.
|
|
94
|
+
static BOOL releases(NSSet<UIPress *> *presses, UIKeyboardHIDUsage key)
|
|
95
|
+
{
|
|
96
|
+
for (UIPress *press in presses) {
|
|
97
|
+
if (press.key != nil && press.key.keyCode == key) {
|
|
98
|
+
return YES;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return NO;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static void installHooks(void)
|
|
105
|
+
{
|
|
106
|
+
Class view = [RCTViewComponentView class];
|
|
107
|
+
NgNativeHook(view, @selector(canBecomeFocused), "B@:", ^id(IMP previous) {
|
|
108
|
+
return ^BOOL(RCTViewComponentView *self) {
|
|
109
|
+
if ([self ngn_takesKeyboardFocus]) {
|
|
110
|
+
return YES;
|
|
111
|
+
}
|
|
112
|
+
return previous != NULL && ((BOOL (*)(id, SEL))previous)(self, @selector(canBecomeFocused));
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
NgNativeHook(view, @selector(focusEffect), "@@:", ^id(IMP previous) {
|
|
116
|
+
return ^UIFocusEffect *(RCTViewComponentView *self) {
|
|
117
|
+
if ([self ngn_takesKeyboardFocus]) {
|
|
118
|
+
return [UIFocusHaloEffect effectWithRoundedRect:self.bounds
|
|
119
|
+
cornerRadius:self.layer.cornerRadius
|
|
120
|
+
curve:kCACornerCurveContinuous];
|
|
121
|
+
}
|
|
122
|
+
return previous != NULL ? ((UIFocusEffect * (*)(id, SEL)) previous)(self, @selector(focusEffect)) : nil;
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
NgNativeHook(view, @selector(pressesBegan:withEvent:), "v@:@@", ^id(IMP previous) {
|
|
126
|
+
return ^(RCTViewComponentView *self, NSSet<UIPress *> *presses, UIPressesEvent *event) {
|
|
127
|
+
UIKeyboardHIDUsage key = keyPressingView(presses);
|
|
128
|
+
if (pressing == nil && key != (UIKeyboardHIDUsage)0 && self.isFocused && [self ngn_takesKeyboardFocus]) {
|
|
129
|
+
pressing = self;
|
|
130
|
+
pressingKey = key;
|
|
131
|
+
[self ngn_sendKeyboardTouch:0];
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (previous != NULL) {
|
|
135
|
+
((void (*)(id, SEL, id, id))previous)(self, @selector(pressesBegan:withEvent:), presses, event);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
NgNativeHook(view, @selector(pressesEnded:withEvent:), "v@:@@", ^id(IMP previous) {
|
|
140
|
+
return ^(RCTViewComponentView *self, NSSet<UIPress *> *presses, UIPressesEvent *event) {
|
|
141
|
+
// Only the key that started the press ends it: another one let go while it is held does not.
|
|
142
|
+
if (pressing == self && releases(presses, pressingKey)) {
|
|
143
|
+
pressing = nil;
|
|
144
|
+
[self ngn_sendKeyboardTouch:1];
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (previous != NULL) {
|
|
148
|
+
((void (*)(id, SEL, id, id))previous)(self, @selector(pressesEnded:withEvent:), presses, event);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
NgNativeHook(view, @selector(pressesCancelled:withEvent:), "v@:@@", ^id(IMP previous) {
|
|
153
|
+
return ^(RCTViewComponentView *self, NSSet<UIPress *> *presses, UIPressesEvent *event) {
|
|
154
|
+
if (pressing == self && releases(presses, pressingKey)) {
|
|
155
|
+
pressing = nil;
|
|
156
|
+
[self ngn_sendKeyboardTouch:2];
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (previous != NULL) {
|
|
160
|
+
((void (*)(id, SEL, id, id))previous)(self, @selector(pressesCancelled:withEvent:), presses, event);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
NgNativeHook(view, @selector(prepareForRecycle), "v@:", ^id(IMP previous) {
|
|
165
|
+
return ^(RCTViewComponentView *self) {
|
|
166
|
+
NgNativeSetKeyboardFocusable(self.tag, NO);
|
|
167
|
+
if (pressing == self) {
|
|
168
|
+
pressing = nil;
|
|
169
|
+
}
|
|
170
|
+
if (previous != NULL) {
|
|
171
|
+
((void (*)(id, SEL))previous)(self, @selector(prepareForRecycle));
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@interface NgNativeKeyboardFocus : NSObject <RCTBridgeModule>
|
|
178
|
+
@end
|
|
179
|
+
|
|
180
|
+
@implementation NgNativeKeyboardFocus
|
|
181
|
+
|
|
182
|
+
RCT_EXPORT_MODULE()
|
|
183
|
+
|
|
184
|
+
+ (BOOL)requiresMainQueueSetup
|
|
185
|
+
{
|
|
186
|
+
return YES;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (dispatch_queue_t)methodQueue
|
|
190
|
+
{
|
|
191
|
+
return dispatch_get_main_queue();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
RCT_EXPORT_METHOD(setFocusable : (double)tag focusable : (BOOL)focusable)
|
|
195
|
+
{
|
|
196
|
+
static dispatch_once_t once;
|
|
197
|
+
dispatch_once(&once, ^{
|
|
198
|
+
installHooks();
|
|
199
|
+
});
|
|
200
|
+
NgNativeSetKeyboardFocusable((NSInteger)tag, focusable);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@end
|