-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mobile): dynamic app icon (#277)
![Simulator Screenshot - iPhone 15 Pro - 2024-09-07 at 05.46.19.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/1VEKR8FQ1Qa5iAiqVGqF/dece2dd7-2a5d-4bbd-ba55-f9c03fe9201e.png) Resolves #270
- Loading branch information
Showing
56 changed files
with
566 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<resources> | ||
<color name="splashscreen_background">#ffffff</color> | ||
<color name="iconBackground">#ffffff</color> | ||
<color name="splashscreen_background">#000000</color> | ||
<color name="iconBackground">#000000</color> | ||
<color name="colorPrimary">#023c69</color> | ||
<color name="colorPrimaryDark">#ffffff</color> | ||
<color name="colorPrimaryDark">#000000</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { toast } from '@/components/common/toast' | ||
import { Badge } from '@/components/ui/badge' | ||
import { Text } from '@/components/ui/text' | ||
import { useUserEntitlements } from '@/hooks/use-purchases' | ||
import { t } from '@lingui/macro' | ||
import { useLingui } from '@lingui/react' | ||
import { getAppIcon, setAppIcon } from 'expo-dynamic-app-icon' | ||
import * as Haptics from 'expo-haptics' | ||
import { useRouter } from 'expo-router' | ||
import { CheckIcon, LockIcon } from 'lucide-react-native' | ||
import { useState } from 'react' | ||
import { FlatList, Image, Pressable, View } from 'react-native' | ||
|
||
const APP_ICONS = [ | ||
{ | ||
name: 'dark', | ||
source: require('../../assets/images/app-icons/dark.png'), | ||
pro: false, | ||
}, | ||
{ | ||
name: 'light', | ||
source: require('../../assets/images/app-icons/light.png'), | ||
pro: true, | ||
}, | ||
{ | ||
name: 'digital', | ||
source: require('../../assets/images/app-icons/digital.png'), | ||
pro: true, | ||
}, | ||
{ | ||
name: 'original', | ||
source: require('../../assets/images/app-icons/original.png'), | ||
pro: false, | ||
}, | ||
] | ||
|
||
type AppIcon = (typeof APP_ICONS)[number] | ||
|
||
export default function AppearanceScreen() { | ||
const [selected, setSelected] = useState<string>(getAppIcon() ?? 'dark') | ||
const { i18n } = useLingui() | ||
const { isPro } = useUserEntitlements() | ||
const router = useRouter() | ||
|
||
function renderDynamicIcon({ item }: { item: AppIcon }) { | ||
return ( | ||
<Pressable | ||
onPress={() => { | ||
if (item.pro && !isPro) { | ||
router.push('/paywall') | ||
return | ||
} | ||
|
||
Haptics.selectionAsync() | ||
setAppIcon(item.name) | ||
setSelected(item.name) | ||
toast.success(t(i18n)`App icon updated!`) | ||
}} | ||
className="flex-1 flex-row items-center justify-center gap-4 rounded-lg bg-card px-6 py-2 active:bg-muted/50" | ||
> | ||
<View className="flex-1 flex-row items-center gap-4"> | ||
<Image | ||
source={item.source} | ||
className="h-16 w-16 rounded-xl border border-border" | ||
/> | ||
<Text className="text-center text-foreground capitalize"> | ||
{item.name} | ||
</Text> | ||
</View> | ||
{selected === item.name ? ( | ||
<CheckIcon className="size-6 text-amount-positive" /> | ||
) : item.pro && !isPro ? ( | ||
<Badge variant="secondary" className="py-1.5"> | ||
<LockIcon className="size-4 text-primary" /> | ||
</Badge> | ||
) : null} | ||
</Pressable> | ||
) | ||
} | ||
|
||
return ( | ||
<FlatList<AppIcon> | ||
data={APP_ICONS} | ||
keyExtractor={(i) => i.name} | ||
ListHeaderComponent={ | ||
<View className="px-6"> | ||
<Text className="mb-4 font-sans text-muted-foreground text-sm"> | ||
{t(i18n)`Choose your preferred app icon`} | ||
</Text> | ||
</View> | ||
} | ||
className="bg-card" | ||
renderItem={renderDynamicIcon} | ||
contentContainerClassName="py-4" | ||
/> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.