drag to rearrange pinned items

This commit is contained in:
Ansh Nanda 2023-05-16 18:28:44 -07:00
parent 139027ac5f
commit 53ca0cd626
7 changed files with 256 additions and 39 deletions

View file

@ -24,13 +24,11 @@ const AlgoItem = observer(
item,
style,
showBottom = true,
onLongPress,
reloadOnFocus = false,
}: {
item: AlgoItemModel
style?: StyleProp<ViewStyle>
showBottom?: boolean
onLongPress?: () => void
reloadOnFocus?: boolean
}) => {
const store = useStores()
@ -54,7 +52,6 @@ const AlgoItem = observer(
rkey: item.data.uri,
})
}}
onLongPress={onLongPress}
key={item.data.uri}>
<View style={[styles.headerContainer]}>
<View style={[s.mr10]}>
@ -64,8 +61,9 @@ const AlgoItem = observer(
<Text style={[pal.text, s.bold]}>
{item.data.displayName ?? 'Feed name'}
</Text>
<Text style={[pal.textLight, styles.description]}>
{item.data.description ?? 'Feed description'}
<Text style={[pal.textLight, styles.description]} numberOfLines={5}>
{item.data.description ??
"Explore our Feed for the latest updates and insights! Dive into a world of intriguing articles, trending news, and exciting stories that cover a wide range of topics. From technology breakthroughs to lifestyle tips, there's something here for everyone. Stay informed and get inspired with us. Join the conversation now!"}
</Text>
</View>
</View>

View file

@ -0,0 +1,50 @@
import React from 'react'
import {View, TouchableOpacity, StyleSheet} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {colors} from 'lib/styles'
import {observer} from 'mobx-react-lite'
import {AlgoItemModel} from 'state/models/feeds/algo/algo-item'
import {SavedFeedsModel} from 'state/models/feeds/algo/saved'
import AlgoItem from './AlgoItem'
export const SavedFeedItem = observer(
({item, savedFeeds}: {item: AlgoItemModel; savedFeeds: SavedFeedsModel}) => {
const isPinned = savedFeeds.isPinned(item)
return (
<View style={styles.itemContainer}>
<AlgoItem
key={item.data.uri}
item={item}
showBottom={false}
style={styles.item}
/>
<TouchableOpacity
accessibilityRole="button"
onPress={() => {
savedFeeds.togglePinnedFeed(item)
console.log('pinned', savedFeeds.pinned)
console.log('isPinned', savedFeeds.isPinned(item))
}}>
<FontAwesomeIcon
icon="thumb-tack"
size={20}
color={isPinned ? colors.blue3 : colors.gray3}
/>
</TouchableOpacity>
</View>
)
},
)
const styles = StyleSheet.create({
itemContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginRight: 18,
},
item: {
borderTopWidth: 0,
},
})