implement suggested subscriptions modal
This commit is contained in:
parent
5fc6bc50c3
commit
6958cdcfcb
6 changed files with 137 additions and 19 deletions
4
src/component/modalSuggestedSubscriptions/index.js
Normal file
4
src/component/modalSuggestedSubscriptions/index.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import ModalSuggestedSubscriptions from './view';
|
||||||
|
|
||||||
|
export default connect()(ModalSuggestedSubscriptions);
|
26
src/component/modalSuggestedSubscriptions/view.js
Normal file
26
src/component/modalSuggestedSubscriptions/view.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||||
|
import modalStyle from 'styles/modal';
|
||||||
|
import subscriptionsStyle from 'styles/subscriptions';
|
||||||
|
import Button from 'component/button';
|
||||||
|
import Colors from 'styles/colors';
|
||||||
|
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||||
|
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||||
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||||
|
|
||||||
|
export default class ModalSuggestedSubcriptions extends React.PureComponent {
|
||||||
|
render() {
|
||||||
|
const { navigation, onDonePress, onOverlayPress } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TouchableOpacity style={modalStyle.overlay} activeOpacity={1} onPress={onOverlayPress}>
|
||||||
|
<TouchableOpacity style={[modalStyle.container, subscriptionsStyle.modalContainer]} activeOpacity={1}>
|
||||||
|
<SuggestedSubscriptions inModal navigation={navigation} />
|
||||||
|
<View style={modalStyle.buttons}>
|
||||||
|
<Button style={modalStyle.doneButton} text={'Done'} onPress={onDonePress} />
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ActivityIndicator, FlatList, SectionList, Text, View } from 'react-native';
|
import { ActivityIndicator, SectionList, Text, View } from 'react-native';
|
||||||
import { MATURE_TAGS, createNormalizedClaimSearchKey, normalizeURI } from 'lbry-redux';
|
import { MATURE_TAGS, createNormalizedClaimSearchKey, normalizeURI } from 'lbry-redux';
|
||||||
import { __, navigateToUri } from 'utils/helper';
|
import { __, navigateToUri } from 'utils/helper';
|
||||||
import SubscribeButton from 'component/subscribeButton';
|
import SubscribeButton from 'component/subscribeButton';
|
||||||
|
@ -49,7 +49,7 @@ class SuggestedSubscriptions extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { suggested, loading, navigation } = this.props;
|
const { suggested, inModal, loading, navigation } = this.props;
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
|
@ -61,8 +61,10 @@ class SuggestedSubscriptions extends React.PureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SectionList
|
<SectionList
|
||||||
style={subscriptionsStyle.scrollContainer}
|
style={inModal ? subscriptionsStyle.modalScrollContainer : subscriptionsStyle.scrollContainer}
|
||||||
contentContainerStyle={subscriptionsStyle.suggestedScrollPadding}
|
contentContainerStyle={
|
||||||
|
inModal ? subscriptionsStyle.modalSuggestedScrollContent : subscriptionsStyle.suggestedScrollContent
|
||||||
|
}
|
||||||
renderItem={({ item, index, section }) => (
|
renderItem={({ item, index, section }) => (
|
||||||
<SuggestedSubscriptionItem key={item} uri={normalizeURI(item)} navigation={navigation} />
|
<SuggestedSubscriptionItem key={item} uri={normalizeURI(item)} navigation={navigation} />
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import FileItem from 'component/fileItem';
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||||
import Link from 'component/link';
|
import Link from 'component/link';
|
||||||
import ModalPicker from 'component/modalPicker';
|
import ModalPicker from 'component/modalPicker';
|
||||||
|
import ModalSuggestedSubscriptions from 'component/modalSuggestedSubscriptions';
|
||||||
import SubscribedChannelList from 'component/subscribedChannelList';
|
import SubscribedChannelList from 'component/subscribedChannelList';
|
||||||
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||||
import UriBar from 'component/uriBar';
|
import UriBar from 'component/uriBar';
|
||||||
|
@ -34,6 +35,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
showingSuggestedSubs: false,
|
showingSuggestedSubs: false,
|
||||||
showSortPicker: false,
|
showSortPicker: false,
|
||||||
showTimePicker: false,
|
showTimePicker: false,
|
||||||
|
showModalSuggestedSubs: false,
|
||||||
orderBy: ['release_time'],
|
orderBy: ['release_time'],
|
||||||
filteredChannels: [],
|
filteredChannels: [],
|
||||||
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1], // should always default to sorting subscriptions by new
|
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1], // should always default to sorting subscriptions by new
|
||||||
|
@ -122,7 +124,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
unreadSubscriptions,
|
unreadSubscriptions,
|
||||||
navigation,
|
navigation,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { currentSortByItem, filteredChannels, showSortPicker, showTimePicker } = this.state;
|
const { currentSortByItem, filteredChannels, showModalSuggestedSubs, showSortPicker, showTimePicker } = this.state;
|
||||||
|
|
||||||
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
||||||
const hasSubscriptions = numberOfSubscriptions > 0;
|
const hasSubscriptions = numberOfSubscriptions > 0;
|
||||||
|
@ -151,6 +153,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
</View>
|
</View>
|
||||||
{!this.state.showingSuggestedSubs && hasSubscriptions && (
|
{!this.state.showingSuggestedSubs && hasSubscriptions && (
|
||||||
<View style={subscriptionsStyle.pickerRow}>
|
<View style={subscriptionsStyle.pickerRow}>
|
||||||
|
<View style={subscriptionsStyle.leftPickerRow}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={subscriptionsStyle.tagSortBy}
|
style={subscriptionsStyle.tagSortBy}
|
||||||
onPress={() => this.setState({ showSortPicker: true })}
|
onPress={() => this.setState({ showSortPicker: true })}
|
||||||
|
@ -169,6 +172,13 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<Link
|
||||||
|
style={subscriptionsStyle.suggestedLink}
|
||||||
|
text={'Suggested'}
|
||||||
|
onPress={() => this.setState({ showModalSuggestedSubs: true })}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
{!this.state.showingSuggestedSubs && hasSubscriptions && !loading && (
|
{!this.state.showingSuggestedSubs && hasSubscriptions && !loading && (
|
||||||
<View style={subscriptionsStyle.subContainer}>
|
<View style={subscriptionsStyle.subContainer}>
|
||||||
|
@ -223,7 +233,9 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!showSortPicker && !showTimePicker && <FloatingWalletBalance navigation={navigation} />}
|
{!showSortPicker && !showTimePicker && !showModalSuggestedSubs && (
|
||||||
|
<FloatingWalletBalance navigation={navigation} />
|
||||||
|
)}
|
||||||
{showSortPicker && (
|
{showSortPicker && (
|
||||||
<ModalPicker
|
<ModalPicker
|
||||||
title={__('Sort content by')}
|
title={__('Sort content by')}
|
||||||
|
@ -242,6 +254,13 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{showModalSuggestedSubs && (
|
||||||
|
<ModalSuggestedSubscriptions
|
||||||
|
navigation={navigation}
|
||||||
|
onOverlayPress={() => this.setState({ showModalSuggestedSubs: false })}
|
||||||
|
onDonePress={() => this.setState({ showModalSuggestedSubs: false })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
48
src/styles/modal.js
Normal file
48
src/styles/modal.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
import Colors from './colors';
|
||||||
|
|
||||||
|
const modalPickerStyle = StyleSheet.create({
|
||||||
|
overlay: {
|
||||||
|
backgroundColor: '#00000055',
|
||||||
|
flex: 1,
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
zIndex: 300,
|
||||||
|
},
|
||||||
|
overlayTouchArea: {
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
position: 'absolute',
|
||||||
|
left: 8,
|
||||||
|
right: 8,
|
||||||
|
bottom: 8,
|
||||||
|
borderRadius: 8,
|
||||||
|
backgroundColor: Colors.White,
|
||||||
|
overflow: 'hidden',
|
||||||
|
},
|
||||||
|
paddedContatiner: {
|
||||||
|
padding: 12,
|
||||||
|
},
|
||||||
|
buttons: {
|
||||||
|
marginTop: 16,
|
||||||
|
left: 8,
|
||||||
|
bottom: 8,
|
||||||
|
position: 'absolute',
|
||||||
|
},
|
||||||
|
doneButton: {
|
||||||
|
alignSelf: 'flex-start',
|
||||||
|
backgroundColor: Colors.LbryGreen,
|
||||||
|
paddingLeft: 16,
|
||||||
|
paddingRight: 16,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default modalPickerStyle;
|
|
@ -13,7 +13,7 @@ const subscriptionsStyle = StyleSheet.create({
|
||||||
suggestedSubsContainer: {
|
suggestedSubsContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
suggestedScrollPadding: {
|
suggestedScrollContent: {
|
||||||
paddingTop: 8,
|
paddingTop: 8,
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
|
@ -159,6 +159,7 @@ const subscriptionsStyle = StyleSheet.create({
|
||||||
pickerRow: {
|
pickerRow: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
marginLeft: 16,
|
marginLeft: 16,
|
||||||
marginRight: 16,
|
marginRight: 16,
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
|
@ -245,6 +246,24 @@ const subscriptionsStyle = StyleSheet.create({
|
||||||
marginRight: 4,
|
marginRight: 4,
|
||||||
marginBottom: 4,
|
marginBottom: 4,
|
||||||
},
|
},
|
||||||
|
leftPickerRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
suggestedLink: {
|
||||||
|
fontFamily: 'Inter-UI-Regular',
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
modalContainer: {
|
||||||
|
height: '80%',
|
||||||
|
backgroundColor: Colors.PageBackground,
|
||||||
|
},
|
||||||
|
modalScrollContainer: {
|
||||||
|
marginBottom: 50,
|
||||||
|
},
|
||||||
|
modalSuggestedScrollContent: {
|
||||||
|
paddingTop: 16,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default subscriptionsStyle;
|
export default subscriptionsStyle;
|
||||||
|
|
Loading…
Reference in a new issue