wip on profile edit form fields

This commit is contained in:
ue 2019-09-05 23:35:42 +03:00
parent 525f2bff1c
commit e4f3bd4758
12 changed files with 110 additions and 21 deletions

View File

@ -28,4 +28,19 @@ export default EStyleSheet.create({
fontSize: 12, fontSize: 12,
marginTop: 4, marginTop: 4,
}, },
addIcon: {
color: '$white',
textAlign: 'center',
},
addButton: {
backgroundColor: '$iconColor',
width: 20,
height: 20,
borderRadius: 20 / 2,
borderColor: '$white',
borderWidth: 1,
position: 'absolute',
bottom: 0,
left: 45,
},
}); });

View File

@ -9,7 +9,7 @@ import { IconButton } from '../iconButton';
// Styles // Styles
import styles from './avatarHeaderStyles'; import styles from './avatarHeaderStyles';
const TooltipView = ({ username, name, reputation, navigation }) => ( const AvatarHeader = ({ username, name, reputation, navigation, avatarUrl }) => (
<LinearGradient <LinearGradient
start={{ x: 0, y: 0 }} start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }} end={{ x: 1, y: 0 }}
@ -25,7 +25,15 @@ const TooltipView = ({ username, name, reputation, navigation }) => (
size={25} size={25}
/> />
<View style={styles.wrapper}> <View style={styles.wrapper}>
<UserAvatar noAction size="xl" username={username} /> <UserAvatar noAction size="xl" username={username} avatarUrl={avatarUrl} />
<IconButton
iconStyle={styles.addIcon}
style={styles.addButton}
iconType="MaterialCommunityIcons"
name="plus"
onPress={() => alert('upload')}
size={15}
/>
<View style={styles.textWrapper}> <View style={styles.textWrapper}>
<Text style={styles.name}>{name}</Text> <Text style={styles.name}>{name}</Text>
<Text style={styles.username}>{`@${username} (${reputation})`}</Text> <Text style={styles.username}>{`@${username} (${reputation})`}</Text>
@ -35,4 +43,4 @@ const TooltipView = ({ username, name, reputation, navigation }) => (
</LinearGradient> </LinearGradient>
); );
export default withNavigation(TooltipView); export default withNavigation(AvatarHeader);

View File

