Skip to content

Commit

Permalink
Merge pull request #112 from yssk22/develop
Browse files Browse the repository at this point in the history
[expo] add UPFCHistoryScreen
  • Loading branch information
yssk22 authored Nov 14, 2024
2 parents 861cf7a + 79b4a12 commit 8f76b6b
Show file tree
Hide file tree
Showing 14 changed files with 1,458 additions and 11 deletions.
3 changes: 3 additions & 0 deletions expo/assets/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"Configure fan club settings": {
"ja": "ファンクラブ設定を行う"
},
"Event History": {
"ja": "イベント履歴"
},
"Goods": {
"ja": "グッズ"
},
Expand Down
2 changes: 2 additions & 0 deletions expo/features/home/internals/menu/HomeTabMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NavigationListItem } from '@hpapp/features/common/list';
import HPSortScreen from '@hpapp/features/hpsort/HPSortScreen';
import SettingsDevOnlyScreen from '@hpapp/features/settings/SettingsDevOnlyScreen';
import ThemeSettingsScreen from '@hpapp/features/settings/SettingsThemeScreen';
import UPFCHistoryScreen from '@hpapp/features/upfc/UPFCHistoryScreen';
import UPFCSettingsScreen from '@hpapp/features/upfc/UPFCSettingsScreen';
import { t } from '@hpapp/system/i18n';
import { Divider, ListItem } from '@rneui/themed';
Expand All @@ -19,6 +20,7 @@ export default function HomeTabSettings() {
return (
<ScrollView>
<NavigationListItem screen={HPSortScreen}>{t('Sort')}</NavigationListItem>
<NavigationListItem screen={UPFCHistoryScreen}>{t('Event History')}</NavigationListItem>
<ListItem containerStyle={{ backgroundColor: sectionColor }}>
<ListItem.Title>
<Text style={{ color: sectionColorContrast, fontWeight: 'bold' }}>{t('Settings')}</Text>
Expand Down
4 changes: 2 additions & 2 deletions expo/features/home/internals/menu/MenuTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import { renderUserComponent } from '@hpapp/features/testhelper';

import HomeTabSettings from './HomeTabMenu';
import HomeTabMenu from './HomeTabMenu';

describe('SettingsTab', () => {
test('render', async () => {
const rendered = await renderUserComponent(<HomeTabSettings />);
const rendered = await renderUserComponent(<HomeTabMenu />);
expect(rendered).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,99 @@ exports[`SettingsTab render 1`] = `
</View>
</View>
</View>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
>
<View
style={
{
"alignItems": "center",
"backgroundColor": "#ffffff",
"borderColor": "#bcbbc1",
"flexDirection": "row",
"padding": 12,
}
}
testID="RNE__LISTITEM__padView"
>
<View
style={
[
{
"alignItems": "flex-start",
"flex": 1,
"justifyContent": "center",
},
undefined,
]
}
>
<Text
style={
[
{
"color": "black",
},
{
"fontSize": 14,
},
undefined,
]
}
>
イベント履歴
</Text>
</View>
<View
style={
{
"paddingLeft": 16,
}
}
/>
<View
style={
{
"alignItems": "flex-end",
"justifyContent": "center",
}
}
>
<Icon
name="navigate-next"
size={16}
/>
</View>
</View>
</View>
<View
replaceTheme={[Function]}
updateTheme={[Function]}
Expand Down
8 changes: 1 addition & 7 deletions expo/features/hpsort/internals/HPSortHistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ const HPSortHistoryListQueryFragmentGraphQL = graphql`
}
`;

/**
* TODO: #103 optimize and fix the logic for HPSortHistoryScreen.
*/
const numPerFetch = 30;
const numPerFetch = 10;

export default function HPSortHistoryList() {
const data = useLazyLoadQuery<HPSortHistoryListQuery>(HPSortHistoryListQueryGraphQL, {
Expand Down Expand Up @@ -79,9 +76,6 @@ export default function HPSortHistoryList() {
}}
onEndReachedThreshold={0.01}
onEndReached={() => {
/**
* TODO: #103 optimize and fix the logic for HPSortHistoryScreen.
*/
histories.loadNext(numPerFetch);
}}
ListFooterComponent={histories.hasNext ? <ListItemLoadMore /> : null}
Expand Down
9 changes: 9 additions & 0 deletions expo/features/upfc/UPFCHistoryScreen.tsx
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 />;
});
73 changes: 73 additions & 0 deletions expo/features/upfc/internals/UPFCEventList.tsx
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}
/>
);
}
71 changes: 71 additions & 0 deletions expo/features/upfc/internals/UPFCEventListItem.tsx
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'
}
});
Loading

0 comments on commit 8f76b6b

Please sign in to comment.