Skip to content

Commit 2e2fd91

Browse files
Merge pull request #216 from galio-org/dev
v0.7.0
2 parents 1332ffc + c7fd335 commit 2e2fd91

File tree

19 files changed

+515
-184
lines changed

19 files changed

+515
-184
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "galio-framework",
33
"main": "src/index.js",
4-
"version": "0.6.3",
4+
"version": "0.7.0",
55
"files": [
66
"src/"
77
],

src/Accordion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
import PropTypes from "prop-types";
1010

1111
import Block from "./Block";
12-
import Icon from "./Icon";
13-
import Text from "./Text";
12+
import Icon from "./atomic/ions/Icon";
13+
import Text from "./atomic/ions/Text";
1414
import GalioTheme from "./theme";
1515

1616
const { width } = Dimensions.get("screen");

src/Avatar.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import React from 'react';
2+
import { View, Text, StyleSheet, Image, ViewPropTypes } from 'react-native';
3+
import PropTypes from 'prop-types';
4+
import { withGalio } from 'theme';
5+
6+
const Avatar = ({
7+
source,
8+
size,
9+
label,
10+
labelColor,
11+
backgroundColor,
12+
labelStyle,
13+
imageProps,
14+
imageStyle,
15+
containerStyle,
16+
styles,
17+
theme,
18+
}) => {
19+
const getContainerStyle = () => {
20+
return {
21+
width: size,
22+
height: size,
23+
alignItems: 'center',
24+
justifyContent: 'center',
25+
borderRadius: size / 2,
26+
};
27+
};
28+
29+
const getLabelContainerStyle = () => {
30+
return {
31+
...StyleSheet.absoluteFillObject,
32+
alignItems: 'center',
33+
justifyContent: 'center',
34+
borderRadius: size / 2,
35+
};
36+
};
37+
38+
const renderImage = () => {
39+
if (source) {
40+
return (
41+
<Image
42+
style={[getContainerStyle(), StyleSheet.absoluteFillObject, imageStyle]}
43+
{...{ source }}
44+
{...imageProps}
45+
/>
46+
);
47+
}
48+
return null;
49+
};
50+
51+
const labelContainerStyle = [
52+
getLabelContainerStyle(),
53+
source && styles.labelContainerWithInset,
54+
{ backgroundColor: backgroundColor || theme.COLORS.MUTED },
55+
];
56+
57+
const labelTextStyle = [
58+
{ fontSize: size * 0.32 },
59+
styles.labelText,
60+
labelColor && { color: labelColor },
61+
labelStyle || {},
62+
];
63+
64+
return (
65+
<View style={[getContainerStyle(), containerStyle]}>
66+
<View style={labelContainerStyle}>
67+
{label && (
68+
<Text numberOfLines={1} style={labelTextStyle}>
69+
{label}
70+
</Text>
71+
)}
72+
</View>
73+
{renderImage()}
74+
</View>
75+
);
76+
};
77+
78+
Avatar.defaultProps = {
79+
size: 50,
80+
};
81+
82+
Avatar.propTypes = {
83+
label: PropTypes.string,
84+
labelColor: PropTypes.string,
85+
size: PropTypes.number,
86+
source: PropTypes.oneOfType([PropTypes.object, PropTypes.number]),
87+
backgroundColor: PropTypes.string,
88+
imageProps: PropTypes.object,
89+
imageStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.number]),
90+
containerStyle: ViewPropTypes.style,
91+
styles: PropTypes.any,
92+
theme: PropTypes.any,
93+
};
94+
95+
const styles = theme =>
96+
StyleSheet.create({
97+
labelContainerWithInset: {
98+
top: 1,
99+
right: 1,
100+
bottom: 1,
101+
left: 1,
102+
},
103+
labelText: {
104+
color: theme.COLORS.BLACK,
105+
backgroundColor: 'transparent',
106+
},
107+
});
108+
109+
export default withGalio(Avatar, styles);

src/Card.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import React from 'react';
33
import { Image, StyleSheet } from 'react-native';
44
import PropTypes from 'prop-types';
5-
6-
import { Block, Icon, Text } from './';
5+
// galio components
6+
import Block from './Block';
7+
import Text from './Text';
8+
import Icon from './Icon';
79
import GalioTheme, { withGalio } from './theme';
810

