Skip to content

Commit

Permalink
- [安卓] 优化细节
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed May 21, 2024
1 parent 4d81b31 commit 82c2db1
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/components/@/ant-design/modal/blur-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const BlurView = observer(({ style, intensity = 100, children }: BlurView
return (
<ExpoBlurView
style={stl(styles.blurView, style)}
tint={_.select('extraLight', 'dark')}
tint={_.select(_.ios('extraLight', 'light'), 'dark')}
intensity={intensity}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/@/ant-design/toast/blur-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const BlurView = observer(({ style, children }: Props) => {
return (
<ExpoBlurView
style={[style, styles.blurView]}
tint={_.select('extraLight', 'dark')}
tint={_.select(_.ios('extraLight', 'light'), 'dark')}
intensity={64}
>
{children}
Expand Down
3 changes: 2 additions & 1 deletion src/components/blur-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react'
import { StyleSheet, View } from 'react-native'
import { observer } from 'mobx-react'
import { BlurView as ExpoBlurView } from 'expo-blur'
import { _ } from '@stores'
import { matchCoverUrl } from '@utils'
import { r } from '@utils/dev'
import { IOS } from '@constants'
Expand All @@ -29,7 +30,7 @@ export const BlurView = observer(
({
style,
src,
tint = 'extraLight',
tint = _.ios('extraLight', 'light'),
intensity = 100,
blurRadius = 16,
children
Expand Down
2 changes: 2 additions & 0 deletions src/components/cover/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { CoverPrefix, CoverSize, Props } from './types'

/** 修正封面图地址 */
export function getCoverSrc(src: Props['src'], width: number, cdn?: boolean, noDefault?: boolean) {
if (typeof src !== 'string') return src

const { prefix, size } = getCoverPramas(width)
return (
getCover400(cdn !== false ? matchCoverUrl(src, noDefault, prefix) : src, size) || IMG_DEFAULT
Expand Down
6 changes: 5 additions & 1 deletion src/components/fixed-textarea/container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ function Container({ children }) {
const styles = memoStyles()
if (IOS || STORYBOOK) {
return (
<BlurView style={styles.container} tint={_.select('extraLight', 'dark')} intensity={100}>
<BlurView
style={styles.container}
tint={_.select(_.ios('extraLight', 'light'), 'dark')}
intensity={100}
>
{children}
</BlurView>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/hardware-texture-blur-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const HardwareTextureBlurView = ({
height: _.flatten(style)?.height || '100%',
...containerStyle
}}
tint={_.select('extraLight', 'dark')}
tint={_.select(_.ios('extraLight', 'light'), 'dark')}
intensity={100}
/>
</Animated.View>
Expand Down
11 changes: 9 additions & 2 deletions src/components/header/transition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @Author: czy0729
* @Date: 2022-03-12 20:43:41
* @Last Modified by: czy0729
* @Last Modified time: 2024-04-09 15:23:40
* @Last Modified time: 2024-05-21 17:30:47
*/
import React from 'react'
import React, { useEffect, useState } from 'react'
import Animated, { useAnimatedStyle, withTiming } from 'react-native-reanimated'
import { r } from '@utils/dev'
import { useObserver } from '@utils/hooks'
Expand All @@ -17,6 +17,11 @@ import { Props } from './types'
function Transition({ fixed, title, headerTitle }: Props) {
r(COMPONENT)

const [show, setShow] = useState(fixed)
useEffect(() => {
if (!show) setShow(true)
}, [fixed, show])

const wrapStyles = useAnimatedStyle(() => ({
opacity: withTiming(fixed ? 1 : 0, {
duration: 160
Expand All @@ -33,6 +38,8 @@ function Transition({ fixed, title, headerTitle }: Props) {
}))

return useObserver(() => {
if (!show) return null

const styles = memoStyles()
return (
<Animated.View style={[styles.view, wrapStyles]}>
Expand Down
16 changes: 1 addition & 15 deletions src/components/image-viewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-05-23 18:57:26
* @Last Modified by: czy0729
* @Last Modified time: 2024-01-14 16:34:24
* @Last Modified time: 2024-05-21 13:22:49
*/
import React from 'react'
import { Modal, View } from 'react-native'
Expand All @@ -14,7 +14,6 @@ import { HOST_DOGE, IOS } from '@constants'
import { Component } from '../component'
import RNImageViewer from '../@/react-native-image-zoom-viewer/image-viewer.component'
import { Iconfont } from '../iconfont'
import { StatusBar } from '../status-bar'
import { Text } from '../text'
import { Touchable } from '../touchable'
import { ACTION_SHEET_DS, COMPONENT } from './ds'
Expand All @@ -36,19 +35,6 @@ export const ImageViewer = observer(
onCancel: () => {}
}

componentDidUpdate() {
if (!IOS) {
const { visible } = this.props
if (visible) {
StatusBar.setHidden(true)
} else {
setTimeout(() => {
StatusBar.setHidden(false)
}, 400)
}
}
}

onRequestClose = () => {
const { onCancel } = this.props
onCancel()
Expand Down
6 changes: 5 additions & 1 deletion src/components/storybook/bottom-tab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export const StorybookBottomTab = () => {
const styles = memoStyles()
return (
<Component id='component-storybook-bottom-tab' style={styles.bottomTab}>
<BlurView style={styles.blurView} tint={_.select('extraLight', 'dark')} intensity={100}>
<BlurView
style={styles.blurView}
tint={_.select(_.ios('extraLight', 'light'), 'dark')}
intensity={100}
>
<Flex>
{DS.map((item: (typeof BOTTOM_TAB_WITH_AUTH_DS)[number]) => {
const storyId = getSPAId(item.id)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/_/base/blur-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const BlurView = ob(({ style, intensity = 100, children, ...other }: Blur
<Component id='base-blur-view'>
<ExpoBlurView
style={style}
tint={_.isDark ? 'dark' : 'extraLight'}
tint={_.isDark ? 'dark' : _.ios('extraLight', 'light')}
intensity={intensity}
{...other}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2024-05-03 23:08:14
* @Last Modified by: czy0729
* @Last Modified time: 2024-05-14 06:34:31
* @Last Modified time: 2024-05-21 17:43:33
*/
import { _ } from '@stores'

Expand All @@ -16,7 +16,7 @@ export const styles = _.create({
marginLeft: 40
},
reverse: {
marginTop: 4,
marginTop: _.ios(4, -1),
transform: [
{
rotate: '180deg'
Expand Down
7 changes: 3 additions & 4 deletions src/screens/rakuen/mine/component/item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
* @Author: czy0729
* @Date: 2020-05-02 16:30:02
* @Last Modified by: czy0729
* @Last Modified time: 2024-05-16 19:18:05
* @Last Modified time: 2024-05-21 13:01:07
*/
import React from 'react'
import { View } from 'react-native'
import { Flex, Text, Touchable } from '@components'
import { Cover } from '@_'
import { Cover, Flex, Text, Touchable } from '@components'
import { _, systemStore } from '@stores'
import { getGroupThumbStatic } from '@utils'
import { HOST_IMAGE } from '@utils/app/ds'
Expand Down Expand Up @@ -46,7 +45,7 @@ function Item({ id, cover, name, num }: any, { navigation }: Ctx) {
}}
>
<Flex align='start'>
<Cover size={styles.body.height} src={src} border radius />
<Cover size={styles.body.height} src={src} radius />
<Flex.Item style={_.ml.sm}>
<Flex style={styles.body} direction='column' align='start' justify='center'>
<Text size={11} numberOfLines={2} bold>
Expand Down
6 changes: 4 additions & 2 deletions src/screens/rakuen/topic/component/top/top.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ const Top = memo(
src={groupThumb || _.select(IMG_EMPTY, IMG_EMPTY_DARK)}
radius={_.radiusXs}
priority='high'
fallback
fallbackSrc={String(groupThumbFallback).replace('/r/100x100', '')}
fallback={isEp}
fallbackSrc={
isEp ? String(groupThumbFallback).replace('/r/100x100', '') : undefined
}
/>
<Text style={styles.group} size={13} numberOfLines={1}>
{HTMLDecode(findSubjectCn(group))}
Expand Down
7 changes: 3 additions & 4 deletions src/screens/tinygrail/_/characters-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* @Author: czy0729
* @Date: 2020-06-28 14:02:31
* @Last Modified by: czy0729
* @Last Modified time: 2024-05-01 16:13:36
* @Last Modified time: 2024-05-21 19:42:47
*/
import React from 'react'
import { BackHandler, View } from 'react-native'
import { computed } from 'mobx'
import { Button, Flex, Iconfont, Modal, StatusBar, Text } from '@components'
import { Button, Flex, Iconfont, Modal, Text } from '@components'
import { Popover } from '@_'
import { _, tinygrailStore } from '@stores'
import {
Expand All @@ -22,7 +22,6 @@ import {
trim
} from '@utils'
import { obc } from '@utils/decorators'
import { IOS } from '@constants'
import { calculateRate } from '../utils'
import Item from './item'
import ItemBottom from './item-bottom'
Expand Down Expand Up @@ -97,7 +96,7 @@ class CharactersModal extends React.Component<Props> {
this.title = nextProps.title
}

if (!IOS) StatusBar.setHidden(nextProps.visible)
// if (!IOS) StatusBar.setHidden(nextProps.visible)
}

onBackAndroid = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/tinygrail/_/progress/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2024-03-03 07:04:28
* @Last Modified by: czy0729
* @Last Modified time: 2024-03-16 17:21:05
* @Last Modified time: 2024-05-21 19:51:41
*/
import { _ } from '@stores'

Expand All @@ -12,7 +12,7 @@ export const memoStyles = _.memoStyles(() => ({
progress: {
padding: PADDING,
borderWidth: 1,
borderColor: _.tSelect('rgba(255, 255, 255, 0.36)', _.colorTinygrailBorder),
borderColor: _.select('rgba(0, 0, 0, 0.16)', _.colorTinygrailBorder),
borderRadius: 8,
overflow: 'hidden'
},
Expand Down
7 changes: 3 additions & 4 deletions src/screens/tinygrail/index/component/bonus-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
* @Author: czy0729
* @Date: 2020-07-30 18:10:42
* @Last Modified by: czy0729
* @Last Modified time: 2024-03-13 08:23:44
* @Last Modified time: 2024-05-21 19:44:39
*/
import React from 'react'
import { BackHandler, View } from 'react-native'
import { Button, Flex, Image, Modal, StatusBar, Text, Touchable } from '@components'
import { Button, Flex, Image, Modal, Text, Touchable } from '@components'
import { _ } from '@stores'
import { stl, tinygrailOSS, toFixed } from '@utils'
import { obc } from '@utils/decorators'
import { r } from '@utils/dev'
import { IOS } from '@constants'
import { Ctx } from '../../types'
import { COMPONENT } from './ds'
import { memoStyles } from './styles'
Expand All @@ -32,7 +31,7 @@ class BonusModal extends React.Component<{
}

UNSAFE_componentWillReceiveProps(nextProps: { visible: boolean }) {
if (!IOS) StatusBar.setHidden(nextProps.visible)
// if (!IOS) StatusBar.setHidden(nextProps.visible)
}

onBackAndroid = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/decorators/cycles/blur-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-11-30 15:23:07
* @Last Modified by: czy0729
* @Last Modified time: 2024-05-10 05:40:12
* @Last Modified time: 2024-05-21 12:57:03
*/
import React from 'react'
import { BlurView as ExpoBlurView } from 'expo-blur'
Expand All @@ -14,7 +14,7 @@ function BlurView({ style, children }) {
return (
<ExpoBlurView
style={stl(_.container.flex, style)}
tint={_.isDark ? 'dark' : 'extraLight'}
tint={_.isDark ? 'dark' : _.ios('extraLight', 'light')}
intensity={100}
>
{children}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/storage/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* @Author: czy0729
* @Date: 2022-09-29 20:48:57
* @Last Modified by: czy0729
* @Last Modified time: 2023-08-03 01:35:49
* @Last Modified time: 2024-05-21 13:32:31
*/
import { STORYBOOK } from '@constants/device'
import { DEV } from '@/config'

/** 本地化字符串大于此值会延迟合并再写入 */
export const LAZY_SET_STORAGE_SIZE = 1024
/** 本地化字符串大于此值会延迟合并再写入 (Bytes) */
export const LAZY_SET_STORAGE_SIZE = 1024 * 20

/** 延迟写入间隔 */
export const LAZY_SET_STORAGE_INTERVAL = STORYBOOK ? 1000 : DEV ? 6000 : 18000
export const LAZY_SET_STORAGE_INTERVAL = STORYBOOK ? 1000 : DEV ? 6000 : 12000

/** 缓存过程中间值 */
export const CACHE_MAP = new Map<string, any>()
4 changes: 2 additions & 2 deletions src/utils/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* @Author: czy0729
* @Date: 2022-04-13 04:14:20
* @Last Modified by: czy0729
* @Last Modified time: 2023-11-01 14:20:43
* @Last Modified time: 2024-05-21 13:31:18
*/
import { queue } from '../utils'
import { getItem, setItem } from './utils'
import { CACHE_MAP, LAZY_SET_STORAGE_SIZE, LAZY_SET_STORAGE_INTERVAL } from './ds'
import { CACHE_MAP, LAZY_SET_STORAGE_INTERVAL, LAZY_SET_STORAGE_SIZE } from './ds'

let setStorageInterval: any
if (setStorageInterval) clearInterval(setStorageInterval)
Expand Down

0 comments on commit 82c2db1

Please sign in to comment.