@iternio/react-native-auto-play 0.3.13 → 0.3.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 +1 -43
- package/ReactNativeAutoPlay.podspec +4 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/SymbolFont.kt +30 -29
- package/android/src/main/res/font/materialsymbolsoutlined_regular.ttf +0 -0
- package/ios/Assets/MaterialSymbolsOutlined-Regular.ttf +0 -0
- package/ios/utils/SymbolFont.swift +44 -44
- package/lib/HybridAutoPlay.d.ts +2 -0
- package/lib/HybridAutoPlay.js +2 -0
- package/lib/hooks/useIsAutoPlayFocused.d.ts +7 -0
- package/lib/hooks/useIsAutoPlayFocused.js +20 -0
- package/lib/hybrid/HybridVoice.d.ts +12 -0
- package/lib/hybrid/HybridVoice.js +13 -0
- package/lib/hybrid.d.ts +2 -0
- package/lib/hybrid.js +2 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +11 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.js +1 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +11 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +1 -0
- package/lib/specs/Voice.nitro.d.ts +51 -0
- package/lib/specs/Voice.nitro.js +1 -0
- package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +23 -0
- package/lib/templates/AutomotivePermissionRequestTemplate.js +18 -0
- package/lib/types/Glyphmap.d.ts +4105 -0
- package/lib/types/Glyphmap.js +4105 -0
- package/lib/types/Image.d.ts +4 -33
- package/lib/types/Maneuver.d.ts +10 -2
- package/lib/types/Voice.d.ts +15 -0
- package/lib/types/Voice.js +1 -0
- package/lib/utils/NitroImage.d.ts +2 -23
- package/lib/utils/NitroImage.js +3 -57
- package/nitrogen/generated/android/c++/JGlyphImage.hpp +1 -6
- package/nitrogen/generated/android/c++/JNitroImage.hpp +1 -1
- package/nitrogen/generated/android/c++/JVariant_GlyphImage_AssetImage_RemoteImage.hpp +1 -1
- package/nitrogen/generated/android/c++/JVariant_PreferredImageLane_ImageLane.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GlyphImage.kt +2 -5
- package/nitrogen/generated/ios/c++/HybridCarPlayDashboardSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/GlyphImage.swift +2 -7
- package/nitrogen/generated/shared/c++/GlyphImage.hpp +1 -6
- package/package.json +3 -2
- package/src/index.ts +0 -1
- package/src/types/Glyphmap.ts +4107 -0
- package/src/types/Image.ts +18 -53
- package/src/types/Maneuver.ts +10 -3
- package/src/utils/NitroImage.ts +5 -66
package/src/types/Image.ts
CHANGED
|
@@ -1,61 +1,26 @@
|
|
|
1
1
|
import type { ImageSourcePropType } from 'react-native';
|
|
2
2
|
import type { ThemedColor } from '../utils/NitroColor';
|
|
3
|
+
import type { GlyphName } from './Glyphmap';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* // autoplay-glyphs.d.ts
|
|
10
|
-
* import type { GlyphName } from './assets/symbolFont/Glyphmap';
|
|
11
|
-
* declare module '@iternio/react-native-auto-play' {
|
|
12
|
-
* interface AutoPlayGlyphMap extends Record<GlyphName, number> {}
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
// biome-ignore lint/suspicious/noEmptyInterface: must be an interface for declaration merging
|
|
17
|
-
export interface AutoPlayGlyphMap {}
|
|
18
|
-
|
|
19
|
-
/** Resolves to the augmented glyph name union, or falls back to `string` when not augmented. */
|
|
20
|
-
export type GlyphMapKey = keyof AutoPlayGlyphMap extends never
|
|
21
|
-
? string
|
|
22
|
-
: Extract<keyof AutoPlayGlyphMap, string>;
|
|
23
|
-
|
|
24
|
-
type GlyphStyleFields = {
|
|
25
|
-
/**
|
|
26
|
-
* Sets the icon dark and light mode color or a single color for both.
|
|
27
|
-
* Defaults to white for dark mode and black for light mode if not specified.
|
|
28
|
-
* Might not get applied everywhere like MapTemplate buttons on Android.
|
|
29
|
-
*/
|
|
30
|
-
color?: ThemedColor | string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Sets the background color for dark and light mode or a single color for both
|
|
34
|
-
* Defaults to transparent if not specified.
|
|
35
|
-
*/
|
|
36
|
-
backgroundColor?: ThemedColor | string;
|
|
37
|
-
fontScale?: number;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/** Glyph by name — looked up in the glyph map registered via {@link setIconFont}. */
|
|
41
|
-
export type AutoGlyphByName = GlyphStyleFields & {
|
|
42
|
-
type: 'glyph';
|
|
43
|
-
/** Key in the glyph map passed to `setIconFont`. */
|
|
44
|
-
name: GlyphMapKey;
|
|
45
|
-
/** Optional override — if set, used instead of the map lookup. */
|
|
46
|
-
codepoint?: number;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** Glyph by raw Unicode code point. */
|
|
50
|
-
export type AutoGlyphByCodepoint = GlyphStyleFields & {
|
|
51
|
-
type: 'glyph';
|
|
52
|
-
codepoint: number;
|
|
53
|
-
};
|
|
5
|
+
export type AutoImage =
|
|
6
|
+
| {
|
|
7
|
+
name: GlyphName;
|
|
54
8
|
|
|
55
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Sets the icon dark and light mode color or a single color for both.
|
|
11
|
+
* Defaults to white for dark mode and black for light mode if not specified.
|
|
12
|
+
* Might not get applied everywhere like MapTemplate buttons on Android.
|
|
13
|
+
*/
|
|
14
|
+
color?: ThemedColor | string;
|
|
56
15
|
|
|
57
|
-
|
|
58
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Sets the background color for dark and light mode or a single color for both
|
|
18
|
+
* Defaults to transparent if not specified.
|
|
19
|
+
*/
|
|
20
|
+
backgroundColor?: ThemedColor | string;
|
|
21
|
+
fontScale?: number;
|
|
22
|
+
type: 'glyph';
|
|
23
|
+
}
|
|
59
24
|
| {
|
|
60
25
|
image: ImageSourcePropType;
|
|
61
26
|
/**
|
package/src/types/Maneuver.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ImageSourcePropType } from 'react-native';
|
|
2
2
|
import type { ThemedColor } from '../utils/NitroColor';
|
|
3
|
-
import type {
|
|
3
|
+
import type { GlyphName } from './Glyphmap';
|
|
4
4
|
import type { TravelEstimates } from './Trip';
|
|
5
5
|
|
|
6
6
|
export enum ManeuverType {
|
|
@@ -174,8 +174,15 @@ export interface PreferredLane extends Lane {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
export type ManeuverImage =
|
|
177
|
-
|
|
|
178
|
-
|
|
177
|
+
| {
|
|
178
|
+
name: GlyphName;
|
|
179
|
+
/**
|
|
180
|
+
* make sure to specify a color with a proper contrast ratio to cardBackgroundColor otherwise it might not get applied
|
|
181
|
+
* defaults to white/black for dark/light mode
|
|
182
|
+
*/
|
|
183
|
+
color?: ThemedColor | string;
|
|
184
|
+
type: 'glyph';
|
|
185
|
+
}
|
|
179
186
|
| {
|
|
180
187
|
image: ImageSourcePropType;
|
|
181
188
|
/**
|
package/src/utils/NitroImage.ts
CHANGED
|
@@ -1,69 +1,8 @@
|
|
|
1
1
|
import { Image, type ImageResolvedAssetSource } from 'react-native';
|
|
2
|
+
import { glyphMap } from '../types/Glyphmap';
|
|
2
3
|
import type { AutoImage } from '../types/Image';
|
|
3
4
|
import { type NitroColor, NitroColorUtil } from './NitroColor';
|
|
4
5
|
|
|
5
|
-
let _iconFont: string | undefined;
|
|
6
|
-
let _glyphMap: Record<string, number> | undefined;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Register the icon font and (optionally) a glyph map for name-based lookups.
|
|
10
|
-
* Must be called **once** before creating any templates. Subsequent calls are ignored.
|
|
11
|
-
*
|
|
12
|
-
* The font name maps directly to a native font asset:
|
|
13
|
-
* - **Android** — `res/font/<name>.ttf` (must be lowercase)
|
|
14
|
-
* - **iOS** — `<name>.ttf` in the app bundle (registered via CoreText automatically)
|
|
15
|
-
*
|
|
16
|
-
* For cross-platform compatibility use lowercase with underscores only.
|
|
17
|
-
*
|
|
18
|
-
* @param name Native font asset name (without extension).
|
|
19
|
-
* @param glyphMap Optional map of glyph names to Unicode code points.
|
|
20
|
-
* When provided, glyphs can use `{ type: 'glyph', name: 'icon_name' }`.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { glyphMap } from './assets/Glyphmap';
|
|
25
|
-
* setIconFont('material_symbols', glyphMap);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export function setIconFont(name: string, glyphMap?: Record<string, number>): void {
|
|
29
|
-
if (_iconFont != null) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
_iconFont = name;
|
|
33
|
-
_glyphMap = glyphMap;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getIconFont(): string {
|
|
37
|
-
if (_iconFont == null) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
'No icon font configured. Call setIconFont("your_font_name") before using glyph images.'
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return _iconFont;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function resolveGlyph(image: Extract<AutoImage, { type: 'glyph' }>): number {
|
|
46
|
-
if ('name' in image && image.name !== undefined) {
|
|
47
|
-
if (image.codepoint !== undefined) {
|
|
48
|
-
return image.codepoint;
|
|
49
|
-
}
|
|
50
|
-
if (_glyphMap == null) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`Glyph name "${image.name}" used but no glyph map was provided to setIconFont().`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
const cp = _glyphMap[image.name];
|
|
56
|
-
if (cp === undefined) {
|
|
57
|
-
throw new Error(`Glyph name "${image.name}" not found in the glyph map.`);
|
|
58
|
-
}
|
|
59
|
-
return cp;
|
|
60
|
-
}
|
|
61
|
-
if (image.codepoint !== undefined) {
|
|
62
|
-
return image.codepoint;
|
|
63
|
-
}
|
|
64
|
-
throw new Error('Glyph image must provide either `name` or `codepoint`.');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
6
|
interface AssetImage extends ImageResolvedAssetSource {
|
|
68
7
|
color?: NitroColor;
|
|
69
8
|
packager_asset: boolean;
|
|
@@ -71,7 +10,6 @@ interface AssetImage extends ImageResolvedAssetSource {
|
|
|
71
10
|
|
|
72
11
|
interface GlyphImage {
|
|
73
12
|
glyph: number;
|
|
74
|
-
fontName: string;
|
|
75
13
|
color: NitroColor;
|
|
76
14
|
backgroundColor: NitroColor;
|
|
77
15
|
fontScale?: number;
|
|
@@ -84,7 +22,8 @@ interface RemoteImage {
|
|
|
84
22
|
}
|
|
85
23
|
|
|
86
24
|
/**
|
|
87
|
-
*
|
|
25
|
+
* we need to map the ButtonImage.name from GlyphName to
|
|
26
|
+
* the actual numeric value so we need a nitro specific type
|
|
88
27
|
*/
|
|
89
28
|
export type NitroImage = GlyphImage | AssetImage | RemoteImage;
|
|
90
29
|
|
|
@@ -99,12 +38,12 @@ function convert(image?: AutoImage): NitroImage | undefined {
|
|
|
99
38
|
const {
|
|
100
39
|
color = { darkColor: 'white', lightColor: 'black' },
|
|
101
40
|
fontScale,
|
|
41
|
+
name,
|
|
102
42
|
backgroundColor = 'transparent',
|
|
103
43
|
} = image;
|
|
104
44
|
|
|
105
45
|
return {
|
|
106
|
-
glyph:
|
|
107
|
-
fontName: getIconFont(),
|
|
46
|
+
glyph: glyphMap[name],
|
|
108
47
|
color: NitroColorUtil.convert(color),
|
|
109
48
|
backgroundColor: NitroColorUtil.convert(backgroundColor),
|
|
110
49
|
fontScale,
|