Merge pull request #1792 from ecency/communities

Communities
This commit is contained in:
Feruz M 2020-12-09 15:05:57 +02:00 committed by GitHub
commit 2ac0b5f342
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 133 additions and 45 deletions

View File

@ -143,7 +143,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "3.0.10"
versionName "3.0.11"
resValue "string", "build_config_package", "app.esteem.mobile.android"
multiDexEnabled true
// react-native-image-crop-picker

View File

@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.10</string>
<string>3.0.11</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2560</string>
<string>2561</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.10</string>
<string>3.0.11</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2560</string>
<string>2561</string>
</dict>
</plist>

View File

@ -1104,7 +1104,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2560;
CURRENT_PROJECT_VERSION = 2561;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 75B6RXTKGT;
HEADER_SEARCH_PATHS = (
@ -1180,7 +1180,7 @@
CODE_SIGN_ENTITLEMENTS = Ecency/Ecency.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2560;
CURRENT_PROJECT_VERSION = 2561;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 75B6RXTKGT;
HEADER_SEARCH_PATHS = (

View File

@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.10</string>
<string>3.0.11</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.10</string>
<string>3.0.11</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2560</string>
<string>2561</string>
</dict>
</plist>

View File

@ -401,8 +401,8 @@ PODS:
- React-Core
- React-RCTImage
- RSKImageCropper
- RNReanimated (1.10.2):
- React
- RNReanimated (1.13.2):
- React-Core
- RNScreens (2.10.1):
- React
- RNSVG (9.13.6):
@ -696,7 +696,7 @@ SPEC CHECKSUMS:
RNGestureHandler: b6b359bb800ae399a9c8b27032bdbf7c18f08a08
RNIap: b4c77c8bc4501203f4b743126a05da23f10f40b4
RNImageCropPicker: 9d1a7eea4f8368fc479cbd2bf26459bd3c74d9aa
RNReanimated: 7de2dca51deacff78bb880f63c1389a24311b376
RNReanimated: e03f7425cb7a38dcf1b644d680d1bfc91c3337ad
RNScreens: b748efec66e095134c7166ca333b628cd7e6f3e2
RNSVG: 8ba35cbeb385a52fd960fd28db9d7d18b4c2974f
RNVectorIcons: 368d6d8b8301224e5ffb6254191f4f8876c2be0d

View File

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>3.0.10</string>
<string>3.0.11</string>
<key>CFBundleVersion</key>
<string>2560</string>
<string>2561</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>

View File

@ -1,6 +1,6 @@
{
"name": "ecency",
"version": "3.0.10",
"version": "3.0.11",
"displayName": "Ecency",
"private": true,
"rnpm": {

View File

@ -527,15 +527,16 @@
"others": "Others",
"communities": {
"title": "Communities",
"subscribe": "Subscribe",
"unsubscribe": "Unsubscribe",
"subscribers": "Subscribers",
"subscribe": "Join",
"unsubscribe": "Leave",
"subscribers": "Members",
"posters": "Posters",
"posts": "Posts"
},
"communities_filter": {
"my": "My Communities",
"rank": "Rank",
"subs": "Subscribers",
"subs": "Members",
"new": "New"
},
"post_result_filter": {

View File

@ -17,22 +17,32 @@ const CommunitiesContainer = ({
isLoggedIn,
}) => {
const [data, setData] = useState();
const [filterIndex, setFilterIndex] = useState(0);
const [filterIndex, setFilterIndex] = useState(1);
const [query, setQuery] = useState('');
const [sort, setSort] = useState('rank');
const [allSubscriptions, setAllSubscriptions] = useState([]);
const [noResult, setNoResult] = useState(false);
useEffect(() => {
let isCancelled = false;
setData([]);
getCommunities('', 100, query, sort).then((res) => {
if (!isEmpty(res)) {
setData(res);
setNoResult(false);
} else {
setNoResult(true);
}
});
if (sort === 'my') {
setNoResult(true);
} else {
getCommunities('', 100, query, sort).then((res) => {
if (!isCancelled) {
if (!isEmpty(res)) {
setData(res);
setNoResult(false);
} else {
setNoResult(true);
}
}
});
}
return () => {
isCancelled = true;
};
}, [query, sort]);
useEffect(() => {
@ -42,13 +52,17 @@ const CommunitiesContainer = ({
}, [searchValue]);
useEffect(() => {
if (data) {
let isCancelled = false;
if (data && !isCancelled) {
getSubscriptions(currentAccount.username).then((result) => {
if (result) {
setAllSubscriptions(result);
}
});
}
return () => {
isCancelled = true;
};
}, [data]);
// Component Functions

View File

@ -1,20 +1,35 @@
import React from 'react';
import { useIntl } from 'react-intl';
import { FlatList, View, Text, TouchableOpacity } from 'react-native';
import get from 'lodash/get';
// Components
import { FilterBar } from '../../../components';
import { FilterBar, UserAvatar } from '../../../components';
import CommunitiesList from './communitiesList';
import { CommunitiesPlaceHolder } from '../../../components/basicUIElements';
import CommunitiesContainer from '../container/communitiesContainer';
import styles from './otherResultsStyles';
import DEFAULT_IMAGE from '../../../assets/no_image.png';
import Tag from '../../../components/basicUIElements/view/tag/tagView';
const filterOptions = ['rank', 'subs', 'new'];
const filterOptions = ['my', 'rank', 'subs', 'new'];
const CommunitiesScreen = ({ navigation, searchValue }) => {
const intl = useIntl();
const activeVotes = get(navigation, 'state.params.activeVotes');
const _renderEmptyContent = () => {
return (
<>
<CommunitiesPlaceHolder />
<CommunitiesPlaceHolder />
<CommunitiesPlaceHolder />
</>
);
};
return (
<CommunitiesContainer data={activeVotes} searchValue={searchValue}>
{({
@ -41,14 +56,49 @@ const CommunitiesScreen = ({ navigation, searchValue }) => {
selectedOptionIndex={filterIndex}
onDropdownSelect={(index) => handleOnVotersDropdownSelect(index, filterOptions[index])}
/>
<CommunitiesList
votes={data}
allSubscriptions={allSubscriptions}
handleOnPress={handleOnPress}
handleSubscribeButtonPress={handleSubscribeButtonPress}
isLoggedIn={isLoggedIn}
noResult={noResult}
/>
{filterIndex !== 0 && (
<CommunitiesList
votes={data}
allSubscriptions={allSubscriptions}
handleOnPress={handleOnPress}
handleSubscribeButtonPress={handleSubscribeButtonPress}
isLoggedIn={isLoggedIn}
noResult={noResult}
/>
)}
{filterIndex === 0 && allSubscriptions && allSubscriptions.length > 0 && (
<FlatList
data={allSubscriptions}
//keyExtractor={(item, ind) => `${item}-${ind}`}
renderItem={({ item, index }) => (
<View style={[styles.communityWrapper, index % 2 !== 0 && styles.itemWrapperGray]}>
<View style={{ flex: 3, flexDirection: 'row' }}>
<TouchableOpacity onPress={() => handleOnPress(item[0])}>
<UserAvatar username={item[0]} defaultSource={DEFAULT_IMAGE} noAction />
</TouchableOpacity>
<TouchableOpacity onPress={() => handleOnPress(item[0])}>
<Text style={styles.username}>{item[1]}</Text>
</TouchableOpacity>
</View>
<View style={{ flex: 1 }}>
<Tag
style={styles.subscribeButton}
textStyle={styles.subscribeButtonText}
value={intl.formatMessage({
id: 'search_result.communities.unsubscribe',
})}
isPin={false}
isFilter
onPress={() =>
handleSubscribeButtonPress({ isSubscribed: true, communityId: item[0] })
}
/>
</View>
</View>
)}
ListEmptyComponent={_renderEmptyContent}
/>
)}
</>
)}
</CommunitiesContainer>

View File

@ -30,25 +30,29 @@ export default EStyleSheet.create({
fontSize: 14,
fontFamily: '$primaryFont',
marginTop: 5,
paddingTop: 10,
color: '$primaryBlack',
},
separator: {
width: 100,
alignSelf: 'center',
backgroundColor: '$primaryDarkGray',
height: 0.5,
marginVertical: 5,
height: 1,
marginVertical: 10,
},
stats: {
fontSize: 14,
fontFamily: '$primaryFont',
color: '$primaryDarkGray',
paddingBottom: 10,
},
subscribeButton: {
borderWidth: 1,
maxWidth: 75,
borderColor: '$primaryBlue',
},
subscribeButtonText: {
textAlign: 'center',
color: '$primaryBlue',
},
header: {

View File

@ -21,4 +21,23 @@ export default EStyleSheet.create({
marginLeft: 10,
color: '$primaryBlack',
},
communityWrapper: {
paddingHorizontal: 16,
paddingTop: 16,
paddingBottom: 8,
borderRadius: 8,
backgroundColor: '$primaryBackgroundColor',
flexDirection: 'row',
alignItems: 'center',
flex: 1,
},
subscribeButton: {
maxWidth: 75,
borderWidth: 1,
borderColor: '$primaryBlue',
},
subscribeButtonText: {
textAlign: 'center',
color: '$primaryBlue',
},
});

View File

@ -7615,9 +7615,9 @@ react-native-qrcode-svg@^6.0.3:
qrcode "^1.3.2"
react-native-reanimated@^1.3.0:
version "1.10.2"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.10.2.tgz#012fd0ddb5f64c82b5df66d4d0e19cb9e95e4b41"
integrity sha512-Bg/FvpK3todfdW8u77M6xKR/n0f6h/z3FVdVbYJR3j47Xibb5BKlrWkG/tc5IE4syePrxK8Nkq0Ja2+tscnUlQ==
version "1.13.2"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.13.2.tgz#1ae5457b24b4913d173a5a064bb28eae7783d293"
integrity sha512-O+WhgxSjOIzcVdAAvx+h2DY331Ek1knKlaq+jsNLpC1fhRy9XTdOObovgob/aF2ve9uJfPEawCx8381g/tUJZQ==
dependencies:
fbjs "^1.0.0"