Improve Device Detection For Better Responsiveness (#1512)
* Refactor `useOnMainScroll` function to use responsive device detection - Replace static `isDesktopWeb` with `useWebMediaQueries` hook to enable dynamic device type detection. - Create `useDeviceLimits` hook to dynamically determine `DY_LIMIT_UP` and `DY_LIMIT_DOWN` based on device type. - Update dependency arrays for the `useCallback` hooks to include new dynamic variables. * Refactor styles to be responsive to device type - Create `useStyles` hook that generates styles object based on device type detected from `useWebMediaQueries`. - Replace static styles object with dynamic styles object generated from `useStyles` hook in components. - This allows `paddingLeft` values for 'ul' and 'ol' styles to adapt to device type dynamically. - This allows `maxWidth` values for 'metaItem'' styles to adapt to device type dynamically. * Remove `isDesktopWeb` in favor of `useWebMediaQueries().isDesktop` * Refactor `SplashScreen` component for responsive design * Revision based on review results * Fix isNative check --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
parent
2e5f73ff61
commit
2aae37d67b
9 changed files with 289 additions and 244 deletions
|
@ -23,7 +23,7 @@ import {ViewHeader} from '../util/ViewHeader'
|
|||
import {ErrorMessage} from '../util/error/ErrorMessage'
|
||||
import {Text} from '../util/text/Text'
|
||||
import {s} from 'lib/styles'
|
||||
import {isNative, isDesktopWeb} from 'platform/detection'
|
||||
import {isNative} from 'platform/detection'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {useSetTitle} from 'lib/hooks/useSetTitle'
|
||||
import {useNavigation} from '@react-navigation/native'
|
||||
|
@ -78,7 +78,7 @@ export const PostThread = observer(function PostThread({
|
|||
treeView: boolean
|
||||
}) {
|
||||
const pal = usePalette('default')
|
||||
const {isTablet} = useWebMediaQueries()
|
||||
const {isTablet, isDesktop} = useWebMediaQueries()
|
||||
const ref = useRef<FlatList>(null)
|
||||
const hasScrolledIntoView = useRef<boolean>(false)
|
||||
const [isRefreshing, setIsRefreshing] = React.useState(false)
|
||||
|
@ -189,7 +189,7 @@ export const PostThread = observer(function PostThread({
|
|||
} else if (item === REPLY_PROMPT) {
|
||||
return (
|
||||
<View>
|
||||
{isDesktopWeb && <ComposePrompt onPressCompose={onPressReply} />}
|
||||
{isDesktop && <ComposePrompt onPressCompose={onPressReply} />}
|
||||
</View>
|
||||
)
|
||||
} else if (item === DELETED) {
|
||||
|
@ -261,7 +261,20 @@ export const PostThread = observer(function PostThread({
|
|||
}
|
||||
return <></>
|
||||
},
|
||||
[onRefresh, onPressReply, pal, posts, isTablet, treeView],
|
||||
[
|
||||
isTablet,
|
||||
isDesktop,
|
||||
onPressReply,
|
||||
pal.border,
|
||||
pal.viewLight,
|
||||
pal.textLight,
|
||||
pal.view,
|
||||
pal.text,
|
||||
pal.colors.border,
|
||||
posts,
|
||||
onRefresh,
|
||||
treeView,
|
||||
],
|
||||
)
|
||||
|
||||
// loading
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue