-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from yssk22/develop
[expo] implement UPFC tab
- Loading branch information
Showing
20 changed files
with
487 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Text from '@hpapp/features/common/components/Text'; | ||
import { FontSize, Spacing } from '@hpapp/features/common/constants'; | ||
import { ColorScheme, useColor } from '@hpapp/features/settings/context/theme'; | ||
import React from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
|
||
type StyleProps = React.ComponentProps<typeof View>['style']; | ||
|
||
export type CardProps = { | ||
colorScheme?: ColorScheme; | ||
headerText?: string; | ||
subHeaderText?: string; | ||
footerContent?: JSX.Element; | ||
containerStyle?: StyleProps; | ||
headerStyle?: StyleProps; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function Card({ | ||
colorScheme = 'primary', | ||
headerText, | ||
subHeaderText, | ||
containerStyle, | ||
headerStyle, | ||
children | ||
}: CardProps) { | ||
const [color, contrast] = useColor(colorScheme); | ||
const showHeader = headerText !== undefined || subHeaderText !== undefined; | ||
return ( | ||
<View style={[styles.container, { borderColor: color }, containerStyle]}> | ||
{showHeader && ( | ||
<View style={[styles.header, { backgroundColor: color }, headerStyle]}> | ||
{headerText && ( | ||
<Text style={[{ color: contrast }, styles.headerText]} numberOfLines={1}> | ||
{headerText} | ||
</Text> | ||
)} | ||
{subHeaderText && ( | ||
<Text style={[{ color: contrast }, styles.subHeaderText]} numberOfLines={1}> | ||
{subHeaderText} | ||
</Text> | ||
)} | ||
</View> | ||
)} | ||
<View>{children}</View> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
borderRadius: 3, | ||
borderWidth: 1 | ||
}, | ||
header: { | ||
padding: Spacing.Small | ||
}, | ||
headerText: { | ||
fontSize: FontSize.Medium, | ||
fontWeight: 'bold' | ||
}, | ||
subHeaderText: { | ||
fontSize: FontSize.XXSmall | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Spacing } from '@hpapp/features/common/constants'; | ||
import { View, StyleSheet } from 'react-native'; | ||
|
||
type StyleProps = React.ComponentProps<typeof View>['style']; | ||
|
||
export type CardBodyProps = { | ||
style?: StyleProps; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function CardBody({ style, children }: CardBodyProps) { | ||
return <View style={[styles.container, style]}>{children}</View>; | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
padding: Spacing.Small | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Spacing } from '@hpapp/features/common/constants'; | ||
import { ColorScheme, useSkeltonColor } from '@hpapp/features/settings/context/theme'; | ||
import ContentLoader, { Rect } from 'react-content-loader/native'; | ||
|
||
type CardSkeltonProps = { | ||
color?: ColorScheme; | ||
}; | ||
|
||
export default function CardSkelton({ color = 'primary' }: CardSkeltonProps) { | ||
const primary = useSkeltonColor(color); | ||
const innerBarX = Spacing.Small + 3 + Spacing.Medium + 50 + Spacing.Medium; | ||
const innerBarWidth = 400 - (Spacing.Small + 3 + Spacing.Medium + 50 + Spacing.Medium * 3); | ||
return ( | ||
<ContentLoader speed={2} width="100%" height="225" viewBox="0 0 400 225" backgroundColor={primary}> | ||
<Rect x={Spacing.Small} y="0" rx="0" ry="0" width={400 - 2 * Spacing.Small} height="45" /> | ||
<Rect x={Spacing.Small} y="225" rx="0" ry="0" width={400 - 2 * Spacing.Small} height="3" /> | ||
|
||
<Rect x={Spacing.Small} y="45" rx="0" ry="0" width="3" height="180" /> | ||
<Rect x={400 - Spacing.Small - 3} y="45" rx="0" ry="0" width="3" height="180" /> | ||
|
||
<Rect x={Spacing.Small + 3 + Spacing.Medium} y="65" rx="0" ry="0" width="50" height="50" /> | ||
<Rect x={Spacing.Small + 3 + Spacing.Medium} y="145" rx="0" ry="0" width="50" height="50" /> | ||
|
||
<Rect x={innerBarX} y="75" rx="0" ry="0" width={innerBarWidth} height="5" /> | ||
<Rect x={innerBarX} y="100" rx="0" ry="0" width={innerBarWidth} height="5" /> | ||
|
||
<Rect x={innerBarX} y="155" rx="0" ry="0" width={innerBarWidth} height="5" /> | ||
<Rect x={innerBarX} y="180" rx="0" ry="0" width={innerBarWidth} height="5" /> | ||
</ContentLoader> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import CalendarDateIcon from '@hpapp/features/common/components/CalendarDateIcon'; | ||
import Text from '@hpapp/features/common/components/Text'; | ||
import Card from '@hpapp/features/common/components/card/Card'; | ||
import ListItem from '@hpapp/features/common/components/list/ListItem'; | ||
import { FontSize, IconSize, Spacing } from '@hpapp/features/common/constants'; | ||
import { useColor } from '@hpapp/features/settings/context/theme'; | ||
import UPFCApplicationStatusLabel from '@hpapp/features/upfc/UPFCApplicationStatusLabel'; | ||
import { EventApplicationTickets } from '@hpapp/features/upfc/scraper'; | ||
import useUPFCWebView from '@hpapp/features/upfc/useUPFCWebView'; | ||
import { toDateString, toTimeString } from '@hpapp/foundation/date'; | ||
import { Button, Icon } from '@rneui/themed'; | ||
import { useMemo } from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
|
||
const styles = StyleSheet.create({ | ||
card: { | ||
margin: Spacing.XSmall | ||
}, | ||
listItem: { | ||
paddingTop: Spacing.XXSmall, | ||
paddingBottom: Spacing.XSmall, | ||
paddingLeft: Spacing.XXSmall, | ||
paddingRight: Spacing.XSmall | ||
}, | ||
listItemCenter: { | ||
justifyContent: 'space-around', | ||
paddingLeft: Spacing.Small, | ||
paddingRight: Spacing.Small, | ||
flexGrow: 1 | ||
}, | ||
listItemCenterText: { | ||
fontSize: FontSize.Small | ||
}, | ||
footer: { | ||
flexGrow: 1, | ||
justifyContent: 'flex-end', | ||
alignItems: 'flex-end', | ||
marginTop: Spacing.Small, | ||
paddingRight: Spacing.Small, | ||
paddingBottom: Spacing.Small | ||
}, | ||
footerButtonIcon: { | ||
marginLeft: Spacing.Small | ||
} | ||
}); | ||
|
||
export type UPFCApplicationCardProps = { | ||
event: EventApplicationTickets; | ||
}; | ||
|
||
export default function UPFCApplicationCard({ event }: UPFCApplicationCardProps) { | ||
const [color] = useColor('primary'); | ||
const openUPFCWeView = useUPFCWebView(); | ||
const paymentWindowString = `${toDateString(event.paymentOpenDate)} ~ ${toDateString(event.paymentDueDate)}`; | ||
const items = useMemo(() => { | ||
return event.tickets.map((t) => { | ||
return ( | ||
<ListItem | ||
containerStyle={styles.listItem} | ||
key={`${event.name}.${t.venue}.${t.startAt.getTime()}`} | ||
leftContent={<CalendarDateIcon date={t.startAt} />} | ||
rightContent={<UPFCApplicationStatusLabel ticket={t} />} | ||
> | ||
<View style={styles.listItemCenter}> | ||
<Text style={styles.listItemCenterText} numberOfLines={1}> | ||
{t.venue} | ||
</Text> | ||
<Text style={styles.listItemCenterText}>{`開場: ${toTimeString(t.openAt)} 開演:${toTimeString( | ||
t.startAt | ||
)}`}</Text> | ||
</View> | ||
</ListItem> | ||
); | ||
}); | ||
}, [event]); | ||
const footer = useMemo(() => { | ||
if (event.paymentDueDate) { | ||
return ( | ||
<View style={styles.footer}> | ||
<Button | ||
color="secondary" | ||
type="outline" | ||
onPress={() => { | ||
openUPFCWeView({ | ||
urlParams: 'Contents=MYPAGE02' | ||
}); | ||
}} | ||
> | ||
{paymentWindowString} | ||
<Icon | ||
style={styles.footerButtonIcon} | ||
type="antdesign" | ||
name="pay-circle1" | ||
size={IconSize.Small} | ||
color={color} | ||
/> | ||
</Button> | ||
</View> | ||
); | ||
} | ||
return null; | ||
}, [event.paymentDueDate]); | ||
return ( | ||
<Card containerStyle={styles.card} headerText={event.name}> | ||
{items} | ||
{footer} | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Text from '@hpapp/features/common/components/Text'; | ||
import { FontSize, Spacing } from '@hpapp/features/common/constants'; | ||
import { ColorScheme, useColor } from '@hpapp/features/settings/context/theme'; | ||
import { EventTicket } from '@hpapp/features/upfc/scraper'; | ||
import React from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
|
||
const StatusColorScheme: Record<string, ColorScheme> = { | ||
申込済: 'success', | ||
入金待: 'error', | ||
入金済: 'primary', | ||
入金忘: 'disabled', | ||
落選: 'disabled', | ||
不明: 'warning' | ||
}; | ||
|
||
export type UPFCApplicationStatusLabelProps = { | ||
ticket: EventTicket; | ||
}; | ||
|
||
export default function UPFCApplicationStatusLabel({ ticket }: UPFCApplicationStatusLabelProps) { | ||
const [color, contrast] = useColor(StatusColorScheme[ticket.status]); | ||
return ( | ||
<View style={[styles.container, { backgroundColor: color }]}> | ||
<Text style={[styles.text, { color: contrast }]}>{ticket.status}</Text> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
paddingLeft: Spacing.XSmall, | ||
paddingRight: Spacing.XSmall, | ||
paddingTop: Spacing.XXSmall, | ||
paddingBottom: Spacing.XXSmall, | ||
width: 50, | ||
alignItems: 'center' | ||
}, | ||
text: { | ||
fontSize: FontSize.XSmall | ||
} | ||
}); |
Oops, something went wrong.