import React from 'react';
import { Platform, ScrollView, View } from 'react-native';
import { useTracked } from '../../provider';
import { DDS } from '../../services/DeviceDetection';
import { presentSheet } from '../../services/EventManager';
import { db } from '../../utils/database';
import { SIZE } from '../../utils/SizeUtils';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
import { ColorTags } from './color-tags';
import { DateMeta } from './date-meta';
import { DevMode } from './dev-mode';
import { Items } from './items';
import Notebooks from './notebooks';
import { Synced } from './synced';
import { Tags } from './tags';
import { Topics } from './topics';
export const Properties = ({ close = () => {}, item, buttons = [], getRef }) => {
const [state, dispatch] = useTracked();
const { colors } = state;
const alias = item
? item.type === 'tag'
? db.tags.alias(item.id)
: item.type === 'color'
? db.colors.alias(item.id)
: item.title
: null;
const onScrollEnd = () => {
getRef().current?.handleChildScrollEnd();
};
return (
{!item || !item.id ? (
Start writing to save your note.
) : (
{item.type === 'tag' ? '#' : null}
{alias}
{item.headline || item.description ? (
{(item.type === 'notebook' || item.itemType === 'notebook') && item?.description
? item.description
: null}
{(item.type === 'note' || item.itemType === 'note') && item?.headline
? item.headline
: null}
) : null}
{item.type === 'note' ? : null}
{item.type === 'note' ? : null}
)}
{item.type === 'note' ? : null}
{DDS.isTab ? (
) : null}
);
};
Properties.present = (item, buttons = []) => {
if (!item) return;
let type = item?.type;
let props = [item];
let android = [];
switch (type) {
case 'trash':
props.push(['PermDelete', 'Restore']);
break;
case 'note':
android = Platform.OS === 'android' ? ['PinToNotif'] : [];
item = db.notes.note(item.id).data;
props.push([
'Add to notebook',
'Share',
'Export',
'Copy',
'Publish',
'Pin',
'Favorite',
'Attachments',
'Vault',
'Delete',
'RemoveTopic',
'History',
'ReadOnly',
...android,
...buttons
]);
break;
case 'notebook':
item = db.notebooks.notebook(item.id).data;
props.push(['Edit Notebook', 'Pin', 'Add Shortcut', 'Delete']);
break;
case 'topic':
item = db.notebooks.notebook(item.notebookId).topics.topic(item.id)._topic;
props.push(['Move notes', 'Edit Topic', 'Add Shortcut', 'Delete']);
break;
case 'tag':
item = db.tags.tag(item.id);
props.push(['Add Shortcut', 'Delete', 'Rename Tag']);
break;
}
presentSheet({
component: (ref, close) => (
{
close();
}}
getRef={() => ref}
item={props[0]}
buttons={props[1]}
/>
)
});
};