This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,502 additions
and
3,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Alert } from 'react-native'; | ||
|
||
import { SNAlertService } from 'snjs'; | ||
|
||
export class AlertService extends SNAlertService { | ||
async alert( | ||
title: string, | ||
text: string, | ||
closeButtonText?: string, | ||
onClose?: () => void | ||
) { | ||
return new Promise(resolve => { | ||
// On iOS, confirm should go first. On Android, cancel should go first. | ||
let buttons = [ | ||
{ | ||
text: closeButtonText, | ||
onPress: async () => { | ||
if (onClose) { | ||
onClose(); | ||
} | ||
resolve(); | ||
}, | ||
}, | ||
]; | ||
Alert.alert(title, text, buttons, { | ||
cancelable: true, | ||
}); | ||
}); | ||
} | ||
|
||
async confirm( | ||
text: string, | ||
title: string, | ||
confirmButtonText = 'Confirm', | ||
cancelButtonText = 'Cancel', | ||
onConfirm: () => void, | ||
onCancel: () => void, | ||
_destructive = false | ||
) { | ||
return new Promise((resolve, reject) => { | ||
// On iOS, confirm should go first. On Android, cancel should go first. | ||
let buttons = [ | ||
{ | ||
text: cancelButtonText, | ||
onPress: async () => { | ||
if (onCancel) { | ||
onCancel(); | ||
} | ||
reject(); | ||
}, | ||
}, | ||
{ | ||
text: confirmButtonText, | ||
onPress: async () => { | ||
if (onConfirm) { | ||
onConfirm(); | ||
} | ||
resolve(); | ||
}, | ||
}, | ||
]; | ||
Alert.alert(title, text, buttons, { | ||
cancelable: true, | ||
onDismiss: async () => { | ||
// TODO: check alerts | ||
// if (onDismiss) { | ||
// onDismiss(); | ||
// } | ||
reject(); | ||
}, | ||
}); | ||
}); | ||
} | ||
} |
Oops, something went wrong.