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

View File

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

View File

@ -1,11 +1,11 @@
import React from 'react'; import React from 'react';
import { View, Text, ScrollView, FlatList } from 'react-native'; import { View, Text, ScrollView, FlatList } from 'react-native';
import globalStyles from '../../../../globalStyles'; import { injectIntl } from 'react-intl';
import CommunityCard from '../../../communityCard'; import CommunityCard from '../../../communityCard';
import { SearchInput } from '../../../searchInput'; import { SearchInput } from '../../../searchInput';
import globalStyles from '../../../../globalStyles';
import styles from './selectCommunityModalStyles'; import styles from './selectCommunityModalStyles';
const SelectCommunityModalView = ({ const SelectCommunityModalView = ({
@ -16,7 +16,10 @@ const SelectCommunityModalView = ({
onPressCloseForSearch, onPressCloseForSearch,
searchedCommunities, searchedCommunities,
showSearchedCommunities, showSearchedCommunities,
currentAccount,
intl,
}) => { }) => {
console.log(subscribedCommunities, 'subscribedCommunities');
return ( return (
<ScrollView style={{ flex: 1 }} showsVerticalScrollIndicator={false}> <ScrollView style={{ flex: 1 }} showsVerticalScrollIndicator={false}>
<SearchInput onChangeText={onChangeSearch} placeholder="search" autoFocus={false} /> <SearchInput onChangeText={onChangeSearch} placeholder="search" autoFocus={false} />
@ -29,7 +32,7 @@ const SelectCommunityModalView = ({
renderItem={({ item, index, separators }) => ( renderItem={({ item, index, separators }) => (
<CommunityCard <CommunityCard
community={item} community={item}
key={item.name} key={index}
onPress={onPressCommunity} onPress={onPressCommunity}
separators={separators} 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 <CommunityCard
community={{ name: 'furkankilic', title: 'My Blog' }} community={{
name: currentAccount.name,
title: intl.formatMessage({ id: 'editor.my_blog' }),
}}
onPress={() => onPressCommunity(null)} 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 && ( {!topCommunities.loading && !topCommunities.error && topCommunities.data.length > 0 && (
<View> <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 <FlatList
ItemSeparatorComponent={() => <Separator />} ItemSeparatorComponent={() => <Separator />}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
@ -60,32 +96,13 @@ const SelectCommunityModalView = ({
/> />
</View> </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> </ScrollView>
); );
}; };
const Separator = () => <View style={styles.separator} />; 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_power_up": "Power Up 100%",
"reward_decline": "Decline Payout", "reward_decline": "Decline Payout",
"beneficiaries": "Beneficiaries", "beneficiaries": "Beneficiaries",
"options": "Options" "options": "Options",
"my_blog": "My Blog",
"my_communities": "My Communities",
"top_communities": "Top Communities"
}, },
"pincode": { "pincode": {
"enter_text": "Enter PIN to unlock", "enter_text": "Enter PIN to unlock",

View File

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