Compare commits

..

No commits in common. "376b5f665cca7ba65a584c34eb58523e9b359e97" and "9bbd3dd6b2ca9dbb1c635638fe9f0b8dd5ca7b29" have entirely different histories.

2 changed files with 80 additions and 37 deletions

View file

@ -7,7 +7,7 @@ import ThemeManager from "../utils/ThemeManager";
import HTML from "react-native-render-html"; import HTML from "react-native-render-html";
import {LinearGradient} from "expo-linear-gradient"; import {LinearGradient} from "expo-linear-gradient";
import i18n from "i18n-js"; import i18n from "i18n-js";
import {Avatar, Card, Text} from 'react-native-paper'; import {Avatar, Card, Text, Title} from 'react-native-paper';
type Props = { type Props = {
isAvailable: boolean, isAvailable: boolean,
@ -28,13 +28,6 @@ export default class DashboardItem extends React.Component<Props> {
displayEvent: undefined, displayEvent: undefined,
}; };
getIcon: Function;
constructor() {
super();
this.getIcon = this.getIcon.bind(this);
}
/** /**
* Convert the date string given by in the event list json to a date object * Convert the date string given by in the event list json to a date object
* @param dateString * @param dateString
@ -71,17 +64,18 @@ export default class DashboardItem extends React.Component<Props> {
getEventPreviewContainer() { getEventPreviewContainer() {
if (this.props.displayEvent !== undefined && this.props.displayEvent !== null) { if (this.props.displayEvent !== undefined && this.props.displayEvent !== null) {
const hasImage = this.props.displayEvent['logo'] !== '' && this.props.displayEvent['logo'] !== null; const hasImage = this.props.displayEvent['logo'] !== '' && this.props.displayEvent['logo'] !== null;
const getImage = () => <Avatar.Image
source={{uri: this.props.displayEvent['logo']}}
size={60}
style={{backgroundColor: 'transparent'}}/>;
return ( return (
<Card style={{marginBottom: 10}}> <Card style={{marginBottom: 10}}>
{hasImage ? {hasImage ?
<Card.Title <Card.Title
title={this.props.displayEvent['title']} title={this.props.displayEvent['title']}
subtitle={this.getFormattedEventTime(this.props.displayEvent)} subtitle={this.getFormattedEventTime(this.props.displayEvent)}
left={getImage} left={() =>
<Avatar.Image
source={{uri: this.props.displayEvent['logo']}}
size={60}
style={{backgroundColor: 'transparent'}}/>
}
/> : /> :
<Card.Title <Card.Title
title={this.props.displayEvent['title']} title={this.props.displayEvent['title']}
@ -143,14 +137,58 @@ export default class DashboardItem extends React.Component<Props> {
getIcon() { getIcon() {
return ( return (
<Avatar.Icon <MaterialCommunityIcons
icon={this.props.icon} name={this.props.icon}
color={this.props.isAvailable ? this.props.color : ThemeManager.getCurrentThemeVariables().textDisabled} color={
size={60} this.props.isAvailable ?
style={{backgroundColor: 'transparent'}}/> this.props.color :
ThemeManager.getCurrentThemeVariables().textDisabled
}
size={this.props.isSquare ? 50 : 40}/>
); );
} }
getText() {
return (
<View style={{
width: this.props.isSquare ? '100%' : 'auto',
}}>
<Title style={{
color: this.props.isAvailable ?
ThemeManager.getCurrentThemeVariables().text :
ThemeManager.getCurrentThemeVariables().textDisabled,
textAlign: this.props.isSquare ? 'center' : 'left',
width: this.props.isSquare ? '100%' : 'auto',
}}>
{this.props.title}
</Title>
<Text style={{
color: this.props.isAvailable ?
ThemeManager.getCurrentThemeVariables().text :
ThemeManager.getCurrentThemeVariables().textDisabled,
textAlign: this.props.isSquare ? 'center' : 'left',
width: this.props.isSquare ? '100%' : 'auto',
}}>
{this.props.subtitle}
</Text>
</View>
);
}
getContent() {
if (this.props.isSquare) {
return (
<View>
<View style={{marginLeft: 'auto', marginRight: 'auto'}}>
{this.getIcon()}
</View>
{this.getText()}
</View>
);
}
}
render() { render() {
// console.log("rendering DashboardItem " + this.props.title); // console.log("rendering DashboardItem " + this.props.title);
let marginRight = 10; let marginRight = 10;
@ -173,17 +211,28 @@ export default class DashboardItem extends React.Component<Props> {
overflow: 'hidden', overflow: 'hidden',
}} }}
onPress={this.props.clickAction}> onPress={this.props.clickAction}>
{this.props.isSquare ?
<Card.Content>
{this.getContent()}
</Card.Content>
:
<View>
<Card.Title <Card.Title
title={this.props.title} title={this.props.title}
titleStyle={{color: color}} titleStyle={{color: color}}
subtitle={this.props.subtitle} subtitle={this.props.subtitle}
subtitleStyle={{color: color}} subtitleStyle={{color: color}}
left={this.getIcon} left={(props) => <Avatar.Icon
{...props}
icon={this.props.icon}
color={this.props.isAvailable ? this.props.color : ThemeManager.getCurrentThemeVariables().textDisabled}
size={60}
style={{backgroundColor: 'transparent'}}/>}
/> />
<Card.Content> <Card.Content>
{this.getEventPreviewContainer()} {this.getEventPreviewContainer()}
</Card.Content> </Card.Content>
</View>}
</Card> </Card>
); );
} }

View file

@ -6,13 +6,6 @@ import i18n from "i18n-js";
const ICON_AMICALE = require('../assets/amicale.png'); const ICON_AMICALE = require('../assets/amicale.png');
function getAvatar() {
return (
<Avatar.Image size={48} source={ICON_AMICALE}
style={{backgroundColor: 'transparent'}}/>
);
}
function FeedItem(props) { function FeedItem(props) {
const {colors} = props.theme; const {colors} = props.theme;
return ( return (
@ -20,7 +13,8 @@ function FeedItem(props) {
<Card.Title <Card.Title
title={props.title} title={props.title}
subtitle={props.subtitle} subtitle={props.subtitle}
left={getAvatar} left={props => <Avatar.Image size={48} source={ICON_AMICALE}
style={{backgroundColor: 'transparent'}}/>}
/> />
{props.full_picture !== '' && props.full_picture !== undefined ? {props.full_picture !== '' && props.full_picture !== undefined ?
<TouchableOpacity onPress={props.onImagePress}> <TouchableOpacity onPress={props.onImagePress}>