From 7cdb783108a11965e1b1ceaf95649fd21ef848fd Mon Sep 17 00:00:00 2001 From: Bartosz Klonowski Date: Thu, 15 Apr 2021 13:30:41 +0200 Subject: [PATCH 1/7] Create the full layout of User's account page --- src/UserAccountPanel.js | 152 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 13 deletions(-) diff --git a/src/UserAccountPanel.js b/src/UserAccountPanel.js index 3393f4a..47b7c6a 100644 --- a/src/UserAccountPanel.js +++ b/src/UserAccountPanel.js @@ -7,21 +7,116 @@ import React from 'react'; import { AppRegistry, StyleSheet, - Text, View, + NativeModules, + Alert, + Image, + TextInput, + Button, + Dimensions, + Text, } from 'react-native'; class UserAccountPanel extends React.Component { + constructor(props) { + super(props); + this.state = { + avatarPicture: "", + userName: "", + userEmail: "", + isEditing: false, + } + }; + + componentDidMount() { + Dimensions.addEventListener("change", this.windowDimensionOnChange); + }; + + componentWillUnmount() { + Dimensions.removeEventListener("change", this.windowDimensionOnChange); + }; + + windowDimensionOnChange = ({window, screen}) => { + this.setState({windowWidth: window.width, windowHeight: window.height}); + }; + + userNameOnChange = (text) => { + this.setState({userName: text}); + }; + + userEmailOnChange = (text) => { + this.setState({userEmail: text}); + } + + + quitButtonPressed = () => { + if(this.state.isEditing) { + Alert.alert("Are you sure?", "It looks like you still have unsaved changes, which are going to be lost.", + [ + { + text: "No!", + style: "cancel" + }, + { + text: "Yes, quit!", + onPress: () => NativeModules.NoteWidgetClickHandler.goToNotesScreen() + } + ]) + } + else { + NativeModules.NoteWidgetClickHandler.goToNotesScreen(); + } + }; + + saveButtonPressed = () => { + NativeModules.Database.updateNote(this.state.title, this.state.message, this.state.id); + this.setState({isEditing: false}); + } + + editButtonPressed = () => { + this.setState({isEditing: true}); + }; + + setAvatar = () => { + }; + render() { - return( - - - UserAccountPanel - This panel will have all the features of User's account. - Further implementation will yet be done! + return ( + + + + + + +