mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +00:00
adding modal for new topics
This commit is contained in:
parent
136fbf4b5f
commit
119fb4f35d
@ -102,4 +102,45 @@ export const styles = StyleSheet.create({
|
|||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
},
|
},
|
||||||
read: {},
|
read: {},
|
||||||
|
modal: {
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
blur: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
},
|
||||||
|
addSurface: {
|
||||||
|
padding: 16,
|
||||||
|
borderRadius: 4,
|
||||||
|
},
|
||||||
|
addContainer: {
|
||||||
|
width: 500,
|
||||||
|
maxWidth: '80%',
|
||||||
|
},
|
||||||
|
addHeader: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
},
|
||||||
|
addClose: {
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
},
|
||||||
|
addLabel: {
|
||||||
|
flexGrow: 1,
|
||||||
|
fontSize: 20,
|
||||||
|
paddingLeft: 4,
|
||||||
|
paddingBottom: 8,
|
||||||
|
},
|
||||||
|
sealSwitch: {
|
||||||
|
transform: [{scaleX: 0.7}, {scaleY: 0.7}],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {Divider, Surface, Button, Text, TextInput, useTheme} from 'react-native-paper';
|
import {Divider, Switch, Surface, IconButton, Button, Text, TextInput, useTheme} from 'react-native-paper';
|
||||||
import {SafeAreaView, FlatList, View} from 'react-native';
|
import {SafeAreaView, Modal, FlatList, View} from 'react-native';
|
||||||
import {styles} from './Content.styled';
|
import {styles} from './Content.styled';
|
||||||
import {useContent} from './useContent.hook';
|
import {useContent} from './useContent.hook';
|
||||||
import {Channel} from '../channel/Channel';
|
import {Channel} from '../channel/Channel';
|
||||||
import {Focus} from 'databag-client-sdk';
|
import {Focus} from 'databag-client-sdk';
|
||||||
|
import {BlurView} from '@react-native-community/blur';
|
||||||
|
|
||||||
export function Content({select}: {select: (focus: Focus) => void}) {
|
export function Content({select}: {select: (focus: Focus) => void}) {
|
||||||
|
const [add, setAdd] = useState(false);
|
||||||
|
const [sealable, setSealable] = useState(false);
|
||||||
const {state, actions} = useContent();
|
const {state, actions} = useContent();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -31,9 +34,7 @@ export function Content({select}: {select: (focus: Focus) => void}) {
|
|||||||
icon="comment-plus"
|
icon="comment-plus"
|
||||||
mode="contained"
|
mode="contained"
|
||||||
style={styles.button}
|
style={styles.button}
|
||||||
onPress={() => {
|
onPress={() => setAdd(true)}>
|
||||||
console.log('ADD CHANNEL');
|
|
||||||
}}>
|
|
||||||
{state.strings.new}
|
{state.strings.new}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
@ -88,13 +89,35 @@ export function Content({select}: {select: (focus: Focus) => void}) {
|
|||||||
icon="comment-plus"
|
icon="comment-plus"
|
||||||
mode="contained"
|
mode="contained"
|
||||||
style={styles.button}
|
style={styles.button}
|
||||||
onPress={() => {
|
onPress={() => setAdd(true)}>
|
||||||
console.log('ADD CHANNEL');
|
|
||||||
}}>
|
|
||||||
{state.strings.new}
|
{state.strings.new}
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Modal animationType="fade" transparent={true} supportedOrientations={['portrait', 'landscape']} visible={add} onRequestClose={() => setAdd(false)}>
|
||||||
|
<View style={styles.modal}>
|
||||||
|
<BlurView style={styles.blur} blurType="dark" blurAmount={2} reducedTransparencyFallbackColor="dark" />
|
||||||
|
<View style={styles.addContainer}>
|
||||||
|
<Surface elevation={5} mode="flat" style={styles.addSurface}>
|
||||||
|
<Text style={styles.addLabel}>{ state.strings.newTopic }</Text>
|
||||||
|
<IconButton style={styles.addClose} icon="close" size={24} onPress={() => setAdd(false)} />
|
||||||
|
<TextInput
|
||||||
|
dense={true}
|
||||||
|
style={styles.input}
|
||||||
|
autoCapitalize={false}
|
||||||
|
unserlineStyle={styles.inputUnderline}
|
||||||
|
mode="outlined"
|
||||||
|
placeholder={state.strings.subjectOptional}
|
||||||
|
left={<TextInput.Icon style={styles.icon} icon="label-outline" />}
|
||||||
|
value={state.topic}
|
||||||
|
onChangeText={value => actions.setTopic(value)}
|
||||||
|
/>
|
||||||
|
<Switch style={styles.sealSwitch} value={sealable} onValueChange={flag => setSealable(flag)} />
|
||||||
|
</Surface>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,20 @@ export function useContent() {
|
|||||||
sorted: [] as Channel[],
|
sorted: [] as Channel[],
|
||||||
filtered: [] as ChannelParams[],
|
filtered: [] as ChannelParams[],
|
||||||
filter: '',
|
filter: '',
|
||||||
|
topic: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const compare = (a: Card, b: Card) => {
|
||||||
|
const aval = `${a.handle}/${a.node}`;
|
||||||
|
const bval = `${b.handle}/${b.node}`;
|
||||||
|
if (aval < bval) {
|
||||||
|
return state.sortAsc ? 1 : -1;
|
||||||
|
} else if (aval > bval) {
|
||||||
|
return state.sortAsc ? -1 : 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const updateState = (value: any) => {
|
const updateState = (value: any) => {
|
||||||
setState(s => ({...s, ...value}));
|
setState(s => ({...s, ...value}));
|
||||||
@ -149,7 +161,18 @@ export function useContent() {
|
|||||||
updateState({guid});
|
updateState({guid});
|
||||||
};
|
};
|
||||||
const setCards = (cards: Card[]) => {
|
const setCards = (cards: Card[]) => {
|
||||||
updateState({cards});
|
const sorted = cards.sort(compare);
|
||||||
|
const connected = [];
|
||||||
|
const sealable = [];
|
||||||
|
sorted.forEach(card => {
|
||||||
|
if (card.status === 'connected') {
|
||||||
|
connected.push(card);
|
||||||
|
if (card.sealable) {
|
||||||
|
sealable.push(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateState({cards, connected, sealable});
|
||||||
};
|
};
|
||||||
const setChannels = ({channels, cardId}: {channels: Channel[]; cardId: string | null}) => {
|
const setChannels = ({channels, cardId}: {channels: Channel[]; cardId: string | null}) => {
|
||||||
cardChannels.current.set(cardId, channels);
|
cardChannels.current.set(cardId, channels);
|
||||||
@ -194,6 +217,9 @@ export function useContent() {
|
|||||||
setFilter: (filter: string) => {
|
setFilter: (filter: string) => {
|
||||||
updateState({filter});
|
updateState({filter});
|
||||||
},
|
},
|
||||||
|
setTopic: (topic: string) => {
|
||||||
|
updateState({topic});
|
||||||
|
},
|
||||||
getFocus: (cardId: string | null, channelId: string) => {
|
getFocus: (cardId: string | null, channelId: string) => {
|
||||||
return app.state.session.setFocus(cardId, channelId);
|
return app.state.session.setFocus(cardId, channelId);
|
||||||
},
|
},
|
||||||
|
@ -883,6 +883,7 @@ export class ContactModule implements Contact {
|
|||||||
cardId,
|
cardId,
|
||||||
offsync: Boolean(item.offsyncProfile || item.offsyncChannel || item.offsyncArticle),
|
offsync: Boolean(item.offsyncProfile || item.offsyncChannel || item.offsyncArticle),
|
||||||
blocked: this.isCardBlocked(cardId),
|
blocked: this.isCardBlocked(cardId),
|
||||||
|
sealable: Boolean(item.profile.seal),
|
||||||
status: detail.status,
|
status: detail.status,
|
||||||
statusUpdated: detail.statusUpdated,
|
statusUpdated: detail.statusUpdated,
|
||||||
guid: profile.guid,
|
guid: profile.guid,
|
||||||
|
@ -2,6 +2,7 @@ export type Card = {
|
|||||||
cardId: string;
|
cardId: string;
|
||||||
offsync: boolean;
|
offsync: boolean;
|
||||||
blocked: boolean;
|
blocked: boolean;
|
||||||
|
sealable: boolean;
|
||||||
status: string;
|
status: string;
|
||||||
statusUpdated: number;
|
statusUpdated: number;
|
||||||
guid: string;
|
guid: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user