1- import { StyleSheet , Text , View , TouchableOpacity , ScrollView , TextInput } from 'react-native' ;
1+ import { StyleSheet , Text , View , TouchableOpacity , ScrollView , TextInput , KeyboardAvoidingView , Platform } from 'react-native' ;
22import * as React from 'react' ;
33import { useEffect , useState } from 'react' ;
44import { type StackNavigationProp } from '@react-navigation/stack' ;
@@ -11,6 +11,8 @@ import { EnergyAPI } from '../../APIs/EnergyAPI';
1111import { type EnergyEntry } from '../../models/Energy' ;
1212import { UsersAPI } from '../../APIs/UsersAPI' ;
1313import { type User } from '../../models/User' ;
14+ import Ionicons from '@expo/vector-icons/Ionicons' ;
15+
1416
1517export type StackNavigation = StackNavigationProp < RootStackParamList > ;
1618
@@ -68,55 +70,67 @@ export default function EnergyEntryEdit(): JSX.Element {
6870 }
6971
7072 return (
71- < SafeAreaView style = { styles . container } >
72- < ScrollView style = { styles . scrollContainer } >
73- < Text style = { styles . header } > Calculate your emissions from energy:</ Text >
74-
75- < View style = { styles . questionContainer } >
76- < Text style = { styles . question } > What is your monthly electricity consumption, in kWh:</ Text >
77- < TextInput
78- style = { styles . input }
79- keyboardType = "numeric"
80- placeholder = { String ( energyEntry ?. electricity ) }
81- onChangeText = { ( text ) => {
82- setElectricityUsage ( Number ( text ) ) ;
83- } }
84- />
85- </ View >
86-
87- < View style = { styles . questionContainer } >
88- < Text style = { styles . question } >
89- What is your monthly natural gas consumption, in { 'm\u00B3' } :
90- </ Text >
91- < TextInput
92- style = { styles . input }
93- keyboardType = "numeric"
94- placeholder = { String ( energyEntry ?. natural_gas ) }
95- onChangeText = { ( text ) => {
96- setNaturalGasUsage ( Number ( text ) ) ;
97- } }
98- />
99- </ View >
100-
101- < View style = { styles . questionContainer } >
102- < Text style = { styles . question } >
103- What is your monthly heating oil consumption, in litres:
104- </ Text >
105- < TextInput
106- style = { styles . input }
107- keyboardType = "numeric"
108- placeholder = { String ( energyEntry ?. heating_oil ) }
109- onChangeText = { ( text ) => {
110- setHeatingOilUsage ( Number ( text ) ) ;
111- } }
112- />
113- </ View >
114-
115- < TouchableOpacity style = { styles . buttoning } onPress = { handleSurveySubmit } >
116- < Text style = { styles . buttoningText } > Save</ Text >
117- </ TouchableOpacity >
118- </ ScrollView >
119- </ SafeAreaView >
73+ < KeyboardAvoidingView
74+ behavior = { Platform . OS === "ios" ? "padding" : "height" }
75+ style = { styles . container }
76+ >
77+ < SafeAreaView style = { styles . container } >
78+ < ScrollView style = { styles . scrollContainer } >
79+ < View style = { styles . headerContainer } >
80+ < TouchableOpacity style = { styles . backButton } onPress = { ( ) => navigation . goBack ( ) } >
81+ < Ionicons name = "arrow-back" size = { 30 } color = { Colors . DARKDARKGREEN } />
82+ < Text style = { styles . buttonText } > Your Forms </ Text >
83+ </ TouchableOpacity >
84+ < Text style = { styles . header } > Calculate Your Energy Emissions!</ Text >
85+ < Text style = { styles . note } > Tip💡: Check your monthly bill to find your usage or email your landlord, they should have the information you need. </ Text >
86+ </ View >
87+
88+ < View style = { styles . questionContainer } >
89+ < Text style = { styles . question } > What is your monthly electricity consumption, in kWh:</ Text >
90+ < TextInput
91+ style = { styles . input }
92+ keyboardType = "numeric"
93+ placeholder = { String ( energyEntry ?. electricity ) }
94+ onChangeText = { ( text ) => {
95+ setElectricityUsage ( Number ( text ) ) ;
96+ } }
97+ />
98+ </ View >
99+
100+ < View style = { styles . questionContainer } >
101+ < Text style = { styles . question } >
102+ What is your monthly natural gas consumption, in { 'm\u00B3' } :
103+ </ Text >
104+ < TextInput
105+ style = { styles . input }
106+ keyboardType = "numeric"
107+ placeholder = { String ( energyEntry ?. natural_gas ) }
108+ onChangeText = { ( text ) => {
109+ setNaturalGasUsage ( Number ( text ) ) ;
110+ } }
111+ />
112+ </ View >
113+
114+ < View style = { styles . questionContainer } >
115+ < Text style = { styles . question } >
116+ What is your monthly heating oil consumption, in litres:
117+ </ Text >
118+ < TextInput
119+ style = { styles . input }
120+ keyboardType = "numeric"
121+ placeholder = { String ( energyEntry ?. heating_oil ) }
122+ onChangeText = { ( text ) => {
123+ setHeatingOilUsage ( Number ( text ) ) ;
124+ } }
125+ />
126+ </ View >
127+
128+ < TouchableOpacity style = { styles . buttoning } onPress = { handleSurveySubmit } >
129+ < Text style = { styles . buttoningText } > Save</ Text >
130+ </ TouchableOpacity >
131+ </ ScrollView >
132+ </ SafeAreaView >
133+ </ KeyboardAvoidingView >
120134 ) ;
121135}
122136
@@ -134,10 +148,8 @@ const styles = StyleSheet.create({
134148 } ,
135149 header : {
136150 color : Colors . DARKGREEN ,
137- fontFamily : 'Montserrat' ,
138- fontSize : 25 ,
151+ fontSize : 36 ,
139152 fontWeight : '700' ,
140- marginBottom : 50 ,
141153 } ,
142154 input : {
143155 borderWidth : 1 ,
@@ -148,7 +160,6 @@ const styles = StyleSheet.create({
148160 backgroundColor : Colors . WHITE ,
149161 } ,
150162 question : {
151- fontFamily : 'Montserrat' ,
152163 fontSize : 20 ,
153164 fontWeight : '700' ,
154165 color : Colors . DARKGREEN ,
@@ -169,4 +180,23 @@ const styles = StyleSheet.create({
169180 questionContainer : {
170181 paddingBottom : 30 ,
171182 } ,
183+ headerContainer :{
184+ top : 20 ,
185+ marginBottom : 40
186+ } ,
187+ backButton : {
188+ alignItems : 'center' ,
189+ flexDirection : 'row' ,
190+ } ,
191+ buttonText : {
192+ color : Colors . DARKDARKGREEN ,
193+ fontSize : 16 ,
194+ fontWeight : '700' ,
195+ } ,
196+ note :{
197+ fontSize : 16 ,
198+ fontWeight : '500' ,
199+ marginTop : 10 ,
200+ color : Colors . LIGHTBLACK
201+ } ,
172202} ) ;
0 commit comments