|
@@ -7,7 +7,7 @@ import ThemeManager from "../utils/ThemeManager";
|
7
|
7
|
import HTML from "react-native-render-html";
|
8
|
8
|
import {LinearGradient} from "expo-linear-gradient";
|
9
|
9
|
import i18n from "i18n-js";
|
10
|
|
-import {Avatar, Card, Text, Title} from 'react-native-paper';
|
|
10
|
+import {Avatar, Card, Text} from 'react-native-paper';
|
11
|
11
|
|
12
|
12
|
type Props = {
|
13
|
13
|
isAvailable: boolean,
|
|
@@ -28,6 +28,13 @@ export default class DashboardItem extends React.Component<Props> {
|
28
|
28
|
displayEvent: undefined,
|
29
|
29
|
};
|
30
|
30
|
|
|
31
|
+ getIcon: Function;
|
|
32
|
+
|
|
33
|
+ constructor() {
|
|
34
|
+ super();
|
|
35
|
+ this.getIcon = this.getIcon.bind(this);
|
|
36
|
+ }
|
|
37
|
+
|
31
|
38
|
/**
|
32
|
39
|
* Convert the date string given by in the event list json to a date object
|
33
|
40
|
* @param dateString
|
|
@@ -64,18 +71,17 @@ export default class DashboardItem extends React.Component<Props> {
|
64
|
71
|
getEventPreviewContainer() {
|
65
|
72
|
if (this.props.displayEvent !== undefined && this.props.displayEvent !== null) {
|
66
|
73
|
const hasImage = this.props.displayEvent['logo'] !== '' && this.props.displayEvent['logo'] !== null;
|
|
74
|
+ const getImage = () => <Avatar.Image
|
|
75
|
+ source={{uri: this.props.displayEvent['logo']}}
|
|
76
|
+ size={60}
|
|
77
|
+ style={{backgroundColor: 'transparent'}}/>;
|
67
|
78
|
return (
|
68
|
79
|
<Card style={{marginBottom: 10}}>
|
69
|
80
|
{hasImage ?
|
70
|
81
|
<Card.Title
|
71
|
82
|
title={this.props.displayEvent['title']}
|
72
|
83
|
subtitle={this.getFormattedEventTime(this.props.displayEvent)}
|
73
|
|
- left={() =>
|
74
|
|
- <Avatar.Image
|
75
|
|
- source={{uri: this.props.displayEvent['logo']}}
|
76
|
|
- size={60}
|
77
|
|
- style={{backgroundColor: 'transparent'}}/>
|
78
|
|
- }
|
|
84
|
+ left={getImage}
|
79
|
85
|
/> :
|
80
|
86
|
<Card.Title
|
81
|
87
|
title={this.props.displayEvent['title']}
|
|
@@ -137,58 +143,14 @@ export default class DashboardItem extends React.Component<Props> {
|
137
|
143
|
|
138
|
144
|
getIcon() {
|
139
|
145
|
return (
|
140
|
|
- <MaterialCommunityIcons
|
141
|
|
- name={this.props.icon}
|
142
|
|
- color={
|
143
|
|
- this.props.isAvailable ?
|
144
|
|
- this.props.color :
|
145
|
|
- ThemeManager.getCurrentThemeVariables().textDisabled
|
146
|
|
- }
|
147
|
|
- size={this.props.isSquare ? 50 : 40}/>
|
148
|
|
- );
|
149
|
|
- }
|
150
|
|
-
|
151
|
|
- getText() {
|
152
|
|
- return (
|
153
|
|
- <View style={{
|
154
|
|
- width: this.props.isSquare ? '100%' : 'auto',
|
155
|
|
- }}>
|
156
|
|
- <Title style={{
|
157
|
|
- color: this.props.isAvailable ?
|
158
|
|
- ThemeManager.getCurrentThemeVariables().text :
|
159
|
|
- ThemeManager.getCurrentThemeVariables().textDisabled,
|
160
|
|
- textAlign: this.props.isSquare ? 'center' : 'left',
|
161
|
|
- width: this.props.isSquare ? '100%' : 'auto',
|
162
|
|
- }}>
|
163
|
|
- {this.props.title}
|
164
|
|
- </Title>
|
165
|
|
- <Text style={{
|
166
|
|
- color: this.props.isAvailable ?
|
167
|
|
- ThemeManager.getCurrentThemeVariables().text :
|
168
|
|
- ThemeManager.getCurrentThemeVariables().textDisabled,
|
169
|
|
- textAlign: this.props.isSquare ? 'center' : 'left',
|
170
|
|
- width: this.props.isSquare ? '100%' : 'auto',
|
171
|
|
- }}>
|
172
|
|
- {this.props.subtitle}
|
173
|
|
- </Text>
|
174
|
|
- </View>
|
|
146
|
+ <Avatar.Icon
|
|
147
|
+ icon={this.props.icon}
|
|
148
|
+ color={this.props.isAvailable ? this.props.color : ThemeManager.getCurrentThemeVariables().textDisabled}
|
|
149
|
+ size={60}
|
|
150
|
+ style={{backgroundColor: 'transparent'}}/>
|
175
|
151
|
);
|
176
|
152
|
}
|
177
|
153
|
|
178
|
|
- getContent() {
|
179
|
|
- if (this.props.isSquare) {
|
180
|
|
- return (
|
181
|
|
- <View>
|
182
|
|
- <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
|
183
|
|
- {this.getIcon()}
|
184
|
|
- </View>
|
185
|
|
- {this.getText()}
|
186
|
|
- </View>
|
187
|
|
- );
|
188
|
|
- }
|
189
|
|
- }
|
190
|
|
-
|
191
|
|
-
|
192
|
154
|
render() {
|
193
|
155
|
// console.log("rendering DashboardItem " + this.props.title);
|
194
|
156
|
let marginRight = 10;
|
|
@@ -211,28 +173,17 @@ export default class DashboardItem extends React.Component<Props> {
|
211
|
173
|
overflow: 'hidden',
|
212
|
174
|
}}
|
213
|
175
|
onPress={this.props.clickAction}>
|
214
|
|
- {this.props.isSquare ?
|
215
|
|
- <Card.Content>
|
216
|
|
- {this.getContent()}
|
217
|
|
- </Card.Content>
|
218
|
|
- :
|
219
|
|
- <View>
|
220
|
|
- <Card.Title
|
221
|
|
- title={this.props.title}
|
222
|
|
- titleStyle={{color: color}}
|
223
|
|
- subtitle={this.props.subtitle}
|
224
|
|
- subtitleStyle={{color: color}}
|
225
|
|
- left={(props) => <Avatar.Icon
|
226
|
|
- {...props}
|
227
|
|
- icon={this.props.icon}
|
228
|
|
- color={this.props.isAvailable ? this.props.color : ThemeManager.getCurrentThemeVariables().textDisabled}
|
229
|
|
- size={60}
|
230
|
|
- style={{backgroundColor: 'transparent'}}/>}
|
231
|
|
- />
|
232
|
|
- <Card.Content>
|
233
|
|
- {this.getEventPreviewContainer()}
|
234
|
|
- </Card.Content>
|
235
|
|
- </View>}
|
|
176
|
+
|
|
177
|
+ <Card.Title
|
|
178
|
+ title={this.props.title}
|
|
179
|
+ titleStyle={{color: color}}
|
|
180
|
+ subtitle={this.props.subtitle}
|
|
181
|
+ subtitleStyle={{color: color}}
|
|
182
|
+ left={this.getIcon}
|
|
183
|
+ />
|
|
184
|
+ <Card.Content>
|
|
185
|
+ {this.getEventPreviewContainer()}
|
|
186
|
+ </Card.Content>
|
236
|
187
|
</Card>
|
237
|
188
|
);
|
238
|
189
|
}
|