Skip to content

Commit 31931fd

Browse files
alexruzenhackandreabadesso
authored andcommitted
feat: add components for nano contract transactions [9] (#456)
* feat(nc): add components
1 parent f96c013 commit 31931fd

File tree

11 files changed

+305
-5
lines changed

11 files changed

+305
-5
lines changed

locale/da/texts.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ msgstr "[Sidste] dddd [•] HH:mm"
6161
msgid "DD MMM YYYY [•] HH:mm"
6262
msgstr "DD MMM YYYY [•] HH:mm"
6363

64-
#: src/utils.js:159
64+
#: src/utils.js:160
6565
msgid "Invalid address"
6666
msgstr "Ugyldig adresse"
6767

locale/pt-br/texts.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ msgstr "[Última] dddd [•] HH:mm"
6161
msgid "DD MMM YYYY [•] HH:mm"
6262
msgstr "DD MMM YYYY [•] HH:mm"
6363

64-
#: src/utils.js:159
64+
#: src/utils.js:160
6565
msgid "Invalid address"
6666
msgstr "Endereço inválido"
6767

locale/ru-ru/texts.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ msgstr "[Последний] dddd [•] HH:mm"
6262
msgid "DD MMM YYYY [•] HH:mm"
6363
msgstr "DD MMM YYYY [•] HH:mm"
6464

65-
#: src/utils.js:159
65+
#: src/utils.js:160
6666
msgid "Invalid address"
6767
msgstr "Неправильный адрес"
6868

locale/texts.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ msgstr ""
5252
msgid "DD MMM YYYY [•] HH:mm"
5353
msgstr ""
5454

55-
#: src/utils.js:159
55+
#: src/utils.js:160
5656
msgid "Invalid address"
5757
msgstr ""
5858

src/components/EditInfoContainer.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) Hathor Labs and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import {
10+
StyleSheet,
11+
View,
12+
TouchableOpacity
13+
} from 'react-native';
14+
import { COLORS } from '../styles/themes';
15+
16+
import { PenIcon } from './Icons/Pen.icon';
17+
18+
export const EditInfoContainer = ({ center, onPress, children }) => (
19+
<TouchableOpacity
20+
style={[
21+
center && styles.editInfoWrapperCentered
22+
]}
23+
onPress={onPress}
24+
>
25+
<View style={[
26+
styles.editInfoContainer,
27+
center && styles.editInfoContainerCentered,
28+
]}
29+
>
30+
<View style={[
31+
center && styles.alignCenter,
32+
]}
33+
>
34+
{children}
35+
</View>
36+
<View style={styles.editIcon}>
37+
<PenIcon />
38+
</View>
39+
</View>
40+
</TouchableOpacity>
41+
);
42+
43+
const styles = StyleSheet.create({
44+
editInfoWrapperCentered: {
45+
alignSelf: 'center',
46+
},
47+
editInfoContainer: {
48+
paddingVertical: 8,
49+
paddingLeft: 8,
50+
paddingRight: 40,
51+
borderRadius: 8,
52+
backgroundColor: COLORS.white,
53+
},
54+
editInfoContainerCentered: {
55+
paddingLeft: 40,
56+
},
57+
alignCenter: {
58+
alignItems: 'center',
59+
},
60+
editIcon: {
61+
position: 'absolute',
62+
display: 'flex',
63+
justifyContent: 'center',
64+
top: 0,
65+
right: 0,
66+
bottom: 0,
67+
width: 24,
68+
height: '100%',
69+
marginVertical: 8,
70+
marginRight: 8,
71+
},
72+
});

