updated read all notification loading indicator

This commit is contained in:
u-e 2019-01-15 15:40:43 +03:00
parent 76aaa191da
commit 1a720ccfb6
3 changed files with 39 additions and 29 deletions

View File

@ -7,7 +7,6 @@ import { DropdownButton } from '../../dropdownButton';
// Components // Components
import { LineBreak } from '../../basicUIElements'; import { LineBreak } from '../../basicUIElements';
import { PulseAnimation } from '../../animations';
// Styles // Styles
import styles from './filterBarStyles'; import styles from './filterBarStyles';
@ -28,7 +27,6 @@ const FilterBarView = ({
rightIconName, rightIconName,
rightIconType, rightIconType,
selectedOptionIndex, selectedOptionIndex,
rightIconLoading,
}) => ( }) => (
<View style={styles.container}> <View style={styles.container}>
{!isHide && ( {!isHide && (
@ -41,7 +39,7 @@ const FilterBarView = ({
onSelect={onDropdownSelect} onSelect={onDropdownSelect}
selectedOptionIndex={selectedOptionIndex} selectedOptionIndex={selectedOptionIndex}
/> />
{rightIconName && !rightIconLoading && ( {rightIconName && (
<TouchableOpacity <TouchableOpacity
onPress={() => onRightIconPress && onRightIconPress()} onPress={() => onRightIconPress && onRightIconPress()}
style={styles.rightIconWrapper} style={styles.rightIconWrapper}
@ -54,18 +52,6 @@ const FilterBarView = ({
/> />
</TouchableOpacity> </TouchableOpacity>
)} )}
{rightIconName && rightIconLoading && (
<View style={styles.rightIconWrapper}>
<PulseAnimation
color="#357ce6"
numPulses={1}
diameter={20}
speed={100}
duration={100}
isShow={!rightIconLoading}
/>
</View>
)}
</View> </View>
</LineBreak> </LineBreak>
)} )}

View File

@ -1,6 +1,6 @@
import React, { PureComponent, Fragment } from 'react'; import React, { PureComponent, Fragment } from 'react';
import { import {
View, ScrollView, FlatList, ActivityIndicator, View, ScrollView, FlatList, ActivityIndicator, RefreshControl,
} from 'react-native'; } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
@ -142,20 +142,26 @@ class NotificationView extends PureComponent {
return 4; return 4;
}; };
_getActivityIndicator = () => (
<View style={styles.loading}>
<ActivityIndicator animating size="large" />
</View>
);
render() { render() {
const { const {
readAllNotification, getActivities, loading, readAllNotificationLoading, readAllNotification,
getActivities,
loading,
readAllNotificationLoading,
isDarkTheme,
} = this.props; } = this.props;
const { filters, selectedFilter } = this.state; const { filters, selectedFilter } = this.state;
const _notifications = this._getNotificationsArrays(); const _notifications = this._getNotificationsArrays();
if (_notifications.length === 0) { if (_notifications.length === 0) {
return ( return this._getActivityIndicator();
<View style={styles.loading}>
<ActivityIndicator animating size="large" />
</View>
);
} }
return ( return (
@ -165,9 +171,9 @@ class NotificationView extends PureComponent {
options={filters.map(item => item.value)} options={filters.map(item => item.value)}
defaultText="ALL ACTIVITIES" defaultText="ALL ACTIVITIES"
onDropdownSelect={this._handleOnDropdownSelect} onDropdownSelect={this._handleOnDropdownSelect}
rightIconName="ios-checkmark" rightIconName="check"
rightIconType="MaterialIcons"
onRightIconPress={readAllNotification} onRightIconPress={readAllNotification}
rightIconLoading={readAllNotificationLoading}
/> />
<ScrollView <ScrollView
style={styles.scrollView} style={styles.scrollView}
@ -175,8 +181,7 @@ class NotificationView extends PureComponent {
let paddingToBottom = 1; let paddingToBottom = 1;
paddingToBottom += e.nativeEvent.layoutMeasurement.height; paddingToBottom += e.nativeEvent.layoutMeasurement.height;
if ( if (
e.nativeEvent.contentOffset.y e.nativeEvent.contentOffset.y >= e.nativeEvent.contentSize.height - paddingToBottom
>= e.nativeEvent.contentSize.height - paddingToBottom
&& !loading && !loading
) { ) {
getActivities(selectedFilter, true); getActivities(selectedFilter, true);
@ -185,6 +190,17 @@ class NotificationView extends PureComponent {
> >
<FlatList <FlatList
data={_notifications} data={_notifications}
refreshing={readAllNotificationLoading}
onRefresh={() => null}
refreshControl={(
<RefreshControl
refreshing={readAllNotificationLoading}
progressBackgroundColor="#357CE6"
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
titleColor="#fff"
colors={['#fff']}
/>
)}
renderItem={({ item, index }) => ( renderItem={({ item, index }) => (
<Fragment> <Fragment>
<ContainerHeader <ContainerHeader

View File

@ -95,12 +95,18 @@ class NotificationContainer extends Component {
}; };
render() { render() {
const { notifications, notificationLoading, readAllNotificationLoading } = this.state; const {
notifications,
notificationLoading,
readAllNotificationLoading,
isDarkTheme,
} = this.state;
return ( return (
<NotificationScreen <NotificationScreen
getActivities={this._getAvtivities} getActivities={this._getAvtivities}
notifications={notifications} notifications={notifications}
isDarkTheme={isDarkTheme}
navigateToNotificationRoute={this._navigateToNotificationRoute} navigateToNotificationRoute={this._navigateToNotificationRoute}
readAllNotification={this._readAllNotification} readAllNotification={this._readAllNotification}
handleLoginPress={this._handleOnPressLogin} handleLoginPress={this._handleOnPressLogin}
@ -113,8 +119,10 @@ class NotificationContainer extends Component {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
username: state.account.currentAccount.name,
isLoggedIn: state.application.isLoggedIn, isLoggedIn: state.application.isLoggedIn,
isDarkTheme: state.application.isDarkTheme,
username: state.account.currentAccount.name,
activeBottomTab: state.ui.activeBottomTab, activeBottomTab: state.ui.activeBottomTab,
}); });