-
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.
Merge pull request #6 from LeleDallas/feat/no-data
feat: no data view
- Loading branch information
Showing
6 changed files
with
59 additions
and
10 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,17 @@ | ||
import { render } from "@testing-library/react-native"; | ||
import NoData from "../src/components/NoData"; | ||
|
||
|
||
describe('NoData', () => { | ||
it('should render correctly', () => { | ||
const { queryByTestId } = render(<NoData length={0} loading={false} />); | ||
expect(queryByTestId('loading')).toBeNull(); | ||
}); | ||
|
||
|
||
it('should render nothing', () => { | ||
const { queryByTestId } = render(<NoData length={1} loading={false} />); | ||
expect(queryByTestId('loading')).toBeNull(); | ||
expect(queryByTestId('no-data')).toBeNull(); | ||
}); | ||
}) |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
import { Image, Text, View } from "react-native"; | ||
import { globalStyle } from "../../styles"; | ||
|
||
type Props = { | ||
length: number; | ||
loading: boolean; | ||
} | ||
|
||
export default ({ length, loading }: Props) => | ||
length === 0 && !loading && | ||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> | ||
<Image source={require('../../../assets/noData.png')} style={{ width: 200, height: 200, alignSelf: 'center' }} /> | ||
<Text style={globalStyle.text}>No data found</Text> | ||
</View> | ||
|
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 |
---|---|---|
@@ -1,12 +1,26 @@ | ||
import LottieView from "lottie-react-native"; | ||
import { View } from "react-native"; | ||
import { ActivityIndicator, Platform, View } from "react-native"; | ||
import { colors } from "../../styles"; | ||
|
||
export default () => | ||
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> | ||
<LottieView | ||
style={{ width: "100%", height: "100%" }} | ||
source={require("../../../assets/spinner2.json")} | ||
autoPlay | ||
loop | ||
/> | ||
</View> | ||
Platform.OS === "ios" ? ( | ||
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> | ||
<LottieView | ||
style={{ width: "100%", height: "100%" }} | ||
source={require("../../../assets/spinner2.json")} | ||
autoPlay | ||
loop | ||
/> | ||
</View>) : ( | ||
<View style={{ | ||
position: 'absolute', | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0, | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
}}> | ||
<ActivityIndicator size={200} color={colors.buttonActive} /> | ||
</View> | ||
); |
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