linked-data-browser 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,9 +15,10 @@ import {
15
15
  DialogDescription,
16
16
  DialogClose,
17
17
  } from '../ui/dialog';
18
- import { TextInput, View } from 'react-native';
18
+ import { View } from 'react-native';
19
19
  import { Button } from '../ui/button';
20
20
  import { Text } from '../ui/text';
21
+ import { Input } from '../ui/input';
21
22
 
22
23
  type DialogOptions =
23
24
  | { type: 'confirm'; title: string; message?: string }
@@ -112,7 +113,7 @@ export const DialogProvider: React.FC<{ children: React.ReactNode }> = ({
112
113
 
113
114
  {options?.type === 'prompt' && (
114
115
  <View className="my-2">
115
- <TextInput
116
+ <Input
116
117
  value={inputValue}
117
118
  onChangeText={setInputValue}
118
119
  placeholder="Enter text..."
@@ -16,6 +16,7 @@ import { Header } from './header/Header';
16
16
  import { View } from 'react-native';
17
17
  import { useValidView, ValidViewProvider } from './useValidView';
18
18
  import { DialogProvider } from './DialogProvider';
19
+ import { useSolidAuth } from '@ldo/solid-react';
19
20
 
20
21
  export const ValidViewContext = createContext<{
21
22
  validViews: ResourceViewConfig[];
@@ -25,6 +26,12 @@ export const ValidViewContext = createContext<{
25
26
  }>({});
26
27
 
27
28
  export const Layout: FunctionComponent = () => {
29
+ const { ranInitialAuthCheck } = useSolidAuth();
30
+
31
+ if (!ranInitialAuthCheck) {
32
+ return <></>;
33
+ }
34
+
28
35
  return (
29
36
  <DialogProvider>
30
37
  <ValidViewProvider>
@@ -1,62 +1,86 @@
1
+ import {
2
+ useLdo,
3
+ useResource,
4
+ useSolidAuth,
5
+ useSubject,
6
+ } from '@ldo/solid-react';
1
7
  import React from 'react';
2
-
3
8
  import { FunctionComponent } from 'react';
4
- import { StyleSheet } from 'react-native';
9
+ import { View } from 'react-native';
10
+ import { SolidProfileShapeShapeType } from '../../../.ldo/profile.shapeTypes';
11
+ import { Avatar, AvatarFallback, AvatarImage } from '../../ui/avatar';
12
+ import { Text } from '../../ui/text';
13
+ import { Button } from '../../ui/button';
14
+ import { ThemeToggleMenu } from './ThemeToggleMenu';
15
+ import {
16
+ DropdownMenu,
17
+ DropdownMenuContent,
18
+ DropdownMenuItem,
19
+ DropdownMenuSeparator,
20
+ DropdownMenuTrigger,
21
+ } from '../../ui/dropdown-menu';
22
+ import { User } from '../../../lib/icons/User';
23
+ import { LogOut } from '../../../lib/icons/LogOut';
24
+ import { useTargetResource } from '../../TargetResourceProvider';
5
25
 
6
26
  export const AvatarMenu: FunctionComponent = () => {
7
- return <></>;
8
- // const [menuVisible, setMenuVisible] = useState(false);
9
- // const { session, logout } = useSolidAuth();
10
- // // TODO: Use WebId Resource to render a skeleton loader
11
- // const webIdResource = useResource(session.webId);
12
- // const profile = useSubject(SolidProfileShapeShapeType, session.webId);
13
- // const renderAvatar = () => (
14
- // <TouchableWithoutFeedback onPress={() => setMenuVisible(true)}>
15
- // <Avatar
16
- // source={{ uri: 'https://api.lorem.space/image/face?w=150&h=150' }}
17
- // />
18
- // </TouchableWithoutFeedback>
19
- // );
20
- // return (
21
- // <Popover
22
- // anchor={renderAvatar}
23
- // visible={menuVisible}
24
- // placement="bottom end"
25
- // onBackdropPress={() => setMenuVisible(false)}
26
- // style={styles.popover}
27
- // >
28
- // <Layout>
29
- // <View style={styles.profileHeader}>
30
- // <Avatar
31
- // size="giant"
32
- // source={{ uri: 'https://api.lorem.space/image/face?w=150&h=150' }}
33
- // />
34
- // <View style={styles.profileText}>
35
- // <Text category="h6">{profile?.fn || ''}</Text>
36
- // <Button size="tiny">Edit your profile</Button>
37
- // </View>
38
- // </View>
39
- // <Divider />
40
- // <ThemeToggleMenu />
41
- // <Divider />
42
- // <MenuItem
43
- // onPress={logout}
44
- // title="Log Out"
45
- // accessoryLeft={(props) => <Icon {...props} name="log-out" />}
46
- // />
47
- // </Layout>
48
- // </Popover>
49
- // );
50
- };
27
+ const { dataset } = useLdo();
28
+ const { session, logout } = useSolidAuth();
29
+ // TODO: Use WebId Resource to render a skeleton loader
30
+ const webIdResource = useResource(session.webId);
31
+ const profile = useSubject(SolidProfileShapeShapeType, session.webId);
32
+ const { navigateTo } = useTargetResource();
33
+
34
+ if (!session.webId) return <></>;
51
35
 
52
- const styles = StyleSheet.create({
53
- popover: { width: 300, overflow: 'hidden', borderRadius: 12 },
54
- profileHeader: { padding: 8, flexDirection: 'row', alignItems: 'center' },
55
- profileText: {
56
- marginLeft: 8,
57
- justifyContent: 'space-around',
58
- alignSelf: 'stretch',
59
- alignItems: 'flex-start',
60
- flex: 1,
61
- },
62
- });
36
+ console.log(profile?.['@id']);
37
+ console.log(profile?.hasPhoto?.['@id']);
38
+ console.log(webIdResource?.isLoading());
39
+ console.log(dataset.toString());
40
+
41
+ return (
42
+ <DropdownMenu>
43
+ <DropdownMenuTrigger asChild>
44
+ <Button key="setMemu" variant="ghost" className="w-10">
45
+ <Avatar alt={profile?.fn ? `${profile.fn}'s Avatar` : ''}>
46
+ <AvatarImage source={{ uri: profile?.hasPhoto?.['@id'] }} />
47
+ <AvatarFallback>
48
+ <Text>
49
+ <User />
50
+ </Text>
51
+ </AvatarFallback>
52
+ </Avatar>
53
+ </Button>
54
+ </DropdownMenuTrigger>
55
+ <DropdownMenuContent className="w-64 native:w-72 mr-2 mt-2">
56
+ <View className="p-2 flex-row items-center">
57
+ <Avatar
58
+ alt={profile?.fn ? `${profile.fn}'s Avatar` : ''}
59
+ className="w-20 h-20"
60
+ >
61
+ <AvatarImage source={{ uri: profile?.hasPhoto?.['@id'] }} />
62
+ <AvatarFallback>
63
+ <Text>
64
+ <User />
65
+ </Text>
66
+ </AvatarFallback>
67
+ </Avatar>
68
+ <View className="ml-2">
69
+ <Text>{profile?.fn || ''}</Text>
70
+ <Button size="sm" onPress={() => navigateTo(session.webId ?? '')}>
71
+ <Text>Edit your profile</Text>
72
+ </Button>
73
+ </View>
74
+ </View>
75
+ <DropdownMenuSeparator />
76
+ <ThemeToggleMenu />
77
+ <DropdownMenuSeparator />
78
+ <DropdownMenuItem onPress={logout}>
79
+ <Text className="flex flex-row gap-1 items-center">
80
+ <LogOut /> Log Out
81
+ </Text>
82
+ </DropdownMenuItem>
83
+ </DropdownMenuContent>
84
+ </DropdownMenu>
85
+ );
86
+ };
@@ -0,0 +1,4 @@
1
+ import { LogOut } from 'lucide-react-native';
2
+ import { iconWithClassName } from './iconWithClassName';
3
+ iconWithClassName(LogOut);
4
+ export { LogOut };
@@ -0,0 +1,4 @@
1
+ import { User } from 'lucide-react-native';
2
+ import { iconWithClassName } from './iconWithClassName';
3
+ iconWithClassName(User);
4
+ export { User };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "linked-data-browser",
3
3
  "main": "index.js",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "scripts": {
6
6
  "dev:ios": "expo start -c --ios",
7
7
  "dev:web": "concurrently \"npm run solid-server\" \"expo start -c --web\"",
@@ -16,6 +16,7 @@ export const RawCodeView: FunctionComponent = () => {
16
16
  const { targetUri } = useTargetResource();
17
17
  const { fetch } = useSolidAuth();
18
18
  const [content, setContent] = useState<string>('');
19
+ const [contentType, setContentType] = useState<string>('');
19
20
 
20
21
  // Independently fetch the target resource, so we have the raw turtle
21
22
  const fetchContent = useCallback(async () => {
@@ -27,12 +28,16 @@ export const RawCodeView: FunctionComponent = () => {
27
28
  });
28
29
  }
29
30
  setContent(await response.text());
31
+ setContentType(response.headers.get('content-type') ?? '');
30
32
  }, [fetch, targetUri]);
31
33
 
32
34
  const submitChanges = useCallback(async () => {
33
35
  if (!targetUri) return;
34
36
  const response = await fetch(targetUri, {
35
37
  method: 'put',
38
+ headers: {
39
+ 'content-type': contentType,
40
+ },
36
41
  body: content,
37
42
  });
38
43
  if (response.status !== 205) {
@@ -44,7 +49,7 @@ export const RawCodeView: FunctionComponent = () => {
44
49
  title: `Document Saved`,
45
50
  });
46
51
  await fetchContent();
47
- }, [content, fetch, fetchContent, targetUri]);
52
+ }, [content, contentType, fetch, fetchContent, targetUri]);
48
53
 
49
54
  useEffect(() => {
50
55
  fetchContent();