fix notebook not loading in list

This commit is contained in:
ammarahm-ed
2020-10-17 13:51:52 +05:00
parent e21d548212
commit 41c8a83670
4 changed files with 11 additions and 15 deletions

View File

@@ -1,23 +1,21 @@
import React from 'react'; import React from 'react';
import {Text, TouchableOpacity, View} from 'react-native'; import {Text, TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import NavigationService from '../../services/Navigation'; import NavigationService from '../../services/Navigation';
import {ActionSheetEvent} from '../DialogManager/recievers'; import {ActionSheetEvent} from '../DialogManager/recievers';
import Seperator from '../Seperator'; import Seperator from '../Seperator';
import {ph, pv, SIZE, WEIGHT} from "../../utils/SizeUtils"; import {ph, pv, SIZE, WEIGHT} from "../../utils/SizeUtils";
import {ActionIcon} from "../ActionIcon";
export const NotebookItem = ({ export const NotebookItem = ({
item, item,
hideMore = false,
isTopic = false, isTopic = false,
notebookID, notebookID,
numColumns,
isTrash, isTrash,
customStyle, customStyle,
}) => { }) => {
const [state, dispatch] = useTracked(); const [state,] = useTracked();
const {colors, selectedItemsList} = state; const {colors,} = state;
return ( return (
<View <View

View File

@@ -12,8 +12,7 @@ export const NotebookItemWrapper = ({
pinned = false, pinned = false,
}) => { }) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {selectionMode, preventDefaultMargins, headerState} = state; const {selectionMode, preventDefaultMargins} = state;
let params = headerState.route.params || {};
const style = useMemo(() => { const style = useMemo(() => {
return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0}; return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};
@@ -76,7 +75,6 @@ export const NotebookItemWrapper = ({
hideMore={preventDefaultMargins} hideMore={preventDefaultMargins}
isTopic={item.type === 'topic'} isTopic={item.type === 'topic'}
customStyle={style} customStyle={style}
noteToMove={params.note}
item={item} item={item}
index={index} index={index}
isTrash={isTrash} isTrash={isTrash}

View File

@@ -58,9 +58,7 @@ const SimpleList = ({
: listData; : listData;
let d = [header, ...mainData]; let d = [header, ...mainData];
/* for (var i = 0; i < 10000; i++) { console.log(d,"D");
d = [...d,...data];
} */
setDataProvider( setDataProvider(
dataProvider.cloneWithRows(d), dataProvider.cloneWithRows(d),
); );
@@ -137,6 +135,7 @@ const SimpleList = ({
return dataProvider.getDataForIndex(index).type; return dataProvider.getDataForIndex(index).type;
}, },
(type, dim) => { (type, dim) => {
console.log(type);
switch (type) { switch (type) {
case 'note': case 'note':
dim.width = width; dim.width = width;
@@ -176,13 +175,14 @@ const SimpleList = ({
switch (type) { switch (type) {
case 'note': case 'note':
return <RenderItem item={data} pinned={data.pinned} index={index}/>; return <RenderItem item={data} pinned={data.pinned} index={index}/>;
case 'notebook':
return <RenderItem item={data} pinned={data.pinned} index={index}/>;
case 'MAIN_HEADER': case 'MAIN_HEADER':
return <ListHeaderComponent type={dataType} data={listData}/>; return <ListHeaderComponent type={dataType} data={listData}/>;
case 'header': case 'header':
return <RenderSectionHeader item={data}/>; return <RenderSectionHeader item={data}/>;
default: default:
s
return null; return null;
} }
}; };

View File

@@ -6,6 +6,8 @@ import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapp
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions'; import {Actions} from '../../provider/Actions';
import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton'; import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';
import note from "notes-core/models/note";
import notebook from "notes-core/models/notebook";
export const Folders = ({route, navigation}) => { export const Folders = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {notebooks} = state; const {notebooks} = state;
@@ -48,7 +50,7 @@ export const Folders = ({route, navigation}) => {
type: Actions.CURRENT_SCREEN, type: Actions.CURRENT_SCREEN,
screen: 'notebooks', screen: 'notebooks',
}); });
console.log(notebooks)
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -87,8 +89,6 @@ export const Folders = ({route, navigation}) => {
focused={() => navigation.isFocused()} focused={() => navigation.isFocused()}
RenderItem={NotebookItemWrapper} RenderItem={NotebookItemWrapper}
placeholder={<Placeholder type="notebooks" />} placeholder={<Placeholder type="notebooks" />}
pinned={true}
placeholderText="Notebooks you add will appear here"
/> />
<ContainerBottomButton <ContainerBottomButton
title="Create a new notebook" title="Create a new notebook"