Skip to content

Commit

Permalink
Merge pull request #1 from murilo-campaner/render-search
Browse files Browse the repository at this point in the history
Added renderSearch feature
  • Loading branch information
murilo-campaner authored Mar 25, 2020
2 parents 934e843 + fc9f011 commit b54f0b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 18 additions & 11 deletions src/Components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ModalComponent extends React.PureComponent<IModalProps, IModalState
}

public render(): JSX.Element {
const { autoSort, modalAnimationType, onClosed, showAlphabeticalIndex, searchInputTextColor, keyExtractor, showToTopButton, onEndReached, removeClippedSubviews, FlatListProps, selectPlaceholderText, searchPlaceholderText, SearchInputProps, selected, disabled, items, requireSelection, renderSelectView, ModalProps, backButtonDisabled} = this.props;
const { autoSort, modalAnimationType, onClosed, showAlphabeticalIndex, searchInputTextColor, keyExtractor, showToTopButton, onEndReached, removeClippedSubviews, FlatListProps, selectPlaceholderText, searchPlaceholderText, SearchInputProps, selected, disabled, items, requireSelection, renderSelectView, ModalProps, backButtonDisabled, renderSearch } = this.props;

const { modalVisible, alphabeticalIndexChars, stickyBottomButton, selectedAlpha, selectedObject, searchText } = this.state;

Expand All @@ -93,16 +93,23 @@ export class ModalComponent extends React.PureComponent<IModalProps, IModalState
{...ModalProps}
>
<SafeAreaView style={ModalStyles.container}>
<SearchComponent
searchText={searchPlaceholderText}
placeholderTextColor={searchInputTextColor}
onClose={this.onClose.bind(this)}
onBackRequest={this.onBackRequest.bind(this)}
forceSelect={requireSelection}
setText={(text: string) => this.setText(text)}
backButtonDisabled={backButtonDisabled}
{...SearchInputProps}
/>
{
renderSearch ? renderSearch(
this.onClose.bind(this),
this.onBackRequest.bind(this)
) : (
<SearchComponent
searchText={searchPlaceholderText}
placeholderTextColor={searchInputTextColor}
onClose={this.onClose.bind(this)}
onBackRequest={this.onBackRequest.bind(this)}
forceSelect={requireSelection}
setText={(text: string) => this.setText(text)}
backButtonDisabled={backButtonDisabled}
{...SearchInputProps}
/>
)
}
<KeyboardAvoidingView style={ModalStyles.keyboardContainer}
behavior={Platform.OS === 'ios' ? 'padding' : null}
enabled>
Expand Down
3 changes: 2 additions & 1 deletion src/Interfaces/IModalProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export interface IModalProps {
requireSelection: boolean;
renderListItem?: (selectedItem: IModalListInDto, listItem: IModalListInDto) => JSX.Element
renderSelectView?: (disabled: boolean, selected: IModalListInDto, showModal: () => void) => React.ReactElement
backButtonDisabled?: boolean
backButtonDisabled?: boolean,
renderSearch?: (onClose: () => void, onBack: () => void ) => JSX.Element,
}

export interface IModalState {
Expand Down

0 comments on commit b54f0b2

Please sign in to comment.