Updated react native paper to latest major version and fixed error on card press

This commit is contained in:
Arnaud Vergnet 2020-07-17 17:28:39 +02:00
parent 8004820c2a
commit d1fc8a9625
5 changed files with 116 additions and 95 deletions

View file

@ -43,7 +43,7 @@
"react-native-linear-gradient": "^2.5.6", "react-native-linear-gradient": "^2.5.6",
"react-native-localize": "^1.4.0", "react-native-localize": "^1.4.0",
"react-native-modalize": "^2.0.4", "react-native-modalize": "^2.0.4",
"react-native-paper": "^3.10.1", "react-native-paper": "^4.0.1",
"react-native-permissions": "^2.1.5", "react-native-permissions": "^2.1.5",
"react-native-push-notification": "^4.0.0", "react-native-push-notification": "^4.0.0",
"react-native-reanimated": "^1.9.0", "react-native-reanimated": "^1.9.0",

View file

@ -1,8 +1,8 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Avatar, Card, Text, withTheme} from 'react-native-paper'; import {Avatar, Card, Text, TouchableRipple, withTheme} from 'react-native-paper';
import {StyleSheet} from "react-native"; import {StyleSheet, View} from "react-native";
import i18n from "i18n-js"; import i18n from "i18n-js";
import type {CustomTheme} from "../../managers/ThemeManager"; import type {CustomTheme} from "../../managers/ThemeManager";
@ -47,9 +47,11 @@ class EventDashBoardItem extends React.Component<Props> {
} else } else
subtitle = i18n.t('screens.home.dashboard.todayEventsSubtitleNA'); subtitle = i18n.t('screens.home.dashboard.todayEventsSubtitleNA');
return ( return (
<Card <Card style={styles.card}>
style={styles.card} <TouchableRipple
style={{flex: 1}}
onPress={props.clickAction}> onPress={props.clickAction}>
<View>
<Card.Title <Card.Title
title={i18n.t('screens.home.dashboard.todayEventsTitle')} title={i18n.t('screens.home.dashboard.todayEventsTitle')}
titleStyle={{color: textColor}} titleStyle={{color: textColor}}
@ -65,6 +67,8 @@ class EventDashBoardItem extends React.Component<Props> {
<Card.Content> <Card.Content>
{props.children} {props.children}
</Card.Content> </Card.Content>
</View>
</TouchableRipple>
</Card> </Card>
); );
} }

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Button, Card, Text} from 'react-native-paper'; import {Button, Card, Text, TouchableRipple} from 'react-native-paper';
import {Image, View} from "react-native"; import {Image, View} from "react-native";
import Autolink from "react-native-autolink"; import Autolink from "react-native-autolink";
import i18n from "i18n-js"; import i18n from "i18n-js";
@ -75,8 +75,11 @@ class FeedItem extends React.Component<Props> {
margin: cardMargin, margin: cardMargin,
height: cardHeight, height: cardHeight,
}} }}
onPress={this.onPress}
> >
<TouchableRipple
style={{flex: 1}}
onPress={this.onPress}>
<View>
<Card.Title <Card.Title
title={this.props.title} title={this.props.title}
subtitle={this.props.subtitle} subtitle={this.props.subtitle}
@ -114,6 +117,8 @@ class FeedItem extends React.Component<Props> {
{i18n.t('screens.home.dashboard.seeMore')} {i18n.t('screens.home.dashboard.seeMore')}
</Button> </Button>
</Card.Actions> </Card.Actions>
</View>
</TouchableRipple>
</Card> </Card>
); );
} }

View file

@ -1,9 +1,9 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {StyleSheet} from "react-native"; import {StyleSheet, View} from "react-native";
import i18n from "i18n-js"; import i18n from "i18n-js";
import {Avatar, Button, Card} from 'react-native-paper'; import {Avatar, Button, Card, TouchableRipple} from 'react-native-paper';
import {getFormattedEventTime, isDescriptionEmpty} from "../../utils/Planning"; import {getFormattedEventTime, isDescriptionEmpty} from "../../utils/Planning";
import CustomHTML from "../Overrides/CustomHTML"; import CustomHTML from "../Overrides/CustomHTML";
import type {CustomTheme} from "../../managers/ThemeManager"; import type {CustomTheme} from "../../managers/ThemeManager";
@ -36,9 +36,12 @@ class PreviewEventDashboardItem extends React.Component<Props> {
return ( return (
<Card <Card
style={styles.card} style={styles.card}
onPress={props.clickAction}
elevation={3} elevation={3}
> >
<TouchableRipple
style={{flex: 1}}
onPress={props.clickAction}>
<View>
{hasImage ? {hasImage ?
<Card.Title <Card.Title
title={event.title} title={event.title}
@ -61,6 +64,8 @@ class PreviewEventDashboardItem extends React.Component<Props> {
{i18n.t("screens.home.dashboard.seeMore")} {i18n.t("screens.home.dashboard.seeMore")}
</Button> </Button>
</Card.Actions> </Card.Actions>
</View>
</TouchableRipple>
</Card> </Card>
); );
} else } else

View file

@ -1,7 +1,8 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Caption, Card, Paragraph} from 'react-native-paper'; import {Caption, Card, Paragraph, TouchableRipple} from 'react-native-paper';
import {View} from "react-native";
import type {cardItem} from "./CardList"; import type {cardItem} from "./CardList";
type Props = { type Props = {
@ -28,8 +29,11 @@ export default class CardListItem extends React.Component<Props> {
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
}} }}
onPress={item.onPress}
> >
<TouchableRipple
style={{flex: 1}}
onPress={item.onPress}>
<View>
<Card.Cover <Card.Cover
style={{height: 80}} style={{height: 80}}
source={source} source={source}
@ -38,6 +42,9 @@ export default class CardListItem extends React.Component<Props> {
<Paragraph>{item.title}</Paragraph> <Paragraph>{item.title}</Paragraph>
<Caption>{item.subtitle}</Caption> <Caption>{item.subtitle}</Caption>
</Card.Content> </Card.Content>
</View>
</TouchableRipple>
</Card> </Card>
); );
} }