-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from pushme-tgxn/develop
Develop
- Loading branch information
Showing
21 changed files
with
12,790 additions
and
12,719 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,9 @@ | ||
name: "Run TODO to Issue" | ||
on: ["push"] | ||
jobs: | ||
build: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: "actions/checkout@v3" | ||
- name: "TODO to Issue" | ||
uses: "alstr/todo-to-issue-action@v4" |
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
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,132 @@ | ||
import React, { useState, useContext } from "react"; | ||
|
||
import { SafeAreaView, View, useColorScheme } from "react-native"; | ||
|
||
import { | ||
Appbar, | ||
Menu, | ||
IconButton, | ||
Colors, | ||
Button, | ||
Modal, | ||
Dialog, | ||
Portal, | ||
Paragraph, | ||
} from "react-native-paper"; | ||
|
||
import * as Notifications from "expo-notifications"; | ||
// import { Picker } from "@react-native-picker/picker"; | ||
|
||
// import { PaperSelect } from "react-native-paper-select"; | ||
|
||
import DropDown from "react-native-paper-dropdown"; | ||
|
||
import { Separator } from "../components/Shared"; | ||
|
||
import { useTheme } from "react-native-paper"; | ||
|
||
import { AppReducer } from "../const"; | ||
import { setPushResponse } from "../reducers/app"; | ||
|
||
import apiService from "../service/api"; | ||
import styles from "../styles"; | ||
|
||
export default function NotificationPopup() { | ||
const theme = useTheme(); | ||
const colorScheme = useColorScheme(); | ||
|
||
const { state, dispatch } = useContext(AppReducer); | ||
|
||
const [visible, setVisible] = useState(false); | ||
const [loading, setLoading] = useState(false); | ||
|
||
const [pushContent, setPushContent] = useState(null); | ||
|
||
const themedStyles = styles(colorScheme); | ||
|
||
const lastNotificationResponse = Notifications.useLastNotificationResponse(); | ||
|
||
React.useEffect(() => { | ||
if (!lastNotificationResponse) return; | ||
|
||
console.log("lastNotificationResponse", lastNotificationResponse); | ||
setPushContent(lastNotificationResponse.notification.request.content); | ||
|
||
// only load for the default type | ||
if ( | ||
lastNotificationResponse && | ||
lastNotificationResponse.actionIdentifier === Notifications.DEFAULT_ACTION_IDENTIFIER | ||
) { | ||
setVisible(true); | ||
} | ||
}, [lastNotificationResponse]); | ||
|
||
// TODO build a list of categories and functions to generate action buttons | ||
|
||
return ( | ||
<Portal> | ||
<Modal | ||
style={{ backgroundColor: "#000000FF" }} | ||
visible={visible} | ||
onDismiss={() => setVisible(false)} | ||
contentContainerStyle={{ | ||
backgroundColor: theme.colors.backdrop, | ||
margin: 20, | ||
}} | ||
> | ||
<Dialog.Title>Incoming Push</Dialog.Title> | ||
<Dialog.Content> | ||
{lastNotificationResponse && pushContent && ( | ||
<View> | ||
<Paragraph> | ||
actionIdentifier: {lastNotificationResponse.actionIdentifier} | ||
</Paragraph> | ||
<Paragraph>title: {pushContent.title}</Paragraph> | ||
<Paragraph>body: {pushContent.body}</Paragraph> | ||
<Paragraph>categoryIdentifier: {pushContent.categoryIdentifier}</Paragraph> | ||
<Paragraph>pushIdent: {pushContent.data.pushIdent}</Paragraph> | ||
<Paragraph>pushId: {pushContent.data.pushId}</Paragraph> | ||
<Separator /> | ||
<Paragraph>{JSON.stringify(lastNotificationResponse)}</Paragraph> | ||
</View> | ||
)} | ||
</Dialog.Content> | ||
<Dialog.Actions> | ||
<Button onPress={() => setVisible(false)}>Thanks</Button> | ||
<Button | ||
onPress={() => { | ||
const responseData = { | ||
pushIdent: pushContent.data.pushIdent, | ||
pushId: pushContent.data.pushId, | ||
actionIdentifier: "reject", // TODO must get the actionIdentifier from the button AND categoryIdentifier OF REQUEST | ||
categoryIdentifier: pushContent.categoryIdentifier, | ||
responseText: null, | ||
}; | ||
dispatch(setPushResponse(responseData)); | ||
setVisible(false); | ||
}} | ||
loading={loading} | ||
> | ||
Reject | ||
</Button> | ||
<Button | ||
onPress={() => { | ||
const responseData = { | ||
pushIdent: pushContent.data.pushIdent, | ||
pushId: pushContent.data.pushId, | ||
actionIdentifier: "approve", // TODO must get the actionIdentifier from the button AND categoryIdentifier OF REQUEST | ||
categoryIdentifier: pushContent.categoryIdentifier, | ||
responseText: null, | ||
}; | ||
dispatch(setPushResponse(responseData)); | ||
setVisible(false); | ||
}} | ||
loading={loading} | ||
> | ||
Approve | ||
</Button> | ||
</Dialog.Actions> | ||
</Modal> | ||
</Portal> | ||
); | ||
} |
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
Oops, something went wrong.