@react-navigation/stack 7.0.3 → 7.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/stack",
3
3
  "description": "Stack navigator component for iOS and Android with animated transitions and gestures",
4
- "version": "7.0.3",
4
+ "version": "7.0.4",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -51,7 +51,7 @@
51
51
  "clean": "del lib"
52
52
  },
53
53
  "dependencies": {
54
- "@react-navigation/elements": "^2.0.3",
54
+ "@react-navigation/elements": "^2.0.4",
55
55
  "color": "^4.2.3"
56
56
  },
57
57
  "devDependencies": {
@@ -102,5 +102,5 @@
102
102
  ]
103
103
  ]
104
104
  },
105
- "gitHead": "596ce0641241b9f003a6ad130f6f4837206ef064"
105
+ "gitHead": "113cea5770fbca7cc86594d7dac1f00c2c392eec"
106
106
  }
@@ -0,0 +1,37 @@
1
+ import Color from 'color';
2
+ import { Platform } from 'react-native';
3
+
4
+ type ShadowConfig = {
5
+ offset: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ radius: number;
10
+ opacity: number;
11
+ color?: string;
12
+ };
13
+
14
+ export function getShadowStyle({
15
+ offset,
16
+ radius,
17
+ opacity,
18
+ color = '#000',
19
+ }: ShadowConfig) {
20
+ const result = Platform.select({
21
+ web: {
22
+ boxShadow: `${offset.width}px ${offset.height}px ${radius}px ${Color(
23
+ color
24
+ )
25
+ .alpha(opacity)
26
+ .toString()}`,
27
+ },
28
+ default: {
29
+ shadowOffset: offset,
30
+ shadowRadius: radius,
31
+ shadowColor: color,
32
+ shadowOpacity: opacity,
33
+ },
34
+ });
35
+
36
+ return result;
37
+ }
@@ -23,6 +23,7 @@ import type {
23
23
  import { CardAnimationContext } from '../../utils/CardAnimationContext';
24
24
  import { getDistanceForDirection } from '../../utils/getDistanceForDirection';
25
25
  import { getInvertedMultiplier } from '../../utils/getInvertedMultiplier';
26
+ import { getShadowStyle } from '../../utils/getShadowStyle';
26
27
  import { memoize } from '../../utils/memoize';
27
28
  import {
28
29
  GestureState,
@@ -610,15 +611,19 @@ const styles = StyleSheet.create({
610
611
  },
611
612
  shadow: {
612
613
  position: 'absolute',
613
- shadowRadius: 5,
614
- shadowColor: '#000',
615
- shadowOpacity: 0.3,
616
614
  },
617
615
  shadowHorizontal: {
618
616
  top: 0,
619
617
  bottom: 0,
620
618
  width: 3,
621
- shadowOffset: { width: -1, height: 1 },
619
+ ...getShadowStyle({
620
+ offset: {
621
+ width: -1,
622
+ height: 1,
623
+ },
624
+ radius: 5,
625
+ opacity: 0.3,
626
+ }),
622
627
  },
623
628
  shadowStart: {
624
629
  start: 0,
@@ -630,7 +635,14 @@ const styles = StyleSheet.create({
630
635
  start: 0,
631
636
  end: 0,
632
637
  height: 3,
633
- shadowOffset: { width: 1, height: -1 },
638
+ ...getShadowStyle({
639
+ offset: {
640
+ width: 1,
641
+ height: -1,
642
+ },
643
+ radius: 5,
644
+ opacity: 0.3,
645
+ }),
634
646
  },
635
647
  shadowTop: {
636
648
  top: 0,