@ -4,8 +4,7 @@ export default EStyleSheet.create({
wrapper: { wrapper: {
borderTopLeftRadius: 8, borderTopLeftRadius: 8,
borderTopRightRadius: 8, borderTopRightRadius: 8,
marginHorizontal: 30, marginTop: 16,
marginVertical: 10,
flexDirection: 'row', flexDirection: 'row',
backgroundColor: '$primaryGray', backgroundColor: '$primaryGray',
height: 60, height: 60,

View File

@ -30,17 +30,10 @@ class FormInputView extends Component {
value: '', value: '',
inputBorderColor: '#c1c5c7', inputBorderColor: '#c1c5c7',
isValid: true, isValid: true,
formInputWidth: '99%',
}; };
} }
// Component Life Cycles // Component Life Cycles
componentWillMount() {
setTimeout(() => {
this.setState({ formInputWidth: '100%' });
}, 100);
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { isValid } = this.props; const { isValid } = this.props;
@ -65,7 +58,7 @@ class FormInputView extends Component {
}; };
render() { render() {
const { inputBorderColor, isValid, value, formInputWidth } = this.state; const { inputBorderColor, isValid, value } = this.state;
const { const {
placeholder, placeholder,
type, type,
@ -75,6 +68,8 @@ class FormInputView extends Component {
rightIconName, rightIconName,
secureTextEntry, secureTextEntry,
iconType, iconType,
wrapperStyle,
height,
} = this.props; } = this.props;
return ( return (
<View <View
@ -83,6 +78,7 @@ class FormInputView extends Component {
{ {
borderBottomColor: isValid ? inputBorderColor : 'red', borderBottomColor: isValid ? inputBorderColor : 'red',
}, },
wrapperStyle,
]} ]}
> >
{isFirstImage && value && value.length > 2 ? ( {isFirstImage && value && value.length > 2 ? (
@ -97,19 +93,21 @@ class FormInputView extends Component {
/> />
</View> </View>
) : ( ) : (
<Icon iconType={iconType || 'MaterialIcons'} name={rightIconName} style={styles.icon} /> rightIconName && (
<Icon iconType={iconType || 'MaterialIcons'} name={rightIconName} style={styles.icon} />
)
)} )}
<View style={styles.textInput}> <View style={styles.textInput}>
<TextInput <TextInput
onFocus={() => this._handleOnFocus()} onFocus={() => this._handleOnFocus()}
autoCapitalize="none" autoCapitalize="none"
secureTextEntry={secureTextEntry} secureTextEntry={secureTextEntry}
height={height}
placeholder={placeholder} placeholder={placeholder}
editable={isEditable || true} editable={isEditable || true}
textContentType={type} textContentType={type}
onChangeText={val => this._handleOnChange(val)} onChangeText={val => this._handleOnChange(val)}
value={value} value={value}
style={{ width: formInputWidth }}
/> />
</View> </View>

View File

@ -10,6 +10,7 @@ import { TextInput } from './textInput';
import ScaleSlider from './scaleSlider/scaleSliderView'; import ScaleSlider from './scaleSlider/scaleSliderView';
import UserListItem from './basicUIElements/view/userListItem/userListItem'; import UserListItem from './basicUIElements/view/userListItem/userListItem';
import PostButton from './postButton/postButtonView'; import PostButton from './postButton/postButtonView';
import ProfileEditForm from './profileEditForm/profileEditFormView';
export { export {
CircularButton, CircularButton,
@ -20,10 +21,11 @@ export {
Modal, Modal,
NumericKeyboard, NumericKeyboard,
PinAnimatedInput, PinAnimatedInput,
PostButton,
ProfileEditForm,
ScaleSlider, ScaleSlider,
SideMenu, SideMenu,
TextButton, TextButton,
TextInput, TextInput,
UserListItem, UserListItem,
PostButton,
}; };

View File

@ -0,0 +1,14 @@
import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({
container: {
paddingHorizontal: 32,
paddingVertical: 16,
backgroundColor: '$primaryBackgroundColor',
flex: 1,
},
formStyle: {
backgroundColor: '$white',
height: 30,
},
});

View File

@ -0,0 +1,38 @@
import React from 'react';
import { withNavigation } from 'react-navigation';
import { View, Text, Platform } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
// Components
import { FormInput } from '../formInput';
// Styles
import styles from './profileEditFormStyles';
const ProfileEditFormView = ({ avatarUrl, coverUrl, name, about, location, website }) => (
<View style={styles.container}>
<KeyboardAwareScrollView
enableAutoAutomaticScroll={Platform.OS === 'ios'}
contentContainerStyle={{ flexGrow: 1 }}
>
<Text>Profile picture URL</Text>
<FormInput
wrapperStyle={styles.formStyle}
isValid
height={30}
onChange={value => alert('changed')}
placeholder="profile picture url"
isEditable
type="username"
isFirstImage
value="sex"
/>
</KeyboardAwareScrollView>
</View>
);
export default withNavigation(ProfileEditFormView);
// placeholder={intl.formatMessage({
// id: 'login.username',
// })}

View File

@ -5,9 +5,9 @@ import { connect } from 'react-redux';
// Styles // Styles
import styles from './textInputStyles'; import styles from './textInputStyles';
const TextInputView = ({ isDarkTheme, innerRef, ...props }) => ( const TextInputView = ({ isDarkTheme, innerRef, height, ...props }) => (
<TextInput <TextInput
style={styles.input} style={[styles.input, { minHeight: height }]}
ref={innerRef} ref={innerRef}
keyboardAppearance={isDarkTheme ? 'dark' : 'light'} keyboardAppearance={isDarkTheme ? 'dark' : 'light'}
{...props} {...props}

View File

@ -42,12 +42,12 @@ class UserAvatarView extends Component {
}; };
render() { render() {
const { username, size, style, disableSize, noAction } = this.props; const { username, size, style, disableSize, noAction, avatarUrl } = this.props;
const imageSize = size === 'xl' ? 'large' : 'small'; const imageSize = size === 'xl' ? 'large' : 'small';
let _size; let _size;
const _avatar = username const _avatar = username
? { uri: `https://steemitimages.com/u/${username}/avatar/${imageSize}` } ? { uri: `https://steemitimages.com/u/${username}/avatar/${imageSize}` }
: DEFAULT_IMAGE; : avatarUrl || DEFAULT_IMAGE;
if (!disableSize) { if (!disableSize) {
_size = 32; _size = 32;

View File

@ -102,7 +102,7 @@ class LoginScreen extends PureComponent {
onKeyboardWillShow={() => this.setState({ keyboardIsOpen: true })} onKeyboardWillShow={() => this.setState({ keyboardIsOpen: true })}
onKeyboardWillHide={() => this.setState({ keyboardIsOpen: false })} onKeyboardWillHide={() => this.setState({ keyboardIsOpen: false })}
enableAutoAutomaticScroll={Platform.OS === 'ios'} enableAutoAutomaticScroll={Platform.OS === 'ios'}
contentContainerStyle={{ flexGrow: 1 }} contentContainerStyle={styles.formWrapper}
> >
<FormInput <FormInput
rightIconName="at" rightIconName="at"

View File

@ -34,4 +34,9 @@ export default EStyleSheet.create({
cancelButton: { cancelButton: {
marginRight: 10, marginRight: 10,
}, },
formWrapper: {
flexGrow: 1,
marginHorizontal: 30,
marginVertical: 10,
},
}); });

View File

@ -5,6 +5,7 @@ import get from 'lodash/get';
import { ProfileEditContainer } from '../../../containers'; import { ProfileEditContainer } from '../../../containers';
import AvatarHeader from '../../../components/avatarHeader/avatarHeaderView'; import AvatarHeader from '../../../components/avatarHeader/avatarHeaderView';
import ProfileEditForm from '../../../components/profileEditForm/profileEditFormView';
class ProfileEditScreen extends PureComponent { class ProfileEditScreen extends PureComponent {
/* Props /* Props
@ -30,6 +31,15 @@ class ProfileEditScreen extends PureComponent {
username={get(currentAccount, 'name')} username={get(currentAccount, 'name')}
name={get(currentAccount, 'about.profile.name')} name={get(currentAccount, 'about.profile.name')}
reputation={get(currentAccount, 'reputation')} reputation={get(currentAccount, 'reputation')}
avatarUrl={null}
/>
<ProfileEditForm
about={get(currentAccount, 'about.profile.about')}
name={get(currentAccount, 'about.profile.name')}
location="location"
website="website"
coverUrl={get(currentAccount, 'reputation')}
avatarUrl={null}
/> />
</Fragment> </Fragment>
)} )}