diff --git a/src/components/AuthFailedApp.js b/src/components/AuthFailedApp.js index 9abecc8a6c..7649d676dc 100644 --- a/src/components/AuthFailedApp.js +++ b/src/components/AuthFailedApp.js @@ -7,8 +7,7 @@ import LText from "./LText"; import type { T } from "../types/common"; import colors from "../colors"; import BottomModal from "./BottomModal"; -import GreyButton from "./GreyButton"; -import BlueButton from "./BlueButton"; +import Button from "./Button"; import LedgerLiveLogo from "./LedgerLiveLogo"; import LiveLogo from "../icons/LiveLogo"; import HardResetModal from "./HardResetModal"; @@ -50,21 +49,17 @@ class AuthFailedApp extends Component { {t("auth.failed.title")} - - { - render() { - return ( - - ); - } -} diff --git a/src/components/BottomModal.js b/src/components/BottomModal.js index 4e28707370..b4654cf09d 100644 --- a/src/components/BottomModal.js +++ b/src/components/BottomModal.js @@ -6,6 +6,7 @@ import ReactNativeModal from "react-native-modal"; import StyledStatusBar from "./StyledStatusBar"; import colors from "../colors"; +import ButtonUseTouchable from "../context/ButtonUseTouchable"; export type Props = { isOpened: boolean, @@ -18,25 +19,27 @@ class BottomModal extends Component { render() { const { isOpened, onClose, children, style } = this.props; return ( - - - - {children} - - + + + + + {children} + + + ); } } diff --git a/src/components/GenerateMockAccountsButton.js b/src/components/GenerateMockAccountsButton.js index 8a7cec18d3..cb712f5147 100644 --- a/src/components/GenerateMockAccountsButton.js +++ b/src/components/GenerateMockAccountsButton.js @@ -2,7 +2,7 @@ import React from "react"; import sample from "lodash/sample"; import { genAccount } from "@ledgerhq/live-common/lib/mock/account"; -import GreyButton from "./GreyButton"; +import Button from "./Button"; import { accountModel } from "../reducers/accounts"; import db from "../db"; import { withReboot } from "../context/Reboot"; @@ -23,7 +23,6 @@ async function injectMockAccountsInDB(count) { } const GenerateMockAccountsButton = ({ - title, reboot, count, ...rest @@ -32,9 +31,9 @@ const GenerateMockAccountsButton = ({ count: number, reboot: *, }) => ( - { await injectMockAccountsInDB(count); reboot(); diff --git a/src/components/GenericButton.js b/src/components/GenericButton.js deleted file mode 100644 index acc97a64e2..0000000000 --- a/src/components/GenericButton.js +++ /dev/null @@ -1,125 +0,0 @@ -/* @flow */ - -import React, { Component } from "react"; -import { - TouchableOpacity, - StyleSheet, - ActivityIndicator, - View, -} from "react-native"; -import LText from "./LText"; - -const WAIT_TIME_BEFORE_SPINNER = 300; - -export default class GenericButton extends Component< - { - // when on press returns a promise, - // the button will toggle in a pending state and - // will wait the promise to complete before enabling the button again - // it also displays a spinner if it takes more than WAIT_TIME_BEFORE_SPINNER - onPress: () => ?Promise, - // if not provided, spinner will be disabled - spinnerColor?: string, - // text of the button - title: string, - containerStyle: ?*, - titleStyle: ?*, - iconLeft?: *, - }, - { - pending: boolean, - spinnerOn: boolean, - }, -> { - state = { - pending: false, - spinnerOn: false, - }; - - timeout: *; - - unmounted = false; - - componentWillUnmount() { - clearTimeout(this.timeout); - this.unmounted = true; - } - - onPress = async () => { - try { - const res = this.props.onPress(); - if (res && res.then) { - // it's a promise, we will use pending/spinnerOn state - this.setState({ pending: true }); - this.timeout = setTimeout(() => { - this.setState(({ pending, spinnerOn }) => { - if (spinnerOn || !pending) return null; - return { spinnerOn: true }; - }); - }, WAIT_TIME_BEFORE_SPINNER); - await res; - } - } finally { - clearTimeout(this.timeout); - if (!this.unmounted) { - this.setState( - ({ pending }) => - pending ? { pending: false, spinnerOn: false } : null, - ); - } - } - }; - - render() { - const { - onPress, - title, - containerStyle, - titleStyle, - spinnerColor, - iconLeft, - ...otherProps - } = this.props; - const { pending, spinnerOn } = this.state; - const disabled = !onPress || pending; - return ( - - {iconLeft && {iconLeft}} - {title} - {spinnerOn && spinnerColor ? ( - - ) : null} - - ); - } -} - -const styles = StyleSheet.create({ - container: { - height: 40, - alignItems: "center", - flexDirection: "row", - justifyContent: "center", - paddingHorizontal: 10, - borderRadius: 4, - }, - containerDisabled: { - opacity: 0.5, - }, - activityIndicator: { - position: "absolute", - }, - title: {}, -}); diff --git a/src/components/GreyButton.js b/src/components/GreyButton.js deleted file mode 100644 index dad95d78cb..0000000000 --- a/src/components/GreyButton.js +++ /dev/null @@ -1,26 +0,0 @@ -/* @flow */ -import React, { Component } from "react"; -import { StyleSheet } from "react-native"; -import GenericButton from "./GenericButton"; - -export default class GreyButton extends Component<*> { - render() { - return ( - - ); - } -} -const styles = StyleSheet.create({ - title: { - color: "#aaa", - }, - container: { - backgroundColor: "#fff", - borderWidth: 1, - borderColor: "#aaa", - }, -}); diff --git a/src/components/HardResetModal.js b/src/components/HardResetModal.js index bbdff7d258..2476bb8f0b 100644 --- a/src/components/HardResetModal.js +++ b/src/components/HardResetModal.js @@ -7,8 +7,7 @@ import type { T } from "../types/common"; import colors from "../colors"; import ModalBottomAction from "./ModalBottomAction"; import Trash from "../icons/Trash"; -import RedButton from "./RedButton"; -import GreyButton from "./GreyButton"; +import Button from "./Button"; import Circle from "./Circle"; type Props = { @@ -30,17 +29,17 @@ class HardResetModal extends PureComponent { description={t("reset.description")} footer={ - - } @@ -57,16 +56,6 @@ const styles = StyleSheet.create({ justifyContent: "space-around", }, buttonContainer: { - height: 48, width: 136, }, - resetButtonBg: { - backgroundColor: colors.alert, - }, - buttonTitle: { - fontSize: 16, - }, - resetButtonTitle: { - color: colors.white, - }, }); diff --git a/src/components/ImportAccountsButton.js b/src/components/ImportAccountsButton.js index 302a90e4a4..47e1c6b52b 100644 --- a/src/components/ImportAccountsButton.js +++ b/src/components/ImportAccountsButton.js @@ -1,7 +1,7 @@ // @flow import React from "react"; import { withNavigation } from "react-navigation"; -import BlueButton from "./BlueButton"; +import Button from "./Button"; const ImportAccountsButton = ({ title, @@ -10,7 +10,8 @@ const ImportAccountsButton = ({ title: string, navigation: *, }) => ( - navigation.navigate("ImportAccounts")} /> diff --git a/src/components/ImportBridgeStreamData.js b/src/components/ImportBridgeStreamData.js index f9e030d89b..068c300dda 100644 --- a/src/components/ImportBridgeStreamData.js +++ b/src/components/ImportBridgeStreamData.js @@ -3,7 +3,7 @@ import React from "react"; // $FlowFixMe import { Buffer } from "buffer"; import { withNavigation } from "react-navigation"; -import GreyButton from "./GreyButton"; +import Button from "./Button"; const ImportBridgeStreamData = ({ title, @@ -17,8 +17,9 @@ const ImportBridgeStreamData = ({ reboot: *, dataStr: *, }) => ( - { const data = JSON.parse(Buffer.from(dataStr, "base64").toString("utf8")); diff --git a/src/components/OutlineButton.js b/src/components/OutlineButton.js deleted file mode 100644 index 6e2ba073ae..0000000000 --- a/src/components/OutlineButton.js +++ /dev/null @@ -1,45 +0,0 @@ -/* @flow */ -import React, { Component } from "react"; -import { StyleSheet } from "react-native"; - -import colors from "../colors"; -import GenericButton from "./Touchable"; - -type Props = { - children: React$Node, - onPress: () => *, - containerStyle?: *, - outlineColor?: string, -}; - -export default class OutlineButton extends Component { - render() { - const { children, outlineColor } = this.props; - const outline = outlineColor - ? { - borderColor: outlineColor, - } - : {}; - return ( - - {children} - - ); - } -} - -const styles = StyleSheet.create({ - containerStyle: { - flexDirection: "row", - alignItems: "center", - justifyContent: "center", - backgroundColor: "transparent", - borderRadius: 4, - borderWidth: 2, - borderColor: colors.live, - paddingVertical: 16, - }, -}); diff --git a/src/components/ReceiveFundsButton.js b/src/components/ReceiveFundsButton.js deleted file mode 100644 index fc0a591290..0000000000 --- a/src/components/ReceiveFundsButton.js +++ /dev/null @@ -1,22 +0,0 @@ -/* @flow */ -import React, { Component } from "react"; -import { StyleSheet } from "react-native"; -import GenericButton from "./GenericButton"; - -export default class ReceiveFundsButton extends Component<*> { - render() { - return ; - } -} - -const styles = StyleSheet.create({ - container: { - width: 80, - height: 40, - margin: 10, - backgroundColor: "white", - borderRadius: 8, - alignItems: "center", - justifyContent: "center", - }, -}); diff --git a/src/components/RedButton.js b/src/components/RedButton.js deleted file mode 100644 index 82c311d152..0000000000 --- a/src/components/RedButton.js +++ /dev/null @@ -1,26 +0,0 @@ -/* @flow */ -import React, { Component } from "react"; -import { StyleSheet } from "react-native"; -import GenericButton from "./GenericButton"; - -export default class RedButton extends Component<*> { - render() { - return ( - - ); - } -} -const styles = StyleSheet.create({ - title: { - color: "#f00", - }, - container: { - backgroundColor: "#fff", - borderWidth: 1, - borderColor: "#f00", - }, -}); diff --git a/src/components/WhiteButton.js b/src/components/WhiteButton.js deleted file mode 100644 index 6a7c5f510b..0000000000 --- a/src/components/WhiteButton.js +++ /dev/null @@ -1,19 +0,0 @@ -/* @flow */ -import React, { Component } from "react"; -import colors from "../colors"; -import GenericButton from "./GenericButton"; - -export default class WhiteButton extends Component<*> { - render() { - return ( - - ); - } -} diff --git a/src/index.js b/src/index.js index f105745248..072b6550bb 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ import { exportSelector as accountsExportSelector } from "./reducers/accounts"; import CounterValues from "./countervalues"; import LocaleProvider from "./context/Locale"; import RebootProvider from "./context/Reboot"; +import ButtonUseTouchable from "./context/ButtonUseTouchable"; import AuthPass from "./context/AuthPass"; import LedgerStoreProvider from "./context/LedgerStore"; import { RootNavigator } from "./navigators"; @@ -101,7 +102,9 @@ export default class Root extends Component<{}, {}> { - + + + diff --git a/src/screens/Account/EmptyStateAccount.js b/src/screens/Account/EmptyStateAccount.js index 296684d2f8..f9a9bbe4d4 100644 --- a/src/screens/Account/EmptyStateAccount.js +++ b/src/screens/Account/EmptyStateAccount.js @@ -8,7 +8,7 @@ import type { Account } from "@ledgerhq/live-common/lib/types"; import colors from "../../colors"; import type { T } from "../../types/common"; import LText from "../../components/LText"; -import BlueButton from "../../components/BlueButton"; +import Button from "../../components/Button"; import Receive from "../../icons/Receive"; class EmptyStateAccount extends PureComponent<{ @@ -40,12 +40,12 @@ class EmptyStateAccount extends PureComponent<{ {config.READ_ONLY === "0" && ( - } + containerStyle={styles.receiveButton} + iconLeft={Receive} /> )} @@ -67,11 +67,7 @@ const styles = StyleSheet.create({ body: { alignItems: "center", }, - buttonTitle: { - fontSize: 16, - }, - recieveButton: { - height: 48, + receiveButton: { width: 290, }, title: { diff --git a/src/screens/AccountSettings/DeleteAccountModal.js b/src/screens/AccountSettings/DeleteAccountModal.js index f835ccbb70..5fc09f46e2 100644 --- a/src/screens/AccountSettings/DeleteAccountModal.js +++ b/src/screens/AccountSettings/DeleteAccountModal.js @@ -9,8 +9,7 @@ import Trash from "../../icons/Trash"; import type { T } from "../../types/common"; import colors from "../../colors"; import ModalBottomAction from "../../components/ModalBottomAction"; -import RedButton from "../../components/RedButton"; -import GreyButton from "../../components/GreyButton"; +import Button from "../../components/Button"; type Props = { t: T, @@ -39,17 +38,17 @@ class DeleteAccountModal extends PureComponent { } footer={ - - } @@ -66,16 +65,6 @@ const styles = StyleSheet.create({ justifyContent: "space-around", }, buttonContainer: { - height: 48, width: 136, }, - deleteButtonBg: { - backgroundColor: colors.alert, - }, - buttonTitle: { - fontSize: 16, - }, - deleteButtonTitle: { - color: colors.white, - }, }); diff --git a/src/screens/AccountSettings/EditAccountName.js b/src/screens/AccountSettings/EditAccountName.js index 18e531d0c5..91ab2fa437 100644 --- a/src/screens/AccountSettings/EditAccountName.js +++ b/src/screens/AccountSettings/EditAccountName.js @@ -19,7 +19,7 @@ import { accountScreenSelector } from "../../reducers/accounts"; import { updateAccount } from "../../actions/accounts"; import type { T } from "../../types/common"; import colors from "../../colors"; -import BlueButton from "../../components/BlueButton"; +import Button from "../../components/Button"; type Props = { navigation: NavigationScreenProp<{ @@ -86,11 +86,11 @@ class EditAccountName extends PureComponent { onSubmitEditing={this.onNameEndEditing} /> - @@ -123,10 +123,6 @@ const styles = StyleSheet.create({ }, buttonContainer: { marginHorizontal: 16, - height: 48, - }, - buttonTitle: { - fontSize: 16, }, flex: { flex: 1, diff --git a/src/screens/Accounts/AccountOrderModal.js b/src/screens/Accounts/AccountOrderModal.js index e5ac482281..bb5b45fd9a 100644 --- a/src/screens/Accounts/AccountOrderModal.js +++ b/src/screens/Accounts/AccountOrderModal.js @@ -10,7 +10,7 @@ import type { T } from "../../types/common"; import MenuTitle from "../../components/MenuTitle"; import OrderOption from "./OrderOption"; import BottomModal from "../../components/BottomModal"; -import BlueButton from "../../components/BlueButton"; +import Button from "../../components/Button"; class AccountOrderModal extends Component<{ navigation: *, @@ -26,11 +26,7 @@ class AccountOrderModal extends Component<{ - +