-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Loader component and update SiteInformation and NavigationRow com…
…ponents
- Loading branch information
1 parent
b4b28d9
commit 3c8c686
Showing
5 changed files
with
99 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useEffect } from 'react' | ||
import { | ||
StyleProp, | ||
StyleSheet, | ||
useWindowDimensions, | ||
View, | ||
ViewStyle | ||
} from 'react-native' | ||
import Animated, { | ||
useSharedValue, | ||
withDelay, | ||
withRepeat, | ||
withTiming | ||
} from 'react-native-reanimated' | ||
|
||
interface Props { | ||
style?: StyleProp<ViewStyle> | ||
disableAnimation?: boolean | ||
shadowWidth?: number | ||
} | ||
|
||
const DEFAULT_SHADOW_WIDTH = 150 | ||
export const LoadingView = ({ | ||
style, | ||
disableAnimation, | ||
shadowWidth = DEFAULT_SHADOW_WIDTH | ||
}: Props) => { | ||
const window = useWindowDimensions() | ||
const initialXValue = -window.width | ||
const translateX = useSharedValue(initialXValue) | ||
|
||
useEffect(() => { | ||
if (disableAnimation) { | ||
translateX.value = initialXValue | ||
return | ||
} | ||
|
||
translateX.value = withDelay( | ||
200, | ||
withRepeat( | ||
withTiming(window.width * 2, { | ||
duration: 1500 | ||
}), | ||
0, | ||
false | ||
) | ||
) | ||
}, [disableAnimation, initialXValue, translateX, window]) | ||
|
||
return ( | ||
<View style={[s.loading, style]}> | ||
<Animated.View | ||
style={[ | ||
s.shadow, | ||
{ | ||
width: shadowWidth, | ||
transform: [{ translateX }, { skewX: '15deg' }] | ||
} | ||
]} | ||
/> | ||
</View> | ||
) | ||
} | ||
|
||
const s = StyleSheet.create({ | ||
loading: { | ||
overflow: 'hidden', | ||
backgroundColor: 'rgba(0, 0, 0, 0.05)' | ||
}, | ||
shadow: { | ||
height: '100%', | ||
position: 'absolute', | ||
left: 0, | ||
top: 0, | ||
backgroundColor: 'rgba(0, 0, 0, 0.08)' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters