-
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 #112 from yssk22/develop
[expo] add UPFCHistoryScreen
- Loading branch information
Showing
14 changed files
with
1,458 additions
and
11 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
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
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,9 @@ | ||
import { defineScreen, useScreenTitle } from '@hpapp/features/common/stack'; | ||
import { t } from '@hpapp/system/i18n'; | ||
|
||
import UPFCEventList from './internals/UPFCEventList'; | ||
|
||
export default defineScreen('/upfc/history/', function UPFCHistoryScreen({ current, previous }) { | ||
useScreenTitle(t('Event History')); | ||
return <UPFCEventList />; | ||
}); |
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,73 @@ | ||
import { ListItemLoadMore } from '@hpapp/features/common/list'; | ||
import { parseDate } from '@hpapp/foundation/date'; | ||
import { FlatList } from 'react-native'; | ||
import { graphql, useLazyLoadQuery, usePaginationFragment } from 'react-relay'; | ||
|
||
import UPFCEventListItem from './UPFCEventListItem'; | ||
import { UPFCEventListQuery } from './__generated__/UPFCEventListQuery.graphql'; | ||
import { UPFCEventListQuery_me_query_events$key } from './__generated__/UPFCEventListQuery_me_query_events.graphql'; | ||
|
||
const UPFCEventListQueryGraphQL = graphql` | ||
query UPFCEventListQuery($first: Int, $after: Cursor) { | ||
me { | ||
...UPFCEventListQuery_me_query_events | ||
} | ||
} | ||
`; | ||
|
||
const HPSortHistoryListQueryFragmentGraphQL = graphql` | ||
fragment UPFCEventListQuery_me_query_events on MeQuery @refetchable(queryName: "UPFCEventListQueryFragmentQuery") { | ||
events(first: $first, after: $after) @connection(key: "UPFCEventListQuery_me_query_events") { | ||
edges { | ||
node { | ||
id | ||
key | ||
displayTitles | ||
openAt | ||
startAt | ||
venue | ||
prefecture | ||
tickets { | ||
applicationTitle | ||
num | ||
status | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const numPerFetch = 20; | ||
|
||
export default function UPFCEventList() { | ||
const data = useLazyLoadQuery<UPFCEventListQuery>(UPFCEventListQueryGraphQL, { | ||
first: numPerFetch | ||
}); | ||
const histories = usePaginationFragment<UPFCEventListQuery, UPFCEventListQuery_me_query_events$key>( | ||
HPSortHistoryListQueryFragmentGraphQL, | ||
data.me | ||
); | ||
return ( | ||
<FlatList | ||
keyExtractor={(item) => item!.node!.id} | ||
data={histories.data.events!.edges} | ||
renderItem={({ item, index }) => { | ||
const tickets = item!.node!.tickets!.map((t) => t.applicationTitle); | ||
return ( | ||
<UPFCEventListItem | ||
name={tickets[0]} | ||
venue={item!.node!.venue!} | ||
startAt={parseDate(item!.node!.startAt)} | ||
openAt={parseDate(item!.node!.openAt)} | ||
/> | ||
); | ||
}} | ||
onEndReachedThreshold={0.01} | ||
onEndReached={() => { | ||
histories.loadNext(numPerFetch); | ||
}} | ||
ListFooterComponent={histories.hasNext ? <ListItemLoadMore /> : null} | ||
/> | ||
); | ||
} |
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,71 @@ | ||
import { useThemeColor } from '@hpapp/features/app/theme'; | ||
import { CalendarDateIcon, Text } from '@hpapp/features/common'; | ||
import { FontSize, IconSize, Spacing } from '@hpapp/features/common/constants'; | ||
import { ListItem } from '@hpapp/features/common/list'; | ||
import * as date from '@hpapp/foundation/date'; | ||
import { t } from '@hpapp/system/i18n'; | ||
import { Icon } from '@rneui/base'; | ||
import { Linking, View, StyleSheet } from 'react-native'; | ||
|
||
export type UPFCEventListItemProps = { | ||
name: string; | ||
venue: string; | ||
openAt?: Date; | ||
startAt: Date; | ||
iconName?: string; | ||
onPress?: () => void; | ||
}; | ||
|
||
export default function UPFCEventListItem({ name, venue, openAt, startAt, iconName, onPress }: UPFCEventListItemProps) { | ||
const [color] = useThemeColor('primary'); | ||
return ( | ||
<ListItem | ||
containerStyle={styles.listItem} | ||
leftContent={<CalendarDateIcon date={startAt} />} | ||
rightContent={iconName !== undefined ? <Icon name={iconName} size={IconSize.Medium} color={color} /> : <></>} | ||
onPress={() => { | ||
Linking.openURL(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(venue)}`); | ||
}} | ||
> | ||
<View style={styles.listItemCenter}> | ||
<View> | ||
<Text style={styles.listItemCenterText} numberOfLines={1}> | ||
{name} | ||
</Text> | ||
<Text style={styles.listItemCenterText} numberOfLines={1}> | ||
{venue} | ||
</Text> | ||
<View style={styles.listItemCenterTextFooterRow}> | ||
{openAt && ( | ||
<Text style={[styles.listItemCenterText, styles.listItemCenterTextColumn]}> | ||
{t('Open At')}: {date.toTimeString(openAt)} | ||
</Text> | ||
)} | ||
<Text style={[styles.listItemCenterText, styles.listItemCenterTextColumn]}> | ||
{t('Start At')}: {date.toTimeString(startAt)} | ||
</Text> | ||
</View> | ||
</View> | ||
</View> | ||
</ListItem> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
listItem: { | ||
paddingLeft: Spacing.XSmall, | ||
paddingRight: Spacing.XSmall | ||
}, | ||
listItemCenter: { | ||
padding: Spacing.XXSmall | ||
}, | ||
listItemCenterText: { | ||
fontSize: FontSize.Small | ||
}, | ||
listItemCenterTextColumn: { | ||
marginRight: Spacing.Large | ||
}, | ||
listItemCenterTextFooterRow: { | ||
flexDirection: 'row' | ||
} | ||
}); |
Oops, something went wrong.