911
function Card({

src/Checkbox.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import React from 'react';
33
import { View, TouchableOpacity, StyleSheet, Image } from 'react-native';
44
import PropTypes from 'prop-types';
55
// galio dependency
6-
import { Icon, Text } from './';
6+
import Icon from './Icon';
7+
import Text from './Text';
78
import GalioTheme, { withGalio } from './theme';
89

910
function Checkbox({
@@ -26,9 +27,7 @@ function Checkbox({
2627
theme,
2728
}) {
2829
const [checked, setChecked] = React.useState(initialValue);
29-
React.useEffect(() => {
30-
onChange(checked);
31-
}, [checked]);
30+
3231
// adding the necessary margins depending on the flexDirection
3332
function spaceAround(direction) {
3433
switch (direction) {
@@ -73,8 +72,9 @@ function Checkbox({
7372

7473
// onPress function that changes the component's state and callbacks the onChange prop
7574
function _onPress() {
76-
setChecked(!checked);
77-
return null;
75+
const current = !checked;
76+
onChange(current);
77+
setChecked(current);
7878
}
7979

8080
const colorStyle = theme.COLORS[color.toUpperCase()]; // this sets the correct color for the theme file

src/NavBar.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { View, TouchableOpacity, StyleSheet, Dimensions } from 'react-native';
33
import PropTypes from 'prop-types';
44

55
// galio components
6-
import { Block, Text, Icon } from './';
6+
import Block from './Block';
7+
import Text from './Text';
8+
import Icon from './Icon';
79
import GalioTheme, { withGalio } from './theme';
810

911
const { height } = Dimensions.get('screen');
@@ -16,6 +18,7 @@ function NavBar({
1618
leftStyle,
1719
leftIconColor,
1820
leftHitSlop,
21+
leftIconSize,
1922
leftIconName,
2023
leftIconFamily,
2124
onLeftPress,
@@ -44,14 +47,14 @@ function NavBar({
4447

4548
function renderLeft() {
4649
if (!hideLeft) {
47-
if (leftIconName || back) {
50+
if (leftIconName || back && !left) {
4851
return (
4952
<View style={[styles.left, leftStyle]}>
5053
<TouchableOpacity onPress={() => onLeftPress && onLeftPress()} hitSlop={leftHitSlop}>
5154
<Icon
5255
family={leftIconFamily || "evilicons"}
5356
color={leftIconColor || theme.COLORS.ICON}
54-
size={theme.SIZES.BASE * 1.0625}
57+
size={leftIconSize || theme.SIZES.BASE * 1.0625}
5558
name={leftIconName || (back ? 'chevron-left' : 'navicon')}
5659
/>
5760
</TouchableOpacity>

src/Radio.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { View, TouchableOpacity, StyleSheet } from 'react-native';
33
import PropTypes from 'prop-types';
44
// G A L I O - D E P E N D E N C Y
5-
import { Text } from './';
5+
import Text from './Text';
66
import GalioTheme, { withGalio } from './theme';
77

88
function Radio({
@@ -20,7 +20,7 @@ function Radio({
2020
theme,
2121
}) {
2222
const [checked, setChecked] = React.useState(initialValue);
23-
React.useEffect(() => onChange(checked), [checked]);
23+
2424
// A D D I N G - R E Q U I R E D - S P A C E (S) - B A S E D - O N - F L E X - D I R E C T I O N
2525
function spaceAround(direction) {
2626
switch (direction) {
@@ -53,7 +53,9 @@ function Radio({
5353

5454
// O N - P R E S S - H A N D L E R
5555
function radioPressHandler() {
56-
setChecked(!checked);
56+
const current = !checked;
57+
onChange(current);
58+
setChecked(current);
5759
}
5860

5961

src/Switch.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ function Switch({
1313
...rest
1414
}) {
1515
const [switchValue, setSwitchValue] = React.useState(initialValue);
16-
React.useEffect(() => {
17-
onChange(switchValue);
18-
}, [switchValue]);
1916
function onPressSwitch() {
2017
setSwitchValue(!switchValue);
2118
return null;
@@ -27,11 +24,12 @@ function Switch({
2724
<Switcher
2825
disabled={disabled}
2926
trackColor={{ ...trackColor }}
30-
ios_backgroundColor={ios_backgroundColor}
27+
ios_backgroundColor={trackColor.false || ios_backgroundColor}
3128
value={switchValue}
3229
onValueChange={() => {
3330
onPressSwitch();
3431
}}
32+
onChange={() => onChange()}
3533
{...rest}
3634
/>
3735
);

src/Toast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22
import { Dimensions, StyleSheet, Animated, ViewPropTypes } from 'react-native';
33
import PropTypes from 'prop-types';
44
// galio components
5-
import { Text } from '.';
5+
import Text from './Text';
66
import GalioTheme, { withGalio } from './theme';
77

88
const { height } = Dimensions.get('screen');

0 commit comments

Comments
 (0)