some cleanup

This commit is contained in:
ammarahm-ed
2020-11-09 19:20:18 +05:00
parent 1deaeba10e
commit 996fa7e9c6

View File

@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react'; import React, {useCallback, useEffect, useState} from 'react';
import { import {
Platform, Platform,
RefreshControl, RefreshControl,
@@ -13,7 +13,6 @@ import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {eSendEvent, ToastEvent} from '../../services/EventManager'; import {eSendEvent, ToastEvent} from '../../services/EventManager';
import { import {
eClearSearch,
eOpenJumpToDialog, eOpenJumpToDialog,
eOpenLoginDialog, eOpenLoginDialog,
eScrollEvent, eScrollEvent,
@@ -33,7 +32,6 @@ const SimpleList = ({
type, type,
placeholder, placeholder,
RenderItem, RenderItem,
focused,
customRefresh, customRefresh,
customRefreshing, customRefreshing,
refreshCallback, refreshCallback,
@@ -55,6 +53,7 @@ const SimpleList = ({
const listData = data; const listData = data;
const dataType = type; const dataType = type;
const _onScroll = (event) => { const _onScroll = (event) => {
console.log(event.nativeEvent);
if (!event) return; if (!event) return;
let y = event.nativeEvent.contentOffset.y; let y = event.nativeEvent.contentOffset.y;
eSendEvent(eScrollEvent, y); eSendEvent(eScrollEvent, y);
@@ -65,15 +64,8 @@ const SimpleList = ({
}, [listData, searchResults.results]); }, [listData, searchResults.results]);
const loadData = () => { const loadData = () => {
let mainData = let mainData = [header, ...listData];
searchResults.type === type && setDataProvider(dataProvider.cloneWithRows(mainData));
focused() &&
searchResults.results.length > 0
? searchResults.results
: listData;
let d = [header, ...mainData];
setDataProvider(dataProvider.cloneWithRows(d));
}; };
const RenderSectionHeader = ({item, index}) => ( const RenderSectionHeader = ({item, index}) => (
@@ -235,6 +227,10 @@ const SimpleList = ({
scrollViewProps={{ scrollViewProps={{
refreshControl: ( refreshControl: (
<RefreshControl <RefreshControl
style={{
opacity: 0,
elevation: 0,
}}
tintColor={colors.accent} tintColor={colors.accent}
colors={[colors.accent]} colors={[colors.accent]}
progressViewOffset={150} progressViewOffset={150}
@@ -242,6 +238,7 @@ const SimpleList = ({
refreshing={customRefresh ? customRefreshing : refreshing} refreshing={customRefresh ? customRefreshing : refreshing}
/> />
), ),
overScrollMode: 'always',
contentContainerStyle: { contentContainerStyle: {
width: '100%', width: '100%',
alignSelf: 'center', alignSelf: 'center',
@@ -252,7 +249,7 @@ const SimpleList = ({
height: '100%', height: '100%',
backgroundColor: colors.bg, backgroundColor: colors.bg,
width: '100%', width: '100%',
paddingTop:10 paddingTop: 10,
}} }}
/> />
); );
@@ -260,36 +257,6 @@ const SimpleList = ({
export default SimpleList; export default SimpleList;
const SearchHeader = () => {
const [state] = useTracked();
const {colors} = state;
const searchResults = {...state.searchResults};
return (
<View style={styles.searchHeader}>
<Text
style={{
fontFamily: WEIGHT.bold,
color: colors.accent,
fontSize: SIZE.xs,
}}>
Showing Results for {searchResults.keyword}
</Text>
<Text
onPress={() => {
eSendEvent(eClearSearch);
}}
style={{
fontFamily: WEIGHT.regular,
color: colors.errorText,
fontSize: SIZE.xs,
}}>
Clear
</Text>
</View>
);
};
const MessageCard = ({data}) => { const MessageCard = ({data}) => {
const [state] = useTracked(); const [state] = useTracked();
const {colors, selectionMode, currentScreen, messageBoardState} = state; const {colors, selectionMode, currentScreen, messageBoardState} = state;