diff options
Diffstat (limited to 'src/view/com/profile/ProfileHeader.tsx')
-rw-r--r-- | src/view/com/profile/ProfileHeader.tsx | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index 50bc2bd19..1eace94aa 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -1,12 +1,20 @@ import React, {useState, useEffect} from 'react' import {observer} from 'mobx-react-lite' -import {ActivityIndicator, Image, StyleSheet, Text, View} from 'react-native' +import { + ActivityIndicator, + Button, + Image, + StyleSheet, + Text, + View, +} from 'react-native' import {OnNavigateContent} from '../../routes/types' import {ProfileViewModel} from '../../../state/models/profile-view' import {useStores} from '../../../state' import {pluralize} from '../../lib/strings' import {s} from '../../lib/styles' import {AVIS} from '../../lib/assets' +import Toast from '../util/Toast' export const ProfileHeader = observer(function ProfileHeader({ user, @@ -29,6 +37,23 @@ export const ProfileHeader = observer(function ProfileHeader({ newView.setup().catch(err => console.error('Failed to fetch profile', err)) }, [user, view?.params.user, store]) + const onPressToggleFollow = () => { + view?.toggleFollowing().then( + () => { + Toast.show( + `${view.myState.hasFollowed ? 'Following' : 'No longer following'} ${ + view.displayName || view.name + }`, + { + duration: Toast.durations.LONG, + position: Toast.positions.TOP, + }, + ) + }, + err => console.error('Failed to toggle follow', err), + ) + } + // loading // = if ( @@ -81,6 +106,12 @@ export const ProfileHeader = observer(function ProfileHeader({ <Text style={s.gray}>{pluralize(view.postsCount, 'post')}</Text> </View> </View> + <View> + <Button + title={view.myState.hasFollowed ? 'Unfollow' : 'Follow'} + onPress={onPressToggleFollow} + /> + </View> </View> ) }) |