Added contact link

Cette révision appartient à :
Arnaud Vergnet 2020-04-23 08:39:07 +02:00
Parent b7d6c98025
révision c4337b13cb
4 fichiers modifiés avec 95 ajouts et 55 suppressions

Voir le fichier

@ -2,22 +2,35 @@
import * as React from 'react';
import {ScrollView, View} from 'react-native';
import {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
import {Avatar, Button, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
import ImageModal from 'react-native-image-modal';
import i18n from "i18n-js";
import AuthenticatedScreen from "../../../components/Amicale/AuthenticatedScreen";
import CustomHTML from "../../../components/Overrides/CustomHTML";
import CustomTabBar from "../../../components/Tabbar/CustomTabBar";
import type {category, club} from "./ClubListScreen";
import type {CustomTheme} from "../../../managers/ThemeManager";
import {StackNavigationProp} from "@react-navigation/stack";
import {Linking} from "expo";
type Props = {
navigation: Object,
route: Object
navigation: StackNavigationProp,
route: {
params?: {
data?: club,
categories?: Array<category>,
clubId?: number,
}, ...
},
theme: CustomTheme
};
type State = {
imageModalVisible: boolean,
};
const AMICALE_MAIL = "clubs@amicale-insat.fr";
/**
* Class defining a club event information page.
* If called with data and categories navigation parameters, will use those to display the data.
@ -25,34 +38,32 @@ type State = {
*/
class ClubDisplayScreen extends React.Component<Props, State> {
displayData: Object;
categories: Object | null;
displayData: club | null;
categories: Array<category> | null;
clubId: number;
shouldFetchData: boolean;
colors: Object;
state = {
imageModalVisible: false,
};
constructor(props) {
super(props);
this.colors = props.theme.colors;
if (this.props.route.params.data !== undefined && this.props.route.params.categories !== undefined) {
if (this.props.route.params != null) {
if (this.props.route.params.data != null && this.props.route.params.categories != null) {
this.displayData = this.props.route.params.data;
this.categories = this.props.route.params.categories;
this.clubId = this.props.route.params.data.id;
this.shouldFetchData = false;
} else {
} else if (this.props.route.params.clubId != null) {
this.displayData = null;
this.categories = null;
this.clubId = this.props.route.params.clubId;
this.shouldFetchData = true;
}
}
}
getCategoryName(id: number) {
if (this.categories !== null) {
@ -64,7 +75,7 @@ class ClubDisplayScreen extends React.Component<Props, State> {
return "";
}
getCategoriesRender(categories: Array<number | null>) {
getCategoriesRender(categories: [number, number]) {
if (this.categories === null)
return null;
@ -84,7 +95,7 @@ class ClubDisplayScreen extends React.Component<Props, State> {
return <View style={{flexDirection: 'row', marginTop: 5}}>{final}</View>;
}
getManagersRender(resp: Array<string>) {
getManagersRender(resp: Array<string>, email: string | null) {
let final = [];
for (let i = 0; i < resp.length; i++) {
final.push(<Paragraph key={i.toString()}>{resp[i]}</Paragraph>)
@ -98,24 +109,46 @@ class ClubDisplayScreen extends React.Component<Props, State> {
left={(props) => <Avatar.Icon
{...props}
style={{backgroundColor: 'transparent'}}
color={hasManagers ? this.colors.success : this.colors.primary}
color={hasManagers ? this.props.theme.colors.success : this.props.theme.colors.primary}
icon="account-tie"/>}
/>
<Card.Content>
{final}
{this.getEmailButton(email, hasManagers)}
</Card.Content>
</Card>
);
}
getEmailButton(email: string | null, hasManagers: boolean) {
const destinationEmail = email != null && hasManagers
? email
: AMICALE_MAIL;
const text = email != null && hasManagers
? i18n.t("clubs.clubContact")
: i18n.t("clubs.amicaleContact");
return (
<Card.Actions>
<Button
icon="email"
mode="contained"
onPress={() => Linking.openURL('mailto:' + destinationEmail)}
style={{marginLeft: 'auto'}}
>
{text}
</Button>
</Card.Actions>
);
}
updateHeaderTitle(data: Object) {
this.props.navigation.setOptions({title: data.name})
}
getScreen = (response: Array<Object>) => {
let data = response[0];
let data: club = response[0];
this.updateHeaderTitle(data);
if (data != null) {
return (
<ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
{this.getCategoriesRender(data.category)}
@ -128,7 +161,7 @@ class ClubDisplayScreen extends React.Component<Props, State> {
}}>
<ImageModal
resizeMode="contain"
imageBackgroundColor={this.colors.background}
imageBackgroundColor={this.props.theme.colors.background}
style={{
width: 300,
height: 300,
@ -145,9 +178,12 @@ class ClubDisplayScreen extends React.Component<Props, State> {
<CustomHTML html={data.description}/>
</Card.Content>
: <View/>}
{this.getManagersRender(data.responsibles)}
{this.getManagersRender(data.responsibles, data.email)}
</ScrollView>
);
} else
return null;
};
render() {

Voir le fichier

@ -24,7 +24,7 @@ export type club = {
name: string,
description: string,
logo: string,
email:string,
email: string | null,
category: [number, number],
responsibles: Array<string>,
};

Voir le fichier

@ -261,6 +261,8 @@
"managersUnavailable": "This club has no one :(",
"categories": "Categories",
"categoriesFilterMessage": "Click on a category to filter the list",
"clubContact": "Contact the club",
"amicaleContact": "Contact the Amicale",
"about": {
"text": "The clubs, making the campus live, with more than sixty clubs offering various activities! From the philosophy club to the PABI (Production Artisanale de Bière Insaienne), without forgetting the multiple music and dance clubs, you will surely find an activity that suits you!",
"title": "A question ?",

Voir le fichier

@ -261,6 +261,8 @@
"managersUnavailable": "Ce club est tout seul :(",
"categories": "Catégories",
"categoriesFilterMessage": "Cliquez sur une catégorie pour filtrer la liste",
"clubContact": "Contacter le club",
"amicaleContact": "Contacter l'Amicale",
"about": {
"text": "Les clubs, c'est ce qui fait vivre le campus au quotidien, plus d'une soixantaine de clubs qui proposent des activités diverses et variées ! Du club Philosophie au PABI (Production Artisanale de Bière Insaienne), en passant par les multiples clubs de musique et de danse, vous trouverez forcément une activité qui vous permettra de vous épanouir sur le campus !",
"title": "Une question ?",