mirror of
https://github.com/tooot-app/app
synced 2025-05-05 20:38:42 +02:00
Rewrite dynamic media width
This commit is contained in:
parent
66385fd0f4
commit
88323a1552
17
App.tsx
17
App.tsx
@ -1,3 +1,4 @@
|
|||||||
|
import NetInfo from '@react-native-community/netinfo'
|
||||||
import client from '@root/api/client'
|
import client from '@root/api/client'
|
||||||
import { Index } from '@root/Index'
|
import { Index } from '@root/Index'
|
||||||
import { persistor, store } from '@root/store'
|
import { persistor, store } from '@root/store'
|
||||||
@ -6,7 +7,7 @@ import ThemeManager from '@utils/styles/ThemeManager'
|
|||||||
import * as SplashScreen from 'expo-splash-screen'
|
import * as SplashScreen from 'expo-splash-screen'
|
||||||
import React, { useCallback, useEffect, useState } from 'react'
|
import React, { useCallback, useEffect, useState } from 'react'
|
||||||
import { enableScreens } from 'react-native-screens'
|
import { enableScreens } from 'react-native-screens'
|
||||||
import { QueryClient, QueryClientProvider } from 'react-query'
|
import { onlineManager, QueryClient, QueryClientProvider } from 'react-query'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import { PersistGate } from 'redux-persist/integration/react'
|
import { PersistGate } from 'redux-persist/integration/react'
|
||||||
import * as Sentry from 'sentry-expo'
|
import * as Sentry from 'sentry-expo'
|
||||||
@ -19,6 +20,12 @@ if (__DEV__) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// onlineManager.setEventListener(setOnline => {
|
||||||
|
// return NetInfo.addEventListener(state => {
|
||||||
|
// setOnline(state.isConnected)
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn:
|
dsn:
|
||||||
'https://c9e29aa05f774aca8f36def98244ce04@o389581.ingest.sentry.io/5571975',
|
'https://c9e29aa05f774aca8f36def98244ce04@o389581.ingest.sentry.io/5571975',
|
||||||
@ -30,7 +37,15 @@ const queryClient = new QueryClient()
|
|||||||
|
|
||||||
enableScreens()
|
enableScreens()
|
||||||
|
|
||||||
|
NetInfo.fetch().then(state => {
|
||||||
|
console.log('Connection type', state.type)
|
||||||
|
console.log('Is connected?', state.isConnected)
|
||||||
|
console.log('Is internet', state.isInternetReachable)
|
||||||
|
console.log('Details', state.details)
|
||||||
|
})
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
|
useEffect(() => onlineManager.setOnline(false), [])
|
||||||
const [appLoaded, setAppLoaded] = useState(false)
|
const [appLoaded, setAppLoaded] = useState(false)
|
||||||
const [startVerification, setStartVerification] = useState(false)
|
const [startVerification, setStartVerification] = useState(false)
|
||||||
const [localCorrupt, setLocalCorrupt] = useState(false)
|
const [localCorrupt, setLocalCorrupt] = useState(false)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/vector-icons": "^12.0.0",
|
"@expo/vector-icons": "^12.0.0",
|
||||||
"@react-native-community/masked-view": "0.1.10",
|
"@react-native-community/masked-view": "0.1.10",
|
||||||
|
"@react-native-community/netinfo": "^5.9.9",
|
||||||
"@react-native-community/segmented-control": "2.2.1",
|
"@react-native-community/segmented-control": "2.2.1",
|
||||||
"@react-native-community/slider": "3.0.3",
|
"@react-native-community/slider": "3.0.3",
|
||||||
"@react-navigation/bottom-tabs": "^5.11.2",
|
"@react-navigation/bottom-tabs": "^5.11.2",
|
||||||
|
@ -71,8 +71,9 @@ const HeaderRight: React.FC<Props> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
{...(!disabled && !loading && { onPress })}
|
onPress={onPress}
|
||||||
children={children}
|
children={children}
|
||||||
|
disabled={disabled || loading}
|
||||||
style={[
|
style={[
|
||||||
styles.base,
|
styles.base,
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ const TimelineDefault: React.FC<Props> = ({
|
|||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<Pressable style={styles.statusView} onPress={onPress} disabled={true}>
|
<Pressable style={styles.statusView} onPress={onPress}>
|
||||||
{item.reblog ? (
|
{item.reblog ? (
|
||||||
<TimelineActioned action='reblog' account={item.account} />
|
<TimelineActioned action='reblog' account={item.account} />
|
||||||
) : pinnedLength && index < pinnedLength ? (
|
) : pinnedLength && index < pinnedLength ? (
|
||||||
|
@ -125,26 +125,28 @@ const TimelineActions: React.FC<Props> = ({ queryKey, status, reblog }) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onPressReply = useCallback(() => {
|
const onPressReply = useCallback(
|
||||||
navigation.navigate(getCurrentTab(navigation), {
|
() =>
|
||||||
screen: 'Screen-Shared-Compose',
|
navigation.navigate(getCurrentTab(navigation), {
|
||||||
params: {
|
screen: 'Screen-Shared-Compose',
|
||||||
type: 'reply',
|
params: {
|
||||||
incomingStatus: status,
|
type: 'reply',
|
||||||
visibilityLock: status.visibility === 'direct'
|
incomingStatus: status,
|
||||||
}
|
visibilityLock: status.visibility === 'direct'
|
||||||
})
|
}
|
||||||
}, [])
|
}),
|
||||||
const onPressReblog = useCallback(() => {
|
[]
|
||||||
if (status.visibility !== 'private' && status.visibility !== 'direct') {
|
)
|
||||||
|
const onPressReblog = useCallback(
|
||||||
|
() =>
|
||||||
mutate({
|
mutate({
|
||||||
id: status.id,
|
id: status.id,
|
||||||
type: 'reblog',
|
type: 'reblog',
|
||||||
stateKey: 'reblogged',
|
stateKey: 'reblogged',
|
||||||
prevState: status.reblogged
|
prevState: status.reblogged
|
||||||
})
|
}),
|
||||||
}
|
[status.reblogged]
|
||||||
}, [status.reblogged])
|
)
|
||||||
const onPressFavourite = useCallback(
|
const onPressFavourite = useCallback(
|
||||||
() =>
|
() =>
|
||||||
mutate({
|
mutate({
|
||||||
@ -264,6 +266,9 @@ const TimelineActions: React.FC<Props> = ({ queryKey, status, reblog }) => {
|
|||||||
style={styles.action}
|
style={styles.action}
|
||||||
onPress={onPressReblog}
|
onPress={onPressReblog}
|
||||||
children={childrenReblog}
|
children={childrenReblog}
|
||||||
|
disabled={
|
||||||
|
status.visibility === 'private' || status.visibility === 'direct'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Pressable
|
<Pressable
|
||||||
|
@ -95,12 +95,7 @@ const TimelineAttachment: React.FC<Props> = ({ status, contentWidth }) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={styles.base}>
|
||||||
style={[
|
|
||||||
styles.base,
|
|
||||||
{ width: contentWidth, height: (contentWidth / 16) * 9 }
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
{attachments}
|
{attachments}
|
||||||
|
|
||||||
{status.sensitive &&
|
{status.sensitive &&
|
||||||
@ -150,8 +145,13 @@ const styles = StyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
|
justifyContent: 'center',
|
||||||
alignContent: 'stretch'
|
alignContent: 'stretch'
|
||||||
},
|
},
|
||||||
|
container: {
|
||||||
|
flexBasis: '50%',
|
||||||
|
aspectRatio: 16 / 9
|
||||||
|
},
|
||||||
sensitiveBlur: {
|
sensitiveBlur: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -44,7 +44,7 @@ const AttachmentAudio: React.FC<Props> = ({ sensitiveShown, audio }) => {
|
|||||||
}, [audioPlayer])
|
}, [audioPlayer])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<View style={styles.base}>
|
||||||
<View style={styles.overlay}>
|
<View style={styles.overlay}>
|
||||||
{sensitiveShown ? (
|
{sensitiveShown ? (
|
||||||
audio.blurhash && (
|
audio.blurhash && (
|
||||||
@ -67,8 +67,9 @@ const AttachmentAudio: React.FC<Props> = ({ sensitiveShown, audio }) => {
|
|||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
type='icon'
|
type='icon'
|
||||||
content={audioPlaying ? 'pause' : 'play'}
|
content={audioPlaying ? 'pause-circle' : 'play-circle'}
|
||||||
size='L'
|
size='L'
|
||||||
|
round
|
||||||
overlay
|
overlay
|
||||||
{...(audioPlaying
|
{...(audioPlaying
|
||||||
? { onPress: pauseAudio }
|
? { onPress: pauseAudio }
|
||||||
@ -79,8 +80,9 @@ const AttachmentAudio: React.FC<Props> = ({ sensitiveShown, audio }) => {
|
|||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
position: 'absolute',
|
||||||
alignSelf: 'flex-end',
|
bottom: 0,
|
||||||
|
width: '100%',
|
||||||
backgroundColor: theme.backgroundOverlay,
|
backgroundColor: theme.backgroundOverlay,
|
||||||
paddingHorizontal: StyleConstants.Spacing.Global.PagePadding,
|
paddingHorizontal: StyleConstants.Spacing.Global.PagePadding,
|
||||||
paddingVertical: StyleConstants.Spacing.XS,
|
paddingVertical: StyleConstants.Spacing.XS,
|
||||||
@ -106,11 +108,17 @@ const AttachmentAudio: React.FC<Props> = ({ sensitiveShown, audio }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
base: {
|
||||||
|
flex: 1,
|
||||||
|
flexBasis: '50%',
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
padding: StyleConstants.Spacing.XS / 2
|
||||||
|
},
|
||||||
background: { position: 'absolute', width: '100%', height: '100%' },
|
background: { position: 'absolute', width: '100%', height: '100%' },
|
||||||
overlay: {
|
overlay: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -72,25 +72,23 @@ const AttachmentImage: React.FC<Props> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}, [imageVisible, sensitiveShown])
|
}, [imageVisible, sensitiveShown])
|
||||||
const onPress = useCallback(() => {
|
const onPress = useCallback(() => navigateToImagesViewer(imageIndex), [])
|
||||||
if (imageVisible && !sensitiveShown) {
|
|
||||||
navigateToImagesViewer(imageIndex)
|
|
||||||
}
|
|
||||||
}, [imageVisible, sensitiveShown])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
style={[styles.imageContainer]}
|
style={[styles.base]}
|
||||||
children={children}
|
children={children}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
|
disabled={!imageVisible || sensitiveShown}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
imageContainer: {
|
base: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexBasis: '50%',
|
flexBasis: '50%',
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
padding: StyleConstants.Spacing.XS / 2
|
padding: StyleConstants.Spacing.XS / 2
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React, { useCallback, useRef, useState } from 'react'
|
import React, { useCallback, useRef, useState } from 'react'
|
||||||
import { Pressable, StyleSheet } from 'react-native'
|
import { Pressable, StyleSheet, View } from 'react-native'
|
||||||
import { Video } from 'expo-av'
|
import { Video } from 'expo-av'
|
||||||
import Button from '@components/Button'
|
import Button from '@components/Button'
|
||||||
import { Surface } from 'gl-react-expo'
|
import { Surface } from 'gl-react-expo'
|
||||||
import { Blurhash } from 'gl-react-blurhash'
|
import { Blurhash } from 'gl-react-blurhash'
|
||||||
|
import { StyleConstants } from '@root/utils/styles/constants'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
sensitiveShown: boolean
|
sensitiveShown: boolean
|
||||||
@ -41,16 +42,17 @@ const AttachmentVideo: React.FC<Props> = ({
|
|||||||
}, [videoLoaded, videoPosition])
|
}, [videoLoaded, videoPosition])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<View style={styles.base}>
|
||||||
<Video
|
<Video
|
||||||
ref={videoPlayer}
|
ref={videoPlayer}
|
||||||
style={{
|
style={{
|
||||||
width,
|
width: '100%',
|
||||||
height
|
height: '100%'
|
||||||
}}
|
}}
|
||||||
resizeMode='cover'
|
resizeMode='cover'
|
||||||
usePoster
|
usePoster
|
||||||
posterSource={{ uri: video.preview_url }}
|
posterSource={{ uri: video.preview_url }}
|
||||||
|
posterStyle={{ flex: 1 }}
|
||||||
useNativeControls={false}
|
useNativeControls={false}
|
||||||
/>
|
/>
|
||||||
<Pressable style={styles.overlay}>
|
<Pressable style={styles.overlay}>
|
||||||
@ -66,18 +68,25 @@ const AttachmentVideo: React.FC<Props> = ({
|
|||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
type='icon'
|
type='icon'
|
||||||
content='play'
|
content='play-circle'
|
||||||
size='L'
|
size='L'
|
||||||
|
round
|
||||||
overlay
|
overlay
|
||||||
onPress={playOnPress}
|
onPress={playOnPress}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
base: {
|
||||||
|
flex: 1,
|
||||||
|
flexBasis: '50%',
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
padding: StyleConstants.Spacing.XS / 2
|
||||||
|
},
|
||||||
overlay: {
|
overlay: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -3,7 +3,6 @@ import { Pressable, StyleSheet } from 'react-native'
|
|||||||
import { Image } from 'react-native-expo-image-cache'
|
import { Image } from 'react-native-expo-image-cache'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import { useTheme } from '@root/utils/styles/ThemeManager'
|
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
queryKey?: QueryKey.Timeline
|
queryKey?: QueryKey.Timeline
|
||||||
@ -11,7 +10,6 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TimelineAvatar: React.FC<Props> = ({ queryKey, account }) => {
|
const TimelineAvatar: React.FC<Props> = ({ queryKey, account }) => {
|
||||||
const { mode } = useTheme()
|
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation()
|
||||||
// Need to fix go back root
|
// Need to fix go back root
|
||||||
const onPress = useCallback(() => {
|
const onPress = useCallback(() => {
|
||||||
|
@ -1702,6 +1702,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.10.tgz#5dda643e19e587793bc2034dd9bf7398ad43d401"
|
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.10.tgz#5dda643e19e587793bc2034dd9bf7398ad43d401"
|
||||||
integrity sha512-rk4sWFsmtOw8oyx8SD3KSvawwaK7gRBSEIy2TAwURyGt+3TizssXP1r8nx3zY+R7v2vYYHXZ+k2/GULAT/bcaQ==
|
integrity sha512-rk4sWFsmtOw8oyx8SD3KSvawwaK7gRBSEIy2TAwURyGt+3TizssXP1r8nx3zY+R7v2vYYHXZ+k2/GULAT/bcaQ==
|
||||||
|
|
||||||
|
"@react-native-community/netinfo@^5.9.9":
|
||||||
|
version "5.9.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-5.9.9.tgz#5e022637f5e08bd74bf94a0c3315748acd4589f9"
|
||||||
|
integrity sha512-Gp0XV4BgabvzkL4Dp6JAsA2l9LcmgBAq3erCLdvRZmEFz7guCWTogQWVfFtl+IbU0uqfwfo9fm2+mQiwdudLCw==
|
||||||
|
|
||||||
"@react-native-community/segmented-control@2.2.1":
|
"@react-native-community/segmented-control@2.2.1":
|
||||||
version "2.2.1"
|
version "2.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@react-native-community/segmented-control/-/segmented-control-2.2.1.tgz#5ca418d78c5f6051353c9586918458713b88a83c"
|
resolved "https://registry.yarnpkg.com/@react-native-community/segmented-control/-/segmented-control-2.2.1.tgz#5ca418d78c5f6051353c9586918458713b88a83c"
|
||||||
@ -2175,7 +2180,7 @@
|
|||||||
hoist-non-react-statics "^3.3.0"
|
hoist-non-react-statics "^3.3.0"
|
||||||
redux "^4.0.0"
|
redux "^4.0.0"
|
||||||
|
|
||||||
"@types/react-test-renderer@*", "@types/react-test-renderer@^16.13.1":
|
"@types/react-test-renderer@*", "@types/react-test-renderer@^17.0.0":
|
||||||
version "17.0.0"
|
version "17.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-17.0.0.tgz#9be47b375eeb906fced37049e67284a438d56620"
|
resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-17.0.0.tgz#9be47b375eeb906fced37049e67284a438d56620"
|
||||||
integrity sha512-nvw+F81OmyzpyIE1S0xWpLonLUZCMewslPuA8BtjSKc5XEbn8zEQBXS7KuOLHTNnSOEM2Pum50gHOoZ62tqTRg==
|
integrity sha512-nvw+F81OmyzpyIE1S0xWpLonLUZCMewslPuA8BtjSKc5XEbn8zEQBXS7KuOLHTNnSOEM2Pum50gHOoZ62tqTRg==
|
||||||
|
Loading…
x
Reference in New Issue
Block a user