Skip to content

Commit 2837de4

Browse files
committed
feat: Refactor Coordinate Notes screens; add LocationTags and CoordinateNote components, update navigation and store types
1 parent ea0ff60 commit 2837de4

File tree

7 files changed

+75
-19
lines changed

7 files changed

+75
-19
lines changed

App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CardStyleInterpolators, createStackNavigator, type StackNavigationOptio
99
import ComputerScienceSettings from '@screens/ComputerScience/ComputerScienceSettings'
1010
import CoordinateNotes from '@screens/CoordinateNotes/CoordinateNotes'
1111
import NewCoordinateNotes from '@screens/CoordinateNotes/NewCoordinateNotes'
12-
import Tags from '@screens/CoordinateNotes/Tags'
12+
import LocationTags from '@screens/CoordinateNotes/LocationTags'
1313
import DeveloperOptions from '@screens/DeveloperOptions/DeveloperOptions'
1414
import MMKVDataEditor, { type MMKVDataEditorParamList } from '@screens/DeveloperOptions/MMKVDataEditor'
1515
import MMKVDataList from '@screens/DeveloperOptions/MMKVDataList'
@@ -61,6 +61,7 @@ import { Dimensions, SafeAreaView, useColorScheme } from 'react-native'
6161
import { GestureHandlerRootView } from 'react-native-gesture-handler'
6262
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated'
6363
import './global.css'
64+
import CoordinateNote, { CoordinateNoteParamList } from '@screens/CoordinateNotes/CoordinateNote'
6465

6566
function App(): React.JSX.Element {
6667
const scheme = useColorScheme()
@@ -197,14 +198,16 @@ function Navigation() {
197198
<Stack.Screen name='Onboarding' component={Onboarding} options={NO_ANIMATION} />
198199
<Stack.Screen name='CoordinateNotes' component={CoordinateNotes} options={GestureEnabled} />
199200
<Stack.Screen name='NewCoordinateNotes' component={NewCoordinateNotes} options={GestureEnabled} />
200-
<Stack.Screen name='Tags' component={Tags} options={IOS_BOTTOM_STYLE} />
201+
<Stack.Screen name='LocationTags' component={LocationTags} options={IOS_BOTTOM_STYLE} />
202+
<Stack.Screen name='CoordinateNote' component={CoordinateNote} options={GestureEnabled} />
201203
</Stack.Navigator>
202204
</>
203205
)
204206
}
205207

