expo-app-icon 1.0.0 → 1.1.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 +21 -17
- package/package.json +1 -1
- package/plugin/build/icons.js +7 -1
- package/plugin/build/types.d.ts +10 -4
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/Daniel-Griffiths/expo-app-icon/master/assets/icon.png" width="128" alt="expo-app-icon" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
# Expo App Icon
|
|
3
6
|
Programmatically change your app's icon at runtime in Expo, with proper Android adaptive-icon support.
|
|
4
7
|
|
|
5
8
|
## Install
|
|
@@ -10,7 +13,7 @@ npx expo install expo-app-icon
|
|
|
10
13
|
|
|
11
14
|
## Configure
|
|
12
15
|
|
|
13
|
-
Add the plugin to your app config and declare your icons. Each icon
|
|
16
|
+
Add the plugin to your `app.json` config and declare your icons. Each icon is just a key and an image path:
|
|
14
17
|
|
|
15
18
|
```json
|
|
16
19
|
{
|
|
@@ -19,14 +22,8 @@ Add the plugin to your app config and declare your icons. Each icon needs an `io
|
|
|
19
22
|
[
|
|
20
23
|
"expo-app-icon",
|
|
21
24
|
{
|
|
22
|
-
"red":
|
|
23
|
-
|
|
24
|
-
"android": "./assets/icons/red.png"
|
|
25
|
-
},
|
|
26
|
-
"blue": {
|
|
27
|
-
"ios": "./assets/icons/blue.png",
|
|
28
|
-
"android": "./assets/icons/blue.png"
|
|
29
|
-
}
|
|
25
|
+
"red": "./assets/icons/red.png",
|
|
26
|
+
"blue": "./assets/icons/blue.png"
|
|
30
27
|
}
|
|
31
28
|
]
|
|
32
29
|
]
|
|
@@ -34,6 +31,19 @@ Add the plugin to your app config and declare your icons. Each icon needs an `io
|
|
|
34
31
|
}
|
|
35
32
|
```
|
|
36
33
|
|
|
34
|
+
The same image is used for both platforms. To use a different image per platform (or mark an iOS icon as prerendered), pass an object instead:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"red": "./assets/icons/red.png",
|
|
39
|
+
"blue": {
|
|
40
|
+
"ios": "./assets/icons/blue-ios.png",
|
|
41
|
+
"android": "./assets/icons/blue-android.png",
|
|
42
|
+
"prerendered": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
37
47
|
Then create a new build (the plugin runs during prebuild):
|
|
38
48
|
|
|
39
49
|
```sh
|
|
@@ -54,9 +64,3 @@ setAppIcon("red");
|
|
|
54
64
|
// Reset back to the default icon
|
|
55
65
|
setAppIcon(null);
|
|
56
66
|
```
|
|
57
|
-
|
|
58
|
-
## Notes
|
|
59
|
-
|
|
60
|
-
- Icon keys are the keys you define in the plugin config.
|
|
61
|
-
- Android icons are generated as adaptive icons. Source images are scaled into the adaptive safe zone, so design your artwork edge-to-edge — it will be centered automatically.
|
|
62
|
-
- Changing the icon on Android briefly closes and reopens the app.
|
package/package.json
CHANGED
package/plugin/build/icons.js
CHANGED
|
@@ -23,7 +23,13 @@ function normalizeIconSet(input) {
|
|
|
23
23
|
return acc;
|
|
24
24
|
}, {});
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
if (!input)
|
|
27
|
+
return {};
|
|
28
|
+
return Object.fromEntries(Object.entries(input).map(([key, value]) => [
|
|
29
|
+
key,
|
|
30
|
+
// String shorthand: one image path used for both platforms.
|
|
31
|
+
typeof value === "string" ? { ios: value, android: value } : value,
|
|
32
|
+
]));
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Build the list of Apple icon variants to emit for the given tablet support.
|
package/plugin/build/types.d.ts
CHANGED
|
@@ -16,14 +16,20 @@ export type IconConfig = {
|
|
|
16
16
|
prerendered?: boolean;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Map of icon key → icon config, as used everywhere internally
|
|
19
|
+
* Map of icon key → icon config, as used everywhere internally (always the
|
|
20
|
+
* fully-resolved object form).
|
|
20
21
|
*/
|
|
21
22
|
export type IconSet = Record<string, IconConfig>;
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* An icon as declared by the user: either a single image path used for both
|
|
25
|
+
* platforms (`"red": "./assets/red.png"`) or the explicit per-platform object.
|
|
25
26
|
*/
|
|
26
|
-
export type
|
|
27
|
+
export type IconInput = string | IconConfig;
|
|
28
|
+
/**
|
|
29
|
+
* What the plugin accepts from the app config: a keyed map (string shorthand or
|
|
30
|
+
* object per icon), a bare list of image paths, or nothing.
|
|
31
|
+
*/
|
|
32
|
+
export type IconPluginInput = Record<string, IconInput> | string[] | void;
|
|
27
33
|
/**
|
|
28
34
|
* Device family an Apple icon variant targets.
|
|
29
35
|
*/
|