Elara has ten app icons. Seven are there all year, and three only turn up in winter. You pick one in Settings, on a picture of a phone, and from December 1 the app swaps its own icon for a frosted one unless you have chosen something else.
The clip is also on X, if you would rather reply or share it there.
The app is Expo and React Native. The feature is small on screen and took four separate pieces to get right: the native switch on each platform, a store that trusts the device, the seasonal default, and the picker.
One list, two native names
Every icon is one entry in a list. The entry carries the name iOS knows it by, the name Android knows it by, and what to show in the picker:
export const APP_ICONS: AppIconOption[] = [
{
id: "normalDark",
nativeKey: "DEFAULT", // the app's own icon
androidKey: "DEFAULT",
name: "Classic",
subtitle: "Cream e on Elara purple",
image: require("@/assets/custom-icons/normal-dark.png"),
},
{
id: "frost",
nativeKey: "frost",
androidKey: "frost",
name: "Frost",
subtitle: "A snow-capped e on frosted purple",
image: require("@/assets/custom-icons/frost.png"),
season: "winter",
},
// ...
];The first entry is the primary icon. Picking it goes back to the app's real icon, not to an alternate copy of it. The subtitle is what VoiceOver reads, so each one says what the icon looks like instead of repeating its name.
The native side comes from expo-dynamic-app-icon, whose config plugin takes the same keys in app.json and generates the iOS alternate icons and the Android launcher entries. I had to patch it on both platforms.
iOS: use the public API and accept the alert
The library changed the icon through a private UIKit method, _setAlternateIconName:completionHandler:, to avoid the system alert that says "You have changed the icon". Private API is a rejection under App Review guideline 2.5.1, and it also meant the call returned before anyone knew whether it had worked.
The patch replaces it with the public method and turns the function into a promise:
AsyncFunction("setAppIcon") { (name: String?, promise: Promise) in
let iconName: String? = (name == nil || name == "DEFAULT") ? nil : name
let app = UIApplication.shared
guard app.supportsAlternateIcons else {
promise.reject("ERR_ALTERNATE_ICONS_UNSUPPORTED", "This device doesn't support changing the app icon.")
return
}
if app.alternateIconName == iconName {
promise.resolve(iconName ?? "DEFAULT")
return
}
app.setAlternateIconName(iconName) { error in
if let error = error {
promise.reject("ERR_SET_APP_ICON", error.localizedDescription)
} else {
promise.resolve(iconName ?? "DEFAULT")
}
}
}.runOnQueue(.main)The alert stays. It turned out to be useful: it is the confirmation, so the app shows no toast of its own when a change succeeds.
Android: never disable the main activity
Android has no call for changing an icon. The icon belongs to whichever launcher entry is enabled, so the plugin adds one activity-alias per icon, all disabled, and switching means enabling one and disabling the rest.
Out of the box the library disabled MainActivity itself when you moved to an alternate icon. In Elara that activity holds every link into the app: the custom scheme, the universal links and the share sheet. Disable it and all of them stop opening the app.
So a small config plugin of my own moves the launcher entry off MainActivity and gives the primary icon an alias of its own:
// MainActivity keeps its link filters and loses MAIN/LAUNCHER
mainActivity["intent-filter"] = mainActivity["intent-filter"].filter((f) => !isLauncherFilter(f));
// The app's own icon becomes an alias like the others, enabled by default
app["activity-alias"] = [
{
$: {
"android:name": `${pkg}.MainActivityDefault`,
"android:enabled": "true",
"android:exported": "true",
"android:icon": "@mipmap/ic_launcher",
"android:targetActivity": ".MainActivity",
},
"intent-filter": [launcherFilter],
},
...aliases,
];Now every icon is an alias, the patched module only ever enables one alias and disables the others, and MainActivity is never touched. Two details are easy to miss:
- Plugin order is backwards. A plugin listed earlier in
app.jsonruns later. Mine is listed beforeexpo-dynamic-app-iconso that it sees the aliases that plugin added. - Read the icon from the system. The module used to remember the current icon in a variable, which is gone after a restart. The patch asks the package manager which launcher alias is enabled.
The device is the source of truth
The picked icon is saved in a Zustand store, but the saved value can be wrong. A reinstall resets the icon and keeps nothing; a change iOS refused leaves the store ahead of the phone. So the store treats its own value as a guess:
setAppIcon: async (iconId) => {
if (get().isChanging) return;
const previous = get().selectedIconId;
// Shown as picked at once; put back if the platform refuses
set({ isChanging: true, selectedIconId: iconId });
try {
const result = await ExpoDynamicAppIcon.setAppIcon(nativeAppIconKey(getAppIconById(iconId), Platform.OS));
if (result === false) throw new Error("The app icon could not be changed");
} catch (error) {
set({ selectedIconId: previous });
throw error;
} finally {
set({ isChanging: false });
}
},
syncFromDevice: () => {
set({ selectedIconId: appIconIdFromNative(ExpoDynamicAppIcon.getAppIcon()) });
},syncFromDevice runs at launch and whenever the picker opens. Whatever the phone reports wins.
A default that follows the calendar
The seasonal part reads the date, in the phone's local time, so it starts at midnight wherever you are:
- December 1 to the end of February: Frost.
- December 18 to 25: the Santa Hat icon, then back to Frost.
- March 1, or when you switch "Festive touches" off: the icon you had before.
The hard part is the word "default". The app may change the icon on its own, but it must not undo a choice you made. That needs three things remembered, and no more:
interface SeasonIconMemory {
autoYear: number | null; // the season the default was last applied for
autoSet: AppIconId | null; // the icon the app set itself
before: AppIconId | null; // the icon to put back when the season ends
}One pure function takes today's seasonal icon, the icon on the device and that memory, and returns what to do:
export function planSeasonIcon(target, year, current, memory, fallback) {
if (target == null || year == null) {
// The season is over, or switched off: a seasonal icon gives way to the one from before
if (!isSeasonalAppIcon(current)) return null;
return { icon: memory.before ?? fallback, memory: { autoYear: null, autoSet: null, before: null } };
}
if (memory.autoYear !== year) {
// The season's first day in this app: its icon becomes the default, once
const before = isSeasonalAppIcon(current) ? memory.before : current;
const next = { autoYear: year, autoSet: target, before };
return current === target ? { memory: next } : { icon: target, memory: next };
}
// Later in the same season: follow the calendar only while the icon is still the one the app set
if (memory.autoSet && memory.autoSet !== target && current === memory.autoSet) {
return { icon: target, memory: { ...memory, autoSet: target } };
}
return null;
}The three branches are the three rules. The season's icon is applied once per year. After that the app only moves the icon if it is still the one the app put there: if current is not autoSet, you picked your own and it stays for the rest of the season. And when the season ends, a seasonal icon is replaced by before, while anything else is left alone.
The function imports nothing from React or React Native, so a plain Node script runs it through the days that matter: December 1, the 18th, the 26th, the end of the season, and the next winter. Date logic that only fires twice a year is exactly the kind you cannot test by hand.
Two remote flags can turn winter or Christmas off without a release, and people on the team can force any day of the season from a debug menu, which is how Christmas got tested in November.
Two limits I did not expect
iOS refuses an icon change while the app is launching. The call simply fails if it comes too early. The automatic change waits three seconds after launch and, if it is refused, tries again at six and twelve.
The automatic change is iOS only. On Android, switching the launcher alias makes some launchers drop the icon from the Home Screen, and you have to add it back from the app drawer. That is acceptable when you asked for a new icon and not when the app decided to do it for you. Android users get the seasonal icons in the picker and choose them by hand.
The picker
The phone in the picker is a picture with a hole where its screen is. The wallpaper and the icons are drawn underneath and show through, so the phone never moves and only the icons do.
One shared value, progress, says where the carousel is, in icons: 2.5 is halfway between the third and the fourth. Everything else is derived from it.
const cellStyle = useAnimatedStyle(() => {
const d = index - progress.get();
return {
opacity: interpolate(Math.abs(d), [0, 1, 2], [1, 0.5, 0], CLAMP),
transform: [
{ translateX: d * ICON_GAP * s },
{ translateY: -d * ICON_GAP * s * PATH_RISE },
{ perspective: 700 * s },
{ rotateY: "18deg" },
{ rotateX: "5deg" },
],
};
});- The icons travel on a slope. The phone is seen from its front left, so the top of its screen climbs to the right. The icons climb with it, 4.5 percent up for each step along, and that is most of what makes them look like they are on the screen.
- Slide first, then turn. The translate comes before the perspective. The other way round, an icon changes shape as it moves.
- Blur is a second image. Animating a blur radius is expensive, so each icon has a pre-blurred copy on top whose opacity follows its distance from the front.
- One icon per flick. On release, the swipe's velocity decides the direction, and the target is clamped to one step from where the drag began. A hard flick cannot throw you past four icons you wanted to see.
- It can be caught. A new drag cancels the running spring and starts from where the icons are, not from where they were heading.
- The ends resist. Past the first or last icon the drag follows the finger at a quarter of its speed.
The name, the description and the button follow whichever icon is nearest the front, and fade out halfway between two so the words change while they are invisible. With Reduce Motion on, the spring becomes a plain 180ms move with no overshoot. For VoiceOver the whole stage is one adjustable control: swipe up or down to step through the icons, and it reads "Stripes, 5 of 8. Navy e on lilac stripes".
What I would tell someone starting this
- Do not use a private API to hide the iOS alert. Use the alert as your confirmation.
- On Android, give the primary icon its own alias and leave the main activity alone, or your deep links will break the first time someone changes the icon.
- Ask the device which icon is set. Do not trust what you saved.
- Keep "the app set this" separate from "the user chose this", and write the rule as a pure function you can run against the calendar.