-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: rename navigation * feat: add recording screens * chore: cleanup * fix: timezones * cleanup: remove extra screen from events
- Loading branch information
1 parent
69384f8
commit d9d12ad
Showing
43 changed files
with
743 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Birdseye from './birdseye.svg'; | ||
import Camera from './camera.svg'; | ||
import DownSquare from './downSquare.svg'; | ||
import Event from './event.svg'; | ||
import Home from './home.svg'; | ||
import PlayRect from './play-rect.svg'; | ||
import Recording from './recording.svg'; | ||
import Settings from './settings.svg'; | ||
import Live from './video-waveform.svg'; | ||
|
||
export { | ||
PlayRect, | ||
Camera, | ||
Birdseye, | ||
DownSquare, | ||
Event, | ||
Home, | ||
Recording, | ||
Settings, | ||
Live, | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {ActivityIndicator} from 'react-native'; | ||
|
||
import {BaseView} from './baseView'; | ||
|
||
export const LoadingView = () => { | ||
return ( | ||
<BaseView className="flex-1"> | ||
<ActivityIndicator size={'large'} /> | ||
</BaseView> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './useCameraEvents'; | ||
export * from './useConfig'; | ||
export * from './useRecordings'; | ||
export * from './useRecordingSummary'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {getTimeZone} from 'react-native-localize'; | ||
import {useQuery} from 'react-query'; | ||
|
||
import {API_BASE} from '@env'; | ||
|
||
import {RecordingResponse} from '../types/recordings'; | ||
|
||
const URL = `${API_BASE}api/:camera/recordings/summary?timezone=:tz`; | ||
|
||
const fetchRecordingSummary = async (cameraName: string) => { | ||
const url = URL.replace(':camera', cameraName).replace(':tz', getTimeZone()); | ||
try { | ||
const response = await fetch(url, {method: 'get'}); | ||
const data = await response.json(); | ||
if (response.ok) { | ||
if (data) { | ||
return Promise.resolve(data as RecordingResponse[]); | ||
} | ||
} else { | ||
return Promise.reject(new Error('ResNotOK')); | ||
} | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
|
||
export const useRecordingSummary = (cameraName?: string) => { | ||
return useQuery({ | ||
queryFn: () => fetchRecordingSummary(cameraName || ''), | ||
queryKey: ['recordings', cameraName], | ||
enabled: !!cameraName, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {useQuery} from 'react-query'; | ||
|
||
import {API_BASE} from '@env'; | ||
|
||
// const buildEventUrl = (eventId: string) => { | ||
// const REC_URL = `${API_BASE}vod/event/${eventId}/index.m3u8`; | ||
// return REC_URL; | ||
// }; | ||
|
||
const URL = `${API_BASE}api/:camera/recordings`; | ||
|
||
const fetchRecordings = async (cameraName: string) => { | ||
const url = URL.replace(':camera', cameraName); | ||
try { | ||
const response = await fetch(url, {method: 'get'}); | ||
const data = await response.json(); | ||
if (response.ok) { | ||
if (data) { | ||
return Promise.resolve(data); | ||
} | ||
} else { | ||
return Promise.reject(new Error('ResNotOK')); | ||
} | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
|
||
export const useRecordings = (cameraName?: string) => | ||
useQuery({ | ||
queryFn: () => fetchRecordings(cameraName || ''), | ||
queryKey: ['recordings', cameraName], | ||
enabled: !!cameraName, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface RecordingResponse { | ||
day: string; | ||
events: number; | ||
hours?: HoursEntity[] | null; | ||
} | ||
|
||
export interface HoursEntity { | ||
duration: number; | ||
events: number; | ||
hour: string; | ||
motion: number; | ||
objects: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import {useColorScheme} from 'react-native'; | ||
|
||
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; | ||
|
||
import {EventsScreen, LiveViewScreen, RecordingsScreen} from '@screens'; | ||
import {hslToHex} from '@utils'; | ||
|
||
import {colors} from '../../themeColors.js'; | ||
|
||
import {TabBarIcon} from './components/TabBarIcon'; | ||
|
||
export type CameraTabsStackParamList = { | ||
Events: undefined; | ||
Live: undefined; | ||
Recordings: undefined; | ||
}; | ||
|
||
const CameraTabStack = createBottomTabNavigator<CameraTabsStackParamList>(); | ||
|
||
export const CameraTabNavigator = () => { | ||
const isDarkMode = useColorScheme() === 'dark'; | ||
|
||
return ( | ||
<CameraTabStack.Navigator | ||
screenOptions={({route}) => ({ | ||
headerTitle: '', | ||
tabBarIcon: ({color, size}) => | ||
TabBarIcon({color, size, route, isDarkMode}), | ||
tabBarActiveTintColor: isDarkMode ? 'white' : 'black', | ||
tabBarInactiveTintColor: 'gray', | ||
tabBarStyle: { | ||
borderTopWidth: 0, | ||
backgroundColor: isDarkMode | ||
? hslToHex(colors.dark.background) | ||
: hslToHex(colors.light.background), | ||
}, | ||
header: () => null, | ||
})}> | ||
<CameraTabStack.Screen name="Live" component={LiveViewScreen} /> | ||
<CameraTabStack.Screen name="Events" component={EventsScreen} /> | ||
<CameraTabStack.Screen name="Recordings" component={RecordingsScreen} /> | ||
</CameraTabStack.Navigator> | ||
); | ||
}; |
Oops, something went wrong.