Skip to content

Commit

Permalink
- [x] [小圣杯] 我的持仓显示圣殿 (等我弄懂怎么玩再对接小圣杯新功能)
Browse files Browse the repository at this point in the history
- [x] [个人中心] 在看、抛弃也显示天数
  • Loading branch information
czy0729 committed Oct 5, 2019
1 parent 8df8b65 commit 4f8b932
Show file tree
Hide file tree
Showing 17 changed files with 273 additions and 70 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ios",
"android"
],
"version": "1.2.5",
"version": "1.3.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
Expand All @@ -28,7 +28,7 @@
},
"android": {
"package": "com.czy0729.bangumi",
"versionCode": 3
"versionCode": 4
},
"androidStatusBar": {
"barStyle": "dark-content",
Expand Down
64 changes: 36 additions & 28 deletions components/@/ant-design/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,44 @@ export class Tabs extends React.PureComponent {
</View>
)
})

if (Platform.OS === 'android') {
return (
<ViewPagerAndroid
key='$content'
keyboardDismissMode='on-drag'
initialPage={currentTab}
scrollEnabled={this.props.swipeable || usePaged}
onPageScroll={e => {
this.state.scrollX.setValue(
e.nativeEvent.position * this.state.containerWidth
)
}}
style={{ flex: 1 }}
onPageSelected={e => {
const index = e.nativeEvent.position
this.setState(
{
currentTab: index
},
() => {
// tslint:disable-next-line:no-unused-expression
this.props.onChange && this.props.onChange(tabs[index], index)
}
)
this.nextCurrentTab = index
}}
ref={ref => (this.viewPager = ref)}
>
{content}
</ViewPagerAndroid>
<>
{!!renderContentHeaderComponent && (
<View key='$renderContentHeaderComponent'>
{renderContentHeaderComponent}
</View>
)}
<ViewPagerAndroid
key='$content'
keyboardDismissMode='on-drag'
initialPage={currentTab}
scrollEnabled={this.props.swipeable || usePaged}
onPageScroll={e => {
this.state.scrollX.setValue(
e.nativeEvent.position * this.state.containerWidth
)
}}
style={{ flex: 1 }}
onPageSelected={e => {
const index = e.nativeEvent.position
this.setState(
{
currentTab: index
},
() => {
// tslint:disable-next-line:no-unused-expression
this.props.onChange && this.props.onChange(tabs[index], index)
}
)
this.nextCurrentTab = index
}}
ref={ref => (this.viewPager = ref)}
>
{content}
</ViewPagerAndroid>
</>
)
}
return (
Expand Down
8 changes: 7 additions & 1 deletion constants/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: czy0729
* @Date: 2019-02-21 21:30:44
* @Last Modified by: czy0729
* @Last Modified time: 2019-10-05 13:14:26
* @Last Modified time: 2019-10-05 16:02:53
*/
import { HOST } from './index'

Expand Down Expand Up @@ -295,3 +295,9 @@ export const API_TINYGRAIL_USERS = monoId =>
*/
export const API_TINYGRAIL_TEST = () =>
`${API_HOST_TINYGRAIL}/api/event/share/bonus/test`

/**
* 用户圣殿信息
*/
export const API_TINYGRAIL_TEMPLE = hash =>
`${API_HOST_TINYGRAIL}/api/chara/user/temple/${hash}/1/50`
3 changes: 2 additions & 1 deletion constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: czy0729
* @Date: 2019-02-22 01:25:31
* @Last Modified by: czy0729
* @Last Modified time: 2019-10-01 15:10:05
* @Last Modified time: 2019-10-05 15:19:40
*/
import { Platform } from 'react-native'
import Constants from 'expo-constants'
Expand All @@ -24,6 +24,7 @@ export const USERID_IOS_AUTH = 474489
// URL
export const HOST_NAME = 'bgm.tv' // 域名
export const HOST = `https://${HOST_NAME}`
export const HOST_WITHOUT_HTTPS = `http://${HOST_NAME}`
export const HOST_2 = 'https://bangumi.tv' // 备用域名
export const OAUTH_URL = `${HOST}/oauth/authorize` // 登陆v1.0 oauth地址
export const OAUTH_REDIRECT_URL = `${HOST}/dev/app` // 登陆v1.0 授权跳转地址
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@ant-design/react-native": "^3.1.3",
"@expo/vector-icons": "^10.0.3",
"axios": "^0.19.0",
"bangumi-data": "^0.3.0",
"bangumi-data": "^0.3.2",
"cheerio-without-node-native": "^0.20.2",
"crypto-js": "^3.1.9-1",
"deepmerge": "^4.0.0",
Expand Down
16 changes: 10 additions & 6 deletions screens/_/item/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-05-25 23:00:45
* @Last Modified by: czy0729
* @Last Modified time: 2019-08-23 00:43:27
* @Last Modified time: 2019-10-05 15:07:29
*/
import React from 'react'
import { StyleSheet, View } from 'react-native'
Expand Down Expand Up @@ -30,7 +30,9 @@ function ItemCollections({
time,
tags = '',
comments,
isOnHold
isDo,
isOnHold,
isDropped
}) {
const _cover = getCoverMedium(cover)
const isFirst = index === 0
Expand All @@ -39,9 +41,9 @@ function ItemCollections({
const hasScore = !!score
const hasTags = !!tags
const hasComment = !!comments
let holdDays
if (isOnHold) {
holdDays = Math.ceil((getTimestamp() - getTimestamp(time)) / 86400)
let days
if (isDo || isOnHold || isDropped) {
days = Math.ceil((getTimestamp() - getTimestamp(time)) / 86400)
}
return (
<Touchable
Expand Down Expand Up @@ -94,7 +96,9 @@ function ItemCollections({
)}
<Text style={_.mr.sm} type='sub' size={12} numberOfLines={2}>
{hasScore && '/ '}
{isOnHold && `搁置${holdDays}天 / `}
{isDo && `${days}天 / `}
{isOnHold && `搁置${days}天 / `}
{isDropped && `抛弃${days}天 / `}
{time} {hasTags && '/'} {tags.replace(' ', '')}
</Text>
</Flex>
Expand Down
13 changes: 11 additions & 2 deletions screens/home/subject/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@
* @Author: czy0729
* @Date: 2019-03-25 05:52:24
* @Last Modified by: czy0729
* @Last Modified time: 2019-08-23 00:34:31
* @Last Modified time: 2019-10-05 15:15:18
*/
import React from 'react'
import { StyleSheet, View } from 'react-native'
import PropTypes from 'prop-types'
import { observer } from 'mobx-react'
import { ActivityIndicator } from '@ant-design/react-native'
import { Expand, Flex, Text, Touchable } from '@components'
import { SectionTitle } from '@screens/_'
import { MODEL_SUBJECT_TYPE } from '@constants/model'
import _ from '@styles'

function Tags({ style }, { $, navigation }) {
const { type } = $.subject
const { tags = [] } = $.subjectFormHTML
const { tags = [], _loaded } = $.subjectFormHTML
const { tag = [] } = $.collection
return (
<View style={[_.container.wind, styles.container, style]}>
<SectionTitle>标签</SectionTitle>
{!_loaded && (
<Flex style={styles.loading} justify='center'>
<ActivityIndicator />
</Flex>
)}
{!!tags.length && (
<Expand style={_.mt.sm}>
<Flex wrap='wrap'>
Expand Down Expand Up @@ -63,6 +69,9 @@ const styles = StyleSheet.create({
container: {
minHeight: 120
},
loading: {
height: 96
},
item: {
paddingVertical: 4,
paddingHorizontal: 8,
Expand Down
13 changes: 10 additions & 3 deletions screens/tinygrail/_/tool-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: czy0729
* @Date: 2019-10-03 21:22:29
* @Last Modified by: czy0729
* @Last Modified time: 2019-10-04 13:45:58
* @Last Modified time: 2019-10-05 15:30:45
*/
import React from 'react'
import { StyleSheet, View, ScrollView } from 'react-native'
Expand Down Expand Up @@ -60,10 +60,17 @@ const styles = StyleSheet.create({
borderBottomColor: colorBorder
},
tips: {
marginHorizontal: 8,
width: 6,
height: 6,
marginLeft: 12,
borderWidth: 6,
borderColor: 'transparent',
borderLeftColor: colorText
borderBottomColor: colorText,
transform: [
{
rotate: '90deg'
}
]
},
item: {
paddingLeft: 8,
Expand Down
63 changes: 63 additions & 0 deletions screens/tinygrail/chara-assets/item-temple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* @Author: czy0729
* @Date: 2019-10-05 16:22:34
* @Last Modified by: czy0729
* @Last Modified time: 2019-10-05 16:34:28
*/
import React from 'react'
import { StyleSheet, View } from 'react-native'
import PropTypes from 'prop-types'
import { observer } from 'mobx-react'
import { Touchable, Text, Image } from '@components'
import { HTMLDecode } from '@utils/html'
import { tinygrailOSS } from '@utils/app'
import { info } from '@utils/ui'
import _ from '@styles'
import { colorText } from '../styles'

const imageWidth = _.window.width * 0.24
const marginLeft = (_.window.width - 3 * imageWidth) / 4

function ItemTemple({ cover, name, sacrifices }) {
return (
<View style={styles.item}>
<Image
size={imageWidth}
height={imageWidth * 1.28}
src={tinygrailOSS(cover)}
radius
onPress={() => info('开发中')}
/>
<Touchable style={_.mt.sm} withoutFeedback onPress={() => info('开发中')}>
<Text type='plain' numberOfLines={2} align='center'>
{HTMLDecode(name)}
</Text>
<Text
style={[
_.mt.xs,
{
color: colorText
}
]}
align='center'
>
{sacrifices}
</Text>
</Touchable>
</View>
)
}

ItemTemple.contextTypes = {
$: PropTypes.object
}

export default observer(ItemTemple)

const styles = StyleSheet.create({
item: {
width: imageWidth,
marginTop: _.lg,
marginLeft
}
})
49 changes: 36 additions & 13 deletions screens/tinygrail/chara-assets/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* @Author: czy0729
* @Date: 2019-09-19 00:35:07
* @Last Modified by: czy0729
* @Last Modified time: 2019-10-04 14:14:47
* @Last Modified time: 2019-10-05 16:33:40
*/
import React from 'react'
import PropTypes from 'prop-types'
import { observer } from 'mobx-react'
import { Loading, ListView } from '@components'
import _ from '@styles'
import Item from '../_/item'
import ItemTemple from './item-temple'
import { sortList } from '../_/utils'

function List({ index }, { $ }) {
Expand All @@ -20,30 +21,52 @@ function List({ index }, { $ }) {

const type = index === 0 ? 'chara' : 'ico'
const isChara = type === 'chara'
const isTemple = index === 2

let data
if (isChara) {
data = chara
} else if (isTemple) {
data = $.temple
} else {
data = ico
}

const { sort, direction } = $.state
let _chara = chara
if (isChara && sort) {
_chara = {
data = {
...chara,
list: sortList(sort, direction, chara.list)
}
}

const numColumns = isTemple ? 3 : undefined
return (
<ListView
key={String(numColumns)}
style={_.container.flex}
keyExtractor={(item, index) => String(index)}
data={isChara ? _chara : ico}
renderItem={({ item, index }) => (
<Item
index={index}
{...item}
type={type}
users={type === 'ico' ? 'ico' : undefined} // 这里api有bug
/>
)}
onHeaderRefresh={() => $.fetchMyCharaAssets()}
data={data}
numColumns={numColumns}
renderItem={({ item, index }) => {
if (isTemple) {
return <ItemTemple index={index} {...item} />
}
return (
<Item
index={index}
{...item}
type={type}
users={type === 'ico' ? 'ico' : undefined} // 这里api有bug
/>
)
}}
onHeaderRefresh={() => {
if (isTemple) {
return $.fetchTemple()
}
return $.fetchMyCharaAssets()
}}
/>
)
}
Expand Down
Loading

0 comments on commit 4f8b932

Please sign in to comment.