This repository has been archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* solana init family * solana add support page url * solana fix lint * solana parametrize memo too long error * solana add opt in flow * remove tokens related code
- Loading branch information
Showing
8 changed files
with
290 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// @flow | ||
import React, { useCallback, useState } from "react"; | ||
import { View, StyleSheet, ScrollView } from "react-native"; | ||
import SafeAreaView from "react-native-safe-area-view"; | ||
import { useTranslation } from "react-i18next"; | ||
import i18next from "i18next"; | ||
import type { Account } from "@ledgerhq/live-common/lib/types"; | ||
import type { Transaction } from "@ledgerhq/live-common/lib/families/solana/types"; | ||
import { getAccountBridge } from "@ledgerhq/live-common/lib/bridge"; | ||
import { useTheme } from "@react-navigation/native"; | ||
import KeyboardView from "../../components/KeyboardView"; | ||
import Button from "../../components/Button"; | ||
import { ScreenName } from "../../const"; | ||
import TextInput from "../../components/FocusedTextInput"; | ||
|
||
const forceInset = { bottom: "always" }; | ||
|
||
type Props = { | ||
navigation: any, | ||
route: { params: RouteParams }, | ||
}; | ||
|
||
type RouteParams = { | ||
account: Account, | ||
transaction: Transaction, | ||
}; | ||
|
||
function SolanaEditMemo({ navigation, route }: Props) { | ||
const { colors } = useTheme(); | ||
const { t } = useTranslation(); | ||
const [memo, setMemo] = useState(route.params.transaction.model.uiState.memo); | ||
const account = route.params.account; | ||
|
||
const onValidateText = useCallback(() => { | ||
const bridge = getAccountBridge(account); | ||
const { transaction } = route.params; | ||
const nextTx = bridge.updateTransaction(transaction, { | ||
model: { | ||
...transaction.model, | ||
uiState: { | ||
...transaction.model.uiState, | ||
memo, | ||
}, | ||
}, | ||
}); | ||
navigation.navigate(ScreenName.SendSummary, { | ||
accountId: account.id, | ||
transaction: nextTx, | ||
}); | ||
}, [navigation, route.params, account, memo]); | ||
|
||
return ( | ||
<SafeAreaView style={styles.root} forceInset={forceInset}> | ||
<KeyboardView | ||
style={[styles.body, { backgroundColor: colors.background }]} | ||
> | ||
<ScrollView | ||
contentContainerStyle={styles.root} | ||
keyboardShouldPersistTaps="always" | ||
> | ||
<TextInput | ||
allowFontScaling={false} | ||
autoFocus | ||
style={[styles.textInputAS, { color: colors.darkBlue }]} | ||
defaultValue={memo} | ||
keyboardType="default" | ||
returnKeyType="done" | ||
onChangeText={setMemo} | ||
multiline | ||
onSubmitEditing={onValidateText} | ||
/> | ||
|
||
<View style={styles.flex}> | ||
<Button | ||
event="SolanaEditMemoContinue" | ||
type="primary" | ||
title={t("send.summary.validateMemo")} | ||
onPress={onValidateText} | ||
containerStyle={styles.buttonContainer} | ||
/> | ||
</View> | ||
</ScrollView> | ||
</KeyboardView> | ||
</SafeAreaView> | ||
); | ||
} | ||
|
||
const options = { | ||
title: i18next.t("send.summary.memo.title"), | ||
headerLeft: null, | ||
}; | ||
|
||
export { SolanaEditMemo as component, options }; | ||
|
||
const styles = StyleSheet.create({ | ||
root: { | ||
flex: 1, | ||
}, | ||
body: { | ||
flexDirection: "column", | ||
flex: 1, | ||
}, | ||
textInputAS: { | ||
padding: 16, | ||
fontSize: 30, | ||
}, | ||
buttonContainer: { | ||
marginHorizontal: 16, | ||
}, | ||
flex: { | ||
flex: 1, | ||
flexDirection: "column", | ||
justifyContent: "flex-end", | ||
paddingBottom: 16, | ||
}, | ||
}); |
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,81 @@ | ||
// @flow | ||
import React, { useCallback } from "react"; | ||
import { View, StyleSheet } from "react-native"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useTheme } from "@react-navigation/native"; | ||
import type { Account } from "@ledgerhq/live-common/lib/types"; | ||
import type { Transaction } from "@ledgerhq/live-common/lib/families/solana/types"; | ||
import LText from "../../components/LText"; | ||
import { ScreenName } from "../../const"; | ||
import SummaryRow from "../../screens/SendFunds/SummaryRow"; | ||
|
||
type Props = { | ||
account: Account, | ||
transaction: Transaction, | ||
navigation: any, | ||
}; | ||
|
||
export default function SolanaSendRowsCustom({ | ||
account, | ||
transaction, | ||
navigation, | ||
}: Props) { | ||
const { colors } = useTheme(); | ||
const { t } = useTranslation(); | ||
|
||
const editMemo = useCallback(() => { | ||
navigation.navigate(ScreenName.SolanaEditMemo, { | ||
account, | ||
transaction, | ||
}); | ||
}, [navigation, account, transaction]); | ||
|
||
return ( | ||
<View> | ||
<SummaryRow title={t("send.summary.memo.title")} onPress={editMemo}> | ||
{transaction.model.uiState.memo ? ( | ||
<LText | ||
semiBold | ||
style={styles.tagText} | ||
onPress={editMemo} | ||
numberOfLines={1} | ||
> | ||
{transaction.model.uiState.memo} | ||
</LText> | ||
) : ( | ||
<LText | ||
style={[ | ||
styles.link, | ||
{ | ||
textDecorationColor: colors.live, | ||
}, | ||
]} | ||
color="live" | ||
onPress={editMemo} | ||
> | ||
{t("common.edit")} | ||
</LText> | ||
)} | ||
</SummaryRow> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
memoContainer: { | ||
flexDirection: "row", | ||
}, | ||
tagText: { | ||
flex: 1, | ||
fontSize: 14, | ||
textAlign: "right", | ||
}, | ||
link: { | ||
textDecorationStyle: "solid", | ||
textDecorationLine: "underline", | ||
marginLeft: 8, | ||
}, | ||
memo: { | ||
marginBottom: 10, | ||
}, | ||
}); |
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,73 @@ | ||
// @flow | ||
import React, { useCallback } from "react"; | ||
import { View, StyleSheet, Linking } from "react-native"; | ||
import type { AccountLike } from "@ledgerhq/live-common/lib/types"; | ||
import { Trans } from "react-i18next"; | ||
import type { Transaction } from "@ledgerhq/live-common/lib/families/solana/types"; | ||
import { | ||
getAccountUnit, | ||
getAccountCurrency, | ||
} from "@ledgerhq/live-common/lib/account"; | ||
import { useTheme } from "@react-navigation/native"; | ||
import SummaryRow from "../../screens/SendFunds/SummaryRow"; | ||
import LText from "../../components/LText"; | ||
import CurrencyUnitValue from "../../components/CurrencyUnitValue"; | ||
import CounterValue from "../../components/CounterValue"; | ||
import ExternalLink from "../../icons/ExternalLink"; | ||
import { urls } from "../../config/urls"; | ||
|
||
type Props = { | ||
account: AccountLike, | ||
transaction: Transaction, | ||
}; | ||
|
||
export default function SolanaFeeRow({ account, transaction }: Props) { | ||
const { colors } = useTheme(); | ||
const extraInfoFees = useCallback(() => { | ||
Linking.openURL(urls.solana.supportPage); | ||
}, []); | ||
|
||
const fees = transaction.feeCalculator?.lamportsPerSignature; | ||
const unit = getAccountUnit(account); | ||
const currency = getAccountCurrency(account); | ||
|
||
return ( | ||
<SummaryRow | ||
onPress={extraInfoFees} | ||
title={<Trans i18nKey="send.fees.title" />} | ||
additionalInfo={ | ||
<View> | ||
<ExternalLink size={12} color={colors.grey} /> | ||
</View> | ||
} | ||
> | ||
<View style={{ alignItems: "flex-end" }}> | ||
<View style={styles.accountContainer}> | ||
{fees ? ( | ||
<LText style={styles.valueText}> | ||
<CurrencyUnitValue unit={unit} value={fees} /> | ||
</LText> | ||
) : null} | ||
</View> | ||
<LText style={styles.countervalue} color="grey"> | ||
{fees ? ( | ||
<CounterValue before="≈ " value={fees} currency={currency} /> | ||
) : null} | ||
</LText> | ||
</View> | ||
</SummaryRow> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
accountContainer: { | ||
flex: 1, | ||
flexDirection: "row", | ||
}, | ||
countervalue: { | ||
fontSize: 12, | ||
}, | ||
valueText: { | ||
fontSize: 16, | ||
}, | ||
}); |
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,4 @@ | ||
// @flow | ||
import * as SolanaEditMemo from "./ScreenEditMemo"; | ||
|
||
export { SolanaEditMemo }; |
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