From 69b86255c6c2275b3403ce6654b17e0a2c56ced6 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Sun, 18 Dec 2022 17:45:23 -0600 Subject: [PATCH] Add WIP 'report account' modal --- src/state/models/shell-ui.ts | 12 +++- src/view/com/modals/Modal.tsx | 8 +++ src/view/com/modals/ReportAccount.tsx | 95 ++++++++++++++++++++++++++ src/view/com/profile/ProfileHeader.tsx | 16 ++++- 4 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 src/view/com/modals/ReportAccount.tsx diff --git a/src/state/models/shell-ui.ts b/src/state/models/shell-ui.ts index d1f45854..6b3134ff 100644 --- a/src/state/models/shell-ui.ts +++ b/src/state/models/shell-ui.ts @@ -59,6 +59,14 @@ export class ReportPostModal { } } +export class ReportAccountModal { + name = 'report-account' + + constructor(public did: string) { + makeAutoObservable(this) + } +} + interface LightboxModel { canSwipeLeft: boolean canSwipeRight: boolean @@ -136,6 +144,7 @@ export class ShellUiModel { | CreateSceneModal | ServerInputModal | ReportPostModal + | ReportAccountModal | undefined isLightboxActive = false activeLightbox: @@ -164,7 +173,8 @@ export class ShellUiModel { | EditProfileModal | CreateSceneModal | ServerInputModal - | ReportPostModal, + | ReportPostModal + | ReportAccountModal, ) { this.isModalActive = true this.activeModal = modal diff --git a/src/view/com/modals/Modal.tsx b/src/view/com/modals/Modal.tsx index e1d2eaca..43271c96 100644 --- a/src/view/com/modals/Modal.tsx +++ b/src/view/com/modals/Modal.tsx @@ -13,6 +13,7 @@ import * as CreateSceneModal from './CreateScene' import * as InviteToSceneModal from './InviteToScene' import * as ServerInputModal from './ServerInput' import * as ReportPostModal from './ReportPost' +import * as ReportAccountModal from './ReportAccount' const CLOSED_SNAPPOINTS = ['10%'] @@ -78,6 +79,13 @@ export const Modal = observer(function Modal() { {...(store.shell.activeModal as models.ReportPostModal)} /> ) + } else if (store.shell.activeModal?.name === 'report-account') { + snapPoints = ReportAccountModal.snapPoints + element = ( + + ) } else { element = } diff --git a/src/view/com/modals/ReportAccount.tsx b/src/view/com/modals/ReportAccount.tsx new file mode 100644 index 00000000..e5491678 --- /dev/null +++ b/src/view/com/modals/ReportAccount.tsx @@ -0,0 +1,95 @@ +import React, {useState} from 'react' +import { + ActivityIndicator, + StyleSheet, + Text, + TouchableOpacity, + View, +} from 'react-native' +import LinearGradient from 'react-native-linear-gradient' +import {useStores} from '../../../state' +import {s, colors, gradients} from '../../lib/styles' +import {RadioGroup, RadioGroupItem} from '../util/forms/RadioGroup' +import {ErrorMessage} from '../util/ErrorMessage' + +const ITEMS: RadioGroupItem[] = [ + {key: 'spam', label: 'Spam or excessive repeat posts'}, + {key: 'abuse', label: 'Abusive, rude, or hateful'}, + {key: 'illegal', label: 'Posts illegal content'}, +] + +export const snapPoints = ['50%'] + +export function Component({did}: {did: string}) { + const store = useStores() + const [isProcessing, setIsProcessing] = useState(false) + const [error, setError] = useState('') + const [issue, setIssue] = useState('') + const onSelectIssue = (v: string) => setIssue(v) + const onPress = async () => { + setError('') + setIsProcessing(true) + try { + // TODO + store.shell.closeModal() + return + } catch (e: any) { + setError(e.toString()) + setIsProcessing(false) + } + } + return ( + + Report account + + What is the issue with this account? + + + {error ? ( + + + + ) : undefined} + {isProcessing ? ( + + + + ) : issue ? ( + + + Send Report + + + ) : undefined} + + ) +} + +const styles = StyleSheet.create({ + title: { + textAlign: 'center', + fontWeight: 'bold', + fontSize: 24, + marginBottom: 12, + }, + description: { + textAlign: 'center', + fontSize: 17, + paddingHorizontal: 22, + color: colors.gray5, + marginBottom: 10, + }, + btn: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + width: '100%', + borderRadius: 32, + padding: 14, + backgroundColor: colors.gray1, + }, +}) diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index a998a461..de9ae1dd 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -10,6 +10,7 @@ import { ConfirmModal, EditProfileModal, InviteToSceneModal, + ReportAccountModal, ProfileImageLightbox, } from '../../../state/models/shell-ui' import {pluralize} from '../../../lib/strings' @@ -85,6 +86,9 @@ export const ProfileHeader = observer(function ProfileHeader({ } onRefreshAll() } + const onPressReportAccount = () => { + store.shell.openModal(new ReportAccountModal(view.did)) + } // loading // = @@ -133,8 +137,15 @@ export const ProfileHeader = observer(function ProfileHeader({ const isMe = store.me.did === view.did const isCreator = view.isScene && view.creator === store.me.did let dropdownItems: DropdownItem[] | undefined + if (!isMe) { + dropdownItems = dropdownItems || [] + dropdownItems.push({ + label: 'Report Account', + onPress: onPressReportAccount, + }) + } if (isCreator || isMember) { - dropdownItems = [] + dropdownItems = dropdownItems || [] if (isCreator) { dropdownItems.push({ label: 'Edit Profile', @@ -182,8 +193,7 @@ export const ProfileHeader = observer(function ProfileHeader({ )} )} - {view.isScene && - (view.myState.member || view.creator === store.me.did) ? ( + {dropdownItems?.length ? (