diff --git a/src/components/Home/ActionsDashboardItem.js b/src/components/Home/ActionsDashboardItem.js index 2540849..8966488 100644 --- a/src/components/Home/ActionsDashboardItem.js +++ b/src/components/Home/ActionsDashboardItem.js @@ -21,7 +21,6 @@ class ActionsDashBoardItem extends React.Component { gotToSettings = () => this.props.navigation.navigate("settings"); render() { - console.log('render action dashboard'); return ( { ); } + onPress = () => { + this.props.navigation.navigate('feed-information', + { + data: this.props.item, + date: this.props.subtitle + }) + }; + render() { - console.log('render feed'); + const item = this.props.item; + const hasImage = item.full_picture !== '' && item.full_picture !== undefined; + + const cardMargin = 10; + const cardHeight = this.props.height - 2 * cardMargin; + const imageSize = 250; + const titleHeight = 80; + const actionsHeight = 48; + const textHeight = hasImage + ? cardHeight - titleHeight - actionsHeight - imageSize + : cardHeight - titleHeight - actionsHeight; return ( - + - {this.props.full_picture !== '' && this.props.full_picture !== undefined ? + {hasImage ? : } + /> : null} - {this.props.message !== undefined ? + {item.message !== undefined ? : + style={{height: textHeight}} + /> : null } - + diff --git a/src/components/Lists/WebSectionList.js b/src/components/Lists/WebSectionList.js index ce6249e..04cb1e5 100644 --- a/src/components/Lists/WebSectionList.js +++ b/src/components/Lists/WebSectionList.js @@ -164,7 +164,11 @@ export default class WebSectionList extends React.PureComponent { */ hideSnackBar = () => this.setState({snackbarVisible: false}); - itemLayout = (data, index) => ({length: this.props.itemHeight, offset: this.props.itemHeight * index, index}); + itemLayout = (data: Object, index: number) => ({ + length: this.props.itemHeight, + offset: this.props.itemHeight * index, + index + }); render() { let dataset = []; @@ -197,6 +201,7 @@ export default class WebSectionList extends React.PureComponent { errorCode={ERROR_TYPE.CONNECTION_ERROR} onRefresh={this.onRefresh}/> } + removeClippedSubviews={true} getItemLayout={this.props.itemHeight !== null ? this.itemLayout : undefined} /> { onDismiss={this.hideSnackBar} action={{ label: 'OK', - onPress: () => {}, + onPress: () => { + }, }} duration={4000} > diff --git a/src/navigation/MainTabNavigator.js b/src/navigation/MainTabNavigator.js index 358e890..d1002be 100644 --- a/src/navigation/MainTabNavigator.js +++ b/src/navigation/MainTabNavigator.js @@ -18,6 +18,7 @@ import i18n from "i18n-js"; import ClubDisplayScreen from "../screens/Amicale/Clubs/ClubDisplayScreen"; import ScannerScreen from "../screens/ScannerScreen"; import MaterialHeaderButtons, {Item} from "../components/Custom/HeaderButton"; +import FeedItemScreen from "../screens/FeedItemScreen"; const TAB_ICONS = { @@ -188,6 +189,16 @@ function HomeStackComponent(initialRoute: string | null, defaultData: Object) { }; }} /> + { + return { + title: 'FEEEEED', + ...TransitionPresets.ModalSlideFromBottomIOS, + }; + }} + /> { + + displayData: Object; + date: string; + + colors: Object; + + constructor(props) { + super(props); + this.colors = props.theme.colors; + this.displayData = this.props.route.params.data; + this.date = this.props.route.params.date; + } + + componentDidMount() { + this.props.navigation.setOptions({ + headerRight: this.getHeaderButton, + }); + } + + onOutLinkPress = () => { + Linking.openURL(this.displayData.permalink_url); + }; + + getHeaderButton = () => { + return + + ; + }; + + getAvatar() { + return ( + + ); + } + + getContent() { + const hasImage = this.displayData.full_picture !== '' && this.displayData.full_picture !== undefined; + return ( + + + {hasImage ? + + : null} + + {this.displayData.message !== undefined ? + : null + } + + + ); + } + + render() { + return this.getContent(); + } +} + +export default withTheme(FeedItemScreen); diff --git a/src/screens/HomeScreen.js b/src/screens/HomeScreen.js index 1fe73aa..73f7546 100644 --- a/src/screens/HomeScreen.js +++ b/src/screens/HomeScreen.js @@ -14,12 +14,12 @@ import ActionsDashBoardItem from "../components/Home/ActionsDashboardItem"; import ConnectionManager from "../managers/ConnectionManager"; import {CommonActions} from '@react-navigation/native'; import MaterialHeaderButtons, {Item} from "../components/Custom/HeaderButton"; -import {Linking} from "expo"; // import DATA from "../dashboard_data.json"; const NAME_AMICALE = 'Amicale INSA Toulouse'; const DATA_URL = "https://etud.insa-toulouse.fr/~amicale_app/dashboard/dashboard_data.json"; +const FEED_ITEM_HEIGHT = 500; const SECTIONS_ID = [ 'dashboard', @@ -415,14 +415,13 @@ class HomeScreen extends React.Component { * @return {*} */ getFeedItem(item: Object) { - const onOutLinkPress = () => Linking.openURL(item.permalink_url); return ( ); } @@ -452,7 +451,9 @@ class HomeScreen extends React.Component { autoRefreshTime={REFRESH_TIME} refreshOnFocus={true} fetchUrl={DATA_URL} - renderItem={this.getRenderItem}/> + renderItem={this.getRenderItem} + itemHeight={FEED_ITEM_HEIGHT} + />