mirror of
				https://github.com/tooot-app/app
				synced 2025-06-05 22:19:13 +02:00 
			
		
		
		
	Restructure the project
This commit is contained in:
		
							
								
								
									
										6
									
								
								App.tsx
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								App.tsx
									
									
									
									
									
								
							| @@ -1,7 +1,9 @@ | ||||
| import React from 'react' | ||||
| import { QueryCache, ReactQueryCacheProvider, setConsole } from 'react-query' | ||||
| import { Provider } from 'react-redux' | ||||
|  | ||||
| import { Index } from 'src/Index' | ||||
| import store from 'src/store' | ||||
|  | ||||
| const queryCache = new QueryCache() | ||||
|  | ||||
| @@ -18,7 +20,9 @@ if (__DEV__) { | ||||
|  | ||||
| const App: React.FC = () => ( | ||||
|   <ReactQueryCacheProvider queryCache={queryCache}> | ||||
|     <Index /> | ||||
|     <Provider store={store}> | ||||
|       <Index /> | ||||
|     </Provider> | ||||
|   </ReactQueryCacheProvider> | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -43,6 +43,8 @@ | ||||
|     "react-navigation": "^4.4.3", | ||||
|     "react-query": "^2.26.2", | ||||
|     "react-redux": "^7.2.2", | ||||
|     "redux-persist": "^6.0.0", | ||||
|     "redux-persist-expo-securestore": "^2.0.0", | ||||
|     "tslib": "^2.0.3" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|   | ||||
							
								
								
									
										130
									
								
								src/Index.tsx
									
									
									
									
									
								
							
							
						
						
									
										130
									
								
								src/Index.tsx
									
									
									
									
									
								
							| @@ -5,83 +5,77 @@ import { enableScreens } from 'react-native-screens' | ||||
|  | ||||
| import React from 'react' | ||||
| 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' | ||||
| import Public from 'src/stacks/Public' | ||||
| import PostRoot from 'src/stacks/PostRoot' | ||||
| import Notifications from 'src/stacks/Notifications' | ||||
| import Me from 'src/stacks/Me' | ||||
| // @ts-ignore | ||||
| import Toast from 'react-native-toast-message' | ||||
|  | ||||
| import ScreenLocal from 'src/screens/Local' | ||||
| import ScreenPublic from 'src/screens/Public' | ||||
| import ScreenNotifications from 'src/screens/Notifications' | ||||
| import ScreenMe from 'src/screens/Me' | ||||
|  | ||||
| enableScreens() | ||||
| const Tab = createBottomTabNavigator() | ||||
|  | ||||
| export const Index: React.FC = () => { | ||||
|   return ( | ||||
|     <Provider store={store}> | ||||
|       <StatusBar style='auto' /> | ||||
|  | ||||
|       <NavigationContainer> | ||||
|         <Tab.Navigator | ||||
|           screenOptions={({ route }) => ({ | ||||
|             tabBarIcon: ({ focused, color, size }) => { | ||||
|               let name: string | ||||
|               switch (route.name) { | ||||
|                 case 'Local': | ||||
|                   name = 'home' | ||||
|                   break | ||||
|                 case 'Public': | ||||
|                   name = 'globe' | ||||
|                   break | ||||
|                 case 'PostRoot': | ||||
|                   name = 'plus' | ||||
|                   break | ||||
|                 case 'Notifications': | ||||
|                   name = 'bell' | ||||
|                   break | ||||
|                 case 'Me': | ||||
|                   name = focused ? 'smile' : 'meh' | ||||
|                   break | ||||
|                 default: | ||||
|                   name = 'alert-octagon' | ||||
|                   break | ||||
|               } | ||||
|               return <Feather name={name} size={size} color={color} /> | ||||
|     <NavigationContainer> | ||||
|       <Tab.Navigator | ||||
|         screenOptions={({ route }) => ({ | ||||
|           tabBarIcon: ({ focused, color, size }) => { | ||||
|             let name: string | ||||
|             switch (route.name) { | ||||
|               case 'Screen-Local': | ||||
|                 name = 'home' | ||||
|                 break | ||||
|               case 'Screen-Public': | ||||
|                 name = 'globe' | ||||
|                 break | ||||
|               case 'Screen-Post': | ||||
|                 name = 'plus' | ||||
|                 break | ||||
|               case 'Screen-Notifications': | ||||
|                 name = 'bell' | ||||
|                 break | ||||
|               case 'Screen-Me': | ||||
|                 name = focused ? 'smile' : 'meh' | ||||
|                 break | ||||
|               default: | ||||
|                 name = 'alert-octagon' | ||||
|                 break | ||||
|             } | ||||
|             return <Feather name={name} size={size} color={color} /> | ||||
|           } | ||||
|         })} | ||||
|         tabBarOptions={{ | ||||
|           activeTintColor: 'black', | ||||
|           inactiveTintColor: 'gray', | ||||
|           showLabel: false | ||||
|         }} | ||||
|       > | ||||
|         <Tab.Screen name='Screen-Local' component={ScreenLocal} /> | ||||
|         <Tab.Screen name='Screen-Public' component={ScreenPublic} /> | ||||
|         <Tab.Screen | ||||
|           name='Screen-Post' | ||||
|           component={() => <></>} | ||||
|           listeners={({ navigation, route }) => ({ | ||||
|             tabPress: e => { | ||||
|               e.preventDefault() | ||||
|               const { | ||||
|                 length, | ||||
|                 [length - 1]: last | ||||
|               } = navigation.dangerouslyGetState().history | ||||
|               navigation.navigate(last.key.split(new RegExp(/(.*?)-/))[1], { | ||||
|                 screen: 'PostToot' | ||||
|               }) | ||||
|             } | ||||
|           })} | ||||
|           tabBarOptions={{ | ||||
|             activeTintColor: 'black', | ||||
|             inactiveTintColor: 'gray', | ||||
|             showLabel: false | ||||
|           }} | ||||
|         > | ||||
|           <Tab.Screen name='Local' component={Local} /> | ||||
|           <Tab.Screen name='Public' component={Public} /> | ||||
|           <Tab.Screen | ||||
|             name='PostRoot' | ||||
|             component={PostRoot} | ||||
|             listeners={({ navigation, route }) => ({ | ||||
|               tabPress: e => { | ||||
|                 e.preventDefault() | ||||
|                 const { | ||||
|                   length, | ||||
|                   [length - 1]: last | ||||
|                 } = navigation.dangerouslyGetState().history | ||||
|                 navigation.navigate(last.key.split(new RegExp(/(.*?)-/))[1], { | ||||
|                   screen: 'PostToot' | ||||
|                 }) | ||||
|               } | ||||
|             })} | ||||
|           /> | ||||
|           <Tab.Screen name='Notifications' component={Notifications} /> | ||||
|           <Tab.Screen name='Me' component={Me} /> | ||||
|         </Tab.Navigator> | ||||
|         /> | ||||
|         <Tab.Screen name='Screen-Notifications' component={ScreenNotifications} /> | ||||
|         <Tab.Screen name='Screen-Me' component={ScreenMe} /> | ||||
|       </Tab.Navigator> | ||||
|  | ||||
|         <Toast ref={(ref: any) => Toast.setRef(ref)} /> | ||||
|       </NavigationContainer> | ||||
|     </Provider> | ||||
|       <Toast ref={(ref: any) => Toast.setRef(ref)} /> | ||||
|     </NavigationContainer> | ||||
|   ) | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import store, { RootState } from 'src/stacks/common/store' | ||||
| import store, { RootState } from 'src/store' | ||||
| import ky from 'ky' | ||||
|  | ||||
| const client = async ({ | ||||
|   | ||||
| @@ -13,8 +13,8 @@ import { useMutation, useQueryCache } from 'react-query' | ||||
| import { Feather } from '@expo/vector-icons' | ||||
|  | ||||
| import client from 'src/api/client' | ||||
| import { getLocalAccountId } from 'src/stacks/common/instancesSlice' | ||||
| import store from 'src/stacks/common/store' | ||||
| import { getLocalAccountId } from 'src/utils/slices/instancesSlice' | ||||
| import store from 'src/store' | ||||
|  | ||||
| const fireMutation = async ({ | ||||
|   id, | ||||
|   | ||||
| @@ -12,8 +12,8 @@ import { useSelector } from 'react-redux' | ||||
| import { | ||||
|   getLocalAccountId, | ||||
|   getLocalUrl | ||||
| } from 'src/stacks/common/instancesSlice' | ||||
| import store from 'src/stacks/common/store' | ||||
| } from 'src/utils/slices/instancesSlice' | ||||
| import store from 'src/store' | ||||
|  | ||||
| const fireMutation = async ({ | ||||
|   id, | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| 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 ( | ||||
|     <TimelinesCombined | ||||
|     <Timelines | ||||
|       name='Local' | ||||
|       content={[ | ||||
|         { title: '关注', page: 'Following' }, | ||||
| @@ -14,4 +14,4 @@ const Local: React.FC = () => { | ||||
|   ) | ||||
| } | ||||
| 
 | ||||
| export default Local | ||||
| export default ScreenLocal | ||||
							
								
								
									
										19
									
								
								src/screens/Me.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/screens/Me.tsx
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										14
									
								
								src/screens/Me/Root.tsx
									
									
									
									
									
										Normal 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 | ||||
| @@ -3,14 +3,14 @@ import { Button, Text, TextInput, View } from 'react-native' | ||||
| import { useQuery } from 'react-query' | ||||
| 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 * as AuthSession from 'expo-auth-session' | ||||
| 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' | ||||
| 
 | ||||
| const Instance: React.FC = () => { | ||||
| const Login: React.FC = () => { | ||||
|   const navigation = useNavigation() | ||||
|   const dispatch = useDispatch() | ||||
|   const [instance, setInstance] = useState('') | ||||
| @@ -142,4 +142,4 @@ const Instance: React.FC = () => { | ||||
|   ) | ||||
| } | ||||
| 
 | ||||
| export default Instance | ||||
| export default Login | ||||
| @@ -2,12 +2,12 @@ import React, { useEffect, useState } from 'react' | ||||
| import { createNativeStackNavigator } from 'react-native-screens/native-stack' | ||||
| import { Feather } from '@expo/vector-icons' | ||||
| 
 | ||||
| import Timeline from 'src/stacks/common/Timeline' | ||||
| import sharedScreens from 'src/stacks/Shared/sharedScreens' | ||||
| import Timeline from 'src/screens/Timelines/Timeline' | ||||
| import sharedScreens from 'src/screens/Shared/sharedScreens' | ||||
| 
 | ||||
| const Stack = createNativeStackNavigator() | ||||
| 
 | ||||
| const Notifications: React.FC = () => { | ||||
| const ScreenNotifications: React.FC = () => { | ||||
|   const [renderHeader, setRenderHeader] = useState(false) | ||||
| 
 | ||||
|   useEffect(() => { | ||||
| @@ -34,4 +34,4 @@ const Notifications: React.FC = () => { | ||||
|   ) | ||||
| } | ||||
| 
 | ||||
| export default Notifications | ||||
| export default ScreenNotifications | ||||
| @@ -1,10 +1,10 @@ | ||||
| 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 ( | ||||
|     <TimelinesCombined | ||||
|     <Timelines | ||||
|       name='Public' | ||||
|       content={[ | ||||
|         { title: '跨站', page: 'LocalPublic' }, | ||||
| @@ -14,4 +14,4 @@ const Public: React.FC = () => { | ||||
|   ) | ||||
| } | ||||
| 
 | ||||
| export default Public | ||||
| export default ScreenPublic | ||||
| @@ -14,9 +14,9 @@ import { Feather } from '@expo/vector-icons' | ||||
| // import * as relationshipsSlice from 'src/stacks/common/relationshipsSlice'
 | ||||
| 
 | ||||
| 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 { accountFetch } from '../common/accountFetch' | ||||
| import { accountFetch } from '../../utils/fetches/accountFetch' | ||||
| 
 | ||||
| // Moved account example: https://m.cmx.im/web/accounts/27812
 | ||||
| 
 | ||||
| @@ -117,7 +117,11 @@ const Toots = ({ account }: { account: string }) => { | ||||
|   ) | ||||
|   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 ( | ||||
|     <> | ||||
| @@ -184,7 +188,7 @@ export interface Props { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const Account: React.FC<Props> = ({ | ||||
| const ScreenSharedAccount: React.FC<Props> = ({ | ||||
|   route: { | ||||
|     params: { id } | ||||
|   } | ||||
| @@ -253,4 +257,4 @@ const styles = StyleSheet.create({ | ||||
|   } | ||||
| }) | ||||
| 
 | ||||
| export default Account | ||||
| export default ScreenSharedAccount | ||||
| @@ -10,10 +10,10 @@ import { SafeAreaView } from 'react-native-safe-area-context' | ||||
| import { createNativeStackNavigator } from 'react-native-screens/native-stack' | ||||
| import { useNavigation } from '@react-navigation/native' | ||||
| 
 | ||||
| import store from 'src/stacks/common/store' | ||||
| import PostMain from './PostToot/PostMain' | ||||
| import store from 'src/store' | ||||
| import PostMain from './Compose/PostMain' | ||||
| import client from 'src/api/client' | ||||
| import { getLocalAccountPreferences } from '../common/instancesSlice' | ||||
| import { getLocalAccountPreferences } from 'src/utils/slices/instancesSlice' | ||||
| 
 | ||||
| const Stack = createNativeStackNavigator() | ||||
| 
 | ||||
| @@ -2,7 +2,7 @@ import React, { Dispatch } from 'react' | ||||
| import { Image, StyleSheet, View } from 'react-native' | ||||
| import { Feather } from '@expo/vector-icons' | ||||
| 
 | ||||
| import { PostAction, PostState } from '../PostToot' | ||||
| import { PostAction, PostState } from '../Compose' | ||||
| 
 | ||||
| export interface Props { | ||||
|   postState: PostState | ||||
| @@ -1,7 +1,7 @@ | ||||
| import React, { Dispatch } from 'react' | ||||
| import { Image, Pressable } from 'react-native' | ||||
| 
 | ||||
| import { PostAction, PostState } from '../PostToot' | ||||
| import { PostAction, PostState } from '../Compose' | ||||
| import updateText from './updateText' | ||||
| 
 | ||||
| export interface Props { | ||||
| @@ -24,8 +24,8 @@ import Autolinker from 'src/modules/autolinker' | ||||
| import PostEmojis from './PostEmojis' | ||||
| import PostPoll from './PostPoll' | ||||
| import PostSuggestions from './PostSuggestions' | ||||
| import { emojisFetch } from 'src/stacks/common/emojisFetch' | ||||
| import { PostAction, PostState } from 'src/stacks/Shared/PostToot' | ||||
| import { emojisFetch } from 'src/utils/fetches/emojisFetch' | ||||
| import { PostAction, PostState } from 'src/screens/Shared/Compose' | ||||
| import addAttachments from './addAttachments' | ||||
| import PostAttachments from './PostAttachments' | ||||
| 
 | ||||
| @@ -9,7 +9,7 @@ import { | ||||
| } from 'react-native' | ||||
| import { Feather } from '@expo/vector-icons' | ||||
| 
 | ||||
| import { PostAction, PostState } from '../PostToot' | ||||
| import { PostAction, PostState } from '../Compose' | ||||
| 
 | ||||
| export interface Props { | ||||
|   postState: PostState | ||||
| @@ -3,8 +3,8 @@ import { ActivityIndicator, Pressable, Text } from 'react-native' | ||||
| import { FlatList } from 'react-native-gesture-handler' | ||||
| import { useQuery } from 'react-query' | ||||
| 
 | ||||
| import { searchFetch } from '../../common/searchFetch' | ||||
| import { PostAction, PostState } from '../PostToot' | ||||
| import { searchFetch } from 'src/utils/fetches/searchFetch' | ||||
| import { PostAction, PostState } from '../Compose' | ||||
| import updateText from './updateText' | ||||
| 
 | ||||
| declare module 'react' { | ||||
| @@ -3,7 +3,7 @@ import { ActionSheetIOS, Alert } from 'react-native' | ||||
| import * as ImagePicker from 'expo-image-picker' | ||||
| 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' | ||||
| 
 | ||||
| const uploadAttachment = async (uri: ImageInfo['uri']) => { | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { PostState } from '../PostToot' | ||||
| import { PostState } from '../Compose' | ||||
| 
 | ||||
| const updateText = ({ | ||||
|   onChangeText, | ||||
| @@ -1,6 +1,6 @@ | ||||
| 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?
 | ||||
| 
 | ||||
| @@ -12,7 +12,7 @@ export interface Props { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const Hashtag: React.FC<Props> = ({ | ||||
| const ScreenSharedHashtag: React.FC<Props> = ({ | ||||
|   route: { | ||||
|     params: { hashtag } | ||||
|   } | ||||
| @@ -20,4 +20,4 @@ const Hashtag: React.FC<Props> = ({ | ||||
|   return <Timeline page='Hashtag' hashtag={hashtag} /> | ||||
| } | ||||
| 
 | ||||
| export default Hashtag | ||||
| export default ScreenSharedHashtag | ||||
| @@ -1,6 +1,6 @@ | ||||
| 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?
 | ||||
| 
 | ||||
| @@ -12,7 +12,7 @@ export interface Props { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const Toot: React.FC<Props> = ({ | ||||
| const ScreenSharedToot: React.FC<Props> = ({ | ||||
|   route: { | ||||
|     params: { toot } | ||||
|   } | ||||
| @@ -20,4 +20,4 @@ const Toot: React.FC<Props> = ({ | ||||
|   return <Timeline page='Toot' toot={toot} disableRefresh /> | ||||
| } | ||||
| 
 | ||||
| export default Toot | ||||
| export default ScreenSharedToot | ||||
| @@ -11,7 +11,7 @@ export interface Props { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const Webview: React.FC<Props> = ({ | ||||
| const ScreenSharedWebview: React.FC<Props> = ({ | ||||
|   route: { | ||||
|     params: { uri } | ||||
|   } | ||||
| @@ -19,4 +19,4 @@ const Webview: React.FC<Props> = ({ | ||||
|   return <WebView source={{ uri: uri }} /> | ||||
| } | ||||
| 
 | ||||
| export default Webview | ||||
| export default ScreenSharedWebview | ||||
							
								
								
									
										56
									
								
								src/screens/Shared/sharedScreens.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/screens/Shared/sharedScreens.tsx
									
									
									
									
									
										Normal 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 | ||||
| @@ -4,7 +4,7 @@ import { setFocusHandler, useInfiniteQuery } from 'react-query' | ||||
| 
 | ||||
| import StatusInNotifications from 'src/components/StatusInNotifications' | ||||
| import StatusInTimeline from 'src/components/StatusInTimeline' | ||||
| import { timelineFetch } from './timelineFetch' | ||||
| import { timelineFetch } from 'src/utils/fetches/timelineFetch' | ||||
| 
 | ||||
| // Opening nesting hashtag pages
 | ||||
| 
 | ||||
| @@ -1,20 +1,31 @@ | ||||
| import React, { useEffect, useRef, useState } from 'react' | ||||
| 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 { createNativeStackNavigator } from 'react-native-screens/native-stack' | ||||
| import { useSelector } from 'react-redux' | ||||
| import { Feather } from '@expo/vector-icons' | ||||
| 
 | ||||
| import Timeline from './Timeline' | ||||
| import sharedScreens from 'src/stacks/Shared/sharedScreens' | ||||
| import { getLocalRegistered } from './instancesSlice' | ||||
| import store from './store' | ||||
| import sharedScreens from 'src/screens/Shared/sharedScreens' | ||||
| import { InstancesState } from 'src/utils/slices/instancesSlice' | ||||
| import { RootState } from 'src/store' | ||||
| 
 | ||||
| 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 ( | ||||
|     <View style={{ width: Dimensions.get('window').width }}> | ||||
|       <Timeline page={page} /> | ||||
|       {localRegistered || page === 'RemotePublic' ? ( | ||||
|         <Timeline page={page} /> | ||||
|       ) : ( | ||||
|         <Text>请先登录</Text> | ||||
|       )} | ||||
|     </View> | ||||
|   ) | ||||
| } | ||||
| @@ -24,8 +35,10 @@ export interface Props { | ||||
|   content: { title: string; page: App.Pages }[] | ||||
| } | ||||
| 
 | ||||
| const TimelinesCombined: React.FC<Props> = ({ name, content }) => { | ||||
|   const localRegistered = getLocalRegistered(store.getState()) | ||||
| const Timelines: React.FC<Props> = ({ name, content }) => { | ||||
|   const localRegistered = useSelector( | ||||
|     (state: RootState) => state.instances.local.url | ||||
|   ) | ||||
|   const [segment, setSegment] = useState(0) | ||||
|   const [renderHeader, setRenderHeader] = useState(false) | ||||
|   const [segmentManuallyTriggered, setSegmentManuallyTriggered] = useState( | ||||
| @@ -37,7 +50,7 @@ const TimelinesCombined: React.FC<Props> = ({ name, content }) => { | ||||
|     return | ||||
|   }, []) | ||||
| 
 | ||||
|   const horizontalPaging = useRef(null!) | ||||
|   const horizontalPaging = useRef<FlatList>(null!) | ||||
| 
 | ||||
|   return ( | ||||
|     <Stack.Navigator> | ||||
| @@ -69,16 +82,11 @@ const TimelinesCombined: React.FC<Props> = ({ name, content }) => { | ||||
|           <FlatList | ||||
|             style={{ width: Dimensions.get('window').width, height: '100%' }} | ||||
|             data={content} | ||||
|             extraData={localRegistered} | ||||
|             keyExtractor={({ page }) => page} | ||||
|             renderItem={({ item, index }) => { | ||||
|               return localRegistered || item.page === 'RemotePublic' ? ( | ||||
|                 <Page key={index} item={item} /> | ||||
|               ) : ( | ||||
|                 <View style={{ width: Dimensions.get('window').width }}> | ||||
|                   <Text>请先登录</Text> | ||||
|                 </View> | ||||
|               ) | ||||
|             }} | ||||
|             renderItem={({ item, index }) => ( | ||||
|               <Page key={index} item={item} localRegistered={localRegistered} /> | ||||
|             )} | ||||
|             ref={horizontalPaging} | ||||
|             bounces={false} | ||||
|             getItemLayout={(data, index) => ({ | ||||
| @@ -108,4 +116,4 @@ const TimelinesCombined: React.FC<Props> = ({ name, content }) => { | ||||
|   ) | ||||
| } | ||||
| 
 | ||||
| export default TimelinesCombined | ||||
| export default Timelines | ||||
| @@ -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 | ||||
| @@ -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 | ||||
| @@ -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 | ||||
| @@ -1,7 +0,0 @@ | ||||
| import React from 'react' | ||||
|  | ||||
| const PostRoot: React.FC = () => { | ||||
|   return <></> | ||||
| } | ||||
|  | ||||
| export default PostRoot | ||||
| @@ -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 | ||||
| @@ -1,6 +1,6 @@ | ||||
| import { configureStore } from '@reduxjs/toolkit' | ||||
| 
 | ||||
| import instancesSlice from 'src/stacks/common/instancesSlice' | ||||
| import instancesSlice from 'src/utils/slices/instancesSlice' | ||||
| 
 | ||||
| const store = configureStore({ | ||||
|   reducer: { | ||||
| @@ -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 } | ||||
| @@ -1,8 +1,9 @@ | ||||
| import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit' | ||||
| import client from 'src/api/client' | ||||
| import { RootState } from './store' | ||||
| import { createAsyncThunk, createSlice } from '@reduxjs/toolkit' | ||||
| 
 | ||||
| type InstancesState = { | ||||
| import { RootState } from 'src/store' | ||||
| import client from 'src/api/client' | ||||
| 
 | ||||
| export type InstancesState = { | ||||
|   local: { | ||||
|     url: 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 getLocalAccountId = (state: RootState) => | ||||
|   state.instances.local.account.id | ||||
							
								
								
									
										6315
									
								
								yarn-error.log
									
									
									
									
									
								
							
							
						
						
									
										6315
									
								
								yarn-error.log
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										10
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								yarn.lock
									
									
									
									
									
								
							| @@ -5166,6 +5166,16 @@ readable-stream@^3.1.1: | ||||
|     string_decoder "^1.1.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: | ||||
|   version "2.3.0" | ||||
|   resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user