mirror of
https://github.com/balzack/databag.git
synced 2025-02-15 04:59:16 +00:00
rendering topic options
This commit is contained in:
parent
0591ed6170
commit
fb6d2e3e7a
@ -45,8 +45,8 @@ export function Session() {
|
|||||||
const ConversationStackScreen = () => {
|
const ConversationStackScreen = () => {
|
||||||
|
|
||||||
const setConversation = (navigation, cardId, channelId, revision) => {
|
const setConversation = (navigation, cardId, channelId, revision) => {
|
||||||
setSelectedConversation({ cardId, channelId, revision });
|
|
||||||
navigation.navigate('conversation');
|
navigation.navigate('conversation');
|
||||||
|
setSelectedConversation({ cardId, channelId, revision });
|
||||||
}
|
}
|
||||||
const clearConversation = (navigation) => {
|
const clearConversation = (navigation) => {
|
||||||
navigation.dispatch(
|
navigation.dispatch(
|
||||||
|
@ -59,7 +59,7 @@ export function ConversationBody() {
|
|||||||
maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } }
|
maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } }
|
||||||
inverted={true}
|
inverted={true}
|
||||||
renderItem={({item}) => <TopicItem item={item} focused={item.topicId === state.focus}
|
renderItem={({item}) => <TopicItem item={item} focused={item.topicId === state.focus}
|
||||||
focus={() => actions.setFocus(item.topicId)} />}
|
focus={() => actions.setFocus(item.topicId)} hosting={state.host == null} />}
|
||||||
keyExtractor={item => item.topicId}
|
keyExtractor={item => item.topicId}
|
||||||
/>
|
/>
|
||||||
<View>
|
<View>
|
||||||
|
@ -16,9 +16,9 @@ import Carousel from 'react-native-snap-carousel';
|
|||||||
import GestureRecognizer from 'react-native-swipe-gestures';
|
import GestureRecognizer from 'react-native-swipe-gestures';
|
||||||
import avatar from 'images/avatar.png';
|
import avatar from 'images/avatar.png';
|
||||||
|
|
||||||
export function TopicItem({ item, focused, focus }) {
|
export function TopicItem({ item, focused, focus, hosting }) {
|
||||||
|
|
||||||
const { state, actions } = useTopicItem(item);
|
const { state, actions } = useTopicItem(item, hosting);
|
||||||
|
|
||||||
const renderAsset = (asset) => {
|
const renderAsset = (asset) => {
|
||||||
return (
|
return (
|
||||||
@ -66,7 +66,19 @@ export function TopicItem({ item, focused, focus }) {
|
|||||||
<Text style={styles.timestamp}>{ state.timestamp }</Text>
|
<Text style={styles.timestamp}>{ state.timestamp }</Text>
|
||||||
{ focused && (
|
{ focused && (
|
||||||
<View style={styles.focused}>
|
<View style={styles.focused}>
|
||||||
<MatIcons name="cloud-braces" size={24} color={Colors.background} />
|
{ state.deletable && (
|
||||||
|
<TouchableOpacity style={styles.icon}>
|
||||||
|
<MatIcons name="delete-outline" size={20} color={Colors.white} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
{ state.editable && (
|
||||||
|
<TouchableOpacity style={styles.icon}>
|
||||||
|
<MatIcons name="pencil-outline" size={20} color={Colors.white} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
<TouchableOpacity style={styles.icon}>
|
||||||
|
<MatIcons name="block-helper" size={18} color={Colors.white} />
|
||||||
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
@ -46,7 +46,19 @@ export const styles = StyleSheet.create({
|
|||||||
focused: {
|
focused: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: -16,
|
top: -16,
|
||||||
right: 16,
|
right: 0,
|
||||||
}
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||||
|
paddingTop: 4,
|
||||||
|
paddingBottom: 4,
|
||||||
|
borderRadius: 4,
|
||||||
|
paddingLeft: 8,
|
||||||
|
paddingRight: 8,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
paddingLeft: 4,
|
||||||
|
paddingRight: 4,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import moment from 'moment';
|
|||||||
import { useWindowDimensions } from 'react-native';
|
import { useWindowDimensions } from 'react-native';
|
||||||
import Colors from 'constants/Colors';
|
import Colors from 'constants/Colors';
|
||||||
|
|
||||||
export function useTopicItem(item) {
|
export function useTopicItem(item, hosting) {
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
name: null,
|
name: null,
|
||||||
@ -20,6 +20,8 @@ export function useTopicItem(item) {
|
|||||||
activeId: null,
|
activeId: null,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontColor: Colors.text,
|
fontColor: Colors.text,
|
||||||
|
editable: false,
|
||||||
|
deletable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = useContext(ProfileContext);
|
const profile = useContext(ProfileContext);
|
||||||
@ -121,7 +123,10 @@ export function useTopicItem(item) {
|
|||||||
timestamp = moment(date).format('M/DD/YYYY');
|
timestamp = moment(date).format('M/DD/YYYY');
|
||||||
}
|
}
|
||||||
|
|
||||||
updateState({ logo, name, known, message, fontSize, fontColor, timestamp, transform, status, assets });
|
const editable = detail.guid === identity.guid;
|
||||||
|
const deletable = editable || hosting;
|
||||||
|
|
||||||
|
updateState({ logo, name, known, message, fontSize, fontColor, timestamp, transform, status, assets, deletable, editable });
|
||||||
}, [card, item]);
|
}, [card, item]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
@ -10,6 +10,7 @@ export function useConversation() {
|
|||||||
latched: true,
|
latched: true,
|
||||||
momentum: false,
|
momentum: false,
|
||||||
focus: null,
|
focus: null,
|
||||||
|
host: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const conversation = useContext(ConversationContext);
|
const conversation = useContext(ConversationContext);
|
||||||
@ -19,7 +20,7 @@ export function useConversation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { subject, logo, topics } = conversation.state;
|
const { subject, logo, topics, host } = conversation.state;
|
||||||
const items = Array.from(topics.values());
|
const items = Array.from(topics.values());
|
||||||
const sorted = items.sort((a, b) => {
|
const sorted = items.sort((a, b) => {
|
||||||
const aTimestamp = a?.detail?.created;
|
const aTimestamp = a?.detail?.created;
|
||||||
@ -32,7 +33,7 @@ export function useConversation() {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
updateState({ topics, subject, logo, topics: sorted });
|
updateState({ topics, subject, logo, host, topics: sorted });
|
||||||
}, [conversation]);
|
}, [conversation]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
@ -11,8 +11,10 @@ export function MemberItem({ hostId, editable, members, item }) {
|
|||||||
|
|
||||||
const setMember = async (member) => {
|
const setMember = async (member) => {
|
||||||
try {
|
try {
|
||||||
|
if (editable) {
|
||||||
actions.setMember(member);
|
actions.setMember(member);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
|
@ -112,7 +112,7 @@ export function Profile() {
|
|||||||
<Ionicons name="picture" size={14} color={Colors.white} />
|
<Ionicons name="picture" size={14} color={Colors.white} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
{ state.disconnected && (
|
{ state.disconnected > 3 && (
|
||||||
<View style={styles.alert}>
|
<View style={styles.alert}>
|
||||||
<Text style={styles.disconnected}>Disconnected</Text>
|
<Text style={styles.disconnected}>Disconnected</Text>
|
||||||
</View>
|
</View>
|
||||||
|
Loading…
Reference in New Issue
Block a user