Fix hardcoded texts

This commit is contained in:
Furkan Kılıç 2020-12-13 18:02:09 +03:00
parent d8d59ac6a3
commit 0679fda5de
5 changed files with 68 additions and 38 deletions

View File

@ -1,5 +1,6 @@
import React, { useEffect } from 'react';
import { TouchableOpacity, Text } from 'react-native';
import { injectIntl } from 'react-intl';
import { UserAvatar } from '../../../userAvatar';
@ -7,7 +8,14 @@ import globalStyles from '../../../../globalStyles';
import styles from './selectCommunityAreStyles';
const SelectCommunityAreaView = ({ community, mode, currentAccount, onPressIn, onPressOut }) => {
const SelectCommunityAreaView = ({
community,
mode,
currentAccount,
onPressIn,
onPressOut,
intl,
}) => {
return (
<TouchableOpacity
style={[globalStyles.containerHorizontal16, styles.selectCommunityAreaViewContainer]}
@ -16,10 +24,10 @@ const SelectCommunityAreaView = ({ community, mode, currentAccount, onPressIn, o
>
<UserAvatar username={mode === 'community' ? community.name : currentAccount.name} noAction />
<Text style={[globalStyles.text, styles.chooseACommunityText]}>
{mode === 'community' ? community.title : 'My Blog'}
{mode === 'community' ? community.title : intl.formatMessage({ id: 'editor.my_blog' })}
</Text>
</TouchableOpacity>
);
};
export default SelectCommunityAreaView;
export default injectIntl(SelectCommunityAreaView);

View File

@ -15,7 +15,7 @@ import {
fetchSubscribedCommunitiesSuccess,
} from '../../../../redux/actions/communitiesAction';
const SelectCommunityModalContainer = ({ onPressCommunity }) => {
const SelectCommunityModalContainer = ({ onPressCommunity, currentAccount }) => {
const dispatch = useDispatch();
const [searchedCommunities, setSearchedCommunities] = useState([]);
@ -32,7 +32,7 @@ const SelectCommunityModalContainer = ({ onPressCommunity }) => {
const callTopCommunities = () => {
dispatch(fetchCommunities());
getCommunities('', 50, '', 'rank')
getCommunities('', 15, '', 'rank')
.then((communities) => {
dispatch(fetchCommunitiesSuccess(communities));
})
@ -43,7 +43,7 @@ const SelectCommunityModalContainer = ({ onPressCommunity }) => {
const callSubscribedCommunities = () => {
dispatch(fetchSubscribedCommunities());
getSubscriptions('furkankilic')
getSubscriptions(currentAccount.name)
.then((subscriptions) => {
dispatch(fetchSubscribedCommunitiesSuccess(subscriptions));
})
@ -53,7 +53,7 @@ const SelectCommunityModalContainer = ({ onPressCommunity }) => {
const handleChangeSearch = (text) => {
if (text.length >= 3) {
setShowSearchedCommunities(true);
getCommunities('', 50, text, 'rank')
getCommunities('', 15, text, 'rank')
.then((searcheds) => {
setSearchedCommunities(searcheds);
console.log(searcheds, text, 'searcheds');
@ -66,8 +66,6 @@ const SelectCommunityModalContainer = ({ onPressCommunity }) => {
}
};
const handlePressCloseForSearch = () => {};
return (
<>
<SelectCommunityModalView
@ -77,6 +75,7 @@ const SelectCommunityModalContainer = ({ onPressCommunity }) => {
onChangeSearch={debounce(handleChangeSearch, 500)}
searchedCommunities={searchedCommunities}
showSearchedCommunities={showSearchedCommunities}
currentAccount={currentAccount}
/>
</>
);

View File

@ -1,11 +1,11 @@
import React from 'react';
import { View, Text, ScrollView, FlatList } from 'react-native';
import globalStyles from '../../../../globalStyles';
import { injectIntl } from 'react-intl';
import CommunityCard from '../../../communityCard';
import { SearchInput } from '../../../searchInput';
import globalStyles from '../../../../globalStyles';
import styles from './selectCommunityModalStyles';
const SelectCommunityModalView = ({
@ -16,7 +16,10 @@ const SelectCommunityModalView = ({
onPressCloseForSearch,
searchedCommunities,
showSearchedCommunities,
currentAccount,
intl,
}) => {
console.log(subscribedCommunities, 'subscribedCommunities');
return (
<ScrollView style={{ flex: 1 }} showsVerticalScrollIndicator={false}>
<SearchInput onChangeText={onChangeSearch} placeholder="search" autoFocus={false} />
@ -29,7 +32,7 @@ const SelectCommunityModalView = ({
renderItem={({ item, index, separators }) => (
<CommunityCard
community={item}
key={item.name}
key={index}
onPress={onPressCommunity}
separators={separators}
/>
@ -37,14 +40,47 @@ const SelectCommunityModalView = ({
/>
) : (
<>
<Text style={[globalStyles.label, styles.title]}>MY BLOG</Text>
<Text style={[globalStyles.label, styles.title]}>
{intl.formatMessage({ id: 'editor.my_blog' }).toUpperCase()}
</Text>
<CommunityCard
community={{ name: 'furkankilic', title: 'My Blog' }}
community={{
name: currentAccount.name,
title: intl.formatMessage({ id: 'editor.my_blog' }),
}}
onPress={() => onPressCommunity(null)}
/>
{!subscribedCommunities.loading &&
!subscribedCommunities.error &&
subscribedCommunities.data.length > 0 && (
<View>
<Text style={[globalStyles.label, styles.title]}>
{intl.formatMessage({ id: 'editor.my_communities' }).toUpperCase()}
</Text>
<FlatList
ItemSeparatorComponent={() => <Separator />}
showsVerticalScrollIndicator={false}
data={subscribedCommunities.data}
renderItem={({ item, index, separators }) => {
const community = { name: item[0], title: item[1] };
return (
<CommunityCard
community={community}
key={community.name}
onPress={onPressCommunity}
separators={separators}
/>
);
}}
/>
</View>
)}
{!topCommunities.loading && !topCommunities.error && topCommunities.data.length > 0 && (
<View>
<Text style={[globalStyles.label, styles.title]}>TOP RATED</Text>
<Text style={[globalStyles.label, styles.title]}>
{' '}
{intl.formatMessage({ id: 'editor.top_communities' }).toUpperCase()}
</Text>
<FlatList
ItemSeparatorComponent={() => <Separator />}
showsVerticalScrollIndicator={false}
@ -60,32 +96,13 @@ const SelectCommunityModalView = ({
/>
</View>
)}
{!subscribedCommunities.loading &&
!subscribedCommunities.error &&
subscribedCommunities.data.length > 0 && (
<View>
<Text style={[globalStyles.label, styles.title]}>SUBSCRIBED</Text>
<FlatList
ItemSeparatorComponent={() => <Separator />}
showsVerticalScrollIndicator={false}
data={subscribedCommunities.data}
renderItem={({ item, index, separators }) => (
<CommunityCard
community={item}
key={item.name}
onPress={onPressCommunity}
separators={separators}
/>
)}
/>
</View>
)}
</>
)}
<View style={{ height: 40 }} />
</ScrollView>
);
};
const Separator = () => <View style={styles.separator} />;
export default SelectCommunityModalView;
export default injectIntl(SelectCommunityModalView);

View File

@ -291,7 +291,10 @@
"reward_power_up": "Power Up 100%",
"reward_decline": "Decline Payout",
"beneficiaries": "Beneficiaries",
"options": "Options"
"options": "Options",
"my_blog": "My Blog",
"my_communities": "My Communities",
"top_communities": "Top Communities"
},
"pincode": {
"enter_text": "Enter PIN to unlock",

View File

@ -280,7 +280,10 @@ class EditorScreen extends Component {
presentationStyle="pageSheet"
style={styles.modal}
>
<SelectCommunityModalContainer onPressCommunity={this._handlePressCommunity} />
<SelectCommunityModalContainer
onPressCommunity={this._handlePressCommunity}
currentAccount={currentAccount}
/>
</Modal>
<BasicHeader
handleDatePickerChange={(date) => handleDatePickerChange(date, fields)}