-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support loading indicator component (#924)
* support loading indicator component * update loading indicator * resolve comments feedback
- Loading branch information
Showing
6 changed files
with
92 additions
and
178 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
This file was deleted.
Oops, something went wrong.
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,70 @@ | ||
import * as React from "react"; | ||
import { StyleProp, ViewStyle } from "react-native"; | ||
import { withTheme } from "@draftbit/theme"; | ||
import type { ReadTheme } from "@draftbit/theme"; | ||
import { | ||
Bounce, | ||
Chase, | ||
Circle, | ||
CircleFade, | ||
Flow, | ||
Fold, | ||
Grid, | ||
Plane, | ||
Pulse, | ||
Swing, | ||
Wander, | ||
Wave, | ||
} from "react-native-animated-spinkit"; | ||
|
||
export enum LoadingIndicatorType { | ||
plane = "plane", | ||
chase = "chase", | ||
bounce = "bounce", | ||
wave = "wave", | ||
pulse = "pulse", | ||
flow = "flow", | ||
swing = "swing", | ||
circle = "circle", | ||
circleFade = "circleFade", | ||
grid = "grid", | ||
fold = "fold", | ||
wander = "wander", | ||
} | ||
|
||
type Props = { | ||
style?: StyleProp<ViewStyle>; | ||
color?: string; | ||
theme: ReadTheme; | ||
type?: LoadingIndicatorType; | ||
size?: number; | ||
}; | ||
|
||
const SPINNER_COMPONENTS = { | ||
[LoadingIndicatorType.plane]: Plane, | ||
[LoadingIndicatorType.chase]: Chase, | ||
[LoadingIndicatorType.bounce]: Bounce, | ||
[LoadingIndicatorType.wave]: Wave, | ||
[LoadingIndicatorType.pulse]: Pulse, | ||
[LoadingIndicatorType.flow]: Flow, | ||
[LoadingIndicatorType.swing]: Swing, | ||
[LoadingIndicatorType.circle]: Circle, | ||
[LoadingIndicatorType.circleFade]: CircleFade, | ||
[LoadingIndicatorType.grid]: Grid, | ||
[LoadingIndicatorType.fold]: Fold, | ||
[LoadingIndicatorType.wander]: Wander, | ||
}; | ||
|
||
const LoadingIndicator: React.FC<React.PropsWithChildren<Props>> = ({ | ||
theme, | ||
color = theme.colors.branding.primary, | ||
type = LoadingIndicatorType.plane, | ||
size, | ||
style, | ||
...rest | ||
}) => { | ||
const SpinnerComponent = SPINNER_COMPONENTS[type]; | ||
return <SpinnerComponent size={size} color={color} style={style} {...rest} />; | ||
}; | ||
|
||
export default withTheme(LoadingIndicator); |
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