Skip to content

Commit

Permalink
feat: few improvments (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpouzet authored Jan 1, 2025
1 parent 1047fad commit c026d46
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 18 deletions.
3 changes: 3 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default ({ config }: ConfigContext): MyExpoConfig => ({
icon: ICON,
ios: {
bundleIdentifier: PACKAGE,
entitlements: {
'aps-environment': 'production',
},
infoPlist: {
CFBundleAllowMixedLocalizations: true,
CFBundleLocalizations: [ 'en', 'fr' ],
Expand Down
2 changes: 0 additions & 2 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@
"submit": {
"staging": {
"ios": {
"appleId": "${EXPO_APPLE_ID}",
"appleTeamId": "${EXPO_APPLE_TEAM_ID}",
"ascAppId": "${EXPO_ASC_APP_ID}"
}
},
"production": {
"ios": {
"appleId": "${EXPO_APPLE_ID}",
"appleTeamId": "${EXPO_APPLE_TEAM_ID}",
"ascAppId": "${EXPO_ASC_APP_ID}"
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build:dev:ios": "cross-env NODE_ENV=development APP_ENV=development npx eas-cli build --profile development --platform ios",
"build:dev:ios:simulator": "cross-env NODE_ENV=development APP_ENV=development npx eas-cli build --profile development-simulator --platform ios",
"build:staging:android": "cross-env NODE_ENV=production APP_ENV=staging npx eas-cli build --profile staging --platform android",
"build:production": "cross-env NODE_ENV=production APP_ENV=production npx eas-cli build --profile production --platform all --auto-submit-with-profile=production",
"update:staging": "cross-env NODE_ENV=production APP_ENV=staging npx eas-cli update --channel staging --auto",
"update:production": "cross-env NODE_ENV=production APP_ENV=production npx eas-cli update --channel production --auto",
"prebuild:staging": "cross-env NODE_ENV=production APP_ENV=staging npx expo prebuild",
Expand Down
33 changes: 19 additions & 14 deletions src/app/(root)/domain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ const options = {
year: 'numeric',
} ;

type Params = {
domain: string
extension: string
} ;

export default function Domain() {
const { i18n, t } = useTranslation() ;
const theme = useTheme() ;
const router = useRouter() ;

const { domain, extension } = useLocalSearchParams() ;
const { domain, extension } = useLocalSearchParams<Params>() ;

const { bottom, top } = useSafeAreaInsets() ;
const { height } = useWindowDimensions() ;
Expand Down Expand Up @@ -189,18 +194,18 @@ export default function Domain() {
} else if( error ) {

// default
let errorTitle = t('domain.error.title') ;
let errorDescription = t('domain.error.title') ;

if( error.response ) {
if( error.response.status === 404 ) {
errorTitle = t('domain.notFound.title') ;
errorDescription = t('domain.notFound.description', { val: (domain + extension) }) ;
} else {
errorTitle = t('domain.badRequest.title') ;
errorDescription = t('domain.badRequest.description', { val: (domain + extension) }) ;
}
}
const errorTitle = t('domain.error.title') ;
const errorDescription = t('domain.error.title') ;

// if( error.response ) {
// if( error.response.status === 404 ) {
// errorTitle = t('domain.notFound.title') ;
// errorDescription = t('domain.notFound.description', { val: (domain + extension) }) ;
// } else {
// errorTitle = t('domain.badRequest.title') ;
// errorDescription = t('domain.badRequest.description', { val: (domain + extension) }) ;
// }
// }

return (
<ErrorView
Expand All @@ -220,8 +225,8 @@ export default function Domain() {
style={{
backgroundColor: 'black',
height: top,
position: 'absolute',
opacity: 0.2,
position: 'absolute',
width: '100%',
zIndex: 10,
}}
Expand Down
3 changes: 3 additions & 0 deletions src/components/AppRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client

import { persister, queryClient } from '@helpers/query' ;
import useAppUpdate from '@hooks/useAppUpdate' ;
import useCheckVersion from '@hooks/useCheckVersion' ;

type Props = {
children: React.ReactNode
Expand All @@ -11,6 +12,8 @@ type Props = {
const AppRoot: FC<Props> = ({ children }) => {
useAppUpdate() ;

useCheckVersion() ;

return (
<PersistQueryClientProvider
client={queryClient}
Expand Down
26 changes: 26 additions & 0 deletions src/hooks/useCheckVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as Application from 'expo-application' ;
import { Image } from 'expo-image' ;
import { useEffect } from 'react' ;

import useSettingsStore from '@hooks/useSettingsStore' ;

const useCheckVersion = () => {
const version = useSettingsStore((state) => state.version) ;
const setVersion = useSettingsStore((state) => state.setVersion) ;

useEffect(() => {
void (async () => {
// check new version
const appVersion = Application.nativeApplicationVersion ;

if ( appVersion && (appVersion !== version) ) {
setVersion(appVersion) ;

// clear cache
await Image.clearDiskCache() ;
}
})() ;
}, []) ;
} ;

export default useCheckVersion ;
2 changes: 1 addition & 1 deletion src/hooks/useColorScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function useColorScheme() {
(state) => state.theme
) ;

const systemTheme = _useColorScheme() ;
const systemTheme = _useColorScheme() ?? 'light' ;

// Return the appropriate theme without causing side effects
return themeStore === 'default' ? systemTheme : themeStore ;
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ export type Theme = 'default' | 'dark' | 'light' ;

export interface SettingsState {
theme: Theme
version: string
}

interface Actions {
setTheme: (theme: Theme) => void,
setTheme: (theme: Theme) => void
setVersion: (version: string) => void
}

const initialState: SettingsState = {
theme: 'default',
version: '',
} ;

const useSettingsStore = create<SettingsState & Actions>()(
persist(
(set) => ({
...initialState,
setTheme: (theme) => set({ theme }),
setVersion: (version) => set({ version }),
}),
{
name: SETTINGS_KEY,
Expand Down

0 comments on commit c026d46

Please sign in to comment.