1
0
mirror of https://github.com/tooot-app/app synced 2025-02-10 00:40:51 +01:00

Restructure the project

This commit is contained in:
Zhiyuan Zheng 2020-11-21 13:19:05 +01:00
parent 3280663144
commit 40266b8ce3
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
42 changed files with 252 additions and 6619 deletions

View File

@ -1,7 +1,9 @@
import React from 'react' import React from 'react'
import { QueryCache, ReactQueryCacheProvider, setConsole } from 'react-query' import { QueryCache, ReactQueryCacheProvider, setConsole } from 'react-query'
import { Provider } from 'react-redux'
import { Index } from 'src/Index' import { Index } from 'src/Index'
import store from 'src/store'
const queryCache = new QueryCache() const queryCache = new QueryCache()
@ -18,7 +20,9 @@ if (__DEV__) {
const App: React.FC = () => ( const App: React.FC = () => (
<ReactQueryCacheProvider queryCache={queryCache}> <ReactQueryCacheProvider queryCache={queryCache}>
<Provider store={store}>
<Index /> <Index />
</Provider>
</ReactQueryCacheProvider> </ReactQueryCacheProvider>
) )

View File

@ -43,6 +43,8 @@
"react-navigation": "^4.4.3", "react-navigation": "^4.4.3",
"react-query": "^2.26.2", "react-query": "^2.26.2",
"react-redux": "^7.2.2", "react-redux": "^7.2.2",
"redux-persist": "^6.0.0",
"redux-persist-expo-securestore": "^2.0.0",
"tslib": "^2.0.3" "tslib": "^2.0.3"
}, },
"devDependencies": { "devDependencies": {

View File

@ -5,44 +5,39 @@ import { enableScreens } from 'react-native-screens'
import React from 'react' import React from 'react'
import { Feather } from '@expo/vector-icons' import { Feather } from '@expo/vector-icons'
import store from 'src/stacks/common/store'
import { Provider } from 'react-redux'
import Toast from 'react-native-toast-message'
import { StatusBar } from 'expo-status-bar'
import Local from 'src/stacks/Local' // @ts-ignore
import Public from 'src/stacks/Public' import Toast from 'react-native-toast-message'
import PostRoot from 'src/stacks/PostRoot'
import Notifications from 'src/stacks/Notifications' import ScreenLocal from 'src/screens/Local'
import Me from 'src/stacks/Me' import ScreenPublic from 'src/screens/Public'
import ScreenNotifications from 'src/screens/Notifications'
import ScreenMe from 'src/screens/Me'
enableScreens() enableScreens()
const Tab = createBottomTabNavigator() const Tab = createBottomTabNavigator()
export const Index: React.FC = () => { export const Index: React.FC = () => {
return ( return (
<Provider store={store}>
<StatusBar style='auto' />
<NavigationContainer> <NavigationContainer>
<Tab.Navigator <Tab.Navigator
screenOptions={({ route }) => ({ screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => { tabBarIcon: ({ focused, color, size }) => {
let name: string let name: string
switch (route.name) { switch (route.name) {
case 'Local': case 'Screen-Local':
name = 'home' name = 'home'
break break
case 'Public': case 'Screen-Public':
name = 'globe' name = 'globe'
break break
case 'PostRoot': case 'Screen-Post':
name = 'plus' name = 'plus'
break break
case 'Notifications': case 'Screen-Notifications':
name = 'bell' name = 'bell'
break break
case 'Me': case 'Screen-Me':
name = focused ? 'smile' : 'meh' name = focused ? 'smile' : 'meh'
break break
default: default:
@ -58,11 +53,11 @@ export const Index: React.FC = () => {
showLabel: false showLabel: false
}} }}
> >
<Tab.Screen name='Local' component={Local} /> <Tab.Screen name='Screen-Local' component={ScreenLocal} />
<Tab.Screen name='Public' component={Public} /> <Tab.Screen name='Screen-Public' component={ScreenPublic} />
<Tab.Screen <Tab.Screen
name='PostRoot' name='Screen-Post'
component={PostRoot} component={() => <></>}
listeners={({ navigation, route }) => ({ listeners={({ navigation, route }) => ({
tabPress: e => { tabPress: e => {
e.preventDefault() e.preventDefault()
@ -76,12 +71,11 @@ export const Index: React.FC = () => {
} }
})} })}
/> />
<Tab.Screen name='Notifications' component={Notifications} /> <Tab.Screen name='Screen-Notifications' component={ScreenNotifications} />
<Tab.Screen name='Me' component={Me} /> <Tab.Screen name='Screen-Me' component={ScreenMe} />
</Tab.Navigator> </Tab.Navigator>
<Toast ref={(ref: any) => Toast.setRef(ref)} /> <Toast ref={(ref: any) => Toast.setRef(ref)} />
</NavigationContainer> </NavigationContainer>
</Provider>
) )
} }

View File

@ -1,4 +1,4 @@
import store, { RootState } from 'src/stacks/common/store' import store, { RootState } from 'src/store'
import ky from 'ky' import ky from 'ky'
const client = async ({ const client = async ({

View File

@ -13,8 +13,8 @@ import { useMutation, useQueryCache } from 'react-query'
import { Feather } from '@expo/vector-icons' import { Feather } from '@expo/vector-icons'
import client from 'src/api/client' import client from 'src/api/client'
import { getLocalAccountId } from 'src/stacks/common/instancesSlice' import { getLocalAccountId } from 'src/utils/slices/instancesSlice'
import store from 'src/stacks/common/store' import store from 'src/store'
const fireMutation = async ({ const fireMutation = async ({
id, id,

View File

@ -12,8 +12,8 @@ import { useSelector } from 'react-redux'
import { import {
getLocalAccountId, getLocalAccountId,
getLocalUrl getLocalUrl
} from 'src/stacks/common/instancesSlice' } from 'src/utils/slices/instancesSlice'
import store from 'src/stacks/common/store' import store from 'src/store'
const fireMutation = async ({ const fireMutation = async ({
id, id,

View File

@ -1,10 +1,10 @@
import React from 'react' import React from 'react'
import TimelinesCombined from 'src/stacks/common/TimelinesCombined' import Timelines from 'src/screens/Timelines/Timelines'
const Local: React.FC = () => { const ScreenLocal: React.FC = () => {
return ( return (
<TimelinesCombined <Timelines
name='Local' name='Local'
content={[ content={[
{ title: '关注', page: 'Following' }, { title: '关注', page: 'Following' },
@ -14,4 +14,4 @@ const Local: React.FC = () => {
) )
} }
export default Local export default ScreenLocal

19
src/screens/Me.tsx Normal file
View File

@ -0,0 +1,19 @@
import React from 'react'
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import ScreenMeRoot from 'src/screens/Me/Root'
import sharedScreens from 'src/screens/Shared/sharedScreens'
const Stack = createNativeStackNavigator()
const ScreenMe: React.FC = () => {
return (
<Stack.Navigator>
<Stack.Screen name='Screen-Me-Root' component={ScreenMeRoot} />
{sharedScreens(Stack)}
</Stack.Navigator>
)
}
export default ScreenMe

14
src/screens/Me/Root.tsx Normal file
View File

@ -0,0 +1,14 @@
import React from 'react'
import { View } from 'react-native'
import store from 'src/store'
import { getLocalRegistered } from 'src/utils/slices/instancesSlice'
import Login from './Root/Login'
const ScreenMeRoot: React.FC = () => {
const localRegistered = getLocalRegistered(store.getState())
return <View>{localRegistered ? <></> : <Login />}</View>
}
export default ScreenMeRoot

View File

@ -3,14 +3,14 @@ import { Button, Text, TextInput, View } from 'react-native'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import { instanceFetch } from 'src/stacks/common/instanceFetch' import { instanceFetch } from 'src/utils/fetches/instanceFetch'
import client from 'src/api/client' import client from 'src/api/client'
import * as AuthSession from 'expo-auth-session' import * as AuthSession from 'expo-auth-session'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { updateLocal } from 'src/stacks/common/instancesSlice' import { updateLocal } from 'src/utils/slices/instancesSlice'
import { useNavigation } from '@react-navigation/native' import { useNavigation } from '@react-navigation/native'
const Instance: React.FC = () => { const Login: React.FC = () => {
const navigation = useNavigation() const navigation = useNavigation()
const dispatch = useDispatch() const dispatch = useDispatch()
const [instance, setInstance] = useState('') const [instance, setInstance] = useState('')
@ -142,4 +142,4 @@ const Instance: React.FC = () => {
) )
} }
export default Instance export default Login

View File

@ -2,12 +2,12 @@ import React, { useEffect, useState } from 'react'
import { createNativeStackNavigator } from 'react-native-screens/native-stack' import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import { Feather } from '@expo/vector-icons' import { Feather } from '@expo/vector-icons'
import Timeline from 'src/stacks/common/Timeline' import Timeline from 'src/screens/Timelines/Timeline'
import sharedScreens from 'src/stacks/Shared/sharedScreens' import sharedScreens from 'src/screens/Shared/sharedScreens'
const Stack = createNativeStackNavigator() const Stack = createNativeStackNavigator()
const Notifications: React.FC = () => { const ScreenNotifications: React.FC = () => {
const [renderHeader, setRenderHeader] = useState(false) const [renderHeader, setRenderHeader] = useState(false)
useEffect(() => { useEffect(() => {
@ -34,4 +34,4 @@ const Notifications: React.FC = () => {
) )
} }
export default Notifications export default ScreenNotifications

View File

@ -1,10 +1,10 @@
import React from 'react' import React from 'react'
import TimelinesCombined from 'src/stacks/common/TimelinesCombined' import Timelines from 'src/screens/Timelines/Timelines'
const Public: React.FC = () => { const ScreenPublic: React.FC = () => {
return ( return (
<TimelinesCombined <Timelines
name='Public' name='Public'
content={[ content={[
{ title: '跨站', page: 'LocalPublic' }, { title: '跨站', page: 'LocalPublic' },
@ -14,4 +14,4 @@ const Public: React.FC = () => {
) )
} }
export default Public export default ScreenPublic

View File

@ -14,9 +14,9 @@ import { Feather } from '@expo/vector-icons'
// import * as relationshipsSlice from 'src/stacks/common/relationshipsSlice' // import * as relationshipsSlice from 'src/stacks/common/relationshipsSlice'
import ParseContent from 'src/components/ParseContent' import ParseContent from 'src/components/ParseContent'
import Timeline from 'src/stacks/common/Timeline' import Timeline from 'src/screens/Timelines/Timeline'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { accountFetch } from '../common/accountFetch' import { accountFetch } from '../../utils/fetches/accountFetch'
// Moved account example: https://m.cmx.im/web/accounts/27812 // Moved account example: https://m.cmx.im/web/accounts/27812
@ -117,7 +117,11 @@ const Toots = ({ account }: { account: string }) => {
) )
const horizontalPaging = useRef<any>() const horizontalPaging = useRef<any>()
const pages = ['Account_Default', 'Account_All', 'Account_Media'] const pages: ['Account_Default', 'Account_All', 'Account_Media'] = [
'Account_Default',
'Account_All',
'Account_Media'
]
return ( return (
<> <>
@ -184,7 +188,7 @@ export interface Props {
} }
} }
const Account: React.FC<Props> = ({ const ScreenSharedAccount: React.FC<Props> = ({
route: { route: {
params: { id } params: { id }
} }
@ -253,4 +257,4 @@ const styles = StyleSheet.create({
} }
}) })
export default Account export default ScreenSharedAccount

View File

@ -10,10 +10,10 @@ import { SafeAreaView } from 'react-native-safe-area-context'
import { createNativeStackNavigator } from 'react-native-screens/native-stack' import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import { useNavigation } from '@react-navigation/native' import { useNavigation } from '@react-navigation/native'
import store from 'src/stacks/common/store' import store from 'src/store'
import PostMain from './PostToot/PostMain' import PostMain from './Compose/PostMain'
import client from 'src/api/client' import client from 'src/api/client'
import { getLocalAccountPreferences } from '../common/instancesSlice' import { getLocalAccountPreferences } from 'src/utils/slices/instancesSlice'
const Stack = createNativeStackNavigator() const Stack = createNativeStackNavigator()

View File

@ -2,7 +2,7 @@ import React, { Dispatch } from 'react'
import { Image, StyleSheet, View } from 'react-native' import { Image, StyleSheet, View } from 'react-native'
import { Feather } from '@expo/vector-icons' import { Feather } from '@expo/vector-icons'
import { PostAction, PostState } from '../PostToot' import { PostAction, PostState } from '../Compose'
export interface Props { export interface Props {
postState: PostState postState: PostState

View File

@ -1,7 +1,7 @@
import React, { Dispatch } from 'react' import React, { Dispatch } from 'react'
import { Image, Pressable } from 'react-native' import { Image, Pressable } from 'react-native'
import { PostAction, PostState } from '../PostToot' import { PostAction, PostState } from '../Compose'
import updateText from './updateText' import updateText from './updateText'
export interface Props { export interface Props {

View File

@ -24,8 +24,8 @@ import Autolinker from 'src/modules/autolinker'
import PostEmojis from './PostEmojis' import PostEmojis from './PostEmojis'
import PostPoll from './PostPoll' import PostPoll from './PostPoll'
import PostSuggestions from './PostSuggestions' import PostSuggestions from './PostSuggestions'
import { emojisFetch } from 'src/stacks/common/emojisFetch' import { emojisFetch } from 'src/utils/fetches/emojisFetch'
import { PostAction, PostState } from 'src/stacks/Shared/PostToot' import { PostAction, PostState } from 'src/screens/Shared/Compose'
import addAttachments from './addAttachments' import addAttachments from './addAttachments'
import PostAttachments from './PostAttachments' import PostAttachments from './PostAttachments'

View File

@ -9,7 +9,7 @@ import {
} from 'react-native' } from 'react-native'
import { Feather } from '@expo/vector-icons' import { Feather } from '@expo/vector-icons'
import { PostAction, PostState } from '../PostToot' import { PostAction, PostState } from '../Compose'
export interface Props { export interface Props {
postState: PostState postState: PostState

View File

@ -3,8 +3,8 @@ import { ActivityIndicator, Pressable, Text } from 'react-native'
import { FlatList } from 'react-native-gesture-handler' import { FlatList } from 'react-native-gesture-handler'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { searchFetch } from '../../common/searchFetch' import { searchFetch } from 'src/utils/fetches/searchFetch'
import { PostAction, PostState } from '../PostToot' import { PostAction, PostState } from '../Compose'
import updateText from './updateText' import updateText from './updateText'
declare module 'react' { declare module 'react' {

View File

@ -3,7 +3,7 @@ import { ActionSheetIOS, Alert } from 'react-native'
import * as ImagePicker from 'expo-image-picker' import * as ImagePicker from 'expo-image-picker'
import { ImageInfo } from 'expo-image-picker/build/ImagePicker.types' import { ImageInfo } from 'expo-image-picker/build/ImagePicker.types'
import { PostAction, PostState } from '../PostToot' import { PostAction, PostState } from '../Compose'
import client from 'src/api/client' import client from 'src/api/client'
const uploadAttachment = async (uri: ImageInfo['uri']) => { const uploadAttachment = async (uri: ImageInfo['uri']) => {

View File

@ -1,4 +1,4 @@
import { PostState } from '../PostToot' import { PostState } from '../Compose'
const updateText = ({ const updateText = ({
onChangeText, onChangeText,

View File

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import Timeline from 'src/stacks/common/Timeline' import Timeline from 'src/screens/Timelines/Timeline'
// Show remote hashtag? Only when private, show local version? // Show remote hashtag? Only when private, show local version?
@ -12,7 +12,7 @@ export interface Props {
} }
} }
const Hashtag: React.FC<Props> = ({ const ScreenSharedHashtag: React.FC<Props> = ({
route: { route: {
params: { hashtag } params: { hashtag }
} }
@ -20,4 +20,4 @@ const Hashtag: React.FC<Props> = ({
return <Timeline page='Hashtag' hashtag={hashtag} /> return <Timeline page='Hashtag' hashtag={hashtag} />
} }
export default Hashtag export default ScreenSharedHashtag

View File

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import Timeline from 'src/stacks/common/Timeline' import Timeline from 'src/screens/Timelines/Timeline'
// Show remote hashtag? Only when private, show local version? // Show remote hashtag? Only when private, show local version?
@ -12,7 +12,7 @@ export interface Props {
} }
} }
const Toot: React.FC<Props> = ({ const ScreenSharedToot: React.FC<Props> = ({
route: { route: {
params: { toot } params: { toot }
} }
@ -20,4 +20,4 @@ const Toot: React.FC<Props> = ({
return <Timeline page='Toot' toot={toot} disableRefresh /> return <Timeline page='Toot' toot={toot} disableRefresh />
} }
export default Toot export default ScreenSharedToot

View File

@ -11,7 +11,7 @@ export interface Props {
} }
} }
const Webview: React.FC<Props> = ({ const ScreenSharedWebview: React.FC<Props> = ({
route: { route: {
params: { uri } params: { uri }
} }
@ -19,4 +19,4 @@ const Webview: React.FC<Props> = ({
return <WebView source={{ uri: uri }} /> return <WebView source={{ uri: uri }} />
} }
export default Webview export default ScreenSharedWebview

View File

@ -0,0 +1,56 @@
import React from 'react'
import ScreenSharedAccount from 'src/screens/Shared/Account'
import ScreenSharedHashtag from 'src/screens/Shared/Hashtag'
import ScreenSharedToot from 'src/screens/Shared/Toot'
import ScreenSharedWebview from 'src/screens/Shared/Webview'
import PostToot from 'src/screens/Shared/Compose'
const sharedScreens = (Stack: any) => {
return [
<Stack.Screen
key='Screen-Shared-Account'
name='Screen-Shared-Account'
component={ScreenSharedAccount}
options={{
headerTranslucent: true,
headerStyle: { backgroundColor: 'rgba(255, 255, 255, 0)' },
headerCenter: () => {}
}}
/>,
<Stack.Screen
key='Screen-Shared-Hashtag'
name='Screen-Shared-Hashtag'
component={ScreenSharedHashtag}
options={({ route }: any) => ({
title: `#${decodeURIComponent(route.params.hashtag)}`
})}
/>,
<Stack.Screen
key='Screen-Shared-Toot'
name='Screen-Shared-Toot'
component={ScreenSharedToot}
options={() => ({
title: '对话'
})}
/>,
<Stack.Screen
key='Screen-Shared-Webview'
name='Screen-Shared-Webview'
component={ScreenSharedWebview}
// options={({ route }) => ({
// title: `${route.params.domain}`
// })}
/>,
<Stack.Screen
key='Screen-Shared-PostToot'
name='Screen-Shared-PostToot'
component={PostToot}
options={{
stackPresentation: 'fullScreenModal'
}}
/>
]
}
export default sharedScreens

View File

@ -4,7 +4,7 @@ import { setFocusHandler, useInfiniteQuery } from 'react-query'
import StatusInNotifications from 'src/components/StatusInNotifications' import StatusInNotifications from 'src/components/StatusInNotifications'
import StatusInTimeline from 'src/components/StatusInTimeline' import StatusInTimeline from 'src/components/StatusInTimeline'
import { timelineFetch } from './timelineFetch' import { timelineFetch } from 'src/utils/fetches/timelineFetch'
// Opening nesting hashtag pages // Opening nesting hashtag pages

View File

@ -1,20 +1,31 @@
import React, { useEffect, useRef, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'
import { Dimensions, FlatList, Text, View } from 'react-native' import { Dimensions, FlatList, Text, View } from 'react-native'
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import SegmentedControl from '@react-native-community/segmented-control' import SegmentedControl from '@react-native-community/segmented-control'
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import { useSelector } from 'react-redux'
import { Feather } from '@expo/vector-icons' import { Feather } from '@expo/vector-icons'
import Timeline from './Timeline' import Timeline from './Timeline'
import sharedScreens from 'src/stacks/Shared/sharedScreens' import sharedScreens from 'src/screens/Shared/sharedScreens'
import { getLocalRegistered } from './instancesSlice' import { InstancesState } from 'src/utils/slices/instancesSlice'
import store from './store' import { RootState } from 'src/store'
const Stack = createNativeStackNavigator() const Stack = createNativeStackNavigator()
const Page = ({ item: { page } }: { item: { page: App.Pages } }) => { const Page = ({
item: { page },
localRegistered
}: {
item: { page: App.Pages }
localRegistered: InstancesState['local']['url'] | undefined
}) => {
return ( return (
<View style={{ width: Dimensions.get('window').width }}> <View style={{ width: Dimensions.get('window').width }}>
{localRegistered || page === 'RemotePublic' ? (
<Timeline page={page} /> <Timeline page={page} />
) : (
<Text></Text>
)}
</View> </View>
) )
} }
@ -24,8 +35,10 @@ export interface Props {
content: { title: string; page: App.Pages }[] content: { title: string; page: App.Pages }[]
} }
const TimelinesCombined: React.FC<Props> = ({ name, content }) => { const Timelines: React.FC<Props> = ({ name, content }) => {
const localRegistered = getLocalRegistered(store.getState()) const localRegistered = useSelector(
(state: RootState) => state.instances.local.url
)
const [segment, setSegment] = useState(0) const [segment, setSegment] = useState(0)
const [renderHeader, setRenderHeader] = useState(false) const [renderHeader, setRenderHeader] = useState(false)
const [segmentManuallyTriggered, setSegmentManuallyTriggered] = useState( const [segmentManuallyTriggered, setSegmentManuallyTriggered] = useState(
@ -37,7 +50,7 @@ const TimelinesCombined: React.FC<Props> = ({ name, content }) => {
return return
}, []) }, [])
const horizontalPaging = useRef(null!) const horizontalPaging = useRef<FlatList>(null!)
return ( return (
<Stack.Navigator> <Stack.Navigator>
@ -69,16 +82,11 @@ const TimelinesCombined: React.FC<Props> = ({ name, content }) => {
<FlatList <FlatList
style={{ width: Dimensions.get('window').width, height: '100%' }} style={{ width: Dimensions.get('window').width, height: '100%' }}
data={content} data={content}
extraData={localRegistered}
keyExtractor={({ page }) => page} keyExtractor={({ page }) => page}
renderItem={({ item, index }) => { renderItem={({ item, index }) => (
return localRegistered || item.page === 'RemotePublic' ? ( <Page key={index} item={item} localRegistered={localRegistered} />
<Page key={index} item={item} /> )}
) : (
<View style={{ width: Dimensions.get('window').width }}>
<Text></Text>
</View>
)
}}
ref={horizontalPaging} ref={horizontalPaging}
bounces={false} bounces={false}
getItemLayout={(data, index) => ({ getItemLayout={(data, index) => ({
@ -108,4 +116,4 @@ const TimelinesCombined: React.FC<Props> = ({ name, content }) => {
) )
} }
export default TimelinesCombined export default Timelines

View File

@ -1,33 +0,0 @@
import React from 'react'
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import Base from './Me/Base'
import Authentication from 'src/stacks/Me/Authentication'
import sharedScreens from 'src/stacks/Shared/sharedScreens'
const Stack = createNativeStackNavigator()
export type ScreenMe = {
'Me-Base': undefined
'Me-Authentication': undefined
}
const Me: React.FC = () => {
return (
<Stack.Navigator>
<Stack.Screen name='Me-Base' component={Base} />
<Stack.Screen
name='Me-Authentication'
component={Authentication}
options={{
stackPresentation: 'modal'
}}
/>
{sharedScreens(Stack)}
</Stack.Navigator>
)
}
export default Me

View File

@ -1,20 +0,0 @@
import React from 'react'
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import Instance from './Authentication/Instance'
const Stack = createNativeStackNavigator()
export type ScreenMeAuthentication = {
'Me-Authentication-Instance': undefined
}
const Base = () => {
return (
<Stack.Navigator>
<Stack.Screen name='Me-Authentication-Instance' component={Instance} />
</Stack.Navigator>
)
}
export default Base

View File

@ -1,19 +0,0 @@
import React from 'react'
import { Button, View } from 'react-native'
import { StackNavigationProp } from '@react-navigation/stack'
import { ScreenMe } from '../Me'
export interface Props {
navigation: StackNavigationProp<ScreenMe, 'Me-Base'>
}
const Base: React.FC<Props> = ({ navigation: { navigate } }) => {
return (
<View>
<Button title='登录' onPress={() => navigate('Me-Authentication')} />
</View>
)
}
export default Base

View File

@ -1,7 +0,0 @@
import React from 'react'
const PostRoot: React.FC = () => {
return <></>
}
export default PostRoot

View File

@ -1,56 +0,0 @@
import React from 'react'
import Account from 'src/stacks/Shared/Account'
import Hashtag from 'src/stacks/Shared/Hashtag'
import Toot from 'src/stacks/Shared/Toot'
import Webview from 'src/stacks/Shared/Webview'
import PostToot from './PostToot'
const sharedScreens = (Stack: any) => {
return [
<Stack.Screen
key='Account'
name='Account'
component={Account}
options={{
headerTranslucent: true,
headerStyle: { backgroundColor: 'rgba(255, 255, 255, 0)' },
headerCenter: () => {}
}}
/>,
<Stack.Screen
key='Hashtag'
name='Hashtag'
component={Hashtag}
options={({ route }: any) => ({
title: `#${decodeURIComponent(route.params.hashtag)}`
})}
/>,
<Stack.Screen
key='Toot'
name='Toot'
component={Toot}
options={() => ({
title: '对话'
})}
/>,
<Stack.Screen
key='Webview'
name='Webview'
component={Webview}
// options={({ route }) => ({
// title: `${route.params.domain}`
// })}
/>,
<Stack.Screen
key='PostToot'
name='PostToot'
component={PostToot}
options={{
stackPresentation: 'fullScreenModal'
}}
/>
]
}
export default sharedScreens

View File

@ -1,6 +1,6 @@
import { configureStore } from '@reduxjs/toolkit' import { configureStore } from '@reduxjs/toolkit'
import instancesSlice from 'src/stacks/common/instancesSlice' import instancesSlice from 'src/utils/slices/instancesSlice'
const store = configureStore({ const store = configureStore({
reducer: { reducer: {

View File

@ -1,26 +0,0 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
const getItem = async () => {
try {
const value = await AsyncStorage.getItem('@social.xmflsct.com')
if (!value) {
await AsyncStorage.setItem(
'@social.xmflsct.com',
'qjzJ0IjvZ1apsn0_wBkGcdjKgX7Dao9KEPhGwggPwAo'
)
}
return value
} catch (e) {
console.error('Get token error')
}
}
const getAllKeys = async () => {
try {
return await AsyncStorage.getAllKeys()
} catch (e) {
console.error('Get all keys error')
}
}
export default { getItem, getAllKeys }

View File

@ -1,8 +1,9 @@
import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit' import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import client from 'src/api/client'
import { RootState } from './store'
type InstancesState = { import { RootState } from 'src/store'
import client from 'src/api/client'
export type InstancesState = {
local: { local: {
url: string | undefined url: string | undefined
token: string | undefined token: string | undefined
@ -83,9 +84,6 @@ const instancesSlice = createSlice({
} }
}) })
export const getLocalRegistered = (state: RootState) =>
state.instances.local.url !== undefined &&
state.instances.local.token !== undefined
export const getLocalUrl = (state: RootState) => state.instances.local.url export const getLocalUrl = (state: RootState) => state.instances.local.url
export const getLocalAccountId = (state: RootState) => export const getLocalAccountId = (state: RootState) =>
state.instances.local.account.id state.instances.local.account.id

File diff suppressed because it is too large Load Diff

View File

@ -5166,6 +5166,16 @@ readable-stream@^3.1.1:
string_decoder "^1.1.1" string_decoder "^1.1.1"
util-deprecate "^1.0.1" util-deprecate "^1.0.1"
redux-persist-expo-securestore@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/redux-persist-expo-securestore/-/redux-persist-expo-securestore-2.0.0.tgz#990d8c007c39a9a624b6311d09952b6b221a548e"
integrity sha512-swD6sC6QCCHyKBV0hFQIBEiO8ph2Nc6Bs96hZ7Qq5iciO/Mk2T6ZDRR8e23jWDjGK5I8uCr4in7ZVb+RPbENQA==
redux-persist@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-6.0.0.tgz#b4d2972f9859597c130d40d4b146fecdab51b3a8"
integrity sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ==
redux-thunk@^2.3.0: redux-thunk@^2.3.0:
version "2.3.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"