src/components/HathorHeader.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const HathorHeader = ({
3030
const left = React.Children.toArray(children).find(
3131
(child) => child.type.displayName === HathorHeaderLeft.displayName
3232
);
33+
const central = React.Children.toArray(children).find(
34+
(child) => child.type.displayName === HathorHeaderCentral.displayName
35+
);
3336
const right = React.Children.toArray(children).find(
3437
(child) => child.type.displayName === HathorHeaderRight.displayName
3538
);
@@ -40,6 +43,7 @@ const HathorHeader = ({
4043
&& (
4144
<InnerWrapper>
4245
{left}
46+
{central}
4347
{right}
4448
</InnerWrapper>
4549
)}
@@ -70,10 +74,14 @@ const InnerWrapper = ({ children }) => (
7074
const HathorHeaderLeft = ({ children }) => (<View>{children}</View>);
7175
HathorHeaderLeft.displayName = 'HathorHeaderLeft';
7276

77+
const HathorHeaderCentral = ({ style, children }) => <View style={style}>{children}</View>;
78+
HathorHeaderCentral.displayName = 'HathorHeaderCentral';
79+
7380
const HathorHeaderRight = ({ children }) => <View>{children}</View>;
7481
HathorHeaderRight.displayName = 'HathorHeaderRight';
7582

7683
HathorHeader.Left = HathorHeaderLeft;
84+
HathorHeader.Central = HathorHeaderCentral;
7785
HathorHeader.Right = HathorHeaderRight;
7886

7987
const CancelButton = ({ onCancel }) => (
@@ -118,7 +126,7 @@ const RightComponent = ({ rightElement, onCancel }) => {
118126

119127
const styles = StyleSheet.create({
120128
wrapper: {
121-
height: STYLE.headerHeight,
129+
minHeight: STYLE.headerHeight,
122130
flexDirection: 'row',
123131
alignItems: 'flex-end',
124132
borderColor: COLORS.borderColor,

src/components/ModalBase.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/**
2+
* Copyright (c) Hathor Labs and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import {
10+
StyleSheet,
11+
View,
12+
Text,
13+
} from 'react-native';
14+
import Modal from 'react-native-modal';
15+
16+
import { COLORS } from '../styles/themes';
17+
import NewHathorButton from './NewHathorButton';
18+
19+
const ModalBase = ({ styleModal, styleWrapper, show, onDismiss, children }) => {
20+
const hasChildren = children != null;
21+
22+
const title = hasChildren && React.Children.toArray(children).find(
23+
(child) => child.type.displayName === Title.displayName
24+
);
25+
const body = hasChildren && React.Children.toArray(children).find(
26+
(child) => child.type.displayName === Body.displayName
27+
);
28+
const button = hasChildren && React.Children.toArray(children).find(
29+
(child) => child.type.displayName === Button.displayName
30+
);
31+
const discreteButton = hasChildren && React.Children.toArray(children).find(
32+
(child) => child.type.displayName === DiscreteButton.displayName
33+
);
34+
35+
return (
36+
<Modal
37+
isVisible={show}
38+
animationIn='slideInUp'
39+
swipeDirection={['down']}
40+
onSwipeComplete={onDismiss}
41+
onBackButtonPress={onDismiss}
42+
onBackdropPress={onDismiss}
43+
style={styleModal}
44+
propagateSwipe
45+
>
46+
<View style={[
47+
styles.wrapper,
48+
styleWrapper,
49+
]}
50+
>
51+
{title && title}
52+
{body && body}
53+
{button && button}
54+
{discreteButton && discreteButton}
55+
</View>
56+
</Modal>
57+
);
58+
};
59+
60+
const Title = ({ children }) => (
61+
<View style={styles.titleWrapper}>
62+
<Text style={styles.title}>
63+
{children}
64+
</Text>
65+
</View>
66+
);
67+
Title.displayName = 'ModalBaseTitle';
68+
69+
/**
70+
* @param {Object} props
71+
* @property {ReactNode} props.children
72+
* @property {StyleProp<ViewStyle>} props.style
73+
*/
74+
const Body = ({ style, children }) => (
75+
<View style={style}>
76+
{children}
77+
</View>
78+
);
79+
Body.displayName = 'ModalBaseBody';
80+
81+
const Button = ({ title, disabled, secondary, danger, onPress }) => (
82+
<NewHathorButton title={title} {...{ disabled, secondary, danger, onPress }} />
83+
);
84+
Button.displayName = 'ModalBaseButton';
85+
86+
const DiscreteButton = ({ title, onPress }) => (
87+
<NewHathorButton title={title} discrete {...{ onPress }} wrapperStyle={styles.discreteButton} />
88+
);
89+
DiscreteButton.displayName = 'ModalBaseDiscreteButton';
90+
91+
ModalBase.Title = Title;
92+
ModalBase.Body = Body;
93+
ModalBase.Button = Button;
94+
ModalBase.DiscreteButton = DiscreteButton;
95+
96+
const styles = StyleSheet.create({
97+
wrapper: {
98+
borderRadius: 8,
99+
paddingVertical: 24,
100+
paddingHorizontal: 16,
101+
backgroundColor: COLORS.white,
102+
},
103+
titleWrapper: {
104+
paddingBottom: 20,
105+
},
106+
title: {
107+
color: 'black',
108+
fontSize: 18,
109+
lineHeight: 20,
110+
},
111+
discreteButton: {
112+
marginTop: 8,
113+
},
114+
});
115+
116+
export { ModalBase }

src/components/NewHathorButton.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const NewHathorButton = (props) => {
2121
textStyle.push(style.textDisabled);
2222
}
2323

24+
if (props.discrete) {
25+
wrapperViewStyle.push(style.wrapperDiscrete);
26+
textStyle.push(style.textDiscrete);
27+
}
28+
2429
if (props.secondary) {
2530
wrapperViewStyle.push(style.wrapperSecondary);
2631
textStyle.push(style.textSecondary);
@@ -34,6 +39,11 @@ const NewHathorButton = (props) => {
3439
}
3540
}
3641

42+
if (props.danger) {
43+
wrapperViewStyle.push(style.wrapperSecondaryDanger);
44+
textStyle.push(style.textSecondaryDanger);
45+
}
46+
3747
return (
3848
<View style={[...wrapperViewStyle, props.wrapperStyle, props.style]}>
3949
<TouchableOpacity onPress={props.onPress} style={style.touchable} disabled={props.disabled}>
@@ -79,6 +89,14 @@ const style = StyleSheet.create({
7989
wrapperSecondaryDisabled: {
8090
borderColor: COLORS.textColorShadow,
8191
},
92+
wrapperDiscrete: {
93+
backgroundColor: COLORS.backgroundColor,
94+
borderColor: COLORS.backgroundColor,
95+
borderWidth: 1.5,
96+
},
97+
wrapperSecondaryDanger: {
98+
borderColor: COLORS.errorBgColor,
99+
},
82100
touchable: {
83101
flex: 1,
84102
flexDirection: 'row',
@@ -101,6 +119,12 @@ const style = StyleSheet.create({
101119
textDisabled: {
102120
color: COLORS.textColorShadow,
103121
},
122+
textDiscrete: {
123+
color: COLORS.freeze300,
124+
},
125+
textSecondaryDanger: {
126+
color: COLORS.errorBgColor,
127+
},
104128
});
105129

106130
export default NewHathorButton;

src/components/TextLabel.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) Hathor Labs and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import {
10+
StyleSheet,
11+
Text,
12+
} from 'react-native';
13+
14+
export const TextLabel = ({ pb8, bold, children }) => (
15+
<Text style={[
16+
styles.textLabel,
17+
pb8 && styles.pb8,
18+
bold && styles.bold,
19+
]}
20+
>{children}</Text>
21+
);
22+
23+
const styles = StyleSheet.create({
24+
textLabel: {
25+
fontSize: 12,
26+
lineHeight: 20,
27+
color: 'hsla(0, 0%, 38%, 1)',
28+
},
29+
pb8: {
30+
paddingBottom: 8,
31+
},
32+
bold: {
33+
fontWeight: 'bold',
34+
},
35+
});

src/components/TextValue.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) Hathor Labs and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import {
10+
StyleSheet,
11+
Text,
12+
} from 'react-native';
13+
14+
export const TextValue = ({ bold, pb4, children }) => (
15+
<Text style={[
16+
styles.textValue,
17+
bold && styles.bold,
18+
pb4 && styles.pb4,
19+
]}
20+
>{children}</Text>
21+
);
22+
23+
const styles = StyleSheet.create({
24+
textValue: {
25+
fontSize: 14,
26+
lineHeight: 20,
27+
color: 'black',
28+
},
29+
pb4: {
30+
paddingBottom: 4,
31+
},
32+
bold: {
33+
fontWeight: 'bold',
34+
},
35+
});

0 commit comments

Comments
 (0)