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 117
/
AccountHeaderTitle.js
70 lines (65 loc) · 1.85 KB
/
AccountHeaderTitle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* @flow */
import React, { Component } from "react";
import { TouchableWithoutFeedback, View, StyleSheet } from "react-native";
import { connect } from "react-redux";
import type { NavigationScreenProp } from "react-navigation";
import type { AccountLike } from "@ledgerhq/live-common/lib/types";
import {
getAccountCurrency,
getAccountName,
} from "@ledgerhq/live-common/lib/account";
import LText from "../../components/LText";
import { accountAndParentScreenSelector } from "../../reducers/accounts";
import ParentCurrencyIcon from "../../components/ParentCurrencyIcon";
type Props = {
navigation: NavigationScreenProp<*>,
account: AccountLike,
};
const mapStateToProps = accountAndParentScreenSelector;
class AccountHeaderTitle extends Component<Props> {
onPress = () => {
// $FlowFixMe flowtyped not up to date
this.props.navigation.emit("refocus");
};
render() {
const { account } = this.props;
if (!account) return null;
return (
<TouchableWithoutFeedback onPress={this.onPress}>
<View style={styles.headerContainer}>
<View style={styles.iconContainer}>
<ParentCurrencyIcon
size={18}
currency={getAccountCurrency(account)}
/>
</View>
<LText
semiBold
secondary
numberOfLines={1}
ellipsizeMode="tail"
style={styles.title}
>
{getAccountName(account)}
</LText>
</View>
</TouchableWithoutFeedback>
);
}
}
export default connect(mapStateToProps)(AccountHeaderTitle);
const styles = StyleSheet.create({
title: {
fontSize: 16,
},
headerContainer: {
flexDirection: "row",
alignItems: "center",
marginHorizontal: 24,
paddingVertical: 5,
},
iconContainer: {
marginRight: 8,
justifyContent: "center",
},
});