@quintype/native-components 2.28.5-beta.2 → 2.29.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin-dev-scripts/standard-version-release.sh +11 -11
- package/package.json +2 -2
- package/src/components/AudioPlayer/index.js +7 -5
- package/src/components/AudioPlayer/styles.js +22 -13
- package/src/components/CollectionCard/index.js +0 -3
- package/src/components/JSEmbedElement/index.js +4 -3
- package/src/components/LightBox/index.js +2 -2
- package/src/components/LightBoxImage/index.js +3 -2
- package/src/components/PrimaryStoryCard/index.js +4 -4
- package/src/components/RelatedStoriesCard/index.js +1 -2
- package/src/components/ResponsiveImage/index.js +4 -4
- package/src/components/SecondaryStoryCard/index.js +4 -3
- package/src/components/SlideshowStoryCard/index.js +4 -4
- package/src/components/SlideshowStoryCard/styles.js +3 -5
- package/src/components/StoryGallery/index.js +3 -1
- package/src/components/StoryGallery/styles.js +3 -3
- package/src/components/StoryHeader/index.js +4 -3
- package/src/components/StoryImage/index.js +5 -4
- package/src/components/StoryImage/styles.js +2 -2
- package/src/components/StorySlideshow/index.js +3 -2
- package/src/components/StorySlideshow/styles.js +4 -6
- package/src/components/YouTubePlayer/index.js +2 -2
- package/src/components/index.js +3 -3
- package/src/utils/imageUtils.js +5 -34
- package/src/utils/screenUtils.js +0 -13
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
#!/bin/bash -e
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
npm install
|
|
4
|
+
git diff --quiet
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
BRANCH=$(git symbolic-ref --short HEAD)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
if [ "$BRANCH" == 'master' ]
|
|
9
|
+
then
|
|
10
|
+
npx standard-version
|
|
11
|
+
else
|
|
12
|
+
npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
|
|
13
|
+
fi
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
git push --follow-tags origin "$BRANCH"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/native-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"react-native-linear-gradient": "^2.8.3",
|
|
37
37
|
"react-native-pdf": ">=6.7.4",
|
|
38
38
|
"react-native-vector-icons": "^10.0.0",
|
|
39
|
+
"react-native-device-info": "^11.1.0",
|
|
39
40
|
"react-native-webview": ">=11.0.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
"metro-react-native-babel-preset": "^0.62.0",
|
|
57
58
|
"react": "18.2.0",
|
|
58
59
|
"react-native": "0.71.17",
|
|
59
|
-
"react-native-device-info": "^5.6.5",
|
|
60
60
|
"react-native-svg": "^12.3.0",
|
|
61
61
|
"react-navigation-hooks": "^1.1.0",
|
|
62
62
|
"react-test-renderer": "16.13.1"
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { useProgress, usePlaybackState, State } from "react-native-track-player";
|
|
4
|
-
import { TouchableOpacity, ActivityIndicator, View, ViewPropTypes } from "react-native";
|
|
4
|
+
import { TouchableOpacity, ActivityIndicator, View, ViewPropTypes, useWindowDimensions } from "react-native";
|
|
5
5
|
import Icon from "react-native-vector-icons/AntDesign";
|
|
6
6
|
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
|
|
7
7
|
import { playerStyles } from "./styles";
|
|
8
8
|
import Slider from "@react-native-community/slider";
|
|
9
9
|
import { AppTheme } from "../../utils";
|
|
10
10
|
import { useContext } from "react";
|
|
11
|
-
import {ResponsiveHeight, ResponsiveWidth} from '../../utils/screenUtils'
|
|
12
11
|
import { Text } from '../index';
|
|
13
12
|
|
|
14
13
|
const ProgressBar = (props) => {
|
|
14
|
+
const screenDimensions = useWindowDimensions();
|
|
15
15
|
const progress = useProgress();
|
|
16
16
|
const { theme } = useContext(AppTheme);
|
|
17
17
|
const { COLORS} = theme;
|
|
18
|
-
const {progressCompleted, progressBar } = playerStyles();
|
|
18
|
+
const {progressCompleted, progressBar } = playerStyles(screenDimensions);
|
|
19
19
|
const stylesWithFlexValue = (flex, styles) => ({ flex: flex, ...styles });
|
|
20
20
|
|
|
21
21
|
return (
|
|
@@ -36,7 +36,8 @@ const ProgressBar = (props) => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export const ControlButton = ({ iconName, onPress, FONT_SIZE }) => {
|
|
39
|
-
const
|
|
39
|
+
const screenDimensions = useWindowDimensions();
|
|
40
|
+
const { controlButtonContainer, controlButton } = playerStyles(screenDimensions);
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<TouchableOpacity style={controlButtonContainer} onPress={onPress} >
|
|
@@ -46,9 +47,10 @@ export const ControlButton = ({ iconName, onPress, FONT_SIZE }) => {
|
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
const PlayerBase = (props) => {
|
|
50
|
+
const screenDimensions = useWindowDimensions();
|
|
49
51
|
const { theme } = useContext(AppTheme);
|
|
50
52
|
const { COLORS,translate, FONT_SIZE, DARK_MODE } = theme;
|
|
51
|
-
const { card, container, subContainer, playerControlStyle, playbackSpeedText, playerContainer } = playerStyles();
|
|
53
|
+
const { card, container, subContainer, playerControlStyle, playbackSpeedText, playerContainer } = playerStyles(screenDimensions);
|
|
52
54
|
const { style, onTogglePlayback, testID, seekTo, rewindOrForward, isFinishedPlaying, restart, closeButtonHandler } = props;
|
|
53
55
|
|
|
54
56
|
const playbackState = usePlaybackState();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { AppTheme } from "../../utils";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
|
|
5
|
-
export const playerStyles = () => {
|
|
4
|
+
|
|
5
|
+
export const playerStyles = (screenDimensions) => {
|
|
6
6
|
const { theme } = useContext(AppTheme);
|
|
7
|
-
const { COLORS, DARK_MODE,FONT_SIZE } = theme;
|
|
7
|
+
const { COLORS, DARK_MODE, FONT_SIZE } = theme;
|
|
8
8
|
|
|
9
9
|
return StyleSheet.create({
|
|
10
|
-
container:{
|
|
10
|
+
container: {
|
|
11
11
|
display: "flex",
|
|
12
12
|
flexDirection: "row",
|
|
13
13
|
justifyContent: "space-between",
|
|
@@ -16,15 +16,15 @@ export const playerStyles = () => {
|
|
|
16
16
|
marginTop: 15,
|
|
17
17
|
marginBottom: 16,
|
|
18
18
|
},
|
|
19
|
-
subContainer:{
|
|
19
|
+
subContainer: {
|
|
20
20
|
fontSize: FONT_SIZE.h2,
|
|
21
21
|
color: COLORS.BRAND_BLACK,
|
|
22
22
|
},
|
|
23
|
-
playerControlStyle:{ display: "flex", flexDirection: "row", alignItems: "center" },
|
|
24
|
-
playbackSpeedText:{
|
|
23
|
+
playerControlStyle: { display: "flex", flexDirection: "row", alignItems: "center" },
|
|
24
|
+
playbackSpeedText: {
|
|
25
25
|
backgroundColor: COLORS.MONO5,
|
|
26
|
-
minWidth:
|
|
27
|
-
height:
|
|
26
|
+
minWidth: screenDimensions.width * .013,
|
|
27
|
+
height: screenDimensions.height * .003,
|
|
28
28
|
borderRadius: 5,
|
|
29
29
|
alignItems: "center",
|
|
30
30
|
justifyContent: "center",
|
|
@@ -45,10 +45,16 @@ export const playerStyles = () => {
|
|
|
45
45
|
display: "flex",
|
|
46
46
|
flexDirection: "row",
|
|
47
47
|
alignItems: "center",
|
|
48
|
-
marginHorizontal:
|
|
49
|
-
borderRadius:5
|
|
48
|
+
marginHorizontal: screenDimensions.width * .0025,
|
|
49
|
+
borderRadius: 5,
|
|
50
|
+
},
|
|
51
|
+
playerContainer: {
|
|
52
|
+
width: screenDimensions.width * .012,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
justifyContent: 'center',
|
|
50
57
|
},
|
|
51
|
-
playerContainer:{width:ResponsiveWidth(12),display:'flex', flexDirection:'row',alignItems:'center',justifyContent:'center'},
|
|
52
58
|
controlButton: {
|
|
53
59
|
alignItems: "center",
|
|
54
60
|
color: COLORS.BRAND_BLACK,
|
|
@@ -58,7 +64,10 @@ export const playerStyles = () => {
|
|
|
58
64
|
flex: 1,
|
|
59
65
|
},
|
|
60
66
|
controls: {},
|
|
61
|
-
progressBar: {
|
|
67
|
+
progressBar: {
|
|
68
|
+
width: screenDimensions.width * .070,
|
|
69
|
+
marginHorizontal: screenDimensions.width * .001,
|
|
70
|
+
},
|
|
62
71
|
progressCompleted: {
|
|
63
72
|
backgroundColor: DARK_MODE ? COLORS.MONO6 : COLORS.BRAND_WHITE,
|
|
64
73
|
},
|
|
@@ -2,7 +2,6 @@ import get from 'lodash/get';
|
|
|
2
2
|
import isEmpty from 'lodash/isEmpty';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { memo } from 'react';
|
|
5
|
-
import { getScreenPercentageWidth } from '../../utils/index';
|
|
6
5
|
import {
|
|
7
6
|
CollectionTitle,
|
|
8
7
|
PrimaryStoryCard,
|
|
@@ -42,7 +41,6 @@ const CollectionCardBase = ({
|
|
|
42
41
|
cdn={cdn}
|
|
43
42
|
story={!isEmpty(stories) ? primaryStory : {}}
|
|
44
43
|
iconComponent={<ShareButton story={primaryStory} inListingStoryCard />}
|
|
45
|
-
imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
|
|
46
44
|
horizontalPadding={horizontalPadding}
|
|
47
45
|
/>
|
|
48
46
|
{stories.slice(1, sliceLimit).map((currentStory) => {
|
|
@@ -55,7 +53,6 @@ const CollectionCardBase = ({
|
|
|
55
53
|
cdn={cdn}
|
|
56
54
|
story={secondaryStory}
|
|
57
55
|
iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
|
|
58
|
-
imageWidth={getScreenPercentageWidth(28)}
|
|
59
56
|
horizontalPadding={horizontalPadding}
|
|
60
57
|
/>
|
|
61
58
|
);
|
|
@@ -2,7 +2,7 @@ import { decode as atob } from 'base-64';
|
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useWindowDimensions, View } from 'react-native';
|
|
6
6
|
import { WebView } from 'react-native-webview';
|
|
7
7
|
import { STORY_ELEMENT_SUBTYPES } from '../../constants/cardConstants';
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ const removeWidthnHeight = (htmlContent) => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const getHTMLContent = (embedJs) => {
|
|
40
|
-
const
|
|
40
|
+
const width = useWindowDimensions().width;
|
|
41
41
|
const decodedContent = getDecodedContent(embedJs);
|
|
42
42
|
let htmlContent = replaceDefaultProtocol(decodedContent);
|
|
43
43
|
htmlContent = removeWidthnHeight(htmlContent);
|
|
@@ -77,10 +77,11 @@ const getHTMLContent = (embedJs) => {
|
|
|
77
77
|
export const JSEmbedElement = (props) => {
|
|
78
78
|
const [height, setHeight] = useState(-1);
|
|
79
79
|
const webViewRef = useRef(null);
|
|
80
|
+
const screenWidth = useWindowDimensions().width;
|
|
80
81
|
const width = get(
|
|
81
82
|
props,
|
|
82
83
|
['currentLayout', 'width'],
|
|
83
|
-
|
|
84
|
+
screenWidth,
|
|
84
85
|
);
|
|
85
86
|
|
|
86
87
|
useEffect(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
useWindowDimensions, Image, Modal, SafeAreaView, TouchableOpacity, View,
|
|
5
5
|
} from 'react-native';
|
|
6
6
|
import ImageZoom from 'react-native-image-pan-zoom';
|
|
7
7
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
@@ -13,7 +13,7 @@ export const LightBox = ({ visible, imageUri, closeModal }) => {
|
|
|
13
13
|
const { COLORS, DARK_MODE } = theme;
|
|
14
14
|
const styles = lightBoxStyles();
|
|
15
15
|
|
|
16
|
-
const { width: screenWidth, height: screenHeight } =
|
|
16
|
+
const { width: screenWidth, height: screenHeight } = useWindowDimensions();
|
|
17
17
|
const imageZoomHeight = screenHeight - 80;
|
|
18
18
|
|
|
19
19
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { TouchableOpacity, useWindowDimensions } from 'react-native';
|
|
4
4
|
import { getImageHeight } from '../../utils';
|
|
5
5
|
import { LightBox } from '../LightBox';
|
|
6
6
|
import { ResponsiveImage } from '../ResponsiveImage';
|
|
@@ -11,8 +11,9 @@ export const LightBoxImage = ({
|
|
|
11
11
|
const {
|
|
12
12
|
cdn, slug, metaData, imageWidth: previewWidth,
|
|
13
13
|
} = data;
|
|
14
|
+
const screenWidth = useWindowDimensions().width;
|
|
14
15
|
const { width, height } = metaData || {};
|
|
15
|
-
const imageHeight = getImageHeight(width, height);
|
|
16
|
+
const imageHeight = getImageHeight(width, height, screenWidth);
|
|
16
17
|
const imageUri = `${data?.cdn}/${data?.slug}`;
|
|
17
18
|
const [showModal, setShowModal] = useState(false);
|
|
18
19
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { get, throttle } from 'lodash';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { memo, useContext } from 'react';
|
|
4
|
-
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import { StyleSheet, TouchableOpacity, View, useWindowDimensions } from 'react-native';
|
|
5
5
|
import PremiumIcons from '../../Icons/PremiumIcons/index';
|
|
6
6
|
import {
|
|
7
7
|
COMP_GENERAL_CONSTANTS,
|
|
@@ -36,8 +36,9 @@ const PrimaryStoryCardBase = (props) => {
|
|
|
36
36
|
]);
|
|
37
37
|
|
|
38
38
|
const isPremiumStory = story['access'] === 'subscription';
|
|
39
|
-
|
|
40
39
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
40
|
+
const screenWidth = useWindowDimensions().width;
|
|
41
|
+
const imageWidth = screenWidth - 2 * props.horizontalPadding;
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
44
|
<>
|
|
@@ -51,7 +52,7 @@ const PrimaryStoryCardBase = (props) => {
|
|
|
51
52
|
metaData={getImageMetadata(story)}
|
|
52
53
|
slug={getImageSlug(story)}
|
|
53
54
|
cdn={props.cdn}
|
|
54
|
-
imageWidth={
|
|
55
|
+
imageWidth={imageWidth}
|
|
55
56
|
>
|
|
56
57
|
<View style={styles.storyTypeContainer}>
|
|
57
58
|
<StoryTemplateIcon storyTemplate={story['story-template']} cardType="primary" theme={theme} />
|
|
@@ -89,7 +90,6 @@ const PrimaryStoryCardBase = (props) => {
|
|
|
89
90
|
|
|
90
91
|
PrimaryStoryCardBase.propTypes = {
|
|
91
92
|
cdn: PropTypes.string,
|
|
92
|
-
imageWidth: PropTypes.number,
|
|
93
93
|
headlineStyle: PropTypes.func,
|
|
94
94
|
story: PropTypes.object.isRequired,
|
|
95
95
|
onPress: PropTypes.func,
|
|
@@ -2,7 +2,7 @@ import get from 'lodash/get';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
4
|
import { Text, View ,I18nManager} from 'react-native';
|
|
5
|
-
import {
|
|
5
|
+
import { AppTheme } from '../../utils/index';
|
|
6
6
|
import { SecondaryStoryCard, ShareButton } from '../index';
|
|
7
7
|
|
|
8
8
|
import { relatedStoriesStyles } from './styles';
|
|
@@ -42,7 +42,6 @@ export const RelatedStoriesCard = ({
|
|
|
42
42
|
return <SecondaryStoryCard
|
|
43
43
|
{...storyCardProps}
|
|
44
44
|
iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
|
|
45
|
-
imageWidth={getScreenPercentageWidth(28)}
|
|
46
45
|
horizontalPadding={4}
|
|
47
46
|
/>
|
|
48
47
|
})}
|
|
@@ -2,17 +2,17 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React, {
|
|
3
3
|
memo, useCallback, useContext, useState,
|
|
4
4
|
} from 'react';
|
|
5
|
-
import { StyleSheet, View, ImageBackground } from 'react-native';
|
|
5
|
+
import { StyleSheet, View, ImageBackground, useWindowDimensions } from 'react-native';
|
|
6
6
|
import FastImage from 'react-native-fast-image';
|
|
7
7
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
8
8
|
import { FallbackIcon } from '../../Icons/FallBackIcon';
|
|
9
9
|
import { AppTheme } from '../../utils';
|
|
10
10
|
import {
|
|
11
11
|
getImageURL,
|
|
12
|
-
getCustomResolutionImageURL,
|
|
13
12
|
} from '../../utils/imageUtils';
|
|
14
13
|
|
|
15
14
|
const ResponsiveImageBase = (props) => {
|
|
15
|
+
const screenWidth = useWindowDimensions().width;
|
|
16
16
|
const [placeholder, setPlaceholder] = useState(true);
|
|
17
17
|
const { theme } = useContext(AppTheme);
|
|
18
18
|
const {
|
|
@@ -61,7 +61,7 @@ const ResponsiveImageBase = (props) => {
|
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
let imageUrl = getImageURL(props)
|
|
64
|
+
let imageUrl = getImageURL(props, screenWidth);
|
|
65
65
|
|
|
66
66
|
const userFallback = () => <Icon name="user" size={20} />;
|
|
67
67
|
|
|
@@ -78,7 +78,7 @@ const ResponsiveImageBase = (props) => {
|
|
|
78
78
|
const onLoadHandler = useCallback(handleImageLoad, []);
|
|
79
79
|
|
|
80
80
|
const lowestQualitySourceURI = {
|
|
81
|
-
uri: decodeURIComponent(
|
|
81
|
+
uri: decodeURIComponent(imageUrl),
|
|
82
82
|
priority: FastImage.priority.high,
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
View,
|
|
8
8
|
TextStyle,
|
|
9
9
|
TouchableOpacityProps,
|
|
10
|
+
useWindowDimensions,
|
|
10
11
|
} from 'react-native';
|
|
11
12
|
import {
|
|
12
13
|
AppTheme,
|
|
@@ -43,8 +44,9 @@ const SecondaryStoryCardBase = (props) => {
|
|
|
43
44
|
]);
|
|
44
45
|
|
|
45
46
|
const isPremiumStory = story['access'] === 'subscription';
|
|
46
|
-
|
|
47
47
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
48
|
+
const screenWidth = useWindowDimensions().width;
|
|
49
|
+
const imageWidth = screenWidth * .28;
|
|
48
50
|
|
|
49
51
|
return (
|
|
50
52
|
<>
|
|
@@ -60,7 +62,7 @@ const SecondaryStoryCardBase = (props) => {
|
|
|
60
62
|
metaData={getImageMetadata(story)}
|
|
61
63
|
slug={getImageSlug(story) || ''}
|
|
62
64
|
cdn={props.cdn || ''}
|
|
63
|
-
imageWidth={
|
|
65
|
+
imageWidth={imageWidth}
|
|
64
66
|
>
|
|
65
67
|
<View style={styles.storyTypeContainer}>
|
|
66
68
|
<StoryTemplateIcon storyTemplate={story['story-template']} theme={theme} />
|
|
@@ -98,7 +100,6 @@ const SecondaryStoryCardBase = (props) => {
|
|
|
98
100
|
|
|
99
101
|
SecondaryStoryCardBase.propTypes = TouchableOpacityProps && {
|
|
100
102
|
cdn: PropTypes.string.isRequired,
|
|
101
|
-
imageWidth: PropTypes.number,
|
|
102
103
|
headlineStyle: TextStyle,
|
|
103
104
|
story: PropTypes.any.isRequired,
|
|
104
105
|
iconComponent: PropTypes.element,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import { View } from 'react-native';
|
|
3
|
+
import { View, useWindowDimensions } from 'react-native';
|
|
4
4
|
import {
|
|
5
5
|
AppTheme,
|
|
6
|
-
getScreenPercentageWidth,
|
|
7
6
|
stripHTML,
|
|
8
7
|
} from '../../utils/index';
|
|
9
8
|
import { Text } from '../index';
|
|
@@ -14,11 +13,12 @@ export const SlideshowStoryCard = ({ card, cdn }) => {
|
|
|
14
13
|
const attribution = card['image-attribution'];
|
|
15
14
|
const { title } = card;
|
|
16
15
|
const { theme } = useContext(AppTheme);
|
|
17
|
-
const
|
|
16
|
+
const screenWidth = useWindowDimensions().width;
|
|
17
|
+
const styles = slideshowStoryCardStyles(theme, screenWidth);
|
|
18
18
|
const imgData = {
|
|
19
19
|
cdn,
|
|
20
20
|
slug: card['image-s3-key'],
|
|
21
|
-
imageWidth:
|
|
21
|
+
imageWidth: screenWidth,
|
|
22
22
|
metaData: card['image-metadata'],
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { StyleSheet
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
export const slideshowStoryCardStyles = ({ COLORS, FONT_FAMILY }) => StyleSheet.create({
|
|
3
|
+
export const slideshowStoryCardStyles = ({ COLORS, FONT_FAMILY }, screenWidth) => StyleSheet.create({
|
|
6
4
|
textContainer: {
|
|
7
5
|
paddingHorizontal: 10,
|
|
8
6
|
flexDirection: 'column',
|
|
@@ -16,7 +14,7 @@ export const slideshowStoryCardStyles = ({ COLORS, FONT_FAMILY }) => StyleSheet.
|
|
|
16
14
|
},
|
|
17
15
|
container: {
|
|
18
16
|
flexDirection: 'column',
|
|
19
|
-
width,
|
|
17
|
+
width: screenWidth,
|
|
20
18
|
},
|
|
21
19
|
attributionText: {
|
|
22
20
|
color: COLORS.BRAND_BLACK,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
FlatList,
|
|
8
8
|
TouchableOpacity,
|
|
9
9
|
ScrollView,
|
|
10
|
+
useWindowDimensions,
|
|
10
11
|
} from 'react-native';
|
|
11
12
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
12
13
|
import FastImage from 'react-native-fast-image';
|
|
@@ -18,7 +19,8 @@ import { LightBoxImage } from '../LightBoxImage';
|
|
|
18
19
|
export const StoryGallery = ({ cdn, card }) => {
|
|
19
20
|
const { theme } = useContext(AppTheme);
|
|
20
21
|
const { COLORS, DARK_MODE } = theme;
|
|
21
|
-
const
|
|
22
|
+
const screenDimensions = useWindowDimensions();
|
|
23
|
+
const galleryStyles = styles(theme, screenDimensions);
|
|
22
24
|
const storyElements = card['story-elements'];
|
|
23
25
|
const [showModal, setShowModal] = useState(false);
|
|
24
26
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { StyleSheet
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { AppTheme } from '../../utils';
|
|
4
4
|
|
|
5
|
-
export const styles = ({ FONT_SIZE }) => {
|
|
6
|
-
const { width: deviceWidth, height: deviceHeight } =
|
|
5
|
+
export const styles = ({ FONT_SIZE }, screenDimensions) => {
|
|
6
|
+
const { width: deviceWidth, height: deviceHeight } = screenDimensions;
|
|
7
7
|
const { theme } = useContext(AppTheme);
|
|
8
8
|
const { COLORS, DARK_MODE, FONT_FAMILY } = theme;
|
|
9
9
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import { TouchableOpacity, useWindowDimensions, View } from 'react-native';
|
|
5
5
|
import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/content-constants/constants';
|
|
6
6
|
import {
|
|
7
7
|
AppTheme,
|
|
8
8
|
getImageMetadata,
|
|
9
|
-
getScreenPercentageWidth,
|
|
10
9
|
getTimeInFormat
|
|
11
10
|
} from '../../utils';
|
|
12
11
|
import { STORY_TYPES } from '../../utils/story-types';
|
|
@@ -25,12 +24,14 @@ const getHeroImage = (cdn, story) => {
|
|
|
25
24
|
const imageSlug = story['hero-image-s3-key'];
|
|
26
25
|
if (!imageSlug) return null;
|
|
27
26
|
|
|
27
|
+
const screenWidth = useWindowDimensions().width;
|
|
28
|
+
|
|
28
29
|
return (
|
|
29
30
|
<ResponsiveImage
|
|
30
31
|
cdn={cdn}
|
|
31
32
|
metaData={getImageMetadata(story)}
|
|
32
33
|
slug={imageSlug}
|
|
33
|
-
imageWidth={
|
|
34
|
+
imageWidth={screenWidth}
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import { View } from 'react-native';
|
|
3
|
+
import { View, useWindowDimensions } from 'react-native';
|
|
4
4
|
import { ShareButton } from '../index';
|
|
5
|
-
import { AppTheme,
|
|
5
|
+
import { AppTheme, stripHTML } from '../../utils';
|
|
6
6
|
import { Text } from '../index';
|
|
7
7
|
import { LightBoxImage } from '../LightBoxImage';
|
|
8
8
|
import { storyImageStyles } from './styles';
|
|
@@ -13,15 +13,16 @@ export const StoryImage = ({
|
|
|
13
13
|
const slug = `?cardId=${card.id}`;
|
|
14
14
|
const sharePhotoCard = storyType === 'photo';
|
|
15
15
|
const { theme } = useContext(AppTheme);
|
|
16
|
+
const screenWidth = useWindowDimensions().width;
|
|
16
17
|
|
|
17
18
|
const imageData = {
|
|
18
19
|
cdn,
|
|
19
20
|
slug: card['image-s3-key'],
|
|
20
21
|
metaData: card['image-metadata'],
|
|
21
|
-
imageWidth:
|
|
22
|
+
imageWidth: screenWidth,
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const styles = storyImageStyles(theme, imageData.metaData);
|
|
25
|
+
const styles = storyImageStyles(theme, imageData.metaData, screenWidth);
|
|
25
26
|
|
|
26
27
|
return (
|
|
27
28
|
<>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
import { getImageHeight } from '../../utils';
|
|
3
3
|
|
|
4
|
-
export const storyImageStyles = ({ COLORS, FONT_SIZE, lineHeightMultiplier }, metadata = {}) => {
|
|
4
|
+
export const storyImageStyles = ({ COLORS, FONT_SIZE, lineHeightMultiplier }, metadata = {}, screenWidth) => {
|
|
5
5
|
const { width, height } = metadata || {};
|
|
6
|
-
const imageHeight = getImageHeight(width, height);
|
|
6
|
+
const imageHeight = getImageHeight(width, height, screenWidth);
|
|
7
7
|
|
|
8
8
|
return StyleSheet.create({
|
|
9
9
|
image: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext, useRef, useState } from 'react';
|
|
3
|
-
import { TouchableOpacity, View, FlatList } from 'react-native';
|
|
3
|
+
import { TouchableOpacity, View, FlatList, useWindowDimensions } from 'react-native';
|
|
4
4
|
import Icon from 'react-native-vector-icons/AntDesign';
|
|
5
5
|
import { AppTheme } from '../../utils';
|
|
6
6
|
import { SlideshowStoryCard } from '../SlideshowStoryCard';
|
|
@@ -9,7 +9,8 @@ import { storySlideshowStyles } from './styles';
|
|
|
9
9
|
export const StorySlideshow = ({ card, cdn }) => {
|
|
10
10
|
const { theme } = useContext(AppTheme);
|
|
11
11
|
const { COLORS } = theme;
|
|
12
|
-
const
|
|
12
|
+
const screenWidth = useWindowDimensions().width;
|
|
13
|
+
const styles = storySlideshowStyles(theme, screenWidth);
|
|
13
14
|
const [currentIndex, setCurrentTabIndex] = useState(0);
|
|
14
15
|
|
|
15
16
|
const flatlistRef = useRef();
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { StyleSheet
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
export const storySlideshowStyles = ({ COLORS }) => StyleSheet.create({
|
|
3
|
+
export const storySlideshowStyles = ({ COLORS }, screenWidth) => StyleSheet.create({
|
|
6
4
|
cardsContainer: {
|
|
7
5
|
marginTop: 10,
|
|
8
6
|
position: 'relative',
|
|
@@ -10,7 +8,7 @@ export const storySlideshowStyles = ({ COLORS }) => StyleSheet.create({
|
|
|
10
8
|
leftArrow: {
|
|
11
9
|
position: 'absolute',
|
|
12
10
|
marginTop: -20,
|
|
13
|
-
top:
|
|
11
|
+
top: screenWidth * 0.28125, // screenWidth * 9/16 / 2
|
|
14
12
|
left: 0,
|
|
15
13
|
zIndex: 999,
|
|
16
14
|
width: 40,
|
|
@@ -23,7 +21,7 @@ export const storySlideshowStyles = ({ COLORS }) => StyleSheet.create({
|
|
|
23
21
|
rightArrow: {
|
|
24
22
|
position: 'absolute',
|
|
25
23
|
marginTop: -20,
|
|
26
|
-
top:
|
|
24
|
+
top: screenWidth * 0.28125, // screenWidth * 9/16 / 2
|
|
27
25
|
right: 0,
|
|
28
26
|
zIndex: 999,
|
|
29
27
|
width: 40,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import PropTypes from "prop-types";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { View,
|
|
3
|
+
import { View, useWindowDimensions } from "react-native";
|
|
4
4
|
import { WebView } from "react-native-webview";
|
|
5
5
|
|
|
6
6
|
export const YouTubePlayer = ({ card = {} }) => {
|
|
7
7
|
const ytEmbedURL = card['embed-url'];
|
|
8
8
|
if (!ytEmbedURL) return null;
|
|
9
9
|
|
|
10
|
-
const windowWidth =
|
|
10
|
+
const windowWidth = useWindowDimensions().width;
|
|
11
11
|
const styles = webviewStyles(windowWidth);
|
|
12
12
|
|
|
13
13
|
const getYoutubeIframe = (ytEmbedURL) => {
|
package/src/components/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export { IconText } from './IconText';
|
|
|
40
40
|
export { CustomSwitch } from './CustomSwitch';
|
|
41
41
|
export { RelatedStoriesCard } from './RelatedStoriesCard';
|
|
42
42
|
export { References } from './References';
|
|
43
|
-
export { StoryTemplateIcon } from './StoryTemplateIcon'
|
|
43
|
+
export { StoryTemplateIcon } from './StoryTemplateIcon';
|
|
44
44
|
export { StoryCardDetailsRow } from './StoryCardDetailsRow';
|
|
45
|
-
export { TextA } from './TextA'
|
|
46
|
-
export { TextQ } from './TextQ'
|
|
45
|
+
export { TextA } from './TextA';
|
|
46
|
+
export { TextQ } from './TextQ';
|
package/src/utils/imageUtils.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import { PixelRatio
|
|
2
|
+
import { PixelRatio } from 'react-native';
|
|
3
3
|
import { FocusedImage } from 'quintype-js';
|
|
4
4
|
import get from 'lodash/get';
|
|
5
5
|
import { AppTheme } from '.';
|
|
6
6
|
|
|
7
|
-
const { width: deviceWidth } = Dimensions.get('window');
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
|--------------------------------------------------
|
|
11
9
|
| Gets a higher resolution image if you are on a high pixel density device.
|
|
@@ -40,28 +38,18 @@ export function getImageQuality() {
|
|
|
40
38
|
return 30;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
/**
|
|
44
|
-
|--------------------------------------------------
|
|
45
|
-
| Gets the percentage width based on device width
|
|
46
|
-
|--------------------------------------------------
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
export function getScreenPercentageWidth(percentage) {
|
|
50
|
-
return Math.round(0.01 * percentage * deviceWidth);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
41
|
/**
|
|
54
42
|
|--------------------------------------------------
|
|
55
43
|
| Gets image height based on device width
|
|
56
44
|
|--------------------------------------------------
|
|
57
45
|
*/
|
|
58
46
|
|
|
59
|
-
export function getImageHeight(imageWidth, imageHeight) {
|
|
47
|
+
export function getImageHeight(imageWidth, imageHeight, screenWidth) {
|
|
60
48
|
/* Return back a default size if either of the params are falsy */
|
|
61
49
|
if (!imageHeight || !imageWidth) {
|
|
62
50
|
return 250;
|
|
63
51
|
}
|
|
64
|
-
const ratio =
|
|
52
|
+
const ratio = screenWidth / imageWidth;
|
|
65
53
|
return imageHeight * ratio;
|
|
66
54
|
}
|
|
67
55
|
|
|
@@ -105,7 +93,7 @@ export function getImageMetadata(story = {}) {
|
|
|
105
93
|
/**
|
|
106
94
|
* Returns an ImageURL
|
|
107
95
|
*/
|
|
108
|
-
export const getImageURL = (props) => {
|
|
96
|
+
export const getImageURL = (props, screenWidth) => {
|
|
109
97
|
const { theme } = useContext(AppTheme);
|
|
110
98
|
const { IMAGE_QUALITY } = theme;
|
|
111
99
|
|
|
@@ -113,26 +101,9 @@ export const getImageURL = (props) => {
|
|
|
113
101
|
aspectRatio, metaData, slug, imageWidth, cdn,
|
|
114
102
|
} = props;
|
|
115
103
|
const image = new FocusedImage(slug, metaData);
|
|
116
|
-
|
|
117
104
|
const imageCdn = cdn || 'https://www.quintype.com';
|
|
118
105
|
return `${imageCdn}/${image.path(aspectRatio || [16, 9], {
|
|
119
|
-
w: getPixelRatioForDevice(imageWidth) || Math.round(
|
|
120
|
-
q: IMAGE_QUALITY,
|
|
121
|
-
})}`;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const getCustomResolutionImageURL = (props, customAspectRatio) => {
|
|
125
|
-
const { theme } = useContext(AppTheme);
|
|
126
|
-
const { IMAGE_QUALITY } = theme;
|
|
127
|
-
|
|
128
|
-
const {
|
|
129
|
-
metaData, slug, imageWidth, cdn,
|
|
130
|
-
} = props;
|
|
131
|
-
const image = new FocusedImage(slug, metaData);
|
|
132
|
-
|
|
133
|
-
const imageCdn = cdn || 'https://www.quintype.com';
|
|
134
|
-
return `${imageCdn}/${image.path(customAspectRatio, {
|
|
135
|
-
w: getPixelRatioForDevice(imageWidth) || Math.round(deviceWidth),
|
|
106
|
+
w: getPixelRatioForDevice(imageWidth) || Math.round(screenWidth),
|
|
136
107
|
q: IMAGE_QUALITY,
|
|
137
108
|
})}`;
|
|
138
109
|
};
|
package/src/utils/screenUtils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import get from "lodash/get";
|
|
2
2
|
import { useNavigationState } from "@react-navigation/native";
|
|
3
|
-
import { Dimensions } from "react-native";
|
|
4
3
|
|
|
5
4
|
export const getScreenCount = (screenName) => {
|
|
6
5
|
/* Note: To figure out if there are screen instances in the stack */
|
|
@@ -12,15 +11,3 @@ export const getScreenCount = (screenName) => {
|
|
|
12
11
|
return acc;
|
|
13
12
|
}, 0);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
export const ResponsiveHeight = (height) => {
|
|
17
|
-
const deviceHeight = Dimensions.get("window").height;
|
|
18
|
-
const responsiveHeight = (deviceHeight * height) / 1000;
|
|
19
|
-
return responsiveHeight;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const ResponsiveWidth = (width) => {
|
|
23
|
-
const deviceWidth = Dimensions.get("window").width;
|
|
24
|
-
const responsiveWidth = (deviceWidth * width) / 1000;
|
|
25
|
-
return responsiveWidth;
|
|
26
|
-
};
|