created owner indicator

This commit is contained in:
u-e 2019-04-01 23:24:20 +03:00
parent 9a3b5b0399
commit c5a8eabc3c
5 changed files with 44 additions and 34 deletions

View File

@ -63,6 +63,7 @@ class CommentView extends PureComponent {
name={comment.author}
reputation={comment.author_reputation}
size={avatarSize || 24}
isShowOwnerIndicator={currentAccountUsername === comment.author}
/>
<View style={[{ marginLeft: marginLeft || 29 }, styles.bodyWrapper]}>
<PostBody isComment handleOnUserPress={handleOnUserPress} body={comment.body} />

View File

@ -32,7 +32,7 @@ class PostHeaderDescription extends PureComponent {
}
// Component Functions
_handleOnUserPress = (username) => {
_handleOnUserPress = username => {
const { navigation, profileOnPress, reputation } = this.props;
if (profileOnPress) {
@ -51,7 +51,14 @@ class PostHeaderDescription extends PureComponent {
render() {
const {
date, isHideImage, name, reputation, size, tag, tagOnPress,
date,
isHideImage,
name,
reputation,
size,
tag,
tagOnPress,
isShowOwnerIndicator,
} = this.props;
const { reblogedBy } = this.state;
@ -81,13 +88,12 @@ class PostHeaderDescription extends PureComponent {
</TouchableOpacity>
)}
<Text style={styles.date}>{date}</Text>
{isShowOwnerIndicator && (
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" />
)}
{!!reblogedBy && (
// <TextWithIcon text={reblogedBy} iconType="MaterialIcons" iconName="repeat" />
<Icon
style={styles.reblogedIcon}
name="repeat"
iconType="MaterialIcons"
/>
<Icon style={styles.reblogedIcon} name="repeat" iconType="MaterialIcons" />
)}
</View>
);

View File

@ -37,4 +37,9 @@ export default EStyleSheet.create({
marginLeft: 10,
alignSelf: 'center',
},
ownerIndicator: {
color: '$primaryBlue',
alignSelf: 'center',
marginLeft: 8,
},
});

View File

@ -1,7 +1,5 @@
import React, { Component } from 'react';
import {
Platform, BackHandler, Alert, NetInfo,
} from 'react-native';
import { Platform, BackHandler, Alert, NetInfo } from 'react-native';
import { connect } from 'react-redux';
import { addLocaleData } from 'react-intl';
import Config from 'react-native-config';
@ -87,7 +85,7 @@ class ApplicationContainer extends Component {
const { isIos } = this.state;
let isConnected;
await NetInfo.isConnected.fetch().then((_isConnected) => {
await NetInfo.isConnected.fetch().then(_isConnected => {
isConnected = _isConnected;
});
@ -104,9 +102,7 @@ class ApplicationContainer extends Component {
};
componentWillReceiveProps(nextProps) {
const {
isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected,
} = this.props;
const { isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected } = this.props;
if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) {
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
@ -131,12 +127,12 @@ class ApplicationContainer extends Component {
}
_fetchApp = async () => {
this._refreshGlobalProps();
await this._refreshGlobalProps();
this._getSettings();
await this._getUserData();
};
_handleConntectionChange = (status) => {
_handleConntectionChange = status => {
const { dispatch, isConnected } = this.props;
if (isConnected !== status) {
@ -170,19 +166,19 @@ class ApplicationContainer extends Component {
let realmData = [];
let currentUsername;
await getAuthStatus().then((res) => {
await getAuthStatus().then(res => {
({ currentUsername } = res);
if (res) {
getUserData().then(async (userData) => {
getUserData().then(async userData => {
if (userData.length > 0) {
realmData = userData;
userData.forEach((accountData, index) => {
if (
!accountData.accessToken
&& !accountData.masterKey
&& !accountData.postingKey
&& !accountData.activeKey
&& !accountData.memoKey
!accountData.accessToken &&
!accountData.masterKey &&
!accountData.postingKey &&
!accountData.activeKey &&
!accountData.memoKey
) {
realmData.splice(index, 1);
if (realmData.length === 0) {
@ -213,7 +209,7 @@ class ApplicationContainer extends Component {
await switchAccount(realmObject[0].username);
}
await getUser(realmObject[0].username)
.then(async (accountData) => {
.then(async accountData => {
dispatch(login(true));
const isExistUser = await getExistUser();
@ -227,7 +223,7 @@ class ApplicationContainer extends Component {
}
this._connectNotificationServer(accountData.name);
})
.catch((err) => {
.catch(err => {
Alert.alert(err);
});
}
@ -239,15 +235,19 @@ class ApplicationContainer extends Component {
_getSettings = () => {
const { dispatch } = this.props;
getSettings().then((response) => {
getSettings().then(response => {
if (response) {
if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme));
if (response.language !== '') dispatch(setLanguage(response.language));
if (response.server !== '') dispatch(setApi(response.server));
if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent)));
if (response.upvotePercent !== '') {
dispatch(setUpvotePercent(Number(response.upvotePercent)));
}
if (response.isDefaultFooter !== '') dispatch(isDefaultFooter(response.isDefaultFooter));
if (response.notification !== '') {
dispatch(changeNotificationSettings({ type: 'notification', action: response.notification }));
dispatch(
changeNotificationSettings({ type: 'notification', action: response.notification }),
);
dispatch(changeAllNotificationSettings(response));
Push.setEnabled(response.notification);
@ -261,7 +261,7 @@ class ApplicationContainer extends Component {
});
};
_connectNotificationServer = (username) => {
_connectNotificationServer = username => {
const { dispatch, unreadActivityCount } = this.props;
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
@ -299,10 +299,10 @@ class ApplicationContainer extends Component {
.catch(() => {});
};
_switchAccount = async (targetAccountUsername) => {
_switchAccount = async targetAccountUsername => {
const { dispatch } = this.props;
await switchAccount(targetAccountUsername).then((accountData) => {
await switchAccount(targetAccountUsername).then(accountData => {
const realmData = getUserDataWithUsername(targetAccountUsername);
const _currentAccount = accountData;
_currentAccount.username = accountData.name;

View File

@ -42,9 +42,7 @@ class ApplicationScreen extends Component {
};
render() {
const {
isConnected, isDarkTheme, locale, toastNotification,
} = this.props;
const { isConnected, isDarkTheme, locale, toastNotification } = this.props;
const { isShowToastNotification } = this.state;
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
const barColor = isDarkTheme ? '#1e2835' : '#fff';