-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Skeleton works * fix: fix radio story event * fix:fix ts type error * fix: fix lint * feat: Screen Component. * doc: add more comment --------- Co-authored-by: hublot <[email protected]>
- Loading branch information
1 parent
b67fc6f
commit daff418
Showing
11 changed files
with
219 additions
and
90 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
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,32 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { useNavigation } from '@react-navigation/native'; | ||
|
||
import useIsLowPerformanceDevice from '../hooks/useIsLowPerformanceDevice'; | ||
import { Spinner } from '../Spinner'; | ||
import { Stack } from '../Stack'; | ||
|
||
const Loading = () => ( | ||
<Stack flex={1} alignContent="center" justifyContent="center"> | ||
<Spinner size="large" /> | ||
</Stack> | ||
); | ||
|
||
function LoadingScreen({ children }: PropsWithChildren<unknown>) { | ||
const [isTransitionEnd, setIsTransitionEnd] = useState(false); | ||
const navigation = useNavigation(); | ||
useEffect(() => { | ||
// 'onTransitionEnd' event is missing in react navigation types | ||
const unsubscribe = navigation.addListener('transitionEnd' as any, () => { | ||
setIsTransitionEnd(true); | ||
}); | ||
return unsubscribe; | ||
}, [navigation]); | ||
return isTransitionEnd ? children : <Loading />; | ||
} | ||
|
||
export function Screen({ children }: PropsWithChildren<unknown>) { | ||
const isLowPerformanceDevice = useIsLowPerformanceDevice(); | ||
return isLowPerformanceDevice ? LoadingScreen : children; | ||
} |
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,5 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
export function Screen({ children }: PropsWithChildren<unknown>) { | ||
return children; | ||
} |
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,47 @@ | ||
import { MotiView } from 'moti'; | ||
import { Skeleton as MotiSkeleton } from 'moti/skeleton'; | ||
import { StyleSheet } from 'react-native'; | ||
|
||
import useTheme from '../Provider/hooks/useTheme'; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
}, | ||
padded: { | ||
padding: 16, | ||
}, | ||
}); | ||
|
||
const Spacer = ({ height = 16 }: { height: number }) => ( | ||
<MotiView style={{ height }} /> | ||
); | ||
|
||
export function Skeleton() { | ||
const { themeVariant } = useTheme(); | ||
return ( | ||
<MotiView | ||
transition={{ | ||
type: 'timing', | ||
}} | ||
style={[styles.container, styles.padded]} | ||
animate={{ | ||
backgroundColor: themeVariant === 'dark' ? '#000000' : '#ffffff', | ||
}} | ||
> | ||
<MotiSkeleton | ||
colorMode={themeVariant} | ||
radius="round" | ||
height={75} | ||
width={75} | ||
/> | ||
<Spacer /> | ||
<MotiSkeleton colorMode={themeVariant} width={250} /> | ||
<Spacer height={8} /> | ||
<MotiSkeleton colorMode={themeVariant} width="100%" /> | ||
<Spacer height={8} /> | ||
<MotiSkeleton colorMode={themeVariant} width="100%" /> | ||
</MotiView> | ||
); | ||
} |
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,6 @@ | ||
// import platformEnv from "@onekeyhq/shared/src/platformEnv"; | ||
|
||
export default function useIsLowPerformanceDevice() { | ||
// return !platformEnv.isDev ? IsLowPerformanceDevice : false; | ||
return false; | ||
} |
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
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,19 @@ | ||
import { Skeleton } from '@onekeyhq/components'; | ||
|
||
import { Layout } from './utils/Layout'; | ||
|
||
const SelectGallery = () => ( | ||
<Layout | ||
description="..." | ||
suggestions={['...']} | ||
boundaryConditions={['...']} | ||
elements={[ | ||
{ | ||
title: '默认状态', | ||
element: <Skeleton />, | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
export default SelectGallery; |
Oops, something went wrong.