2023-01-16 14:34:15 +00:00
|
|
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
|
|
/* eslint-disable import/namespace */
|
2023-01-11 13:38:47 +00:00
|
|
|
import 'expo-dev-client'
|
|
|
|
|
2023-01-20 14:06:26 +00:00
|
|
|
import { useMemo, useState } from 'react'
|
2023-01-11 13:38:47 +00:00
|
|
|
|
2023-01-24 13:41:25 +00:00
|
|
|
import { useNavigation, useRoute } from '@react-navigation/native'
|
2023-01-20 14:06:26 +00:00
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
2023-01-24 13:41:25 +00:00
|
|
|
import { Heading, IconButton, Paragraph } from '@status-im/components'
|
2023-01-20 14:06:26 +00:00
|
|
|
import { Avatar } from '@status-im/components/src/avatar'
|
2023-04-14 21:27:05 +00:00
|
|
|
import { ArrowLeftIcon, MembersIcon } from '@status-im/icons'
|
2023-01-20 14:06:26 +00:00
|
|
|
import { Stack as View, TamaguiProvider } from '@tamagui/core'
|
2023-01-16 14:34:15 +00:00
|
|
|
import { useFonts } from 'expo-font'
|
2023-01-24 13:41:25 +00:00
|
|
|
import { Platform } from 'react-native'
|
2023-01-20 14:06:26 +00:00
|
|
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
|
|
import { AnimatePresence } from 'tamagui'
|
2023-01-11 13:38:47 +00:00
|
|
|
|
2023-01-20 14:06:26 +00:00
|
|
|
import { NavigationProvider } from './navigation/provider'
|
|
|
|
import { ChannelScreen } from './screens/channel'
|
|
|
|
import { HomeScreen } from './screens/home'
|
2023-01-11 13:38:47 +00:00
|
|
|
import tamaguiConfig from './tamagui.config'
|
|
|
|
|
2023-01-24 13:41:25 +00:00
|
|
|
import type { RouteProp } from '@react-navigation/native'
|
|
|
|
import type { HeaderBackButtonProps } from '@react-navigation/native-stack/lib/typescript/src/types'
|
|
|
|
|
|
|
|
export type RootStackParamList = {
|
|
|
|
Home: undefined
|
|
|
|
Channel: { channelId: string }
|
|
|
|
}
|
|
|
|
|
|
|
|
const Stack = createNativeStackNavigator<RootStackParamList>()
|
|
|
|
|
|
|
|
const CustomHeaderLeft = (props: HeaderBackButtonProps) => {
|
|
|
|
const navigation = useNavigation()
|
|
|
|
const route = useRoute<RouteProp<RootStackParamList, 'Channel'>>()
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<IconButton
|
2023-04-14 21:27:05 +00:00
|
|
|
icon={<ArrowLeftIcon size={20} />}
|
2023-01-24 13:41:25 +00:00
|
|
|
onPress={() => {
|
|
|
|
props.canGoBack && navigation.goBack()
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Paragraph weight="semibold" marginLeft={12}>
|
|
|
|
# {route.params.channelId || 'channel'}
|
|
|
|
</Paragraph>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2023-01-16 14:34:15 +00:00
|
|
|
|
2023-01-11 13:38:47 +00:00
|
|
|
export default function App() {
|
2023-01-20 14:06:26 +00:00
|
|
|
const [position, setPosition] = useState(0)
|
|
|
|
|
2023-01-16 14:34:15 +00:00
|
|
|
const [loaded] = useFonts({
|
|
|
|
Inter: require('@tamagui/font-inter/otf/Inter-Medium.otf'),
|
|
|
|
InterBold: require('@tamagui/font-inter/otf/Inter-Bold.otf'),
|
|
|
|
// Tamagui does this for you on web, but you need to do it manually on native. Only for the demo. We should seek a better solution.
|
|
|
|
UbuntuMono: require('./assets/fonts/UbuntuMono.ttf'),
|
|
|
|
})
|
|
|
|
|
2023-01-20 14:06:26 +00:00
|
|
|
const onScroll = event => {
|
|
|
|
if (event.nativeEvent.contentOffset.y > 90) {
|
|
|
|
setPosition(event.nativeEvent.contentOffset.y)
|
|
|
|
} else {
|
|
|
|
setPosition(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const showMinimizedHeader = useMemo(() => {
|
|
|
|
return position > 90
|
|
|
|
}, [position])
|
|
|
|
|
2023-01-16 14:34:15 +00:00
|
|
|
if (!loaded) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2023-01-11 13:38:47 +00:00
|
|
|
return (
|
2023-01-20 14:06:26 +00:00
|
|
|
<TamaguiProvider config={tamaguiConfig} defaultTheme="light">
|
|
|
|
<NavigationProvider>
|
|
|
|
<SafeAreaProvider>
|
2023-01-24 13:41:25 +00:00
|
|
|
<Stack.Navigator
|
|
|
|
screenOptions={{
|
|
|
|
animation: 'slide_from_right',
|
|
|
|
}}
|
|
|
|
>
|
2023-01-20 14:06:26 +00:00
|
|
|
<Stack.Screen
|
|
|
|
name="Home"
|
|
|
|
options={{
|
|
|
|
headerTransparent: true,
|
2023-01-24 13:41:25 +00:00
|
|
|
headerShadowVisible: false,
|
2023-01-20 14:06:26 +00:00
|
|
|
header: () => (
|
|
|
|
<View
|
|
|
|
height={100}
|
|
|
|
animation="fast"
|
|
|
|
backgroundColor={
|
|
|
|
showMinimizedHeader ? '$background' : 'transparent'
|
|
|
|
}
|
|
|
|
padding={16}
|
|
|
|
paddingTop={48}
|
|
|
|
flexDirection="row"
|
|
|
|
justifyContent="space-between"
|
|
|
|
alignItems="center"
|
|
|
|
>
|
|
|
|
<AnimatePresence>
|
|
|
|
{showMinimizedHeader && (
|
|
|
|
<View
|
|
|
|
key="header"
|
|
|
|
animation={[
|
|
|
|
'fast',
|
|
|
|
{
|
|
|
|
opacity: {
|
|
|
|
overshootClamping: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
enterStyle={{ opacity: 0 }}
|
|
|
|
exitStyle={{ opacity: 0 }}
|
|
|
|
opacity={1}
|
|
|
|
flexDirection="row"
|
|
|
|
alignItems="center"
|
|
|
|
justifyContent="space-between"
|
|
|
|
width="100%"
|
|
|
|
>
|
|
|
|
<Heading color="$textPrimary">Rarible</Heading>
|
|
|
|
<Avatar
|
|
|
|
src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.seadn.io%2Fgae%2FFG0QJ00fN3c_FWuPeUr9-T__iQl63j9hn5d6svW8UqOmia5zp3lKHPkJuHcvhZ0f_Pd6P2COo9tt9zVUvdPxG_9BBw%3Fw%3D500%26auto%3Dformat&f=1&nofb=1&ipt=c177cd71d8d0114080cfc6efd3f9e098ddaeb1b347919bd3089bf0aacb003b3e&ipo=images"
|
|
|
|
size={48}
|
2023-03-22 09:39:42 +00:00
|
|
|
outline
|
2023-01-20 14:06:26 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</AnimatePresence>
|
|
|
|
</View>
|
|
|
|
),
|
|
|
|
}}
|
2023-01-18 13:15:51 +00:00
|
|
|
>
|
2023-01-20 14:06:26 +00:00
|
|
|
{props => (
|
|
|
|
<HomeScreen
|
|
|
|
{...props}
|
|
|
|
onScroll={onScroll}
|
|
|
|
isMinimized={showMinimizedHeader}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Stack.Screen>
|
|
|
|
<Stack.Screen
|
|
|
|
name="Channel"
|
|
|
|
component={ChannelScreen}
|
2023-01-24 13:41:25 +00:00
|
|
|
options={{
|
|
|
|
headerBlurEffect: 'systemUltraThinMaterialLight',
|
|
|
|
headerStyle: {
|
|
|
|
backgroundColor: Platform.select({
|
|
|
|
ios: 'transparent',
|
|
|
|
default: 'white',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
headerTransparent: true,
|
|
|
|
headerShadowVisible: false,
|
|
|
|
headerTitle: '',
|
|
|
|
headerLeft(props) {
|
|
|
|
return <CustomHeaderLeft {...props} />
|
|
|
|
},
|
|
|
|
headerRight() {
|
|
|
|
return (
|
|
|
|
<IconButton
|
2023-04-14 21:27:05 +00:00
|
|
|
icon={<MembersIcon size={20} />}
|
2023-01-24 13:41:25 +00:00
|
|
|
onPress={() => {
|
|
|
|
// noop
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}}
|
2023-01-20 14:06:26 +00:00
|
|
|
/>
|
|
|
|
</Stack.Navigator>
|
|
|
|
</SafeAreaProvider>
|
|
|
|
</NavigationProvider>
|
2023-01-11 13:38:47 +00:00
|
|
|
</TamaguiProvider>
|
|
|
|
)
|
|
|
|
}
|