diff --git a/src/view/com/discover/LiteSuggestedFollows.tsx b/src/view/com/discover/LiteSuggestedFollows.tsx new file mode 100644 index 0000000000..ce01af7c7a --- /dev/null +++ b/src/view/com/discover/LiteSuggestedFollows.tsx @@ -0,0 +1,194 @@ +import React, {useEffect, useState} from 'react' +import { + ActivityIndicator, + StyleSheet, + TouchableOpacity, + View, +} from 'react-native' +import LinearGradient from 'react-native-linear-gradient' +import {observer} from 'mobx-react-lite' +import _omit from 'lodash.omit' +import {ErrorMessage} from '../util/error/ErrorMessage' +import {Link} from '../util/Link' +import {Text} from '../util/text/Text' +import {UserAvatar} from '../util/UserAvatar' +import * as Toast from '../util/Toast' +import {useStores} from '../../../state' +import * as apilib from '../../../state/lib/api' +import { + SuggestedActorsViewModel, + SuggestedActor, +} from '../../../state/models/suggested-actors-view' +import {s, gradients} from '../../lib/styles' +import {usePalette} from '../../lib/hooks/usePalette' + +export const LiteSuggestedFollows = observer(() => { + const store = useStores() + const [suggestions, setSuggestions] = useState( + undefined, + ) + const [follows, setFollows] = useState>({}) + + useEffect(() => { + const view = new SuggestedActorsViewModel(store) + view.loadMore().then( + () => { + setSuggestions(view.suggestions.slice().sort(randomize).slice(0, 3)) + }, + (err: any) => { + setSuggestions([]) + store.log.error('Failed to fetch suggestions', err) + }, + ) + }, [store, store.log]) + + const onPressFollow = async (item: SuggestedActor) => { + try { + const res = await apilib.follow(store, item.did, item.declaration.cid) + setFollows({[item.did]: res.uri, ...follows}) + } catch (e: any) { + store.log.error('Failed fo create follow', e) + Toast.show('An issue occurred, please try again.') + } + } + const onPressUnfollow = async (item: SuggestedActor) => { + try { + await apilib.unfollow(store, follows[item.did]) + setFollows(_omit(follows, [item.did])) + } catch (e: any) { + store.log.error('Failed fo delete follow', e) + Toast.show('An issue occurred, please try again.') + } + } + + return ( + + {!suggestions ? ( + + + + ) : ( + + {suggestions.map(item => ( + + + + ))} + + )} + + ) +}) + +const User = ({ + item, + follow, + onPressFollow, + onPressUnfollow, +}: { + item: SuggestedActor + follow: string | undefined + onPressFollow: (item: SuggestedActor) => void + onPressUnfollow: (item: SuggestedActor) => void +}) => { + const pal = usePalette('default') + return ( + + + + + + + + {item.displayName || item.handle} + + + @{item.handle} + + + + {follow ? ( + onPressUnfollow(item)}> + + + Unfollow + + + + ) : ( + onPressFollow(item)}> + + + Follow + + + + )} + + + + ) +} + +function randomize() { + return Math.random() > 0.5 ? 1 : -1 +} + +const styles = StyleSheet.create({ + footer: { + height: 200, + paddingTop: 20, + }, + + actor: {}, + actorMeta: { + flexDirection: 'row', + }, + actorAvi: { + width: 50, + paddingTop: 10, + paddingBottom: 10, + }, + actorContent: { + flex: 1, + paddingRight: 10, + paddingTop: 10, + }, + actorBtn: { + paddingRight: 10, + paddingTop: 10, + }, + + gradientBtn: { + paddingHorizontal: 14, + paddingVertical: 6, + }, + secondaryBtn: { + paddingHorizontal: 8, + }, + btn: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + paddingVertical: 7, + borderRadius: 50, + marginLeft: 6, + }, +}) diff --git a/src/view/shell/web/index.tsx b/src/view/shell/web/index.tsx index 93ae92824d..fedc9c3d6b 100644 --- a/src/view/shell/web/index.tsx +++ b/src/view/shell/web/index.tsx @@ -1,10 +1,10 @@ import React from 'react' import {observer} from 'mobx-react-lite' -import {View, StyleSheet, Text} from 'react-native' +import {View, StyleSheet} from 'react-native' import {useStores} from '../../../state' import {match, MatchResult} from '../../routes' import {DesktopLeftColumn} from './left-column' -// import {DesktopRightColumn} from './right-column' +import {DesktopRightColumn} from './right-column' import {Login} from '../../screens/Login' import {ErrorBoundary} from '../../com/util/ErrorBoundary' import {usePalette} from '../../lib/hooks/usePalette' @@ -35,6 +35,7 @@ export const WebShell: React.FC = observer(() => { ))} + ) // TODO @@ -48,25 +49,6 @@ export const WebShell: React.FC = observer(() => { // imagesOpen={store.shell.composerOpts?.imagesOpen} // onPost={store.shell.composerOpts?.onPost} // /> - // return ( - // - // {store.session.hasSession ? ( - // <> - // - // - // Hello, world! (Logged in) - // {children} - // - // - // - // ) : ( - // - // Hello, world! (Logged out) - // {children} - // - // )} - // - // ) }) /** diff --git a/src/view/shell/web/left-column.tsx b/src/view/shell/web/left-column.tsx index b7309d9c5f..411b4674b3 100644 --- a/src/view/shell/web/left-column.tsx +++ b/src/view/shell/web/left-column.tsx @@ -42,7 +42,9 @@ export const NavItem = observer( )} - {label} + + {label} + ) @@ -86,10 +88,11 @@ export const DesktopLeftColumn = observer(() => { const styles = StyleSheet.create({ container: { position: 'absolute', - left: 'calc(50vw - 500px)', - width: '200px', + left: 'calc(50vw - 530px)', + width: '230px', height: '100%', borderRightWidth: 1, + paddingTop: 20, }, navItem: { padding: '1rem', @@ -109,7 +112,11 @@ const styles = StyleSheet.create({ backgroundColor: colors.red3, color: colors.white, fontSize: 12, + fontWeight: 'bold', paddingHorizontal: 4, - borderRadius: 4, + borderRadius: 6, + }, + navItemLabel: { + fontSize: 19, }, }) diff --git a/src/view/shell/web/right-column.tsx b/src/view/shell/web/right-column.tsx index 5fe65cac81..2daa16f6a2 100644 --- a/src/view/shell/web/right-column.tsx +++ b/src/view/shell/web/right-column.tsx @@ -1,10 +1,28 @@ import React from 'react' -import {Text, View, StyleSheet} from 'react-native' +import {View, StyleSheet} from 'react-native' +import {Link} from '../../com/util/Link' +import {Text} from '../../com/util/text/Text' +import {usePalette} from '../../lib/hooks/usePalette' +import {MagnifyingGlassIcon} from '../../lib/icons' +import {LiteSuggestedFollows} from '../../com/discover/LiteSuggestedFollows' +import {s} from '../../lib/styles' export const DesktopRightColumn: React.FC = () => { + const pal = usePalette('default') return ( - - Right Column + + + + + + + Search + + + + Suggested Follows + + ) } @@ -12,8 +30,23 @@ export const DesktopRightColumn: React.FC = () => { const styles = StyleSheet.create({ container: { position: 'absolute', - right: 'calc(50vw - 500px)', - width: '200px', + right: 'calc(50vw - 650px)', + width: '350px', height: '100%', + borderLeftWidth: 1, + overscrollBehavior: 'auto', + paddingLeft: 30, + paddingTop: 10, + }, + searchContainer: { + flexDirection: 'row', + alignItems: 'center', + paddingHorizontal: 14, + paddingVertical: 10, + borderRadius: 20, + marginBottom: 20, + }, + searchIcon: { + marginRight: 5, }, })