206208
export type RootStackParamList = {
207-
Tags: undefined
209+
CoordinateNote: CoordinateNoteParamList
210+
LocationTags: undefined
208211
Home: undefined
209212
Location: undefined
210213
Test: undefined
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import SettWrapper from '@components/Settings/SettWrapper'
2+
import { RouteProp } from '@react-navigation/native'
3+
import { LocationNote } from '@screens/CoordinateNotes/coordinateNotesStore'
4+
import { Medium } from '@utils/fonts'
5+
import type { StackNav } from '@utils/types'
6+
7+
type ParamList = {
8+
CoordinateNote: CoordinateNoteParamList
9+
}
10+
11+
export type CoordinateNoteParamList = {
12+
data: LocationNote
13+
}
14+
15+
type CoordinateNoteProps = {
16+
route: RouteProp<ParamList, 'CoordinateNote'>
17+
navigation: StackNav
18+
}
19+
20+
export default function CoordinateNote({ navigation, route }: CoordinateNoteProps) {
21+
const data = route.params.data
22+
23+
return (
24+
<>
25+
<SettWrapper navigation={navigation} title={data.title}>
26+
<Medium>{JSON.stringify(data, null, 2)}</Medium>
27+
</SettWrapper>
28+
</>
29+
)
30+
}

src/screens/CoordinateNotes/CoordinateNotes.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { coordinateNotesStore } from '@screens/CoordinateNotes/coordinateNotesStore'
2-
import { PlusSignSolidIcon } from '@assets/icons/icons'
1+
import { Location01Icon, PlusSignSolidIcon } from '@assets/icons/icons'
2+
import { Gap12 } from '@components/Gap'
33
import Press from '@components/Press'
4+
import RoundedIcon from '@components/RoundedIcon'
5+
import SettGroup from '@components/Settings/SettGroup'
6+
import { SettOption } from '@components/Settings/SettOption'
7+
import SettText from '@components/Settings/SettText'
48
import SettWrapper from '@components/Settings/SettWrapper'
59
import { useNavigation } from '@react-navigation/native'
10+
import { coordinateNotesStore } from '@screens/CoordinateNotes/coordinateNotesStore'
611
import fabStyles from '@screens/Home/styles/fabStyles'
7-
import { Medium } from '@utils/fonts'
812
import type { NavProp, StackNav } from '@utils/types'
913
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated'
1014
import { useSafeAreaInsets } from 'react-native-safe-area-context'
@@ -15,8 +19,25 @@ export default function CoordinateNotes({ navigation }: NavProp) {
1519
return (
1620
<>
1721
<SettWrapper navigation={navigation} title='Coordinate Notes'>
18-
<NoNotes />
19-
<Medium>{JSON.stringify(notes, null, 2)}</Medium>
22+
<NoNotes notes={notes} />
23+
<Gap12>
24+
<SettText className='mt-3.5'>
25+
{notes.length === 0
26+
? ''
27+
: `Found ${notes.length} note${notes.length > 1 ? 's' : ''}. Tap on a note to view details.`}
28+
</SettText>
29+
<SettGroup title='Notes'>
30+
{notes.map((item) => (
31+
<SettOption
32+
key={item.location.timestamp}
33+
title={item.title}
34+
Icon={<RoundedIcon Icon={Location01Icon} />}
35+
arrow
36+
onPress={() => navigation.navigate('CoordinateNote', { data: item })}
37+
/>
38+
))}
39+
</SettGroup>
40+
</Gap12>
2041
</SettWrapper>
2142
<FabButton />
2243
</>

src/screens/CoordinateNotes/Tags.tsx renamed to src/screens/CoordinateNotes/LocationTags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Bold, Medium } from '@utils/fonts'
44
import { StatusBar, View } from 'react-native'
55
import { ScrollView } from 'react-native-gesture-handler'
66

7-
export default function Tags() {
7+
export default function LocationTags() {
88
return (
99
<View className='flex-1 bg-zinc-50 dark:bg-zinc-950'>
1010
<StatusBar barStyle='default' />

src/screens/CoordinateNotes/NewCoordinateNotes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function NewCoordinateNotes({ navigation }: NavProp) {
6969
title=''
7070
placeholder='Add a tag'
7171
Icon={<RoundedIcon Icon={Home01SolidIcon} className='bg-rose-500' />}
72-
onPress={() => navigation.navigate('Tags')}
72+
onPress={() => navigation.navigate('LocationTags')}
7373
arrow
7474
/>
7575
</SettGroup>

src/screens/CoordinateNotes/NoCoordinateNotes.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { Lottie } from '@components/Lottie'
33
import { W } from '@utils/dimensions'
44
import { Regular } from '@utils/fonts'
55
import { View } from 'react-native'
6+
import { LocationNote } from './coordinateNotesStore'
67

7-
export default function CoordinateNotes() {
8+
export default function CoordinateNotes({ notes }: { notes: LocationNote[] }) {
9+
if (notes.length > 0) return null
810
return (
911
<View>
1012
<Lottie source={Animations.location} size={W} />

src/screens/CoordinateNotes/coordinateNotesStore.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import S from '@utils/storage'
22
import { GeoPosition } from 'react-native-geolocation-service'
33
import { create } from 'zustand'
44

5-
type Note = {
5+
export type LocationNote = {
66
title: string
77
description: string
88
location: GeoPosition
99
}
1010

1111
type CoordinateNotesStore = {
12-
notes: Note[]
13-
setNotes: (notes: Note[]) => void
14-
newNote: (note: Note) => void
12+
notes: LocationNote[]
13+
setNotes: (notes: LocationNote[]) => void
14+
newNote: (note: LocationNote) => void
1515
}
1616

1717
export const coordinateNotesStore = create<CoordinateNotesStore>((set) => ({
1818
notes: getNotes(),
19-
setNotes: (notes: Note[]) => setNotes(notes, set),
20-
newNote : (note: Note) => newNote(note, set),
19+
setNotes: (notes: LocationNote[]) => setNotes(notes, set),
20+
newNote: (note: LocationNote) => newNote(note, set),
2121
}))
2222

2323
type Set = (fn: (state: CoordinateNotesStore) => CoordinateNotesStore) => void
@@ -26,13 +26,13 @@ function getNotes() {
2626
return JSON.parse(S.get('CoordinateNotes') || '[]')
2727
}
2828

29-
function newNote(note: Note, set: Set) {
29+
function newNote(note: LocationNote, set: Set) {
3030
const notes = getNotes()
3131
notes.push(note)
3232
setNotes(notes, set)
3333
}
3434

35-
function setNotes(notes: Note[], set: Set) {
35+
function setNotes(notes: LocationNote[], set: Set) {
3636
S.set('CoordinateNotes', JSON.stringify(notes))
3737
set((state) => ({ ...state, notes }))
3838
}

0 commit comments

Comments
 (0)