Skip to content

Commit

Permalink
- [目录详情] 功能迭代
Browse files Browse the repository at this point in the history
  • Loading branch information
czy0729 committed Aug 10, 2024
1 parent ac36489 commit 8886e99
Show file tree
Hide file tree
Showing 45 changed files with 616 additions and 315 deletions.
3 changes: 2 additions & 1 deletion src/constants/events/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-05-11 04:37:23
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-07 22:50:02
* @Last Modified time: 2024-08-10 16:37:09
*/

/** Discovery */
Expand Down Expand Up @@ -71,6 +71,7 @@ export default {
'目录详情.取消收藏': 'CatalogDetail.doErase',
'目录详情.封面图查看': 'CatalogDetail.imageView',
'目录详情.排序': 'CatalogDetail.sort',
'目录详情.收藏范围': 'CatalogDetail.collect',
'目录详情.管理': 'CatalogDetail.manage',
'目录详情.复制': 'CatalogDetail.doCopy',
'目录详情.切换布局': 'CatalogDetail.switchLayout',
Expand Down
16 changes: 10 additions & 6 deletions src/screens/_/base/manage/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ function Content({ icon, size, type, collection, horizontal }) {
return (
<Flex style={[styles.content, styles.horizontal]}>
<Iconfont name={icon} size={size - 1} color={_[`color${titleCase(type)}`]} />
<Text style={_.ml.xs} type={type} size={13} lineHeight={15} align='center'>
{collection}
</Text>
{!!collection && (
<Text style={_.ml.xs} type={type} size={13} lineHeight={15} align='center'>
{collection}
</Text>
)}
</Flex>
)
}
Expand All @@ -29,9 +31,11 @@ function Content({ icon, size, type, collection, horizontal }) {
<Flex style={styles.icon} justify='center'>
<Iconfont name={icon} size={size} color={_[`color${titleCase(type)}`]} />
</Flex>
<Text style={styles.text} type={type} size={11} align='center'>
{collection}
</Text>
{!!collection && (
<Text style={styles.text} type={type} size={11} align='center'>
{collection}
</Text>
)}
</View>
)
}
Expand Down
20 changes: 11 additions & 9 deletions src/screens/_/item/catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2020-01-03 11:23:42
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-02 03:05:28
* @Last Modified time: 2024-08-09 21:21:30
*/
import React from 'react'
import { View } from 'react-native'
Expand All @@ -16,7 +16,7 @@ import { InView } from '../../base'
import Covers from './covers'
import { AVATAR_WIDTH, COMPONENT, ITEM_HEIGHT } from './ds'
import { memoStyles } from './styles'
import { Props as ItemCatalogProps } from './types'
import { Context, Props as ItemCatalogProps } from './types'

export { ItemCatalogProps }

