@quintype/native-components 2.20.3 → 2.20.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.20.5](https://github.com/quintype/native-components/compare/v2.20.4...v2.20.5) (2023-03-21)
6
+
7
+ ### [2.20.4](https://github.com/quintype/native-components/compare/v2.20.3...v2.20.4) (2023-02-01)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **fonts:** Fixes font for Related-Stories and Also-Read on Android :hammer: ([#197](https://github.com/quintype/native-components/issues/197)) ([952c95b](https://github.com/quintype/native-components/commit/952c95b43b76f55eeb25cf9e071a88a3d939ce60))
13
+
5
14
  ### [2.20.3](https://github.com/quintype/native-components/compare/v2.20.2...v2.20.3) (2023-02-01)
6
15
 
7
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.20.3",
3
+ "version": "2.20.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -25,8 +25,8 @@ export const AlsoRead = (props) => {
25
25
  const linkedImage = get(linkedStories, [linkedStoryId, 'hero-image-s3-key']);
26
26
 
27
27
  const { theme } = useContext(AppTheme);
28
- const { COLORS, FONT_SIZE, DARK_MODE, CustomFallBackIcon ,translate} = theme;
29
- const styles = alsoReadStyles(COLORS, FONT_SIZE, DARK_MODE);
28
+ const { CustomFallBackIcon, translate } = theme;
29
+ const styles = alsoReadStyles(theme);
30
30
 
31
31
  const fallBackIcon = CustomFallBackIcon ? <CustomFallBackIcon /> : <FallbackIcon />;
32
32
 
@@ -1,30 +1,33 @@
1
- import { StyleSheet } from 'react-native';
1
+ import { StyleSheet } from "react-native";
2
2
 
3
- export const alsoReadStyles = (COLORS, FONT_SIZE, DARK_MODE) => StyleSheet.create({
4
- wrapper: {
5
- padding: 10,
6
- },
7
- container: {
8
- flexDirection: 'row',
9
- },
10
- alsoReadContentWrapper: {
11
- paddingLeft: 12,
12
- flex: 1,
13
- },
14
- alsoReadText: {
15
- fontSize: FONT_SIZE.h2,
16
- fontWeight: 'bold',
17
- color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
18
- },
19
- alsoReadTitle: {
20
- fontSize: FONT_SIZE.h2,
21
- color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
22
- },
23
- fallBackImageWrapper: {
24
- backgroundColor: COLORS.BRAND_WHITE,
25
- width: 150,
26
- height: 84,
27
- alignItems: 'center',
28
- justifyContent: 'center',
29
- },
30
- });
3
+ export const alsoReadStyles = (appThemeContext) => {
4
+ const { COLORS, FONT_SIZE, FONT_FAMILY, DARK_MODE } = appThemeContext;
5
+ return StyleSheet.create({
6
+ wrapper: {
7
+ padding: 10,
8
+ },
9
+ container: {
10
+ flexDirection: "row",
11
+ },
12
+ alsoReadContentWrapper: {
13
+ paddingLeft: 12,
14
+ flex: 1,
15
+ },
16
+ alsoReadText: {
17
+ fontSize: FONT_SIZE.h2,
18
+ fontFamily: FONT_FAMILY.secondaryBold,
19
+ color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
20
+ },
21
+ alsoReadTitle: {
22
+ fontSize: FONT_SIZE.h2,
23
+ color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
24
+ },
25
+ fallBackImageWrapper: {
26
+ backgroundColor: COLORS.BRAND_WHITE,
27
+ width: 150,
28
+ height: 84,
29
+ alignItems: "center",
30
+ justifyContent: "center",
31
+ },
32
+ });
33
+ };
@@ -1,11 +1,11 @@
1
1
  import { StyleSheet,I18nManager } from 'react-native';
2
2
 
3
3
  export const relatedStoriesStyles = (appThemeContext) => {
4
- const { COLORS, FONT_SIZE } = appThemeContext;
4
+ const { COLORS, FONT_SIZE, FONT_FAMILY } = appThemeContext;
5
5
  return StyleSheet.create({
6
6
  titleStyle: {
7
7
  fontSize: FONT_SIZE.title,
8
- fontWeight: 'bold',
8
+ fontFamily: FONT_FAMILY.secondaryBold,
9
9
  color: COLORS.BRAND_BLACK,
10
10
  writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
11
11
  paddingHorizontal:5,
@@ -1,4 +1,3 @@
1
-
2
1
  import PropTypes from "prop-types";
3
2
  import React, { useContext, useRef, useState } from "react";
4
3
  import { TouchableOpacity, View } from "react-native";
@@ -23,15 +22,15 @@ export const StorySlideshow = ({ card, cdn }) => {
23
22
 
24
23
  const moveNext = () => {
25
24
  if (!lastSlide) {
26
- flatlistRef.current.scrollToIndex({ index: currentIndex + 1 });
25
+ flatlistRef.current.scrollToIndex({ index: Math.floor(Math.min(currentIndex + 1, totalSlides - 1))});
27
26
  setCurrentTabIndex(currentIndex + 1);
28
27
  }
29
28
  };
30
29
 
31
30
  const movePrev = () => {
32
31
  if (!firstSlide) {
33
- flatlistRef.current.scrollToIndex({ index: currentIndex - 1 });
34
- setCurrentTabIndex(currentIndex - 1);
32
+ flatlistRef.current.scrollToIndex({ index: Math.ceil(Math.max(currentIndex - 1, 0)) });
33
+ setCurrentTabIndex(Math.max(currentIndex - 1, 0));
35
34
  }
36
35
  };
37
36
 
@@ -49,6 +48,23 @@ export const StorySlideshow = ({ card, cdn }) => {
49
48
  );
50
49
  };
51
50
 
51
+ const handleScroll = (event) => {
52
+ const xOffset = event.nativeEvent?.contentOffset?.x;
53
+ const contentWidth = event.nativeEvent?.contentSize?.width;
54
+ const layoutWidth = event.nativeEvent?.layoutMeasurement?.width;
55
+ const value = (xOffset / contentWidth);
56
+ const leftThreshold = contentWidth / ( 2 * totalSlides );
57
+ const rightThreshold = contentWidth - ( 1.5 ) * layoutWidth;
58
+
59
+ if((leftThreshold <= xOffset && (layoutWidth > xOffset || rightThreshold > xOffset ))){
60
+ setCurrentTabIndex(value * totalSlides);
61
+ } else if(xOffset < leftThreshold){
62
+ setCurrentTabIndex(0);
63
+ } else if(xOffset >= rightThreshold){
64
+ setCurrentTabIndex(totalSlides-1);
65
+ }
66
+ }
67
+
52
68
  return (
53
69
  <View style={styles.wrapper}>
54
70
  <Text primary style={styles.titleText}>
@@ -62,6 +78,7 @@ export const StorySlideshow = ({ card, cdn }) => {
62
78
  keyExtractor={(item) => item.id}
63
79
  horizontal
64
80
  extraData={currentIndex}
81
+ onScroll={handleScroll}
65
82
  />
66
83
 
67
84
  {!firstSlide && showArrow("left")}