mirror of
https://github.com/tooot-app/app
synced 2025-02-18 21:00:49 +01:00
Now can scroll to top
This commit is contained in:
parent
ce7563ecbc
commit
c1076b8e94
6
App.tsx
6
App.tsx
@ -55,10 +55,12 @@ const App: React.FC = () => {
|
||||
<AppearanceProvider>
|
||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
||||
<Provider store={store}>
|
||||
<PersistGate persistor={persistor}>
|
||||
<PersistGate
|
||||
persistor={persistor}
|
||||
onBeforeLift={() => setAppLoaded(true)}
|
||||
>
|
||||
{bootstrapped => {
|
||||
if (bootstrapped) {
|
||||
setAppLoaded(true)
|
||||
require('@root/i18n/i18n')
|
||||
return (
|
||||
<ThemeManager>
|
||||
|
@ -9,6 +9,7 @@ import { timelineFetch } from '@utils/fetches/timelineFetch'
|
||||
import TimelineSeparator from '@components/Timelines/Timeline/Separator'
|
||||
import TimelineEmpty from '@components/Timelines/Timeline/Empty'
|
||||
import TimelineEnd from '@components/Timelines/Timeline/Shared/End'
|
||||
import { useScrollToTop } from '@react-navigation/native'
|
||||
|
||||
export interface Props {
|
||||
page: App.Pages
|
||||
@ -148,6 +149,8 @@ const Timeline: React.FC<Props> = ({
|
||||
)
|
||||
}, [])
|
||||
|
||||
useScrollToTop(flRef)
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
ref={flRef}
|
||||
|
@ -31,27 +31,42 @@ const TimelineConversation: React.FC<Props> = ({
|
||||
)
|
||||
|
||||
const conversationChildren = useMemo(() => {
|
||||
return item.last_status && <TimelineContent status={item.last_status} />
|
||||
return (
|
||||
item.last_status && (
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.S + StyleConstants.Spacing.S
|
||||
}}
|
||||
>
|
||||
<TimelineContent
|
||||
status={item.last_status}
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<View style={styles.statusView}>
|
||||
<View style={styles.status}>
|
||||
<View style={styles.conversationView}>
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar account={item.accounts[0]} />
|
||||
<View style={styles.details}>
|
||||
<TimelineHeaderConversation
|
||||
queryKey={queryKey}
|
||||
id={item.id}
|
||||
account={item.accounts[0]}
|
||||
created_at={item.last_status?.created_at}
|
||||
/>
|
||||
<Pressable
|
||||
onPress={conversationOnPress}
|
||||
children={conversationChildren}
|
||||
/>
|
||||
</View>
|
||||
<TimelineHeaderConversation
|
||||
queryKey={queryKey}
|
||||
id={item.id}
|
||||
account={item.accounts[0]}
|
||||
created_at={item.last_status?.created_at}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Pressable
|
||||
onPress={conversationOnPress}
|
||||
children={conversationChildren}
|
||||
/>
|
||||
|
||||
<View
|
||||
style={{
|
||||
paddingLeft: highlighted
|
||||
@ -66,18 +81,15 @@ const TimelineConversation: React.FC<Props> = ({
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
statusView: {
|
||||
conversationView: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
padding: StyleConstants.Spacing.Global.PagePadding
|
||||
},
|
||||
status: {
|
||||
header: {
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
flexDirection: 'row'
|
||||
},
|
||||
details: {
|
||||
flex: 1,
|
||||
flexGrow: 1
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -46,14 +46,12 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
const tootChildren = useMemo(
|
||||
() => (
|
||||
<View
|
||||
style={[
|
||||
styles.content,
|
||||
{
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.S + StyleConstants.Spacing.S
|
||||
}
|
||||
]}
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.S + StyleConstants.Spacing.S
|
||||
}}
|
||||
>
|
||||
{actualStatus.content.length > 0 && (
|
||||
<TimelineContent status={actualStatus} highlighted={highlighted} />
|
||||
@ -75,10 +73,12 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
{item.reblog && (
|
||||
<TimelineActioned action='reblog' account={item.account} />
|
||||
)}
|
||||
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar account={actualStatus.account} />
|
||||
<TimelineHeaderDefault queryKey={queryKey} status={actualStatus} />
|
||||
</View>
|
||||
|
||||
<Pressable onPress={tootOnPress} children={tootChildren} />
|
||||
<View
|
||||
style={{
|
||||
@ -102,9 +102,6 @@ const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
flexDirection: 'row'
|
||||
},
|
||||
content: {
|
||||
paddingTop: StyleConstants.Spacing.S
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -16,32 +16,49 @@ import { StyleConstants } from '@utils/styles/constants'
|
||||
export interface Props {
|
||||
notification: Mastodon.Notification
|
||||
queryKey: App.QueryKey
|
||||
highlighted?: boolean
|
||||
}
|
||||
|
||||
const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
||||
const TimelineNotifications: React.FC<Props> = ({
|
||||
notification,
|
||||
queryKey,
|
||||
highlighted = false
|
||||
}) => {
|
||||
const navigation = useNavigation()
|
||||
const actualAccount = notification.status
|
||||
? notification.status.account
|
||||
: notification.account
|
||||
const contentWidth =
|
||||
Dimensions.get('window').width -
|
||||
StyleConstants.Spacing.Global.PagePadding * 2 - // Global page padding on both sides
|
||||
StyleConstants.Avatar.S - // Avatar width
|
||||
StyleConstants.Spacing.S // Avatar margin to the right
|
||||
const contentWidth = highlighted
|
||||
? Dimensions.get('window').width -
|
||||
StyleConstants.Spacing.Global.PagePadding * 2 // Global page padding on both sides
|
||||
: Dimensions.get('window').width -
|
||||
StyleConstants.Spacing.Global.PagePadding * 2 - // Global page padding on both sides
|
||||
StyleConstants.Avatar.S - // Avatar width
|
||||
StyleConstants.Spacing.S // Avatar margin to the right
|
||||
|
||||
const tootOnPress = useCallback(
|
||||
() =>
|
||||
navigation.navigate('Screen-Shared-Toot', {
|
||||
toot: notification
|
||||
toot: notification.status
|
||||
}),
|
||||
[]
|
||||
)
|
||||
const tootChildren = useMemo(
|
||||
() =>
|
||||
notification.status ? (
|
||||
<>
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.S + StyleConstants.Spacing.S
|
||||
}}
|
||||
>
|
||||
{notification.status.content.length > 0 && (
|
||||
<TimelineContent status={notification.status} />
|
||||
<TimelineContent
|
||||
status={notification.status}
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
)}
|
||||
{notification.status.poll && (
|
||||
<TimelinePoll queryKey={queryKey} status={notification.status} />
|
||||
@ -55,7 +72,7 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
||||
{notification.status.card && (
|
||||
<TimelineCard card={notification.status.card} />
|
||||
)}
|
||||
</>
|
||||
</View>
|
||||
) : null,
|
||||
[notification.status?.poll?.voted]
|
||||
)
|
||||
@ -68,33 +85,37 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
||||
notification
|
||||
/>
|
||||
|
||||
<View style={styles.notification}>
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar account={actualAccount} />
|
||||
<View style={styles.details}>
|
||||
<TimelineHeaderNotification notification={notification} />
|
||||
<Pressable onPress={tootOnPress} children={tootChildren} />
|
||||
{notification.status && (
|
||||
<TimelineActions queryKey={queryKey} status={notification.status} />
|
||||
)}
|
||||
</View>
|
||||
<TimelineHeaderNotification notification={notification} />
|
||||
</View>
|
||||
|
||||
<Pressable onPress={tootOnPress} children={tootChildren} />
|
||||
|
||||
{notification.status && (
|
||||
<View
|
||||
style={{
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.S + StyleConstants.Spacing.S
|
||||
}}
|
||||
>
|
||||
<TimelineActions queryKey={queryKey} status={notification.status} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
notificationView: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
padding: StyleConstants.Spacing.Global.PagePadding
|
||||
padding: StyleConstants.Spacing.Global.PagePadding,
|
||||
paddingBottom: StyleConstants.Spacing.M
|
||||
},
|
||||
notification: {
|
||||
header: {
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
flexDirection: 'row'
|
||||
},
|
||||
details: {
|
||||
flex: 1,
|
||||
flexGrow: 1
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import React, { useRef } from 'react'
|
||||
import { ScrollView } from 'react-native'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
@ -9,12 +9,16 @@ import MyInfo from '@screens/Me/Root/MyInfo'
|
||||
import Collections from '@screens/Me/Root/Collections'
|
||||
import Settings from '@screens/Me/Root/Settings'
|
||||
import Logout from '@screens/Me/Root/Logout'
|
||||
import { useScrollToTop } from '@react-navigation/native'
|
||||
|
||||
const ScreenMeRoot: React.FC = () => {
|
||||
const localRegistered = useSelector(getLocalUrl)
|
||||
|
||||
const scrollRef = useRef<ScrollView>(null)
|
||||
useScrollToTop(scrollRef)
|
||||
|
||||
return (
|
||||
<ScrollView keyboardShouldPersistTaps='handled'>
|
||||
<ScrollView ref={scrollRef} keyboardShouldPersistTaps='handled'>
|
||||
{localRegistered ? <MyInfo /> : <Login />}
|
||||
{localRegistered && <Collections />}
|
||||
<Settings />
|
||||
|
Loading…
x
Reference in New Issue
Block a user