@@ -5,13 +5,8 @@ import { Query } from 'react-apollo';
55
66import { device , normalize } from '../config' ;
77import { CardList , Image , TextList , Title , TitleContainer , TitleShadow } from '../components' ;
8- import {
9- GET_EVENT_RECORDS ,
10- GET_NEWS_ITEMS ,
11- GET_POINTS_OF_INTEREST ,
12- GET_PUBLIC_JSON_FILE
13- } from '../queries' ;
14- import { momentFormat } from '../helpers' ;
8+ import { getQuery } from '../queries' ;
9+ import { momentFormat , shareMessage } from '../helpers' ;
1510
1611export const HomeScreen = ( { navigation } ) => (
1712 < ScrollView >
@@ -20,7 +15,7 @@ export const HomeScreen = ({ navigation }) => (
2015 < Title > { 'Nachrichten' . toUpperCase ( ) } </ Title >
2116 </ TitleContainer >
2217 { device . platform === 'ios' && < TitleShadow /> }
23- < Query query = { GET_NEWS_ITEMS } variables = { { limit : 3 } } fetchPolicy = "cache-and-network" >
18+ < Query query = { getQuery ( 'newsItems' ) } variables = { { limit : 3 } } fetchPolicy = "cache-and-network" >
2419 { ( { data, loading } ) => {
2520 if ( loading ) {
2621 return (
@@ -43,7 +38,10 @@ export const HomeScreen = ({ navigation }) => (
4338 title : 'Nachricht' ,
4439 query : 'newsItem' ,
4540 queryVariables : { id : `${ newsItem . id } ` } ,
46- rootRouteName : 'NewsItems'
41+ rootRouteName : 'NewsItems' ,
42+ shareContent : {
43+ message : shareMessage ( newsItem , 'newsItem' )
44+ }
4745 } ,
4846 __typename : newsItem . __typename
4947 } ) ) ;
@@ -72,7 +70,11 @@ export const HomeScreen = ({ navigation }) => (
7270 < Title > { 'Orte & Routen' . toUpperCase ( ) } </ Title >
7371 </ TitleContainer >
7472 { device . platform === 'ios' && < TitleShadow /> }
75- < Query query = { GET_POINTS_OF_INTEREST } variables = { { limit : 3 } } fetchPolicy = "cache-and-network" >
73+ < Query
74+ query = { getQuery ( 'pointsOfInterest' ) }
75+ variables = { { limit : 3 } }
76+ fetchPolicy = "cache-and-network"
77+ >
7678 { ( { data, loading } ) => {
7779 if ( loading ) {
7880 return (
@@ -95,12 +97,15 @@ export const HomeScreen = ({ navigation }) => (
9597 title : 'Ort' ,
9698 query : 'pointOfInterest' ,
9799 queryVariables : { id : `${ pointOfInterest . id } ` } ,
98- rootRouteName : 'PointsOfInterest'
100+ rootRouteName : 'PointsOfInterest' ,
101+ shareContent : {
102+ message : shareMessage ( pointOfInterest , 'pointOfInterest' )
103+ }
99104 } ,
100105 __typename : pointOfInterest . __typename
101106 } ) ) ;
102107
103- if ( ! pointsOfInterest . length ) return null ;
108+ if ( ! pointsOfInterest || ! pointsOfInterest . length ) return null ;
104109
105110 return (
106111 < View >
@@ -131,7 +136,11 @@ export const HomeScreen = ({ navigation }) => (
131136 < Title > { 'Veranstaltungen' . toUpperCase ( ) } </ Title >
132137 </ TitleContainer >
133138 { device . platform === 'ios' && < TitleShadow /> }
134- < Query query = { GET_EVENT_RECORDS } variables = { { limit : 3 } } fetchPolicy = "cache-and-network" >
139+ < Query
140+ query = { getQuery ( 'eventRecords' ) }
141+ variables = { { limit : 3 } }
142+ fetchPolicy = "cache-and-network"
143+ >
135144 { ( { data, loading } ) => {
136145 if ( loading ) {
137146 return (
@@ -154,7 +163,10 @@ export const HomeScreen = ({ navigation }) => (
154163 title : 'Veranstaltung' ,
155164 query : 'eventRecord' ,
156165 queryVariables : { id : `${ eventRecord . id } ` } ,
157- rootRouteName : 'EventRecords'
166+ rootRouteName : 'EventRecords' ,
167+ shareContent : {
168+ message : shareMessage ( eventRecord , 'eventRecord' )
169+ }
158170 } ,
159171 __typename : eventRecord . __typename
160172 } ) ) ;
@@ -184,7 +196,7 @@ export const HomeScreen = ({ navigation }) => (
184196 </ TitleContainer >
185197 { device . platform === 'ios' && < TitleShadow /> }
186198 < Query
187- query = { GET_PUBLIC_JSON_FILE }
199+ query = { getQuery ( 'publicJsonFile' ) }
188200 variables = { { name : 'homeRoutes' } }
189201 fetchPolicy = "cache-and-network"
190202 >
0 commit comments