mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
fix list top padding on ios
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import React, {useCallback, useEffect, useMemo, useState} from 'react';
|
||||
import {StyleSheet, useWindowDimensions} from 'react-native';
|
||||
import {Dimensions, Platform, RefreshControl, Text, View} from 'react-native';
|
||||
import Orientation from 'react-native-orientation';
|
||||
import {Platform, RefreshControl, StyleSheet, Text, useWindowDimensions, View} from 'react-native';
|
||||
import {initialWindowMetrics} from 'react-native-safe-area-context';
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import {DataProvider, LayoutProvider, RecyclerListView} from 'recyclerlistview';
|
||||
@@ -9,11 +7,7 @@ import {COLORS_NOTE, SIZE, WEIGHT} from '../../common/common';
|
||||
import {useTracked} from '../../provider';
|
||||
import {ACTIONS} from '../../provider/actions';
|
||||
import {eSendEvent} from '../../services/eventManager';
|
||||
import {
|
||||
eClearSearch,
|
||||
eOpenLoginDialog,
|
||||
eScrollEvent,
|
||||
} from '../../services/events';
|
||||
import {eClearSearch, eOpenLoginDialog, eScrollEvent,} from '../../services/events';
|
||||
import {db, ToastEvent} from '../../utils/utils';
|
||||
import {PressableButton} from '../PressableButton';
|
||||
|
||||
@@ -30,7 +24,7 @@ const SimpleList = ({
|
||||
customRefresh,
|
||||
customRefreshing,
|
||||
refreshCallback,
|
||||
}) => {
|
||||
}) => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const {colors, selectionMode, user} = state;
|
||||
const searchResults = {...state.searchResults};
|
||||
@@ -40,12 +34,11 @@ const SimpleList = ({
|
||||
return r1 !== r2;
|
||||
}).cloneWithRows([]),
|
||||
);
|
||||
const {width, height, fontScale,scale} = useWindowDimensions();
|
||||
const {width, fontScale} = useWindowDimensions();
|
||||
|
||||
const listData = data;
|
||||
const dataType = type;
|
||||
const _onScroll = (event) => {
|
||||
|
||||
if (!event) return;
|
||||
let y = event.nativeEvent.contentOffset.y;
|
||||
eSendEvent(eScrollEvent, y);
|
||||
@@ -168,7 +161,9 @@ const SimpleList = ({
|
||||
case 'MAIN_HEADER':
|
||||
dim.width = width;
|
||||
dim.height =
|
||||
(user && user.Id) || !listData[0] || selectionMode ? 0 : 40 * fontScale;
|
||||
(user && user.Id) || !listData[0] || selectionMode
|
||||
? 0
|
||||
: 40 * fontScale;
|
||||
break;
|
||||
default:
|
||||
dim.width = width;
|
||||
@@ -180,13 +175,14 @@ const SimpleList = ({
|
||||
const _renderRow = (type, data, index) => {
|
||||
switch (type) {
|
||||
case 'note':
|
||||
return <RenderItem item={data} pinned={data.pinned} index={index} />;
|
||||
return <RenderItem item={data} pinned={data.pinned} index={index}/>;
|
||||
case 'MAIN_HEADER':
|
||||
return <ListHeaderComponent type={dataType} data={listData} />;
|
||||
return <ListHeaderComponent type={dataType} data={listData}/>;
|
||||
case 'header':
|
||||
return <RenderSectionHeader item={data} />;
|
||||
return <RenderSectionHeader item={data}/>;
|
||||
|
||||
default:
|
||||
s
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -197,10 +193,10 @@ const SimpleList = ({
|
||||
backgroundColor: colors.bg,
|
||||
width: '100%',
|
||||
paddingTop:
|
||||
Platform.OS == 'ios'
|
||||
Platform.OS === 'ios'
|
||||
? listData[0] && !selectionMode
|
||||
? 115
|
||||
: 115 - 60
|
||||
? 130
|
||||
: 130 - 60
|
||||
: listData[0] && !selectionMode
|
||||
? 155 - initialWindowMetrics.insets.top
|
||||
: 155 - initialWindowMetrics.insets.top - 60,
|
||||
@@ -239,7 +235,7 @@ const SimpleList = ({
|
||||
export default SimpleList;
|
||||
|
||||
const SearchHeader = () => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const [state,] = useTracked();
|
||||
const {colors} = state;
|
||||
const searchResults = {...state.searchResults};
|
||||
|
||||
@@ -269,7 +265,7 @@ const SearchHeader = () => {
|
||||
};
|
||||
|
||||
const LoginCard = ({type, data}) => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const [state,] = useTracked();
|
||||
const {colors, selectionMode, user, currentScreen} = state;
|
||||
|
||||
return (
|
||||
@@ -339,13 +335,13 @@ const LoginCard = ({type, data}) => {
|
||||
};
|
||||
|
||||
const ListHeaderComponent = ({type, data}) => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const [state, ] = useTracked();
|
||||
const searchResults = {...state.searchResults};
|
||||
|
||||
return searchResults.type === type && searchResults.results.length > 0 ? (
|
||||
<SearchHeader />
|
||||
<SearchHeader/>
|
||||
) : (
|
||||
<LoginCard type={type} data={data} />
|
||||
<LoginCard type={type} data={data}/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user