-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
settings: Add the ability to see all toast notifications in current s…
…ession
- Loading branch information
Showing
5 changed files
with
104 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React, { useLayoutEffect } from "react"; | ||
import { FlatList, StyleSheet } from "react-native"; | ||
import { Body, Card, CardItem, Icon, Row, Text } from "native-base"; | ||
import { StackNavigationProp } from "@react-navigation/stack"; | ||
import { RouteProp } from "@react-navigation/native"; | ||
import Clipboard from "@react-native-community/clipboard"; | ||
|
||
import Container from "../../components/Container"; | ||
import { NavigationButton } from "../../components/NavigationButton"; | ||
import { SettingsStackParamList } from "./index"; | ||
import { toast, useGetToastEntries } from "../../utils"; | ||
import { fontFactorNormalized } from "../../utils/scale"; | ||
|
||
import { useTranslation } from "react-i18next"; | ||
import { namespaces } from "../../i18n/i18n.constants"; | ||
|
||
|
||
export interface ISelectListProps { | ||
navigation: StackNavigationProp<SettingsStackParamList, "LightningPeers">; | ||
route: RouteProp<SettingsStackParamList, "LightningPeers">; | ||
} | ||
|
||
export default function({ navigation }: ISelectListProps) { | ||
const t = useTranslation(namespaces.settings.lightningPeers).t; | ||
const toastEntries = useGetToastEntries(); | ||
|
||
useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
headerTitle: t("layout.title"), | ||
headerShown: true, | ||
headerRight: () => { | ||
return ( | ||
<NavigationButton onPress={onPressCopyAllToasts}> | ||
<Icon type="MaterialCommunityIcons" name="content-copy" style={{ fontSize: 22 }} /> | ||
</NavigationButton> | ||
) | ||
} | ||
}); | ||
}, [navigation]); | ||
|
||
const onCopyToastMessage = (i: number) => { | ||
console.log(toastEntries); | ||
Clipboard.setString(toastEntries[i] ?? ""); | ||
toast("Copied to clipboard"); | ||
} | ||
|
||
const onPressCopyAllToasts = () => { | ||
Clipboard.setString(toastEntries.join("\n") ?? ""); | ||
toast("Copied to clipboard"); | ||
} | ||
|
||
return ( | ||
<Container> | ||
<FlatList | ||
contentContainerStyle={{ padding: 14 }} | ||
initialNumToRender={20} | ||
data={toastEntries} | ||
renderItem={({ item: toast, index }) => ( | ||
<Card style={style.card} key={index}> | ||
<CardItem> | ||
<Body> | ||
<Row style={{ width: "100%" }}> | ||
<Text style={{marginRight: 28 }}>{toast}</Text> | ||
<Text style={{ position:"absolute", right: 0 }}> | ||
<Icon type="MaterialCommunityIcons" name="content-copy" style={style.icon} onPress={() => onCopyToastMessage(index)} /> | ||
</Text> | ||
</Row> | ||
</Body> | ||
</CardItem> | ||
</Card> | ||
)} | ||
keyExtractor={(toast, i) => toast + i} | ||
/> | ||
</Container> | ||
) | ||
} | ||
|
||
const style = StyleSheet.create({ | ||
icon: { | ||
fontSize: 18 * fontFactorNormalized, | ||
}, | ||
}); |
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
25d96d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blixt-wallet – ./
blixt-wallet-git-master-hsjoberg.vercel.app
blixt-wallet-hsjoberg.vercel.app