@@ -1,6 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {
|
import {
|
||||||
Animated,
|
|
||||||
StyleProp,
|
StyleProp,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
@@ -9,10 +8,11 @@ import {
|
|||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'
|
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'
|
||||||
import {
|
// DISABLED see #135
|
||||||
TriggerableAnimated,
|
// import {
|
||||||
TriggerableAnimatedRef,
|
// TriggerableAnimated,
|
||||||
} from './anim/TriggerableAnimated'
|
// TriggerableAnimatedRef,
|
||||||
|
// } from './anim/TriggerableAnimated'
|
||||||
import {Text} from './text/Text'
|
import {Text} from './text/Text'
|
||||||
import {PostDropdownBtn} from './forms/DropdownButton'
|
import {PostDropdownBtn} from './forms/DropdownButton'
|
||||||
import {
|
import {
|
||||||
@@ -44,6 +44,8 @@ interface PostCtrlsOpts {
|
|||||||
|
|
||||||
const HITSLOP = {top: 5, left: 5, bottom: 5, right: 5}
|
const HITSLOP = {top: 5, left: 5, bottom: 5, right: 5}
|
||||||
|
|
||||||
|
// DISABLED see #135
|
||||||
|
/*
|
||||||
function ctrlAnimStart(interp: Animated.Value) {
|
function ctrlAnimStart(interp: Animated.Value) {
|
||||||
return Animated.sequence([
|
return Animated.sequence([
|
||||||
Animated.timing(interp, {
|
Animated.timing(interp, {
|
||||||
@@ -76,6 +78,7 @@ function ctrlAnimStyle(interp: Animated.Value) {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
export function PostCtrls(opts: PostCtrlsOpts) {
|
export function PostCtrls(opts: PostCtrlsOpts) {
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
@@ -87,19 +90,25 @@ export function PostCtrls(opts: PostCtrlsOpts) {
|
|||||||
)
|
)
|
||||||
const [repostMod, setRepostMod] = React.useState<number>(0)
|
const [repostMod, setRepostMod] = React.useState<number>(0)
|
||||||
const [likeMod, setLikeMod] = React.useState<number>(0)
|
const [likeMod, setLikeMod] = React.useState<number>(0)
|
||||||
const repostRef = React.useRef<TriggerableAnimatedRef | null>(null)
|
// DISABLED see #135
|
||||||
const likeRef = React.useRef<TriggerableAnimatedRef | null>(null)
|
// const repostRef = React.useRef<TriggerableAnimatedRef | null>(null)
|
||||||
|
// const likeRef = React.useRef<TriggerableAnimatedRef | null>(null)
|
||||||
const onPressToggleRepostWrapper = () => {
|
const onPressToggleRepostWrapper = () => {
|
||||||
if (!opts.isReposted) {
|
if (!opts.isReposted) {
|
||||||
ReactNativeHapticFeedback.trigger('impactMedium')
|
ReactNativeHapticFeedback.trigger('impactMedium')
|
||||||
setRepostMod(1)
|
setRepostMod(1)
|
||||||
repostRef.current?.trigger(
|
opts
|
||||||
{start: ctrlAnimStart, style: ctrlAnimStyle},
|
.onPressToggleRepost()
|
||||||
async () => {
|
.catch(_e => undefined)
|
||||||
await opts.onPressToggleRepost().catch(_e => undefined)
|
.then(() => setRepostMod(0))
|
||||||
setRepostMod(0)
|
// DISABLED see #135
|
||||||
},
|
// repostRef.current?.trigger(
|
||||||
)
|
// {start: ctrlAnimStart, style: ctrlAnimStyle},
|
||||||
|
// async () => {
|
||||||
|
// await opts.onPressToggleRepost().catch(_e => undefined)
|
||||||
|
// setRepostMod(0)
|
||||||
|
// },
|
||||||
|
// )
|
||||||
} else {
|
} else {
|
||||||
setRepostMod(-1)
|
setRepostMod(-1)
|
||||||
opts
|
opts
|
||||||
@@ -112,13 +121,18 @@ export function PostCtrls(opts: PostCtrlsOpts) {
|
|||||||
if (!opts.isUpvoted) {
|
if (!opts.isUpvoted) {
|
||||||
ReactNativeHapticFeedback.trigger('impactMedium')
|
ReactNativeHapticFeedback.trigger('impactMedium')
|
||||||
setLikeMod(1)
|
setLikeMod(1)
|
||||||
likeRef.current?.trigger(
|
opts
|
||||||
{start: ctrlAnimStart, style: ctrlAnimStyle},
|
.onPressToggleUpvote()
|
||||||
async () => {
|
.catch(_e => undefined)
|
||||||
await opts.onPressToggleUpvote().catch(_e => undefined)
|
.then(() => setLikeMod(0))
|
||||||
setLikeMod(0)
|
// DISABLED see #135
|
||||||
},
|
// likeRef.current?.trigger(
|
||||||
)
|
// {start: ctrlAnimStart, style: ctrlAnimStyle},
|
||||||
|
// async () => {
|
||||||
|
// await opts.onPressToggleUpvote().catch(_e => undefined)
|
||||||
|
// setLikeMod(0)
|
||||||
|
// },
|
||||||
|
// )
|
||||||
} else {
|
} else {
|
||||||
setLikeMod(-1)
|
setLikeMod(-1)
|
||||||
opts
|
opts
|
||||||
@@ -152,7 +166,17 @@ export function PostCtrls(opts: PostCtrlsOpts) {
|
|||||||
hitSlop={HITSLOP}
|
hitSlop={HITSLOP}
|
||||||
onPress={onPressToggleRepostWrapper}
|
onPress={onPressToggleRepostWrapper}
|
||||||
style={styles.ctrl}>
|
style={styles.ctrl}>
|
||||||
<TriggerableAnimated ref={repostRef}>
|
<RepostIcon
|
||||||
|
style={
|
||||||
|
opts.isReposted || repostMod > 0
|
||||||
|
? styles.ctrlIconReposted
|
||||||
|
: defaultCtrlColor
|
||||||
|
}
|
||||||
|
strokeWidth={2.4}
|
||||||
|
size={opts.big ? 24 : 20}
|
||||||
|
/>
|
||||||
|
{
|
||||||
|
undefined /*DISABLED see #135 <TriggerableAnimated ref={repostRef}>
|
||||||
<RepostIcon
|
<RepostIcon
|
||||||
style={
|
style={
|
||||||
opts.isReposted || repostMod > 0
|
opts.isReposted || repostMod > 0
|
||||||
@@ -162,8 +186,8 @@ export function PostCtrls(opts: PostCtrlsOpts) {
|
|||||||
strokeWidth={2.4}
|
strokeWidth={2.4}
|
||||||
size={opts.big ? 24 : 20}
|
size={opts.big ? 24 : 20}
|
||||||
/>
|
/>
|
||||||
</TriggerableAnimated>
|
</TriggerableAnimated>*/
|
||||||
|
}
|
||||||
{typeof opts.repostCount !== 'undefined' ? (
|
{typeof opts.repostCount !== 'undefined' ? (
|
||||||
<Text
|
<Text
|
||||||
style={
|
style={
|
||||||
@@ -181,7 +205,20 @@ export function PostCtrls(opts: PostCtrlsOpts) {
|
|||||||
style={styles.ctrl}
|
style={styles.ctrl}
|
||||||
hitSlop={HITSLOP}
|
hitSlop={HITSLOP}
|
||||||
onPress={onPressToggleUpvoteWrapper}>
|
onPress={onPressToggleUpvoteWrapper}>
|
||||||
<TriggerableAnimated ref={likeRef}>
|
{opts.isUpvoted || likeMod > 0 ? (
|
||||||
|
<HeartIconSolid
|
||||||
|
style={[styles.ctrlIconUpvoted]}
|
||||||
|
size={opts.big ? 22 : 16}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<HeartIcon
|
||||||
|
style={[defaultCtrlColor, opts.big ? styles.mt1 : undefined]}
|
||||||
|
strokeWidth={3}
|
||||||
|
size={opts.big ? 20 : 16}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{
|
||||||
|
undefined /*DISABLED see #135 <TriggerableAnimated ref={likeRef}>
|
||||||
{opts.isUpvoted || likeMod > 0 ? (
|
{opts.isUpvoted || likeMod > 0 ? (
|
||||||
<HeartIconSolid
|
<HeartIconSolid
|
||||||
style={[styles.ctrlIconUpvoted]}
|
style={[styles.ctrlIconUpvoted]}
|
||||||
@@ -194,7 +231,8 @@ export function PostCtrls(opts: PostCtrlsOpts) {
|
|||||||
size={opts.big ? 20 : 16}
|
size={opts.big ? 20 : 16}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</TriggerableAnimated>
|
</TriggerableAnimated>*/
|
||||||
|
}
|
||||||
{typeof opts.upvoteCount !== 'undefined' ? (
|
{typeof opts.upvoteCount !== 'undefined' ? (
|
||||||
<Text
|
<Text
|
||||||
style={
|
style={
|
||||||
|
|||||||
Reference in New Issue
Block a user