1
1
import { Home01SolidIcon , InformationCircleSolidIcon , Location01Icon } from '@assets/icons/icons'
2
- import { BtnTransparent } from '@components/Button'
2
+ import Btn , { BtnTransparent } from '@components/Button'
3
3
import { Gap12 } from '@components/Gap'
4
4
import { Input } from '@components/Input'
5
5
import RoundedIcon from '@components/RoundedIcon'
@@ -9,12 +9,13 @@ import SettWrapper from '@components/Settings/SettWrapper'
9
9
import { fetchLocation } from '@screens/LocationNotes/lib'
10
10
import { locationNotesStore } from '@screens/LocationNotes/locationNotesStore'
11
11
import { useQuery } from '@tanstack/react-query'
12
+ import { NavProp } from '@utils/types'
12
13
import { useCallback , useEffect , useState } from 'react'
13
14
import { BackHandler , View } from 'react-native'
14
15
import { GeoPosition } from 'react-native-geolocation-service'
15
16
import LocationDetails from './LocationDetails'
16
17
17
- export default function NewLocationNote ( ) {
18
+ export default function NewLocationNote ( { navigation } : NavProp ) {
18
19
const [ name , setName ] = useState < string > ( '' )
19
20
const [ description , setDescription ] = useState < string > ( '' )
20
21
const updateNote = locationNotesStore ( ( state ) => state . updateNote )
@@ -45,6 +46,11 @@ export default function NewLocationNote() {
45
46
return false
46
47
} , [ handleSave ] )
47
48
49
+ function saveAndGoBack ( ) {
50
+ handleSave ( )
51
+ navigation . goBack ( )
52
+ }
53
+
48
54
useEffect ( ( ) => {
49
55
const backHandler = BackHandler . addEventListener ( 'hardwareBackPress' , onBackPress )
50
56
return ( ) => backHandler . remove ( )
@@ -55,8 +61,10 @@ export default function NewLocationNote() {
55
61
return ( ) => clearTimeout ( timer )
56
62
} , [ handleSave ] )
57
63
64
+ const isDisabled = ! name || name . trim ( ) . length === 0 || ! data
65
+
58
66
return (
59
- < SettWrapper className = 'flex-1' title = { name || 'New Location Note' } >
67
+ < SettWrapper className = 'flex-1' title = { name || 'New Location Note' } onBackPress = { saveAndGoBack } >
60
68
< Gap12 className = 'mt-3' >
61
69
< SettGroup title = 'Location Name' >
62
70
< Input
@@ -68,7 +76,7 @@ export default function NewLocationNote() {
68
76
</ SettGroup >
69
77
< SettGroup title = 'Description' >
70
78
< Input
71
- placeholder = 'This is a input field with multiple lines. You can type as much as you want .'
79
+ placeholder = 'Describe this location.. .'
72
80
multiline
73
81
numberOfLines = { 10 }
74
82
value = { description }
@@ -85,12 +93,13 @@ export default function NewLocationNote() {
85
93
/>
86
94
</ SettGroup >
87
95
< LocationDetails data = { data } />
88
- < View className = 'px-5' >
96
+ < View className = 'gap-8 px-5' >
89
97
< BtnTransparent
90
98
title = { isFetching ? 'Fetching...' : 'Refetch Location' }
91
99
onPress = { ( ) => refetch ( ) }
92
100
disabled = { isFetching }
93
101
/>
102
+ < Btn title = 'Save This Location' onPress = { saveAndGoBack } disabled = { isDisabled } />
94
103
</ View >
95
104
</ Gap12 >
96
105
</ SettWrapper >
0 commit comments