1
1
import { useEffect , useState } from 'react'
2
2
import { Stack } from 'tamagui'
3
+ import { usePwa , useSafeAreaInsets } from '../utils'
3
4
4
5
const getTimeout = ( progress : number ) : number => {
5
6
if ( progress < 0.7 ) {
@@ -20,6 +21,8 @@ const LoadingBar = ({ visible }: { visible: boolean }) => {
20
21
21
22
const translate = 100 - progress * 100
22
23
24
+ const insets = useSafeAreaInsets ( )
25
+
23
26
useEffect ( ( ) => {
24
27
if ( render ) {
25
28
const timeoutId = setTimeout ( ( ) => {
@@ -65,7 +68,7 @@ const LoadingBar = ({ visible }: { visible: boolean }) => {
65
68
} , [ visible ] )
66
69
67
70
return (
68
- < Stack w = "100%" h = " $0.5" overflow = "hidden" position = "relative" >
71
+ < Stack w = "100%" h = { insets . bottom > 0 ? ' $0.75' : '$0.5' } overflow = "hidden" position = "relative" >
69
72
< Stack
70
73
position = "absolute"
71
74
top = { 0 }
@@ -74,14 +77,31 @@ const LoadingBar = ({ visible }: { visible: boolean }) => {
74
77
width = "100%"
75
78
bc = "$primary"
76
79
opacity = { ! render || ( render && progress === 0 ) ? 0 : 1 }
77
- style = { { transform : `translateX(-${ translate } %)` } }
80
+ animation = "quick"
81
+ transformStyle = "preserve-3d"
82
+ x = { `-${ translate } %` }
83
+ animateOnly = { [ 'transform' ] }
78
84
/>
79
85
</ Stack >
80
86
)
81
87
}
82
88
83
- export const PendingIndicatorBar = ( { pending } : { pending : boolean } ) => (
84
- < Stack position = "absolute" left = { 0 } top = { 0 } w = "100%" pointerEvents = "none" zIndex = { 20 } >
85
- < LoadingBar visible = { pending } />
86
- </ Stack >
87
- )
89
+ export const PendingIndicatorBar = ( { pending } : { pending : boolean } ) => {
90
+ const isPwa = usePwa ( )
91
+
92
+ const placement = isPwa ? { bottom : 0 } : { top : 0 }
93
+
94
+ return (
95
+ < Stack
96
+ position = "absolute"
97
+ left = { 0 }
98
+ w = "100%"
99
+ pointerEvents = "none"
100
+ zIndex = { 20 }
101
+ { ...placement }
102
+ $platform-native = { { bottom : 0 } }
103
+ >
104
+ < LoadingBar visible = { pending } />
105
+ </ Stack >
106
+ )
107
+ }
0 commit comments