Expand All @@ -43,7 +43,7 @@ export const ItemCatalog = obc(
detail,
children
}: ItemCatalogProps,
{ navigation }
{ navigation }: Context
) => {
if (!isUser && !book && !anime && !music && !game && !real) return null

Expand Down Expand Up @@ -71,10 +71,12 @@ export const ItemCatalog = obc(
if (_desc === 'undefined') _desc = ''

let dateText = ''
let lastUpdate = ''
if (last) {
dateText = `创建于 ${last}`
} else if (time && !time.includes('创建于')) {
dateText = `最后更新 ${lastDate(getTimestamp(time))}`
lastUpdate = time
} else if (_detailTime) {
dateText = `创建于 ${lastDate(getTimestamp(_detailTime))?.slice(0, 10)}`
}
Expand All @@ -85,16 +87,16 @@ export const ItemCatalog = obc(
style={styles.container}
animate
onPress={() => {
const { id: eventId, data: eventData } = event
t(eventId, {
to: 'CatalogDetail',
navigation.push('CatalogDetail', {
catalogId: id,
...eventData
_lastUpdate: lastUpdate,
_hideScore: hideScore
})

navigation.push('CatalogDetail', {
t(event.id, {
to: 'CatalogDetail',
catalogId: id,
_hideScore: hideScore
...event.data
})
}}
>
Expand Down
6 changes: 5 additions & 1 deletion src/screens/_/item/catalog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @Last Modified time: 2023-04-19 20:47:27
*/
import { CatalogDetail } from '@stores/discovery/types'
import { EventType, Id } from '@types'
import { EventType, Id, Navigation } from '@types'

export type Props = {
event?: EventType
Expand Down Expand Up @@ -38,3 +38,7 @@ export type Props = {
/** 目录详情信息 */
detail?: CatalogDetail
}

export type Context = {
navigation?: Navigation
}
11 changes: 7 additions & 4 deletions src/screens/_/item/collections/bottom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-08-08 17:35:40
* @Last Modified by: czy0729
* @Last Modified time: 2024-03-19 04:47:06
* @Last Modified time: 2024-08-10 16:54:38
*/
import React from 'react'
import { View } from 'react-native'
Expand All @@ -24,7 +24,8 @@ function Bottom({
hideScore,
isDo,
isOnHold,
isDropped
isDropped,
hasComment
}) {
const hasScore = !!score

Expand Down Expand Up @@ -55,8 +56,10 @@ function Bottom({
const hasLeft = showRank || showScore || showTotal || showInfo
const hasCenter = showVisibility || showR18
const hasRight = showTags

if (!hasLeft && !hasCenter && !hasRight) return null
if (!hasLeft && !hasCenter && !hasRight) {
if (hasComment) return null
return <View style={_.mt.md} />
}

return (
<Flex style={_.mt.md}>
Expand Down
6 changes: 4 additions & 2 deletions src/screens/_/item/collections/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2022-06-17 12:19:32
* @Last Modified by: czy0729
* @Last Modified time: 2024-03-25 07:04:54
* @Last Modified time: 2024-08-10 16:53:41
*/
import React from 'react'
import { Component, Cover, Flex, Text, Touchable } from '@components'
Expand Down Expand Up @@ -65,6 +65,7 @@ const Item = memo(
const subjectId = String(id).replace('/subject/', '')
const titleLength = name.length + nameCn.length
const width = IMG_WIDTH * 1.1
const hasComment = !!comments && comments !== 'undefined'
return (
<Component id='item-collections' data-key={id}>
<Touchable
Expand Down Expand Up @@ -160,6 +161,7 @@ const Item = memo(
isDo={isDo}
isOnHold={isOnHold}
isDropped={isDropped}
hasComment={hasComment}
/>
</Flex.Item>
{isEditable && (
Expand All @@ -171,7 +173,7 @@ const Item = memo(
)}
</Flex>
</Flex>
{!!comments && comments !== 'undefined' && (
{hasComment && (
<Text
style={styles.comments}
size={comments.length >= 80 ? 12 : comments.length >= 40 ? 13 : 14}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
* @Author: czy0729
* @Date: 2021-06-09 06:34:29
* @Last Modified by: czy0729
* @Last Modified time: 2024-01-12 05:55:22
* @Last Modified time: 2024-08-10 14:15:28
*/
import React from 'react'
import { IconHeader } from '@_'
import { _ } from '@stores'
import { _, userStore } from '@stores'
import { ob } from '@utils/decorators'
import { Ctx } from '../../types'
import { COMPONENT } from './ds'

function IconCopy({ $, navigation }: Ctx) {
if (!userStore.isLogin) return null

return (
<IconHeader
style={_.mr.xs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2020-01-06 16:50:15
* @Last Modified by: czy0729
* @Last Modified time: 2024-01-12 05:56:22
* @Last Modified time: 2024-08-10 15:29:56
*/
import React from 'react'
import { Flex, Heatmap, Text } from '@components'
Expand All @@ -14,9 +14,11 @@ import { COMPONENT } from './ds'
import { styles } from './styles'

function IconFavor({ $ }: Ctx) {
if (!($.detail.joinUrl || $.detail.byeUrl)) return null

const { collect } = $.catalogDetail
return (
<Flex style={collect ? styles.withCollect : _.mr.xs}>
<Flex style={collect ? styles.withCollect : _.mr.sm}>
<IconHeader
name={$.isCollect ? 'md-star' : 'md-star-outline'}
size={22}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* @Author: czy0729
* @Date: 2022-10-11 14:20:42
* @Last Modified by: czy0729
* @Last Modified time: 2022-10-11 14:31:40
* @Last Modified time: 2024-08-10 15:29:52
*/
import { _ } from '@stores'

export const styles = _.create({
withCollect: {
paddingRight: _.xs,
marginRight: _.xs
marginRight: _.sm
},
num: {
position: 'absolute',
Expand Down
10 changes: 10 additions & 0 deletions src/screens/discovery/catalog-detail/component/info/content/ds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* @Author: czy0729
* @Date: 2024-08-10 14:28:41
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-10 14:28:41
*/
import { rc } from '@utils/dev'
import { COMPONENT as PARENT } from '../ds'

export const COMPONENT = rc(PARENT, 'Content')
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* @Author: czy0729
* @Date: 2024-08-10 13:59:11
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-10 14:29:27
*/
import React from 'react'
import { Expand, RenderHtml } from '@components'
import { _ } from '@stores'
import { appNavigate } from '@utils'
import { obc } from '@utils/decorators'
import { Ctx } from '../../../types'
import { COMPONENT } from './ds'

function Content(props, { $, navigation }: Ctx) {
const { content } = $.detail
if (!content) return null

return (
<Expand style={_.mt.lg} ratio={0.64}>
<RenderHtml html={content} onLinkPress={href => appNavigate(href, navigation)} />
</Expand>
)
}

export default obc(Content, COMPONENT)
10 changes: 10 additions & 0 deletions src/screens/discovery/catalog-detail/component/info/desc/ds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* @Author: czy0729
* @Date: 2024-08-10 14:32:58
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-10 14:41:18
*/
import { rc } from '@utils/dev'
import { COMPONENT as PARENT } from '../ds'

export const COMPONENT = rc(PARENT, 'Desc')
54 changes: 54 additions & 0 deletions src/screens/discovery/catalog-detail/component/info/desc/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* @Author: czy0729
* @Date: 2024-08-10 13:59:11
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-10 14:11:31
*/
import React from 'react'
import { Flex, Text } from '@components'
import { _ } from '@stores'
import { simpleTime } from '@utils'
import { obc } from '@utils/decorators'
import { t } from '@utils/fetch'
import { Ctx } from '../../../types'
import { COMPONENT } from './ds'

function Desc(props, { $, navigation }: Ctx) {
const { avatar, nickname, userId, time } = $.detail
if (!nickname || time) return null

const lastUpdate = $.params._lastUpdate || ''
return (
<Flex style={_.mt.sm}>
<Text
type='title'
size={13}
lineHeight={15}
bold
onPress={() => {
navigation.push('Zone', {
userId,
_id: userId,
_name: nickname,
_image: avatar
})

t('目录详情.跳转', {
to: 'Zone',
catalogId: $.catalogId,
userId
})
}}
>
{nickname}
</Text>
<Text type='sub' size={13} lineHeight={15} bold>
{nickname ? ` · ` : ''}
{simpleTime(String(time).replace(/\n/g, ''))}
{!!lastUpdate && ` · 最后更新 ${simpleTime(lastUpdate)}`}
</Text>
</Flex>
)
}

export default obc(Desc, COMPONENT)
10 changes: 10 additions & 0 deletions src/screens/discovery/catalog-detail/component/info/footer/ds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* @Author: czy0729
* @Date: 2024-08-10 14:32:58
* @Last Modified by: czy0729
* @Last Modified time: 2024-08-10 14:41:06
*/
import { rc } from '@utils/dev'
import { COMPONENT as PARENT } from '../ds'

export const COMPONENT = rc(PARENT, 'Footer')
Loading

0 comments on commit 8886e99

Please sign in to comment.