-
Notifications
You must be signed in to change notification settings - Fork 455
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 #539 from shoutem/release/4.0.11
Release/4.0.11
- Loading branch information
Showing
5 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
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,61 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, { PureComponent } from 'react'; | ||
import autoBindReact from 'auto-bind/react'; | ||
import _ from 'lodash'; | ||
import { connectStyle } from '@shoutem/theme'; | ||
import { Text, Title, View } from '@shoutem/ui'; | ||
import EmptyList from '../assets/images/emptyList.svg' | ||
|
||
class EmptyListImage extends PureComponent { | ||
static defaultProps = { | ||
title: "It's empty in here", | ||
message: "We couldn't find anything to show...", | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
autoBindReact(this); | ||
} | ||
|
||
resolveImage() { | ||
const { image } = this.props; | ||
|
||
if (image && !_.isFunction(image)) { | ||
console.warn(`Image must be an SVG file imported as a React component.`); | ||
} else if (image && _.isFunction(image)) { | ||
return image; | ||
} | ||
|
||
return EmptyList; | ||
} | ||
|
||
render() { | ||
const { message, title, imageStyle, titleStyle, messageStyle, style } = this.props | ||
const EmptyStateImage = this.resolveImage(); | ||
|
||
return ( | ||
<View styleName="vertical h-center "> | ||
<EmptyStateImage style={[style.image, imageStyle]} /> | ||
<Title styleName="title" style={[style.title, titleStyle]}>{title}</Title> | ||
<Text styleName="description" style={[style.message, messageStyle]}>{message}</Text> | ||
</View > | ||
); | ||
} | ||
} | ||
|
||
EmptyListImage.propTypes = { | ||
...EmptyListImage.propTypes, | ||
image: PropTypes.func, | ||
imageStyle: PropTypes.object, | ||
message: PropTypes.string, | ||
messageStyle: PropTypes.object, | ||
title: PropTypes.string, | ||
titleStyle: PropTypes.object, | ||
}; | ||
|
||
const StyledView = connectStyle('shoutem.ui.EmptyListImage')(EmptyListImage); | ||
|
||
export { | ||
StyledView as EmptyListImage, | ||
}; |
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