diff options
Diffstat (limited to 'src/view/com/util')
-rw-r--r-- | src/view/com/util/PostCtrls.tsx | 70 | ||||
-rw-r--r-- | src/view/com/util/Toast.native.tsx | 2 | ||||
-rw-r--r-- | src/view/com/util/Toast.tsx | 69 | ||||
-rw-r--r-- | src/view/com/util/ViewHeader.tsx | 42 |
4 files changed, 75 insertions, 108 deletions
diff --git a/src/view/com/util/PostCtrls.tsx b/src/view/com/util/PostCtrls.tsx index a316d8959..10b54be3f 100644 --- a/src/view/com/util/PostCtrls.tsx +++ b/src/view/com/util/PostCtrls.tsx @@ -12,9 +12,10 @@ import {UpIcon, UpIconSolid} from '../../lib/icons' import {s, colors} from '../../lib/styles' interface PostCtrlsOpts { - replyCount: number - repostCount: number - upvoteCount: number + big?: boolean + replyCount?: number + repostCount?: number + upvoteCount?: number isReposted: boolean isUpvoted: boolean onPressReply: () => void @@ -30,17 +31,17 @@ export function PostCtrls(opts: PostCtrlsOpts) { const interp2 = useSharedValue<number>(0) const anim1Style = useAnimatedStyle(() => ({ - transform: [{scale: interpolate(interp1.value, [0, 1.0], [1.0, 3.0])}], + transform: [{scale: interpolate(interp1.value, [0, 1.0], [1.0, 4.0])}], opacity: interpolate(interp1.value, [0, 1.0], [1.0, 0.0]), })) const anim2Style = useAnimatedStyle(() => ({ - transform: [{scale: interpolate(interp2.value, [0, 1.0], [1.0, 3.0])}], + transform: [{scale: interpolate(interp2.value, [0, 1.0], [1.0, 4.0])}], opacity: interpolate(interp2.value, [0, 1.0], [1.0, 0.0]), })) const onPressToggleRepostWrapper = () => { if (!opts.isReposted) { - interp1.value = withTiming(1, {duration: 300}, () => { + interp1.value = withTiming(1, {duration: 400}, () => { interp1.value = withDelay(100, withTiming(0, {duration: 20})) }) } @@ -48,7 +49,7 @@ export function PostCtrls(opts: PostCtrlsOpts) { } const onPressToggleUpvoteWrapper = () => { if (!opts.isUpvoted) { - interp2.value = withTiming(1, {duration: 300}, () => { + interp2.value = withTiming(1, {duration: 400}, () => { interp2.value = withDelay(100, withTiming(0, {duration: 20})) }) } @@ -62,9 +63,11 @@ export function PostCtrls(opts: PostCtrlsOpts) { <FontAwesomeIcon style={styles.ctrlIcon} icon={['far', 'comment']} - size={14} + size={opts.big ? 20 : 14} /> - <Text style={[sRedgray, s.ml5, s.f16]}>{opts.replyCount}</Text> + {typeof opts.replyCount !== 'undefined' ? ( + <Text style={[sRedgray, s.ml5, s.f16]}>{opts.replyCount}</Text> + ) : undefined} </TouchableOpacity> </View> <View style={s.flex1}> @@ -77,17 +80,19 @@ export function PostCtrls(opts: PostCtrlsOpts) { opts.isReposted ? styles.ctrlIconReposted : styles.ctrlIcon } icon="retweet" - size={18} + size={opts.big ? 22 : 18} /> </Animated.View> - <Text - style={ - opts.isReposted - ? [s.bold, s.green3, s.f16, s.ml5] - : [sRedgray, s.f16, s.ml5] - }> - {opts.repostCount} - </Text> + {typeof opts.repostCount !== 'undefined' ? ( + <Text + style={ + opts.isReposted + ? [s.bold, s.green3, s.f16, s.ml5] + : [sRedgray, s.f16, s.ml5] + }> + {opts.repostCount} + </Text> + ) : undefined} </TouchableOpacity> </View> <View style={s.flex1}> @@ -96,19 +101,28 @@ export function PostCtrls(opts: PostCtrlsOpts) { onPress={onPressToggleUpvoteWrapper}> <Animated.View style={anim2Style}> {opts.isUpvoted ? ( - <UpIconSolid style={[styles.ctrlIconUpvoted]} size={18} /> + <UpIconSolid + style={[styles.ctrlIconUpvoted]} + size={opts.big ? 22 : 18} + /> ) : ( - <UpIcon style={[styles.ctrlIcon]} size={18} strokeWidth={1.5} /> + <UpIcon + style={[styles.ctrlIcon]} + size={opts.big ? 22 : 18} + strokeWidth={1.5} + /> )} </Animated.View> - <Text - style={ - opts.isUpvoted - ? [s.bold, s.red3, s.f16, s.ml5] - : [sRedgray, s.f16, s.ml5] - }> - {opts.upvoteCount} - </Text> + {typeof opts.upvoteCount !== 'undefined' ? ( + <Text + style={ + opts.isUpvoted + ? [s.bold, s.red3, s.f16, s.ml5] + : [sRedgray, s.f16, s.ml5] + }> + {opts.upvoteCount} + </Text> + ) : undefined} </TouchableOpacity> </View> <View style={s.flex1}></View> diff --git a/src/view/com/util/Toast.native.tsx b/src/view/com/util/Toast.native.tsx deleted file mode 100644 index 4b9fd7f80..000000000 --- a/src/view/com/util/Toast.native.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import Toast from 'react-native-root-toast' -export default Toast diff --git a/src/view/com/util/Toast.tsx b/src/view/com/util/Toast.tsx index 1726b71b3..197f47422 100644 --- a/src/view/com/util/Toast.tsx +++ b/src/view/com/util/Toast.tsx @@ -1,62 +1,11 @@ -/* - * Note: the dataSet properties are used to leverage custom CSS in public/index.html - */ - -import React, {useState, useEffect} from 'react' -// @ts-ignore no declarations available -prf -import {Text, View} from 'react-native-web' -import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' - -interface ActiveToast { - text: string -} -type GlobalSetActiveToast = (_activeToast: ActiveToast | undefined) => void - -// globals -// = -let globalSetActiveToast: GlobalSetActiveToast | undefined -let toastTimeout: NodeJS.Timeout | undefined - -// components -// = -type ToastContainerProps = {} -const ToastContainer: React.FC<ToastContainerProps> = ({}) => { - const [activeToast, setActiveToast] = useState<ActiveToast | undefined>() - useEffect(() => { - globalSetActiveToast = (t: ActiveToast | undefined) => { - setActiveToast(t) - } +import Toast from 'react-native-root-toast' + +export function show(message: string) { + Toast.show(message, { + duration: Toast.durations.LONG, + position: 50, + shadow: true, + animation: true, + hideOnPress: true, }) - return ( - <> - {activeToast && ( - <View dataSet={{'toast-container': 1}}> - <FontAwesomeIcon icon="check" size={24} /> - <Text>{activeToast.text}</Text> - </View> - )} - </> - ) -} - -// exports -// = -export default { - show(text: string, _opts: any) { - console.log('TODO: toast', text) - if (toastTimeout) { - clearTimeout(toastTimeout) - } - globalSetActiveToast?.({text}) - toastTimeout = setTimeout(() => { - globalSetActiveToast?.(undefined) - }, 2e3) - }, - positions: { - TOP: 0, - }, - durations: { - LONG: 0, - }, - ToastContainer, } diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx index 55a71ea26..50b7e6532 100644 --- a/src/view/com/util/ViewHeader.tsx +++ b/src/view/com/util/ViewHeader.tsx @@ -1,7 +1,6 @@ import React from 'react' import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' -import {UserAvatar} from './UserAvatar' import {colors} from '../../lib/styles' import {MagnifyingGlassIcon} from '../../lib/icons' import {useStores} from '../../../state' @@ -9,14 +8,19 @@ import {useStores} from '../../../state' export function ViewHeader({ title, subtitle, + onPost, }: { title: string subtitle?: string + onPost?: () => void }) { const store = useStores() const onPressBack = () => { store.nav.tab.goBack() } + const onPressCompose = () => { + store.shell.openComposer({onPost}) + } const onPressSearch = () => { store.nav.navigate(`/search`) } @@ -26,9 +30,7 @@ export function ViewHeader({ <TouchableOpacity onPress={onPressBack} style={styles.backIcon}> <FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} /> </TouchableOpacity> - ) : ( - <View style={styles.cornerPlaceholder} /> - )} + ) : undefined} <View style={styles.titleContainer}> <Text style={styles.title}>{title}</Text> {subtitle ? ( @@ -37,8 +39,17 @@ export function ViewHeader({ </Text> ) : undefined} </View> - <TouchableOpacity onPress={onPressSearch} style={styles.searchBtn}> - <MagnifyingGlassIcon size={17} style={styles.searchBtnIcon} /> + <TouchableOpacity onPress={onPressCompose} style={styles.btn}> + <FontAwesomeIcon size={18} icon="plus" /> + </TouchableOpacity> + <TouchableOpacity + onPress={onPressSearch} + style={[styles.btn, {marginLeft: 8}]}> + <MagnifyingGlassIcon + size={18} + strokeWidth={3} + style={styles.searchBtnIcon} + /> </TouchableOpacity> </View> ) @@ -59,33 +70,28 @@ const styles = StyleSheet.create({ titleContainer: { flexDirection: 'row', alignItems: 'baseline', - marginLeft: 'auto', marginRight: 'auto', }, title: { - fontSize: 16, + fontSize: 21, fontWeight: '600', }, subtitle: { - fontSize: 15, - marginLeft: 3, + fontSize: 18, + marginLeft: 6, color: colors.gray4, maxWidth: 200, }, - cornerPlaceholder: { - width: 30, - height: 30, - }, backIcon: {width: 30, height: 30}, - searchBtn: { + btn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', backgroundColor: colors.gray1, - width: 30, - height: 30, - borderRadius: 15, + width: 36, + height: 36, + borderRadius: 20, }, searchBtnIcon: { color: colors.black, |