Skip to content
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

fix: UI fixes #1591

Merged
merged 6 commits into from
Feb 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/AppOnboarded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const AppOnboarded = (): ReactElement => {
dispatch(updateUi({ isOnline: true }));
} else {
showToast({
type: 'error',
type: 'warning',
title: t('connection_issue'),
description: t('connection_issue_explain'),
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/AuthWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const AuthWidget = ({
: `An error occurred: ${e.message}`;

showToast({
type: 'error',
type: 'warning',
title: t('auth_error_link'),
description: message,
});
Expand All @@ -67,7 +67,7 @@ const AuthWidget = ({
if (magiclink) {
Linking.openURL(magiclink.url).catch((e) => {
showToast({
type: 'error',
type: 'warning',
title: t('auth_error_link'),
description: e.message,
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/BaseFeedWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../styles/icons';
import { useAppDispatch } from '../hooks/redux';
import { useSlashfeed } from '../hooks/widgets';
import { truncate } from '../utils/helpers';
import { deleteWidget } from '../store/slices/widgets';
import Dialog from './Dialog';
import SvgImage from './SvgImage';
Expand Down Expand Up @@ -80,7 +81,7 @@ const BaseFeedWidget = ({
</View>

<Text01M style={styles.name} numberOfLines={1}>
{widgetName}
{truncate(widgetName, 18)}
</Text01M>
</View>

Expand Down
2 changes: 1 addition & 1 deletion src/components/FactsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const FactsWidget = ({
console.error(error);
setIsLoading(false);
showToast({
type: 'error',
type: 'warning',
title: t('widget_error_drive'),
description: `An error occurred: ${error.message}`,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeadlinesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const HeadlinesWidget = ({
console.error(error);
setIsLoading(false);
showToast({
type: 'error',
type: 'warning',
title: t('widget_error_drive'),
description: `An error occurred: ${error.message}`,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/PinPad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const PinPad = ({
vibrate({ type: 'default' });
await wipeApp();
showToast({
type: 'error',
type: 'warning',
title: t('wiped_title'),
description: t('wiped_message'),
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/SlashtagsProvider2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const SlashtagsProvider2 = ({
(primaryKeyRes.data && primaryKeyRes.data.length === 0)
) {
showToast({
type: 'error',
type: 'warning',
title: 'Data Connection Issue',
description:
'An error occurred: Could not load primary key from keychain.',
Expand Down
8 changes: 7 additions & 1 deletion src/components/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ const Toast = ({
gradientColor = '#00294e';
}

if (type === 'error') {
if (type === 'warning') {
titleColor = 'brand';
gradientColor = '#411a00';
}

if (type === 'error') {
titleColor = 'red';
gradientColor = '#2b1215';
}

return (
<BlurView style={[{ width: dimensions.width - 16 * 2 }, containerStyles]}>
<HorizontalGradient style={styles.gradient} color={gradientColor} />
Expand Down Expand Up @@ -73,5 +78,6 @@ const styles = StyleSheet.create({
export const toastConfig: ToastConfig = {
success: (props) => <Toast {...props} />,
info: (props) => <Toast {...props} />,
warning: (props) => <Toast {...props} />,
error: (props) => <Toast {...props} />,
};
4 changes: 2 additions & 2 deletions src/navigation/bottom-sheet/ForceTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const ForceTransfer = (): ReactElement => {
});
if (closeResponse.isErr()) {
showToast({
type: 'error',
type: 'warning',
title: t('close_error'),
description: closeResponse.error.message,
});
Expand All @@ -118,7 +118,7 @@ const ForceTransfer = (): ReactElement => {
} else {
console.log('force close failed.');
showToast({
type: 'error',
type: 'warning',
title: t('force_failed_title'),
description: t('force_failed_msg'),
});
Expand Down
48 changes: 26 additions & 22 deletions src/screens/Activity/ActivityDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import Clipboard from '@react-native-clipboard/clipboard';
import { useTranslation } from 'react-i18next';
import { parse } from '@synonymdev/slashtags-url';
import { EBoostType, EPaymentType } from 'beignet';

import { View as ThemedView } from '../../styles/components';
import { Caption13Up, Text02M, Title } from '../../styles/text';
Expand Down Expand Up @@ -77,7 +78,7 @@ import {
} from '../../store/slices/metadata';
import { getTransactions } from '../../utils/wallet/electrum';
import { ITransaction, ITxHash } from '../../utils/wallet';
import { openURL } from '../../utils/helpers';
import { ellipsis, openURL } from '../../utils/helpers';
import { getBoostedTransactionParents } from '../../utils/boost';
import { showToast } from '../../utils/notifications';
import {
Expand All @@ -95,7 +96,6 @@ import type {
import { i18nTime } from '../../utils/i18n';
import { useSwitchUnit } from '../../hooks/wallet';
import { contactsSelector } from '../../store/reselect/slashtags';
import { EBoostType, EPaymentType } from 'beignet';

const Section = memo(
({ title, value }: { title: string; value: ReactNode }) => {
Expand Down Expand Up @@ -195,7 +195,7 @@ const OnchainActivityDetail = ({
getTransactions({ txHashes: [{ tx_hash: id }] }).then((txResponse) => {
if (txResponse.isErr()) {
showToast({
type: 'error',
type: 'warning',
title: t('activity_error_get'),
description: t('activity_error_get_description'),
});
Expand All @@ -204,7 +204,7 @@ const OnchainActivityDetail = ({
const txData = txResponse.value.data;
if (txData.length === 0) {
showToast({
type: 'error',
type: 'warning',
title: t('activity_error_get'),
description: t('activity_error_tx_not_found'),
});
Expand Down Expand Up @@ -285,14 +285,14 @@ const OnchainActivityDetail = ({
await openURL(blockExplorerUrl);
}, [blockExplorerUrl]);

const copyTransactionId = useCallback(() => {
Clipboard.setString(id);
const onCopy = (text: string): void => {
Clipboard.setString(text);
showToast({
type: 'success',
title: t('activity_copied_tx'),
description: id,
title: t('copied'),
description: ellipsis(text, 40),
});
}, [id, t]);
};

const getOutputAddresses = useCallback(() => {
if (txDetails && txDetails.vout.length > 0) {
Expand Down Expand Up @@ -552,19 +552,21 @@ const OnchainActivityDetail = ({
) : (
<>
<TouchableOpacity
onPress={copyTransactionId}
style={styles.sectionContainer}>
style={styles.sectionContainer}
onPress={(): void => onCopy(id)}>
<Section
title={t('activity_tx_id')}
value={<Text02M>{id}</Text02M>}
/>
</TouchableOpacity>
<View style={styles.sectionContainer}>
<TouchableOpacity
style={styles.sectionContainer}
onPress={(): void => onCopy(address)}>
<Section
title={t('activity_address')}
value={<Text02M>{address}</Text02M>}
/>
</View>
</TouchableOpacity>
{txDetails ? (
<>
<View style={styles.sectionContainer}>
Expand Down Expand Up @@ -682,14 +684,14 @@ const LightningActivityDetail = ({
});
};

const copyTransactionId = useCallback(() => {
Clipboard.setString(id);
const onCopy = (text: string): void => {
Clipboard.setString(text);
showToast({
type: 'success',
title: t('activity_copied_tx'),
description: id,
title: t('copied'),
description: ellipsis(text, 40),
});
}, [id, t]);
};

const isSend = txType === EPaymentType.sent;
const total = value + (fee ?? 0);
Expand Down Expand Up @@ -914,19 +916,21 @@ const LightningActivityDetail = ({
) : (
<>
<TouchableOpacity
onPress={copyTransactionId}
style={styles.sectionContainer}>
style={styles.sectionContainer}
onPress={(): void => onCopy(id)}>
<Section
title={t('activity_payment_hash')}
value={<Text02M>{id}</Text02M>}
/>
</TouchableOpacity>
<View style={styles.sectionContainer}>
<TouchableOpacity
style={styles.sectionContainer}
onPress={(): void => onCopy(address)}>
<Section
title={t('activity_invoice')}
value={<Text02M>{address}</Text02M>}
/>
</View>
</TouchableOpacity>
</>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Contacts/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Contact = ({
} else {
console.log(res.error.message);
showToast({
type: 'error',
type: 'warning',
title: t('contact_pay_error'),
description: `An error occurred: ${res.error.message}`,
});
Expand Down
6 changes: 3 additions & 3 deletions src/screens/Lightning/CustomConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
const fiatTransactionFee = useDisplayValues(transactionFee);
const clientBalance = useDisplayValues(order?.clientBalanceSat ?? 0);

// avoid flashing different price after confirmation
// TODO: avoid flashing different price & allocation after confirmation
// eslint-disable-next-line react-hooks/exhaustive-deps

Check warning on line 57 in src/screens/Lightning/CustomConfirm.tsx

View workflow job for this annotation

GitHub Actions / Run lint check

'react-hooks/exhaustive-deps' rule is disabled but never reported
const txFee = useMemo(() => fiatTransactionFee.fiatValue, [orderId]);
const txFee = fiatTransactionFee.fiatValue;
const lspFee = purchaseFeeValue.fiatValue - clientBalance.fiatValue;

const handleConfirm = async (): Promise<void> => {
Expand Down Expand Up @@ -83,7 +83,7 @@
});
if (purchaseResponse.isErr()) {
showToast({
type: 'error',
type: 'warning',
title: t('error_channel_purchase'),
description: purchaseResponse.error.message,
});
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Lightning/CustomSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ const CustomSetup = ({
});
}
showToast({
type: 'error',
type: 'warning',
title: t('error_channel_purchase'),
description: msg,
});
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Lightning/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const Introduction = ({
onPress={(): void => {
if (accountVersion < 2) {
showToast({
type: 'error',
type: 'warning',
title: t('migrating_ldk_title'),
description: t('migrating_ldk_description'),
});
Expand All @@ -93,7 +93,7 @@ const Introduction = ({
onPress={(): void => {
if (accountVersion < 2) {
showToast({
type: 'error',
type: 'warning',
title: t('migrating_ldk_title'),
description: t('migrating_ldk_description'),
});
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Lightning/QuickConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
const fiatTransactionFee = useDisplayValues(transactionFee);
const clientBalance = useDisplayValues(order?.clientBalanceSat ?? 0);

// avoid flashing different price after confirmation
// TODO: avoid flashing different price & allocation after confirmation
// eslint-disable-next-line react-hooks/exhaustive-deps

Check warning on line 52 in src/screens/Lightning/QuickConfirm.tsx

View workflow job for this annotation

GitHub Actions / Run lint check

'react-hooks/exhaustive-deps' rule is disabled but never reported
const txFee = useMemo(() => fiatTransactionFee.fiatValue, [orderId]);
const txFee = fiatTransactionFee.fiatValue;
const lspFee = purchaseFeeValue.fiatValue - clientBalance.fiatValue;

const savingsAmount = onchainBalance - spendingAmount;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Lightning/QuickSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const QuickSetup = ({
setLoading(false);
if (purchaseResponse.isErr()) {
showToast({
type: 'error',
type: 'warning',
title: t('error_channel_purchase'),
description: purchaseResponse.error.message,
});
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Onboarding/RestoreFromSeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const RestoreFromSeed = (): ReactElement => {
});
if (res.isErr()) {
showToast({
type: 'error',
type: 'warning',
title: t('restore_error_title'),
description: res.error.message,
});
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Onboarding/Restoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const RestoringScreen = (): ReactElement => {
if (res.isErr()) {
console.log(res.error.message);
showToast({
type: 'error',
type: 'warning',
title: t('restore_error_title'),
description: t('restore_error_description'),
});
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Onboarding/Slideshow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Slideshow = ({
if (res.isErr()) {
setIsCreatingWallet(false);
showToast({
type: 'error',
type: 'warning',
title: t('error_create'),
description: res.error.message,
});
Expand Down
Loading
Loading