Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

西鉄ナンバリング対応 #3591

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/NumberingIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import NumberingIconSMR from './NumberingIconSMR'
import NumberingIconSanyo from './NumberingIconSanyo'
import NumberingIconSquare from './NumberingIconSquare'
import NumberingIconTWR from './NumberingIconTWR'
import NumberingNishitetsu from './NumberingNishitetsu'

type Props = {
shape: string
Expand Down Expand Up @@ -243,6 +244,14 @@ const NumberingIconOriginal: React.FC<Props> = ({
stationNumber={stationNumber}
/>
)
case MARK_SHAPE.NISHITETSU:
return (
<NumberingNishitetsu
lineColor={lineColor}
stationNumber={stationNumber}
size={size}
/>
)
default:
return null
}
Expand Down
100 changes: 100 additions & 0 deletions src/components/NumberingNishitetsu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React from 'react'
import { StyleSheet, View } from 'react-native'
import { FONTS, NUMBERING_ICON_SIZE, NumberingIconSize } from '../constants'
import isTablet from '../utils/isTablet'
import NumberingIconReversedSquare from './NumberingIconReversedSquare'
import Typography from './Typography'

type Props = {
stationNumber: string
lineColor: string
size?: NumberingIconSize
}

const styles = StyleSheet.create({
root: {
width: isTablet ? 84 * 1.5 : 84,
height: isTablet ? 55 * 1.5 : 55,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
borderWidth: 1,
borderColor: 'white',
padding: 4,
borderRadius: 4,
gap: 4,
},
rootMediumContainer: {
width: 38 * 1.5,
height: 38,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
borderWidth: 1,
borderColor: 'white',
},
lineSymbol: {
width: '35%',
fontSize: isTablet ? 18 * 1.5 : 18,
textAlign: 'center',
fontFamily: FONTS.RobotoBold,
},
stationNumberContainer: {
flex: 1,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center',
height: '100%',
},
stationNumber: {
color: '#231f20',
fontSize: isTablet ? 28 * 1.5 : 28,
textAlign: 'center',
fontFamily: FONTS.RobotoBold,
},
})

const NumberingIconNishitetsu: React.FC<Props> = ({
stationNumber: stationNumberRaw,
lineColor,
size,
}: Props) => {
const darkText = false
const [lineSymbol, ...stationNumberRest] = stationNumberRaw.split('-')
const stationNumber = stationNumberRest.join('')

if (size === NUMBERING_ICON_SIZE.SMALL) {
return (
<NumberingIconReversedSquare
stationNumber={stationNumberRaw}
lineColor={lineColor}
size={NUMBERING_ICON_SIZE.SMALL}
/>
)
}

if (size === NUMBERING_ICON_SIZE.MEDIUM) {
return (
<NumberingIconReversedSquare
stationNumber={stationNumberRaw}
lineColor={lineColor}
size={NUMBERING_ICON_SIZE.MEDIUM}
/>
)
}

return (
<View style={[styles.root, { backgroundColor: lineColor }]}>
<Typography
style={[styles.lineSymbol, { color: darkText ? '#231f20' : 'white' }]}
>
{lineSymbol}
</Typography>
<View style={styles.stationNumberContainer}>
<Typography style={styles.stationNumber}>{stationNumber}</Typography>
</View>
</View>
)
}

export default React.memo(NumberingIconNishitetsu)
1 change: 1 addition & 0 deletions src/constants/numbering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const MARK_SHAPE = {
KEISEI: 'KEISEI',
NTL: 'NTL',
SMR: 'SMR',
NISHITETSU: 'NISHITETSU',
} as const

export const NUMBERING_ICON_SIZE = {
Expand Down
Loading