diff --git a/src/screens/Home/Views/Setting/NavList.tsx b/src/screens/Home/Views/Setting/Horizontal/NavList.tsx similarity index 98% rename from src/screens/Home/Views/Setting/NavList.tsx rename to src/screens/Home/Views/Setting/Horizontal/NavList.tsx index c7bdc22c..43bcf44f 100644 --- a/src/screens/Home/Views/Setting/NavList.tsx +++ b/src/screens/Home/Views/Setting/Horizontal/NavList.tsx @@ -7,7 +7,7 @@ import { useTheme } from '@/store/theme/hook' import { createStyle } from '@/utils/tools' import Text from '@/components/common/Text' import { scaleSizeH } from '@/utils/pixelRatio' -import { SETTING_SCREENS, type SettingScreenIds } from './Main' +import { SETTING_SCREENS, type SettingScreenIds } from '../Main' import { useI18n } from '@/lang' type FlatListType = FlatListProps diff --git a/src/screens/Home/Views/Setting/Horizontal.tsx b/src/screens/Home/Views/Setting/Horizontal/index.tsx similarity index 96% rename from src/screens/Home/Views/Setting/Horizontal.tsx rename to src/screens/Home/Views/Setting/Horizontal/index.tsx index 8db4a72a..a7fe9048 100644 --- a/src/screens/Home/Views/Setting/Horizontal.tsx +++ b/src/screens/Home/Views/Setting/Horizontal/index.tsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react' import { ScrollView, View } from 'react-native' import NavList from './NavList' -import Main, { type MainType } from './Main' +import Main, { type MainType } from '../Main' import { createStyle } from '@/utils/tools' import { BorderWidths } from '@/theme' import { useTheme } from '@/store/theme/hook' diff --git a/src/screens/Home/Views/Setting/Vertical/NavList.tsx b/src/screens/Home/Views/Setting/Vertical/NavList.tsx index 21b22018..fae67426 100644 --- a/src/screens/Home/Views/Setting/Vertical/NavList.tsx +++ b/src/screens/Home/Views/Setting/Vertical/NavList.tsx @@ -1,35 +1,98 @@ -import React, { forwardRef, useImperativeHandle, useState } from 'react' -import type { SettingScreenIds } from '../Main' +import React, { memo, useCallback, useState } from 'react' +import { View, TouchableOpacity, ScrollView } from 'react-native' -import NavList from '../NavList' - -export interface NavListTypeProps { - onChangeId: (id: SettingScreenIds) => void -} -export interface NavListTypeType { - show: () => void -} +import { useTheme } from '@/store/theme/hook' +import { createStyle } from '@/utils/tools' +import Text from '@/components/common/Text' +import { SETTING_SCREENS, type SettingScreenIds } from '../Main' +import { useI18n } from '@/lang' +import { BorderRadius, BorderWidths } from '@/theme' -export default forwardRef(({ onChangeId }, ref) => { - const [visible, setVisible] = useState(false) +const ListItem = memo(({ id, activeId, onPress }: { + onPress: (item: SettingScreenIds) => void + activeId: string + id: SettingScreenIds +}) => { + const theme = useTheme() + const t = useI18n() - useImperativeHandle(ref, () => { - let isInited = false - return { - show() { - if (isInited) return - requestAnimationFrame(() => { - setVisible(true) - }) - isInited = true - }, - } - }) + const active = activeId == id + + const handlePress = () => { + onPress(id) + } return ( - visible - ? - : null + + + {t(`setting_${id}`)} + + + ) +}, (prevProps, nextProps) => { + return !!(prevProps.id === nextProps.id && + prevProps.activeId != nextProps.id && + nextProps.activeId != nextProps.id ) }) + + +export default ({ onChangeId }: { + onChangeId: (id: SettingScreenIds) => void +}) => { + const [activeId, setActiveId] = useState(global.lx.settingActiveId) + const theme = useTheme() + + const handleChangeId = useCallback((id: SettingScreenIds) => { + onChangeId(id) + setActiveId(id) + global.lx.settingActiveId = id + }, []) + + return ( + + { + SETTING_SCREENS.map(id => ) + } + + ) +} + + +const styles = createStyle({ + container: { + height: '20%', + flexGrow: 0, + flexShrink: 0, + borderBottomWidth: BorderWidths.normal, + }, + contentContainer: { + flexDirection: 'row', + flexWrap: 'wrap', + paddingHorizontal: 5, + // backgroundColor: 'rgba(0, 0, 0, 0.1)', + }, + // listContainer: { + // // borderBottomWidth: BorderWidths.normal2, + // }, + + listItem: { + width: '33.33%', + height: 'auto', + flexDirection: 'row', + alignItems: 'center', + paddingHorizontal: 5, + paddingVertical: 8, + borderRadius: BorderRadius.normal, + marginBottom: 5, + }, + listName: { + // justifyContent: 'center', + alignItems: 'center', + flexGrow: 1, + flexShrink: 1, + // paddingLeft: 5, + // backgroundColor: 'rgba(0,0,0,0.1)', + }, +}) diff --git a/src/screens/Home/Views/Setting/Vertical/index.tsx b/src/screens/Home/Views/Setting/Vertical/index.tsx index 7a444652..a68acb3b 100644 --- a/src/screens/Home/Views/Setting/Vertical/index.tsx +++ b/src/screens/Home/Views/Setting/Vertical/index.tsx @@ -1,70 +1,37 @@ import React, { useCallback, useRef } from 'react' import { ScrollView, View, type DrawerLayoutAndroid } from 'react-native' // import { getWindowSise, onDimensionChange } from '@/utils/tools' -import NavList, { type NavListTypeType } from './NavList' -import Header, { type HeaderType } from './Header' +import NavList from './NavList' import Main, { type SettingScreenIds, type MainType } from '../Main' -import { useSettingValue } from '@/store/setting/hook' -import { COMPONENT_IDS } from '@/config/constant' -import DrawerLayoutFixed from '@/components/common/DrawerLayoutFixed' -import { scaleSizeW } from '@/utils/pixelRatio' import { createStyle } from '@/utils/tools' -import { useTheme } from '@/store/theme/hook' -const MAX_WIDTH = scaleSizeW(300) const Content = () => { const drawer = useRef(null) - const navListRef = useRef(null) - const headerRef = useRef(null) const mainRef = useRef(null) - const drawerLayoutPosition = useSettingValue('common.drawerLayoutPosition') - const theme = useTheme() - const handleShowDrawer = useCallback(() => { - drawer.current?.openDrawer() - navListRef.current?.show() - }, []) const handleChangeId = useCallback((id: SettingScreenIds) => { drawer.current?.closeDrawer() mainRef.current?.setActiveId(id) - headerRef.current?.setActiveId(id) }, []) - const navigationView = () => ( - - - - ) // console.log('render drawer content') return ( - -
+ +
- {/* - */} - + ) } const styles = createStyle({ - nav: { - paddingTop: 10, - paddingBottom: 10, + container: { + flex: 1, + flexDirection: 'column', }, main: { paddingLeft: 15, diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 1770c832..3bdd75f4 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -385,6 +385,7 @@ export const trasformeStyle = (styles: T): T => { case 'marginBottom': case 'paddingTop': case 'paddingBottom': + case 'paddingVertical': newStyle[p] = scaleSizeH(v) break case 'width': @@ -393,6 +394,7 @@ export const trasformeStyle = (styles: T): T => { case 'marginRight': case 'paddingLeft': case 'paddingRight': + case 'paddingHorizontal': newStyle[p] = scaleSizeW(v) break case 'padding':