Separated local/remote clipboard views
This commit is contained in:
parent
e8d914e270
commit
cceb78f7c3
90
src/App.tsx
90
src/App.tsx
@ -5,63 +5,57 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {NavigationContainer} from '@react-navigation/native';
|
import { NavigationContainer } from '@react-navigation/native';
|
||||||
import type {PropsWithChildren} from 'react';
|
import type { PropsWithChildren } from 'react';
|
||||||
import {
|
import {
|
||||||
SafeAreaView,
|
SafeAreaView,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
StatusBar,
|
StatusBar,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
useColorScheme,
|
useColorScheme,
|
||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
import {createNativeStackNavigator} from '@react-navigation/native-stack';
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
|
import ClipViewLocal from './clip/ClipViewLocal';
|
||||||
|
import ClipViewRemote from './clip/ClipViewRemote';
|
||||||
|
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
|
||||||
|
|
||||||
const Stack = createNativeStackNavigator();
|
const Stack = createMaterialBottomTabNavigator();
|
||||||
|
|
||||||
function App(): JSX.Element {
|
function App(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<NavigationContainer>
|
<NavigationContainer>
|
||||||
<Stack.Navigator>
|
<Stack.Navigator>
|
||||||
{/* <Stack.Screen
|
<Stack.Screen name="Remote" options={{ title: 'remote' }}>
|
||||||
name="Login"
|
{(props) => <ClipViewRemote navigation={props.navigation} type={"remote"} />}
|
||||||
component={LoginScreen}
|
</Stack.Screen>
|
||||||
options={{title: 'Login Screen'}}
|
<Stack.Screen name="Local" options={{ title: 'local' }}>
|
||||||
/>
|
{(props) => <ClipViewLocal navigation={props.navigation} type={"local"} />}
|
||||||
<Stack.Screen
|
</Stack.Screen>
|
||||||
name="Home"
|
</Stack.Navigator>
|
||||||
component={RemoteClipboard}
|
</NavigationContainer>
|
||||||
options={{title: 'Welcome'}}
|
);
|
||||||
/>\
|
|
||||||
<Stack.Screen
|
|
||||||
name="Home"
|
|
||||||
component={LocalClipboard}
|
|
||||||
options={{title: 'Welcome'}}
|
|
||||||
/>*/}
|
|
||||||
</Stack.Navigator>
|
|
||||||
</NavigationContainer>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
sectionContainer: {
|
sectionContainer: {
|
||||||
marginTop: 32,
|
marginTop: 32,
|
||||||
paddingHorizontal: 24,
|
paddingHorizontal: 24,
|
||||||
},
|
},
|
||||||
sectionTitle: {
|
sectionTitle: {
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: '600',
|
fontWeight: '600',
|
||||||
},
|
},
|
||||||
sectionDescription: {
|
sectionDescription: {
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: '400',
|
fontWeight: '400',
|
||||||
},
|
},
|
||||||
highlight: {
|
highlight: {
|
||||||
fontWeight: '700',
|
fontWeight: '700',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
18
src/clip/AClipView.tsx
Normal file
18
src/clip/AClipView.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { ScrollView, Text, Button } from 'react-native';
|
||||||
|
import ClipList from './ClipList';
|
||||||
|
|
||||||
|
|
||||||
|
export default abstract class AClipView extends React.Component<any, any> {
|
||||||
|
|
||||||
|
constructor(props: any) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
clips: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract getClips(): any;
|
||||||
|
|
||||||
|
abstract componentDidMount(): any;
|
||||||
|
}
|
@ -1,45 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
import React from 'react';
|
|
||||||
import { ScrollView, Text } from 'react-native';
|
|
||||||
import ClipList from './ClipList';
|
|
||||||
|
|
||||||
type Clip = {
|
|
||||||
content: string;
|
|
||||||
token: string;
|
|
||||||
deviceName: string;
|
|
||||||
id: number;
|
|
||||||
timestamp: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function getLocalClips() {
|
|
||||||
return [{ content: "test" }, { content: "test2" }];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getRemoteClips() {
|
|
||||||
const { data, status } = await axios.get("http://notifysync.simailadjalim.fr/clipboard?token=FFmkeNAxguFM5My52PhhzlOB_1ZwDr0ureD2kzuewMlhmJ6Ia6YkhcdZd1Nw4SXdLu9Ji0gzVYCfGCcgB8v8zQ");
|
|
||||||
return Object.values(data['clipboard']);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class ClipView extends React.Component<any, any> {
|
|
||||||
|
|
||||||
constructor(props: any) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
clips: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
let clips;
|
|
||||||
if (this.props.type === "local") clips = await getLocalClips();
|
|
||||||
else clips = await getRemoteClips();
|
|
||||||
this.setState({clips: clips});
|
|
||||||
}
|
|
||||||
|
|
||||||
render(): JSX.Element {
|
|
||||||
return <ScrollView>
|
|
||||||
<Text style={{ fontWeight: 'bold', fontSize: 30, margin: 20 }}>{this.props.type[0].toUpperCase() + this.props.type.slice(1) + " Clipboard"}</Text>
|
|
||||||
<ClipList type={this.props.type} clips={this.state.clips} />
|
|
||||||
</ScrollView>;
|
|
||||||
}
|
|
||||||
}
|
|
32
src/clip/ClipViewLocal.tsx
Normal file
32
src/clip/ClipViewLocal.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import React from 'react';
|
||||||
|
import { ScrollView, Text, Button } from 'react-native';
|
||||||
|
import ClipList from './ClipList';
|
||||||
|
import AClipView from './AClipView';
|
||||||
|
|
||||||
|
|
||||||
|
export default class ClipViewLocal extends AClipView {
|
||||||
|
|
||||||
|
constructor(props: any) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
getClips() {
|
||||||
|
return [{ content: "test" }, { content: "test2" }];
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
let clips;
|
||||||
|
clips = this.getClips();
|
||||||
|
this.setState({clips: clips});
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): JSX.Element {
|
||||||
|
let title = "Local Clipboard";
|
||||||
|
let notTitle = "Remote Clipboard";
|
||||||
|
return <ScrollView>
|
||||||
|
<Text style={{ fontWeight: 'bold', fontSize: 30, margin: 20 }}>{title}</Text>
|
||||||
|
<ClipList type={this.props.type} clips={this.state.clips} />
|
||||||
|
</ScrollView>;
|
||||||
|
}
|
||||||
|
}
|
32
src/clip/ClipViewRemote.tsx
Normal file
32
src/clip/ClipViewRemote.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import React from 'react';
|
||||||
|
import { ScrollView, Text, Button } from 'react-native';
|
||||||
|
import ClipList from './ClipList';
|
||||||
|
import AClipView from './AClipView';
|
||||||
|
|
||||||
|
export default class ClipViewRemote extends AClipView {
|
||||||
|
constructor(props: any) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getClips() {
|
||||||
|
const { data, status } = await axios.get("http://notifysync.simailadjalim.fr/clipboard?token=FFmkeNAxguFM5My52PhhzlOB_1ZwDr0ureD2kzuewMlhmJ6Ia6YkhcdZd1Nw4SXdLu9Ji0gzVYCfGCcgB8v8zQ");
|
||||||
|
return Object.values(data['clipboard']);
|
||||||
|
}
|
||||||
|
|
||||||
|
async componentDidMount() {
|
||||||
|
let clips;
|
||||||
|
clips = await this.getClips();
|
||||||
|
this.setState({clips: clips});
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): JSX.Element {
|
||||||
|
let title = "Remote Clipboard";
|
||||||
|
let notTitle = "Local Clipboard";
|
||||||
|
return <ScrollView>
|
||||||
|
<Text style={{ fontWeight: 'bold', fontSize: 30, margin: 20 }}>{title}</Text>
|
||||||
|
<ClipList type={this.props.type} clips={this.state.clips} />
|
||||||
|
<Button title="Refresh" onPress={() => this.componentDidMount()} />
|
||||||
|
</ScrollView>;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user