Add inter, integrate

This commit is contained in:
Eric Bailey
2024-09-15 12:13:29 -05:00
parent d5b62f21f5
commit bf509eb6d5
26 changed files with 82 additions and 9 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -123,6 +123,7 @@
"expo-dev-client": "^4.0.14", "expo-dev-client": "^4.0.14",
"expo-device": "~6.0.2", "expo-device": "~6.0.2",
"expo-file-system": "^17.0.1", "expo-file-system": "^17.0.1",
"expo-font": "~12.0.10",
"expo-haptics": "^13.0.1", "expo-haptics": "^13.0.1",
"expo-image": "~1.12.9", "expo-image": "~1.12.9",
"expo-image-manipulator": "^12.0.5", "expo-image-manipulator": "^12.0.5",
+3 -2
View File
@@ -55,7 +55,7 @@ import {TestCtrls} from '#/view/com/testing/TestCtrls'
import {Provider as ActiveVideoProvider} from '#/view/com/util/post-embeds/ActiveVideoNativeContext' import {Provider as ActiveVideoProvider} from '#/view/com/util/post-embeds/ActiveVideoNativeContext'
import * as Toast from '#/view/com/util/Toast' import * as Toast from '#/view/com/util/Toast'
import {Shell} from '#/view/shell' import {Shell} from '#/view/shell'
import {ThemeProvider as Alf} from '#/alf' import {ThemeProvider as Alf, useFonts} from '#/alf'
import {useColorModeTheme} from '#/alf/util/useColorModeTheme' import {useColorModeTheme} from '#/alf/util/useColorModeTheme'
import {NuxDialogs} from '#/components/dialogs/nuxs' import {NuxDialogs} from '#/components/dialogs/nuxs'
import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry' import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry'
@@ -73,6 +73,7 @@ function InnerApp() {
const {resumeSession} = useSessionApi() const {resumeSession} = useSessionApi()
const theme = useColorModeTheme() const theme = useColorModeTheme()
const {_} = useLingui() const {_} = useLingui()
const [fontsLoaded] = useFonts()
useIntentHandler() useIntentHandler()
const hasCheckedReferrer = useStarterPackEntry() const hasCheckedReferrer = useStarterPackEntry()
@@ -110,7 +111,7 @@ function InnerApp() {
<StatsigProvider key={currentAccount?.did}> <StatsigProvider key={currentAccount?.did}>
<Alf theme={theme}> <Alf theme={theme}>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<Splash isReady={isReady && hasCheckedReferrer}> <Splash isReady={isReady && hasCheckedReferrer && fontsLoaded}>
<ActiveVideoProvider> <ActiveVideoProvider>
<RootSiblingParent> <RootSiblingParent>
<QueryProvider currentDid={currentAccount?.did}> <QueryProvider currentDid={currentAccount?.did}>
+3 -2
View File
@@ -44,7 +44,7 @@ import {Provider as ActiveVideoProvider} from '#/view/com/util/post-embeds/Activ
import * as Toast from '#/view/com/util/Toast' import * as Toast from '#/view/com/util/Toast'
import {ToastContainer} from '#/view/com/util/Toast.web' import {ToastContainer} from '#/view/com/util/Toast.web'
import {Shell} from '#/view/shell/index' import {Shell} from '#/view/shell/index'
import {ThemeProvider as Alf} from '#/alf' import {ThemeProvider as Alf, useFonts} from '#/alf'
import {useColorModeTheme} from '#/alf/util/useColorModeTheme' import {useColorModeTheme} from '#/alf/util/useColorModeTheme'
import {NuxDialogs} from '#/components/dialogs/nuxs' import {NuxDialogs} from '#/components/dialogs/nuxs'
import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry' import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry'
@@ -60,6 +60,7 @@ function InnerApp() {
const {_} = useLingui() const {_} = useLingui()
useIntentHandler() useIntentHandler()
const hasCheckedReferrer = useStarterPackEntry() const hasCheckedReferrer = useStarterPackEntry()
const [fontsLoaded] = useFonts()
// init // init
useEffect(() => { useEffect(() => {
@@ -88,7 +89,7 @@ function InnerApp() {
}, [_]) }, [_])
// wait for session to resume // wait for session to resume
if (!isReady || !hasCheckedReferrer) return null if (!isReady || !hasCheckedReferrer || !fontsLoaded) return null
return ( return (
<KeyboardProvider enabled={false}> <KeyboardProvider enabled={false}>
+43
View File
@@ -0,0 +1,43 @@
import {useFonts as defaultUseFonts} from 'expo-font'
export function useFonts() {
return defaultUseFonts({
'Inter-Thin': require('../../assets/fonts/inter/Inter-Thin.otf'),
'Inter-ThinItalic': require('../../assets/fonts/inter/Inter-ThinItalic.otf'),
'Inter-ExtraLight': require('../../assets/fonts/inter/Inter-ExtraLight.otf'),
'Inter-ExtraLightItalic': require('../../assets/fonts/inter/Inter-ExtraLightItalic.otf'),
'Inter-Light': require('../../assets/fonts/inter/Inter-Light.otf'),
'Inter-LightItalic': require('../../assets/fonts/inter/Inter-LightItalic.otf'),
'Inter-Regular': require('../../assets/fonts/inter/Inter-Regular.otf'),
'Inter-Italic': require('../../assets/fonts/inter/Inter-Italic.otf'),
'Inter-Medium': require('../../assets/fonts/inter/Inter-Medium.otf'),
'Inter-MediumItalic': require('../../assets/fonts/inter/Inter-MediumItalic.otf'),
'Inter-SemiBold': require('../../assets/fonts/inter/Inter-SemiBold.otf'),
'Inter-SemiBoldItalic': require('../../assets/fonts/inter/Inter-SemiBoldItalic.otf'),
'Inter-Bold': require('../../assets/fonts/inter/Inter-Bold.otf'),
'Inter-BoldItalic': require('../../assets/fonts/inter/Inter-BoldItalic.otf'),
'Inter-ExtraBold': require('../../assets/fonts/inter/Inter-ExtraBold.otf'),
'Inter-ExtraBoldItalic': require('../../assets/fonts/inter/Inter-ExtraBoldItalic.otf'),
'Inter-Black': require('../../assets/fonts/inter/Inter-Black.otf'),
'Inter-BlackItalic': require('../../assets/fonts/inter/Inter-BlackItalic.otf'),
})
}
export function applyFonts(style: Record<string, any>) {
style.fontFamily =
{
'100': 'Inter-Thin',
'200': 'Inter-ExtraLight',
'300': 'Inter-Light',
'400': 'Inter-Regular',
'500': 'Inter-Medium',
'600': 'Inter-SemiBold',
'700': 'Inter-Bold',
'800': 'Inter-ExtraBold',
'900': 'Inter-Black',
}[style.fontWeight as string] || 'Inter-Regular'
if (style.fontStyle === 'italic') {
style.fontFamily += 'Italic'
}
}
+5 -1
View File
@@ -8,6 +8,7 @@ import {BLUE_HUE, GREEN_HUE, RED_HUE} from '#/alf/util/colorGeneration'
import * as fontScaling from '#/alf/util/fontScaling' import * as fontScaling from '#/alf/util/fontScaling'
export {atoms} from '#/alf/atoms' export {atoms} from '#/alf/atoms'
export * from '#/alf/fonts'
export * as tokens from '#/alf/tokens' export * as tokens from '#/alf/tokens'
export * from '#/alf/types' export * from '#/alf/types'
export * from '#/alf/util/flatten' export * from '#/alf/util/flatten'
@@ -51,7 +52,10 @@ export function ThemeProvider({
}: React.PropsWithChildren<{theme: ThemeName}>) { }: React.PropsWithChildren<{theme: ThemeName}>) {
const gate = useGate() const gate = useGate()
const [neue] = React.useState(() => gate('typography_neue')) const [neue] = React.useState(() => gate('typography_neue'))
const [fontScale, setFontScale] = React.useState(() => fontScaling.get()) const [fontScale, setFontScale] = React.useState(() => {
if (!neue) return 1
return fontScaling.get()
})
const setFontScaleAndPersist = React.useCallback( const setFontScaleAndPersist = React.useCallback(
(fontScale: number) => { (fontScale: number) => {
setFontScale(fontScale) setFontScale(fontScale)
+8 -3
View File
@@ -3,7 +3,7 @@ import {StyleProp, TextProps as RNTextProps, TextStyle} from 'react-native'
import {UITextView} from 'react-native-uitextview' import {UITextView} from 'react-native-uitextview'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
import {atoms, flatten, useAlf, useTheme, web} from '#/alf' import {applyFonts, atoms, flatten, useAlf, useTheme, web} from '#/alf'
export type TextProps = RNTextProps & { export type TextProps = RNTextProps & {
/** /**
@@ -36,7 +36,7 @@ export function leading<
*/ */
export function normalizeTextStyles( export function normalizeTextStyles(
styles: StyleProp<TextStyle>, styles: StyleProp<TextStyle>,
{fontScale}: {fontScale: number}, {fontScale, flags}: {fontScale: number; flags: {neue: boolean}},
) { ) {
const s = flatten(styles) const s = flatten(styles)
// should always be defined on these components // should always be defined on these components
@@ -50,6 +50,10 @@ export function normalizeTextStyles(
s.lineHeight = s.fontSize s.lineHeight = s.fontSize
} }
if (flags.neue) {
applyFonts(s)
}
return s return s
} }
@@ -57,10 +61,11 @@ export function normalizeTextStyles(
* Our main text component. Use this most of the time. * Our main text component. Use this most of the time.
*/ */
export function Text({style, selectable, ...rest}: TextProps) { export function Text({style, selectable, ...rest}: TextProps) {
const {fontScale} = useAlf() const {fontScale, flags} = useAlf()
const t = useTheme() const t = useTheme()
const s = normalizeTextStyles([atoms.text_sm, t.atoms.text, flatten(style)], { const s = normalizeTextStyles([atoms.text_sm, t.atoms.text, flatten(style)], {
fontScale, fontScale,
flags,
}) })
return <UITextView selectable={selectable} uiTextView style={s} {...rest} /> return <UITextView selectable={selectable} uiTextView style={s} {...rest} />
+12 -1
View File
@@ -54,7 +54,7 @@ import * as Toast from 'view/com/util/Toast'
import {UserAvatar} from 'view/com/util/UserAvatar' import {UserAvatar} from 'view/com/util/UserAvatar'
import {ScrollView} from 'view/com/util/Views' import {ScrollView} from 'view/com/util/Views'
import {DeactivateAccountDialog} from '#/screens/Settings/components/DeactivateAccountDialog' import {DeactivateAccountDialog} from '#/screens/Settings/components/DeactivateAccountDialog'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useAlf, useTheme} from '#/alf'
import {useDialogControl} from '#/components/Dialog' import {useDialogControl} from '#/components/Dialog'
import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings' import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings'
import {Email2FAToggle} from './Email2FAToggle' import {Email2FAToggle} from './Email2FAToggle'
@@ -133,6 +133,7 @@ function SettingsAccountCard({
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Settings'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'Settings'>
export function SettingsScreen({}: Props) { export function SettingsScreen({}: Props) {
const {setFontScale} = useAlf()
const queryClient = useQueryClient() const queryClient = useQueryClient()
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
@@ -819,6 +820,16 @@ export function SettingsScreen({}: Props) {
</TouchableOpacity> </TouchableOpacity>
{__DEV__ ? ( {__DEV__ ? (
<> <>
<TouchableOpacity
style={[pal.view, styles.linkCardNoIcon]}
onPress={() => setFontScale(0.9375)}
accessibilityRole="button"
accessibilityLabel={_(msg`Set test font scale`)}
accessibilityHint={_(msg`Set test font scale`)}>
<Text type="lg" style={pal.text}>
<Trans>Enable neue font scale</Trans>
</Text>
</TouchableOpacity>
<TouchableOpacity <TouchableOpacity
style={[pal.view, styles.linkCardNoIcon]} style={[pal.view, styles.linkCardNoIcon]}
onPress={onPressStorybook} onPress={onPressStorybook}
+7
View File
@@ -12221,6 +12221,13 @@ expo-file-system@^17.0.1, expo-file-system@~17.0.1:
resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-17.0.1.tgz#b9f8af8c1c06ec71d96fd7a0d2567fa9e1c88f15" resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-17.0.1.tgz#b9f8af8c1c06ec71d96fd7a0d2567fa9e1c88f15"
integrity sha512-dYpnZJqTGj6HCYJyXAgpFkQWsiCH3HY1ek2cFZVHFoEc5tLz9gmdEgTF6nFHurvmvfmXqxi7a5CXyVm0aFYJBw== integrity sha512-dYpnZJqTGj6HCYJyXAgpFkQWsiCH3HY1ek2cFZVHFoEc5tLz9gmdEgTF6nFHurvmvfmXqxi7a5CXyVm0aFYJBw==
expo-font@~12.0.10:
version "12.0.10"
resolved "https://registry.yarnpkg.com/expo-font/-/expo-font-12.0.10.tgz#62deaf1f46159d7839f01305f44079268781b1db"
integrity sha512-Q1i2NuYri3jy32zdnBaHHCya1wH1yMAsI+3CCmj9zlQzlhsS9Bdwcj2W3c5eU5FvH2hsNQy4O+O1NnM6o/pDaQ==
dependencies:
fontfaceobserver "^2.1.0"
expo-font@~12.0.5: expo-font@~12.0.5:
version "12.0.5" version "12.0.5"
resolved "https://registry.yarnpkg.com/expo-font/-/expo-font-12.0.5.tgz#3451c2bd3f98859b127a6484d3474a292889b93f" resolved "https://registry.yarnpkg.com/expo-font/-/expo-font-12.0.5.tgz#3451c2bd3f98859b127a6484d3474a292889b93f"