Skip to content

Commit 7a5d0da

Browse files
author
Igor Canedo
committed
depthMargin passing by props from getBlocks
1 parent 5af5b47 commit 7a5d0da

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

src/components/OrderedListItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ OrderedListItem.defaultProps = {
7070
counter: 1,
7171
depth: 0,
7272
separator: '.',
73-
defaultMarginLeft: 7,
73+
defaultMarginLeft: 8,
7474
};
7575

7676
export default OrderedListItem;

src/components/UnorderedListItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const UnorderedListItem = (props: UnorderedListItemPropsType): any => {
5959
};
6060

6161
UnorderedListItem.defaultProps = {
62-
defaultMarginLeft: 7,
62+
defaultMarginLeft: 8,
6363
depth: 0,
6464
};
6565

src/getBlocks.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// @flow
88

99
import React from 'react';
10-
import {
11-
View,
12-
} from 'react-native';
10+
import { View } from 'react-native';
1311

1412
import BlockQuote from './components/BlockQuote';
1513
import DraftJsText from './components/DraftJsText';
@@ -23,16 +21,22 @@ type ParamsType = {
2321
atomicHandler: Function,
2422
navigate?: Function,
2523
orderedListSeparator?: string,
26-
customBlockHandler?: (Object, ParamsType) => any
24+
customBlockHandler?: (Object, ParamsType) => any,
25+
depthMargin?: number,
2726
};
2827

28+
export const ViewAfterList = (props: Object): React$Element<*> => (
29+
<View {...props} />
30+
);
31+
2932
const getBlocks = (params: ParamsType): ?Array<*> => {
3033
const {
3134
contentState,
3235
customStyles,
3336
navigate,
3437
orderedListSeparator,
3538
customBlockHandler,
39+
depthMargin,
3640
} = params;
3741
let { atomicHandler } = params;
3842

@@ -55,19 +59,19 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
5559
},
5660
};
5761

58-
function ViewAfterList(): any {
59-
return <View style={customStyles.viewAfterList} />;
60-
}
61-
62-
function checkCounter(counter: Object): any {
62+
const checkCounter = (counter: Object): any => {
6363
const myCounter = counter;
6464

65-
6665
// list types
6766
if (myCounter.count >= 0) {
6867
if (myCounter.count > 0) {
6968
myCounter.count = 0;
70-
return <ViewAfterList key={generateKey()} />;
69+
return (
70+
<ViewAfterList
71+
style={customStyles && customStyles.viewAfterList}
72+
key={generateKey()}
73+
/>
74+
);
7175
}
7276
return null;
7377
}
@@ -76,11 +80,16 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
7680
if (myCounter['unordered-list-item'].count > 0 || myCounter['ordered-list-item'].count > 0) {
7781
myCounter['unordered-list-item'].count = 0;
7882
myCounter['ordered-list-item'].count = 0;
79-
return <ViewAfterList key={generateKey()} />;
83+
return (
84+
<ViewAfterList
85+
style={customStyles && customStyles.viewAfterList}
86+
key={generateKey()}
87+
/>
88+
);
8089
}
8190

8291
return null;
83-
}
92+
};
8493

8594
return contentState.blocks
8695
.map((item: Object): any => {
@@ -158,6 +167,7 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
158167
entityMap={contentState.entityMap}
159168
customStyles={customStyles}
160169
navigate={navigate}
170+
defaultMarginLeft={depthMargin}
161171
/>
162172
</View>
163173
);
@@ -195,6 +205,7 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
195205
entityMap={contentState.entityMap}
196206
customStyles={customStyles}
197207
navigate={navigate}
208+
defaultMarginLeft={depthMargin}
198209
/>
199210
</View>
200211
);
@@ -212,4 +223,4 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
212223
});
213224
};
214225

215-
module.exports = getBlocks;
226+
export default getBlocks;

0 commit comments

Comments
 (0)