Skip to content

Dialog button style individually configurable #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions src/interface/paperSelect.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export interface paperSelect {
textInputColor?: string;
textInputHeight?: number;
textInputStyle?: TextStyle;
dialogButtonLabelStyle?: TextStyle;
hideSearchBox?: boolean;
searchPlaceholder?: string;
modalCloseButtonText?: string;
modalDoneButtonText?: string;
dialogCloseButtonText?: string;
dialogDoneButtonText?: string;
dialogCloseButtonStyle?: TextStyle;
dialogDoneButtonStyle?: TextStyle;
theme?: {
dark?: boolean;
mode?: 'adaptive' | 'exact';
Expand Down
36 changes: 18 additions & 18 deletions src/module/paperSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ const PaperSelect = ({
textInputColor,
textInputHeight,
textInputStyle,
dialogButtonLabelStyle,
hideSearchBox,
searchPlaceholder,
modalCloseButtonText,
modalDoneButtonText,
theme
searchPlaceholder = "Search",
dialogCloseButtonText = 'Close',
dialogDoneButtonText = 'Done',
dialogCloseButtonStyle,
dialogDoneButtonStyle,
theme,
}: paperSelect) => {
const [searchKey, setSearchKey] = useState<string>('');

Expand All @@ -72,15 +73,15 @@ const PaperSelect = ({

const _hideDialog = () => {
setSearchKey("");
var data: Array<list> = [...arrayHolder];
let data: Array<list> = [...arrayHolder];
// console.log(selectedList);
var selectedData: Array<list> = [...selectedList];
let selectedData: Array<list> = [...selectedList];
// console.log(selectedData);
let finalText: string = "";
selectedData.forEach((val, index) => {
data.forEach((el) => {
if (val._id === el._id) {
finalText += (index !== selectedData.length - 1) ? `${el.value}, ` : `${el.value}`;
finalText += index !== selectedData.length - 1 ? `${el.value}, ` : `${el.value}`;
}
});
});
Expand All @@ -90,7 +91,6 @@ const PaperSelect = ({
selectedList: selectedData,
});


setVisible(false);

if (selectInputRef && selectInputRef.current) {
Expand All @@ -114,7 +114,7 @@ const PaperSelect = ({
};

const _onChecked = (item: any) => {
var selectedData = [...selectedList];
let selectedData = [...selectedList];
// const index = data.findIndex(x => x._id === item._id);
const indexSelected = selectedData.findIndex((val) => val._id === item._id);
if (indexSelected > -1) {
Expand All @@ -126,7 +126,7 @@ const PaperSelect = ({
};

const _onCheckedSingle = (item: any) => {
var selectedData = [...selectedList];
let selectedData = [...selectedList];
// const index = data.findIndex(x => x._id === item._id);
const indexSelected = selectedData.findIndex((val) => val._id === item._id);
if (indexSelected > -1) {
Expand All @@ -142,7 +142,7 @@ const PaperSelect = ({

const _exists = (item: any) => {
// console.log(selectedList);
let _temp = [...selectedList]
let _temp = [...selectedList];
return _temp.find((val: any) => val._id === item._id) ? true : false;
};

Expand All @@ -154,7 +154,7 @@ const PaperSelect = ({

const _checkAll = () => {
const data = [...list];
var selectedData = [...selectedList];
let selectedData = [...selectedList];
if (selectedData.length === data.length) {
selectedData = [];
} else if (selectedData.length === 0 || selectedData.length > 0) {
Expand Down Expand Up @@ -280,7 +280,7 @@ const PaperSelect = ({
>
{hideSearchBox ? <Text style={{ margin: 0, height: 0 }} /> : <Searchbar
value={searchKey}
placeholder={searchPlaceholder || "Search"}
placeholder={searchPlaceholder}
onChangeText={(text: string) => _filterFunction(text)}
iconColor={searchStyle?.iconColor || 'black'}
style={{
Expand Down Expand Up @@ -322,11 +322,11 @@ const PaperSelect = ({
</Dialog.ScrollArea>
</Dialog.Content>
<Dialog.Actions style={{ marginTop: -20 }}>
<Button labelStyle={dialogButtonLabelStyle} onPress={_closeDialog}>
{modalCloseButtonText || "Close"}
<Button labelStyle={dialogCloseButtonStyle} onPress={_closeDialog}>
{dialogCloseButtonText}
</Button>
<Button labelStyle={dialogButtonLabelStyle} onPress={_hideDialog}>
{modalDoneButtonText || "Done"}
<Button labelStyle={dialogDoneButtonStyle} onPress={_hideDialog}>
{dialogDoneButtonText}
</Button>
</Dialog.Actions>
</Dialog>
Expand Down