mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 22:03:21 +03:00
successfully rendering app navigation
This commit is contained in:
parent
d742d3a5a8
commit
154339538c
@ -3,7 +3,6 @@ import { get } from 'lodash';
|
||||
import { FlatListProps, FlatList, RefreshControl, ActivityIndicator, View } from 'react-native';
|
||||
import { useSelector } from 'react-redux';
|
||||
import PostCard from '../../postCard';
|
||||
import { ThemeContainer } from '../../../containers';
|
||||
import styles from '../view/postsListStyles';
|
||||
|
||||
export interface PostsListRef {
|
||||
@ -40,6 +39,7 @@ const postsListContainer = (
|
||||
const [imageHeights, setImageHeights] = useState(new Map<string, number>());
|
||||
|
||||
const isHideImages = useSelector((state) => state.application.hidePostsThumbnails);
|
||||
const isDarkTheme = useSelector((state) => state.application.isDarkThem);
|
||||
const posts = useSelector((state) => {
|
||||
return isFeedScreen ? state.posts.feedPosts : state.posts.otherPosts;
|
||||
});
|
||||
@ -152,48 +152,46 @@ const postsListContainer = (
|
||||
);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
}};
|
||||
|
||||
return (
|
||||
<ThemeContainer>
|
||||
{({ isDarkTheme }) => (
|
||||
<FlatList
|
||||
ref={flatListRef}
|
||||
data={posts}
|
||||
showsVerticalScrollIndicator={false}
|
||||
renderItem={_renderItem}
|
||||
keyExtractor={(content, index) => `${content.author}/${content.permlink}-${index}`}
|
||||
removeClippedSubviews
|
||||
onEndReachedThreshold={1}
|
||||
maxToRenderPerBatch={3}
|
||||
initialNumToRender={3}
|
||||
windowSize={5}
|
||||
extraData={imageHeights}
|
||||
onEndReached={_onEndReached}
|
||||
onMomentumScrollBegin={() => {
|
||||
_onEndReachedCalledDuringMomentum = false;
|
||||
|
||||
<FlatList
|
||||
ref={flatListRef}
|
||||
data={posts}
|
||||
showsVerticalScrollIndicator={false}
|
||||
renderItem={_renderItem}
|
||||
keyExtractor={(content, index) => `${content.author}/${content.permlink}-${index}`}
|
||||
removeClippedSubviews
|
||||
onEndReachedThreshold={1}
|
||||
maxToRenderPerBatch={3}
|
||||
initialNumToRender={3}
|
||||
windowSize={5}
|
||||
extraData={imageHeights}
|
||||
onEndReached={_onEndReached}
|
||||
onMomentumScrollBegin={() => {
|
||||
_onEndReachedCalledDuringMomentum = false;
|
||||
}}
|
||||
ListFooterComponent={_renderFooter}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={isRefreshing}
|
||||
onRefresh={() => {
|
||||
if (onLoadPosts) {
|
||||
onLoadPosts(true);
|
||||
}
|
||||
}}
|
||||
ListFooterComponent={_renderFooter}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={isRefreshing}
|
||||
onRefresh={() => {
|
||||
if (onLoadPosts) {
|
||||
onLoadPosts(true);
|
||||
}
|
||||
}}
|
||||
progressBackgroundColor="#357CE6"
|
||||
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
|
||||
titleColor="#fff"
|
||||
colors={['#fff']}
|
||||
/>
|
||||
}
|
||||
{...props}
|
||||
progressBackgroundColor="#357CE6"
|
||||
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
|
||||
titleColor="#fff"
|
||||
colors={['#fff']}
|
||||
/>
|
||||
)}
|
||||
</ThemeContainer>
|
||||
}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
export default forwardRef(postsListContainer);
|
||||
|
@ -19,56 +19,57 @@ export const TabbedPosts = ({
|
||||
stackedTabs,
|
||||
onTabChange,
|
||||
...props
|
||||
}:TabbedPostsProps) => {
|
||||
}: TabbedPostsProps) => {
|
||||
|
||||
//initialize state
|
||||
const [initialTabIndex] = useState(selectedOptionIndex == 0 && stackedTabs ? filterOptions.length : selectedOptionIndex)
|
||||
|
||||
const mainFilters = filterOptions.map((label, index)=>({
|
||||
filterKey:filterOptionsValue[index],
|
||||
label
|
||||
} as TabItem));
|
||||
const mainFilters = filterOptions.map((label, index) => ({
|
||||
filterKey: filterOptionsValue[index],
|
||||
label
|
||||
} as TabItem));
|
||||
|
||||
const subFilters = feedSubfilterOptions
|
||||
? feedSubfilterOptions.map((label, index)=>({
|
||||
filterKey:feedSubfilterOptionsValue[index],
|
||||
? feedSubfilterOptions.map((label, index) => ({
|
||||
filterKey: feedSubfilterOptionsValue[index],
|
||||
label
|
||||
} as TabItem))
|
||||
: [];
|
||||
|
||||
const combinedFilters = [...mainFilters, ...subFilters]
|
||||
|
||||
|
||||
const [selectedFilter, setSelectedFilter] = useState(combinedFilters[initialTabIndex].filterKey)
|
||||
const [filterScrollRequest, createFilterScrollRequest] = useState<string|null>(null)
|
||||
const [filterScrollRequest, createFilterScrollRequest] = useState<string | null>(null)
|
||||
|
||||
|
||||
|
||||
//components actions
|
||||
const _onFilterSelect = (filter:string) => {
|
||||
if(filter === selectedFilter){
|
||||
createFilterScrollRequest(selectedFilter)
|
||||
}else{
|
||||
setSelectedFilter(filter)
|
||||
}
|
||||
//components actions
|
||||
const _onFilterSelect = (filter: string) => {
|
||||
if (filter === selectedFilter) {
|
||||
createFilterScrollRequest(selectedFilter)
|
||||
} else {
|
||||
setSelectedFilter(filter)
|
||||
}
|
||||
}
|
||||
|
||||
const _onScrollRequestProcessed = () => {
|
||||
createFilterScrollRequest(null);
|
||||
}
|
||||
const _onScrollRequestProcessed = () => {
|
||||
createFilterScrollRequest(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//initialize first set of pages
|
||||
const pages = combinedFilters.map((filter, index)=>{
|
||||
if(tabContentOverrides && tabContentOverrides.has(index)){
|
||||
const pages = combinedFilters.map((filter, index) => {
|
||||
if (tabContentOverrides && tabContentOverrides.has(index)) {
|
||||
return tabContentOverrides.get(index);
|
||||
}
|
||||
return (
|
||||
|
||||
return (
|
||||
<TabContent
|
||||
key={filter.filterKey}
|
||||
filterKey={filter.filterKey}
|
||||
isFeedScreen={isFeedScreen}
|
||||
isInitialTab={ initialTabIndex == index }
|
||||
isInitialTab={initialTabIndex == index}
|
||||
feedUsername={feedUsername}
|
||||
pageType={pageType}
|
||||
filterScrollRequest={filterScrollRequest}
|
||||
@ -82,7 +83,7 @@ export const TabbedPosts = ({
|
||||
//render tab bar
|
||||
const _renderTabBar = (props) => {
|
||||
return (
|
||||
<StackedTabBar
|
||||
<StackedTabBar
|
||||
{...props}
|
||||
firstStack={mainFilters}
|
||||
secondStack={subFilters}
|
||||
@ -102,7 +103,7 @@ export const TabbedPosts = ({
|
||||
initialPage={initialTabIndex}
|
||||
renderTabBar={_renderTabBar}
|
||||
onTabChange={onTabChange}
|
||||
>
|
||||
>
|
||||
{pages}
|
||||
</ScrollableTabView>
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { StatusBar, Platform, View, Alert, Text } from 'react-native';
|
||||
import { StatusBar, Platform, View, Alert } from 'react-native';
|
||||
import EStyleSheet from 'react-native-extended-stylesheet';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
@ -116,9 +116,7 @@ class ApplicationScreen extends Component {
|
||||
{!isConnected && <NoInternetConnection />}
|
||||
|
||||
<AppNavigator />
|
||||
{/* <Text style={{ flex: 1, justifyContent: 'center', alignItems: 'center', color: 'green' }}> */}
|
||||
{/* I am working though */}
|
||||
{/* </Text> */}
|
||||
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Fragment, useState } from 'react';
|
||||
import { SafeAreaView } from 'react-native';
|
||||
import { View, Text } from 'react-native';
|
||||
import get from 'lodash/get';
|
||||
|
||||
// Components
|
||||
@ -36,7 +36,8 @@ const FeedScreen = () => {
|
||||
{({ currentAccount }) => (
|
||||
<Fragment>
|
||||
<Header showQR={true} />
|
||||
<SafeAreaView style={styles.container} onLayout={_lazyLoadContent}>
|
||||
<View style={styles.container} onLayout={_lazyLoadContent}>
|
||||
|
||||
{lazyLoad && (
|
||||
<TabbedPosts
|
||||
key={JSON.stringify(filterOptions)} // this hack of key change resets tabbedposts whenever filters chanage, effective to remove filter change android bug
|
||||
@ -49,7 +50,7 @@ const FeedScreen = () => {
|
||||
pageType="main"
|
||||
/>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
</Fragment>
|
||||
)}
|
||||
</AccountContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user