-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WALLET AccessPrompt Confirm request access (#46)
* Show loading, and handle error * Show loading, and handle error * Handle error * Show loading when search Resource and handle error * Revert icon file * Revert file aoo.config.js * fixup! Revert file aoo.config.js --------- Co-authored-by: Nicolas Ayral Seydoux <[email protected]> Co-authored-by: Chelsea Pinka <[email protected]>
- Loading branch information
1 parent
5366e7c
commit d003ca7
Showing
8 changed files
with
188 additions
and
23 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,69 @@ | ||
// | ||
// Copyright Inrupt Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
import React from "react"; | ||
import { View, StyleSheet, TouchableOpacity } from "react-native"; | ||
import Close from "@/assets/images/close.svg"; | ||
import { ThemedText } from "../ThemedText"; | ||
|
||
interface ErrorPopupProps { | ||
errorMsg: string; | ||
onClose: () => void; | ||
} | ||
|
||
const ErrorPopup: React.FC<ErrorPopupProps> = ({ | ||
errorMsg, | ||
onClose = () => null, | ||
}) => { | ||
return ( | ||
<View style={styles.errorPopup}> | ||
<ThemedText style={styles.loadingText}>{errorMsg}</ThemedText> | ||
<TouchableOpacity onPress={onClose} style={styles.closeView}> | ||
<Close width="20" height="20" onPress={onClose} /> | ||
</TouchableOpacity> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
errorPopup: { | ||
position: "absolute", | ||
bottom: 80, | ||
left: 24, | ||
right: 24, | ||
backgroundColor: "white", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
flexDirection: "row", | ||
shadowColor: "rgba(0, 0, 0)", | ||
shadowOffset: { width: 2, height: 4 }, | ||
shadowOpacity: 0.2, | ||
shadowRadius: 30, | ||
elevation: 5, | ||
borderRadius: 16, | ||
paddingVertical: 16, | ||
}, | ||
loadingText: { | ||
paddingLeft: 16, | ||
fontSize: 16, | ||
}, | ||
closeView: { | ||
alignItems: "center", | ||
paddingLeft: 24, | ||
paddingRight: 16, | ||
}, | ||
}); | ||
|
||
export default ErrorPopup; |
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,53 @@ | ||
// | ||
// Copyright Inrupt Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
import React, { createContext, useCallback, useState } from "react"; | ||
import ErrorPopup from "@/components/error/ErrorPopup"; | ||
|
||
const ErrorContext = createContext<{ | ||
showErrorMsg: (msg: string) => void; | ||
}>({ | ||
showErrorMsg: () => null, | ||
}); | ||
|
||
export const ErrorViewProvider = ({ children }: React.PropsWithChildren) => { | ||
const [showError, setShowError] = useState<boolean>(false); | ||
const [errorMsg, setErrorMsg] = useState<string | undefined>(undefined); | ||
|
||
const showErrorMsg = useCallback((msg: string) => { | ||
setShowError(true); | ||
setErrorMsg(msg); | ||
}, []); | ||
|
||
const handleClose = useCallback(() => { | ||
setShowError(false); | ||
setErrorMsg(undefined); | ||
}, []); | ||
|
||
return ( | ||
<ErrorContext.Provider | ||
value={{ | ||
showErrorMsg, | ||
}} | ||
> | ||
{children} | ||
{showError && Boolean(errorMsg) && ( | ||
<ErrorPopup errorMsg={errorMsg!} onClose={handleClose} /> | ||
)} | ||
</ErrorContext.Provider> | ||
); | ||
}; | ||
|
||
export const useError = () => React.useContext(ErrorContext); |