From 5961c268005eda9c37b26d48fe9f5ae2def9106e Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 26 Jan 2023 23:24:37 -0600 Subject: [PATCH] Update 'load latest' btn for web --- src/view/com/util/LoadLatestBtn.tsx | 57 +++++++++++++++++++++++++ src/view/com/util/LoadLatestBtn.web.tsx | 36 ++++++++++++++++ src/view/screens/Home.tsx | 56 +++--------------------- 3 files changed, 99 insertions(+), 50 deletions(-) create mode 100644 src/view/com/util/LoadLatestBtn.tsx create mode 100644 src/view/com/util/LoadLatestBtn.web.tsx diff --git a/src/view/com/util/LoadLatestBtn.tsx b/src/view/com/util/LoadLatestBtn.tsx new file mode 100644 index 00000000..43fa97e6 --- /dev/null +++ b/src/view/com/util/LoadLatestBtn.tsx @@ -0,0 +1,57 @@ +import React from 'react' +import {StyleSheet, TouchableOpacity} from 'react-native' +import {observer} from 'mobx-react-lite' +import LinearGradient from 'react-native-linear-gradient' +import {useSafeAreaInsets} from 'react-native-safe-area-context' +import {Text} from './text/Text' +import {colors, gradients} from '../../lib/styles' +import {clamp} from 'lodash' +import {useStores} from '../../../state' + +const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20} + +export const LoadLatestBtn = observer(({onPress}: {onPress: () => void}) => { + const store = useStores() + const safeAreaInsets = useSafeAreaInsets() + return ( + + + + Load new posts + + + + ) +}) + +const styles = StyleSheet.create({ + loadLatest: { + position: 'absolute', + left: 20, + bottom: 35, + shadowColor: '#000', + shadowOpacity: 0.3, + shadowOffset: {width: 0, height: 1}, + }, + loadLatestInner: { + flexDirection: 'row', + paddingHorizontal: 14, + paddingVertical: 10, + borderRadius: 30, + }, + loadLatestText: { + color: colors.white, + }, +}) diff --git a/src/view/com/util/LoadLatestBtn.web.tsx b/src/view/com/util/LoadLatestBtn.web.tsx new file mode 100644 index 00000000..38892738 --- /dev/null +++ b/src/view/com/util/LoadLatestBtn.web.tsx @@ -0,0 +1,36 @@ +import React from 'react' +import {StyleSheet, TouchableOpacity} from 'react-native' +import {Text} from './text/Text' +import {usePalette} from '../../lib/hooks/usePalette' + +const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20} + +export const LoadLatestBtn = ({onPress}: {onPress: () => void}) => { + const pal = usePalette('default') + return ( + + + Load new posts + + + ) +} + +const styles = StyleSheet.create({ + loadLatest: { + flexDirection: 'row', + position: 'absolute', + left: 'calc(50vw - 80px)', + top: 30, + shadowColor: '#000', + shadowOpacity: 0.2, + shadowOffset: {width: 0, height: 2}, + shadowRadius: 4, + paddingHorizontal: 24, + paddingVertical: 10, + borderRadius: 30, + }, +}) diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 384ee15e..4222c751 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -1,20 +1,15 @@ import React, {useEffect} from 'react' -import {StyleSheet, TouchableOpacity, View} from 'react-native' +import {View} from 'react-native' import {observer} from 'mobx-react-lite' import useAppState from 'react-native-appstate-hook' -import LinearGradient from 'react-native-linear-gradient' -import {useSafeAreaInsets} from 'react-native-safe-area-context' import {ViewHeader} from '../com/util/ViewHeader' import {Feed} from '../com/posts/Feed' -import {Text} from '../com/util/text/Text' import {FAB} from '../com/util/FAB' +import {LoadLatestBtn} from '../com/util/LoadLatestBtn' import {useStores} from '../../state' import {ScreenParams} from '../routes' -import {s, colors, gradients} from '../lib/styles' +import {s} from '../lib/styles' import {useOnMainScroll} from '../lib/hooks/useOnMainScroll' -import {clamp} from 'lodash' - -const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20} export const Home = observer(function Home({ navIdx, @@ -23,7 +18,6 @@ export const Home = observer(function Home({ }: ScreenParams) { const store = useStores() const onMainScroll = useOnMainScroll(store) - const safeAreaInsets = useSafeAreaInsets() const [wasVisible, setWasVisible] = React.useState(false) const {appState} = useAppState({ onForeground: () => doPoll(true), @@ -95,48 +89,10 @@ export const Home = observer(function Home({ onPressTryAgain={onPressTryAgain} onScroll={onMainScroll} /> - {store.me.mainFeed.hasNewLatest && !store.me.mainFeed.isRefreshing ? ( - - - - Load new posts - - - - ) : undefined} + {store.me.mainFeed.hasNewLatest && !store.me.mainFeed.isRefreshing && ( + + )} onPressCompose(false)} /> ) }) - -const styles = StyleSheet.create({ - loadLatest: { - position: 'absolute', - left: 20, - bottom: 35, - shadowColor: '#000', - shadowOpacity: 0.3, - shadowOffset: {width: 0, height: 1}, - }, - loadLatestInner: { - flexDirection: 'row', - paddingHorizontal: 14, - paddingVertical: 10, - borderRadius: 30, - }, - loadLatestText: { - color: colors.white, - }, -})