mirror of
https://github.com/tooot-app/app
synced 2025-02-08 16:08:44 +01:00
Fix #722
This commit is contained in:
parent
5b640879f0
commit
4977e91b66
@ -1 +1,2 @@
|
|||||||
toooting愉快!此版本包括以下改进和修复:
|
toooting愉快!此版本包括以下改进和修复:
|
||||||
|
- 添加neodb.social书影音展示卡片
|
@ -5,6 +5,7 @@ import { useNeodbQuery } from '@utils/queryHooks/neodb'
|
|||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import * as Linking from 'expo-linking'
|
import * as Linking from 'expo-linking'
|
||||||
|
import { useState } from 'react'
|
||||||
import { Pressable, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
import { Rating } from './Rating'
|
import { Rating } from './Rating'
|
||||||
|
|
||||||
@ -23,9 +24,9 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
|
|
||||||
if (!data) return null
|
if (!data) return null
|
||||||
|
|
||||||
const pressableDefaults = {
|
const pressableProps = {
|
||||||
style: {
|
style: {
|
||||||
marginTop: StyleConstants.Spacing.S,
|
marginTop: StyleConstants.Spacing.M,
|
||||||
backgroundColor: colors.shimmerDefault,
|
backgroundColor: colors.shimmerDefault,
|
||||||
borderRadius: StyleConstants.BorderRadius,
|
borderRadius: StyleConstants.BorderRadius,
|
||||||
padding: StyleConstants.Spacing.S,
|
padding: StyleConstants.Spacing.S,
|
||||||
@ -33,6 +34,9 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
},
|
},
|
||||||
onPress: () => openLink(card.url)
|
onPress: () => openLink(card.url)
|
||||||
}
|
}
|
||||||
|
const contentProps = { style: { flex: 1, gap: StyleConstants.Spacing.S } }
|
||||||
|
|
||||||
|
const [headingLines, setHeadingLines] = useState(3)
|
||||||
|
|
||||||
const itemImage = data.cover_image_url ? (
|
const itemImage = data.cover_image_url ? (
|
||||||
<GracefullyImage
|
<GracefullyImage
|
||||||
@ -53,13 +57,14 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
style={{ color: colors.primaryDefault }}
|
style={{ color: colors.primaryDefault }}
|
||||||
numberOfLines={3}
|
numberOfLines={3}
|
||||||
children={value}
|
children={value}
|
||||||
|
onTextLayout={({ nativeEvent }) => setHeadingLines(nativeEvent.lines.length)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
const itemDetails = (value: string) => (
|
const itemDetails = (value: string) => (
|
||||||
<CustomText
|
<CustomText
|
||||||
fontStyle='S'
|
fontStyle='S'
|
||||||
style={{ color: colors.secondary }}
|
style={{ color: colors.secondary }}
|
||||||
numberOfLines={1}
|
numberOfLines={4 - headingLines}
|
||||||
children={value}
|
children={value}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -67,9 +72,9 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
switch (segments[0]) {
|
switch (segments[0]) {
|
||||||
case 'movie':
|
case 'movie':
|
||||||
return (
|
return (
|
||||||
<Pressable {...pressableDefaults}>
|
<Pressable {...pressableProps}>
|
||||||
{itemImage}
|
{itemImage}
|
||||||
<View style={{ flex: 1, gap: StyleConstants.Spacing.S }}>
|
<View {...contentProps}>
|
||||||
{itemHeading(
|
{itemHeading(
|
||||||
[data.title, data.orig_title, data.year ? `(${data.year})` : null]
|
[data.title, data.orig_title, data.year ? `(${data.year})` : null]
|
||||||
.filter(d => d)
|
.filter(d => d)
|
||||||
@ -78,7 +83,11 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
<Rating rating={data.rating / 2} />
|
<Rating rating={data.rating / 2} />
|
||||||
{itemDetails(
|
{itemDetails(
|
||||||
[
|
[
|
||||||
data.duration ? `${data.duration}分钟` : null,
|
data.duration
|
||||||
|
? parseInt(data.duration).toString() === data.duration
|
||||||
|
? `${data.duration}分钟`
|
||||||
|
: data.duration
|
||||||
|
: null,
|
||||||
data.area?.join(' '),
|
data.area?.join(' '),
|
||||||
data.genre?.join(' '),
|
data.genre?.join(' '),
|
||||||
data.director?.join(' ')
|
data.director?.join(' ')
|
||||||
@ -91,23 +100,16 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
)
|
)
|
||||||
case 'book':
|
case 'book':
|
||||||
return (
|
return (
|
||||||
<Pressable {...pressableDefaults}>
|
<Pressable {...pressableProps}>
|
||||||
{itemImage}
|
{itemImage}
|
||||||
<View style={{ flex: 1, gap: StyleConstants.Spacing.S }}>
|
<View {...contentProps}>
|
||||||
{itemHeading(
|
{itemHeading(data.title)}
|
||||||
[
|
|
||||||
data.title,
|
|
||||||
data.pub_year && data.pub_month ? `(${data.pub_year}年${data.pub_month}月)` : null
|
|
||||||
]
|
|
||||||
.filter(d => d)
|
|
||||||
.join(' ')
|
|
||||||
)}
|
|
||||||
<Rating rating={data.rating / 2} />
|
<Rating rating={data.rating / 2} />
|
||||||
{itemDetails(
|
{itemDetails(
|
||||||
[
|
[
|
||||||
data.author?.join(' '),
|
data.author?.join(' '),
|
||||||
data.language,
|
|
||||||
data.pages ? `${data.pages}页` : null,
|
data.pages ? `${data.pages}页` : null,
|
||||||
|
data.language,
|
||||||
data.pub_house
|
data.pub_house
|
||||||
]
|
]
|
||||||
.filter(d => d)
|
.filter(d => d)
|
||||||
@ -118,9 +120,9 @@ export const CardNeodb: React.FC<Props> = ({ card }) => {
|
|||||||
)
|
)
|
||||||
case 'tv':
|
case 'tv':
|
||||||
return (
|
return (
|
||||||
<Pressable {...pressableDefaults}>
|
<Pressable {...pressableProps}>
|
||||||
{itemImage}
|
{itemImage}
|
||||||
<View style={{ flex: 1, gap: StyleConstants.Spacing.S }}>
|
<View {...contentProps}>
|
||||||
{itemHeading(
|
{itemHeading(
|
||||||
[data.title, data.orig_title, data.year ? `(${data.year})` : null]
|
[data.title, data.orig_title, data.year ? `(${data.year})` : null]
|
||||||
.filter(d => d)
|
.filter(d => d)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import { uniqueId } from 'lodash'
|
import { uniqueId } from 'lodash'
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { Defs, LinearGradient, Path, Stop, Svg } from 'react-native-svg'
|
import { Defs, LinearGradient, Path, Stop, Svg } from 'react-native-svg'
|
||||||
|
|
||||||
interface StarProps {
|
interface StarProps {
|
||||||
@ -17,10 +16,7 @@ export const Star: React.FC<StarProps> = ({ size, strokeLinejoin, strokeLinecap,
|
|||||||
const innerRadius = 25
|
const innerRadius = 25
|
||||||
const outerRadius = 50
|
const outerRadius = 50
|
||||||
|
|
||||||
const [id, setId] = useState<string>('')
|
const id = uniqueId()
|
||||||
useEffect(() => {
|
|
||||||
setId(uniqueId())
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const center = Math.max(innerRadius, outerRadius)
|
const center = Math.max(innerRadius, outerRadius)
|
||||||
const angle = Math.PI / NUM_POINT
|
const angle = Math.PI / NUM_POINT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user