mirror of
https://github.com/tooot-app/app
synced 2025-02-17 04:10:46 +01:00
Updates
This commit is contained in:
parent
c7a4129b82
commit
d1f32524ba
2
src/@types/mastodon.d.ts
vendored
2
src/@types/mastodon.d.ts
vendored
@ -187,7 +187,7 @@ declare namespace mastodon {
|
|||||||
type Status = {
|
type Status = {
|
||||||
// Base
|
// Base
|
||||||
id: string
|
id: string
|
||||||
urk: string
|
url: string
|
||||||
created_at: string
|
created_at: string
|
||||||
account: Account
|
account: Account
|
||||||
content: string
|
content: string
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { Modal, Pressable, StyleSheet, Text, View } from 'react-native'
|
import {
|
||||||
|
ActionSheetIOS,
|
||||||
|
Clipboard,
|
||||||
|
Modal,
|
||||||
|
Pressable,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
View
|
||||||
|
} from 'react-native'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { Feather } from '@expo/vector-icons'
|
import { Feather } from '@expo/vector-icons'
|
||||||
|
|
||||||
import action from './action'
|
import action from './action'
|
||||||
|
import Success from './Responses/Success'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
id: string
|
id: string
|
||||||
|
url: string
|
||||||
replies_count: number
|
replies_count: number
|
||||||
reblogs_count: number
|
reblogs_count: number
|
||||||
reblogged?: boolean
|
reblogged?: boolean
|
||||||
@ -17,6 +27,7 @@ export interface Props {
|
|||||||
|
|
||||||
const Actions: React.FC<Props> = ({
|
const Actions: React.FC<Props> = ({
|
||||||
id,
|
id,
|
||||||
|
url,
|
||||||
replies_count,
|
replies_count,
|
||||||
reblogs_count,
|
reblogs_count,
|
||||||
reblogged,
|
reblogged,
|
||||||
@ -27,8 +38,19 @@ const Actions: React.FC<Props> = ({
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const [modalVisible, setModalVisible] = useState(false)
|
const [modalVisible, setModalVisible] = useState(false)
|
||||||
|
|
||||||
|
const [successMessage, setSuccessMessage] = useState()
|
||||||
|
useEffect(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setSuccessMessage(undefined)
|
||||||
|
console.log('ajwieorjawioejri')
|
||||||
|
}, 2000)
|
||||||
|
return () => {}
|
||||||
|
}, [successMessage])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Success message={successMessage} />
|
||||||
|
|
||||||
<View style={styles.actions}>
|
<View style={styles.actions}>
|
||||||
<Pressable style={styles.action}>
|
<Pressable style={styles.action}>
|
||||||
<Feather name='message-circle' color='gray' />
|
<Feather name='message-circle' color='gray' />
|
||||||
@ -96,7 +118,38 @@ const Actions: React.FC<Props> = ({
|
|||||||
onPress={() => setModalVisible(false)}
|
onPress={() => setModalVisible(false)}
|
||||||
>
|
>
|
||||||
<View style={styles.modalSheet}>
|
<View style={styles.modalSheet}>
|
||||||
<Text>分享,复制链接,(删除)</Text>
|
<Pressable
|
||||||
|
onPress={() =>
|
||||||
|
ActionSheetIOS.showShareActionSheetWithOptions(
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
excludedActivityTypes: [
|
||||||
|
'com.apple.UIKit.activity.Mail',
|
||||||
|
'com.apple.UIKit.activity.Print',
|
||||||
|
'com.apple.UIKit.activity.SaveToCameraRoll',
|
||||||
|
'com.apple.UIKit.activity.OpenInIBooks'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
() => {},
|
||||||
|
() => {
|
||||||
|
setModalVisible(false)
|
||||||
|
setSuccessMessage('分享成功!')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Text>分享</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable
|
||||||
|
onPress={() => {
|
||||||
|
Clipboard.setString(url)
|
||||||
|
// Success message
|
||||||
|
setModalVisible(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>复制链接</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Text>(删除)</Text>
|
||||||
<Text>(静音),(置顶)</Text>
|
<Text>(静音),(置顶)</Text>
|
||||||
<Text>静音用户,屏蔽用户,屏蔽域名,举报用户</Text>
|
<Text>静音用户,屏蔽用户,屏蔽域名,举报用户</Text>
|
||||||
</View>
|
</View>
|
||||||
|
62
src/components/Toot/Responses/Success.tsx
Normal file
62
src/components/Toot/Responses/Success.tsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react'
|
||||||
|
import { Animated, StyleSheet, Text, View } from 'react-native'
|
||||||
|
|
||||||
|
export interface Props {
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const Success: React.FC<Props> = ({ message }) => {
|
||||||
|
const fadeAnim = useRef(new Animated.Value(0)).current
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(message)
|
||||||
|
if (message !== undefined) {
|
||||||
|
fadeIn()
|
||||||
|
} else {
|
||||||
|
fadeOut()
|
||||||
|
}
|
||||||
|
}, [message])
|
||||||
|
|
||||||
|
const fadeIn = () => {
|
||||||
|
// Will change fadeAnim value to 1 in 5 seconds
|
||||||
|
Animated.timing(fadeAnim, {
|
||||||
|
useNativeDriver: false,
|
||||||
|
toValue: 300,
|
||||||
|
duration: 1000
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
const fadeOut = () => {
|
||||||
|
// Will change fadeAnim value to 0 in 5 seconds
|
||||||
|
Animated.timing(fadeAnim, {
|
||||||
|
useNativeDriver: false,
|
||||||
|
toValue: 400,
|
||||||
|
duration: 1000
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Animated.View
|
||||||
|
style={[
|
||||||
|
styles.success,
|
||||||
|
{
|
||||||
|
top: fadeAnim
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Text>{message}</Text>
|
||||||
|
</Animated.View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
success: {
|
||||||
|
width: '80%',
|
||||||
|
height: 25,
|
||||||
|
position: 'absolute',
|
||||||
|
top: 400,
|
||||||
|
backgroundColor: 'red',
|
||||||
|
zIndex: 50
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default Success
|
@ -17,7 +17,6 @@ const action = async ({
|
|||||||
stateKey: 'favourited' | 'reblogged' | 'bookmarked' | 'muted' | 'pinned'
|
stateKey: 'favourited' | 'reblogged' | 'bookmarked' | 'muted' | 'pinned'
|
||||||
statePrev: boolean
|
statePrev: boolean
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
console.log(stateKey + ' --- ' + statePrev)
|
|
||||||
const alert = {
|
const alert = {
|
||||||
title: 'This is a title',
|
title: 'This is a title',
|
||||||
message: 'This is a message'
|
message: 'This is a message'
|
||||||
@ -37,7 +36,6 @@ const action = async ({
|
|||||||
|
|
||||||
if (!res.body[stateKey] === statePrev) {
|
if (!res.body[stateKey] === statePrev) {
|
||||||
dispatch(updateStatus(res.body))
|
dispatch(updateStatus(res.body))
|
||||||
console.log('------ ' + res.body[stateKey])
|
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(alert.title, alert.message, [
|
Alert.alert(alert.title, alert.message, [
|
||||||
{ text: 'OK', onPress: () => console.log('OK Pressed') }
|
{ text: 'OK', onPress: () => console.log('OK Pressed') }
|
||||||
|
@ -20,7 +20,7 @@ const TootTimeline: React.FC<Props> = ({ toot }) => {
|
|||||||
|
|
||||||
let actualContent = toot.reblog ? toot.reblog : toot
|
let actualContent = toot.reblog ? toot.reblog : toot
|
||||||
|
|
||||||
// const tootView = useMemo(() => {
|
const tootView = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<View style={styles.tootTimeline}>
|
<View style={styles.tootTimeline}>
|
||||||
{toot.reblog && (
|
{toot.reblog && (
|
||||||
@ -76,6 +76,7 @@ const TootTimeline: React.FC<Props> = ({ toot }) => {
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
<Actions
|
<Actions
|
||||||
id={actualContent.id}
|
id={actualContent.id}
|
||||||
|
url={actualContent.url}
|
||||||
replies_count={actualContent.replies_count}
|
replies_count={actualContent.replies_count}
|
||||||
reblogs_count={actualContent.reblogs_count}
|
reblogs_count={actualContent.reblogs_count}
|
||||||
reblogged={actualContent.reblogged}
|
reblogged={actualContent.reblogged}
|
||||||
@ -87,9 +88,9 @@ const TootTimeline: React.FC<Props> = ({ toot }) => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
// }, [toot])
|
}, [toot])
|
||||||
|
|
||||||
// return tootView
|
return tootView
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -19,7 +19,6 @@ const Timeline: React.FC<{
|
|||||||
}> = ({ page, hashtag, list, toot, account, disableRefresh = false }) => {
|
}> = ({ page, hashtag, list, toot, account, disableRefresh = false }) => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const state = useSelector((state: RootState) => state.timelines[page])
|
const state = useSelector((state: RootState) => state.timelines[page])
|
||||||
const [updateStatus, setUpdateStatus] = useState(false)
|
|
||||||
const [timelineReady, setTimelineReady] = useState(false)
|
const [timelineReady, setTimelineReady] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -28,7 +27,6 @@ const Timeline: React.FC<{
|
|||||||
dispatch(fetch({ page, hashtag, list, toot, account }))
|
dispatch(fetch({ page, hashtag, list, toot, account }))
|
||||||
setTimelineReady(true)
|
setTimelineReady(true)
|
||||||
}
|
}
|
||||||
setUpdateStatus(!updateStatus)
|
|
||||||
return () => {
|
return () => {
|
||||||
mounted = false
|
mounted = false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user