-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add birdseye screen and nav button on home screen #6
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d91c7ae
Add birdseye screen and nav button on home screen
e7233b8
support dark mode
e279969
Code cleanup
612293c
Merge branch 'main' of github.com:billyjacoby/bird-watcher into featu…
b241fbd
Align icon size with settings
9fe97ca
Handle non correct birdseye settings
8f62dc4
Use new birdseye icon
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||
import {TouchableOpacity, useColorScheme} from 'react-native'; | ||||||
|
||||||
import BirdseyeIcon from '@icons/birdseye.svg'; | ||||||
import EventIcon from '@icons/event.svg'; | ||||||
import HomeIcon from '@icons/home.svg'; | ||||||
import SettingsIcon from '@icons/settings.svg'; | ||||||
|
@@ -12,7 +13,9 @@ import { | |||||
} from '@react-navigation/native'; | ||||||
import {createNativeStackNavigator} from '@react-navigation/native-stack'; | ||||||
|
||||||
import {useConfig} from '@api'; | ||||||
import { | ||||||
BirdseyeScreen, | ||||||
EventsScreen, | ||||||
HomeScreen, | ||||||
LiveViewScreen, | ||||||
|
@@ -26,6 +29,7 @@ import {colors} from '../../themeColors.js'; | |||||
|
||||||
export type MainStackParamList = { | ||||||
Home: undefined; | ||||||
Birdseye: undefined; | ||||||
Tabs: NavigatorScreenParams<TabsStackParamList>; | ||||||
Settings: undefined; | ||||||
Onboarding: undefined; | ||||||
|
@@ -43,6 +47,7 @@ const TabStack = createBottomTabNavigator<TabsStackParamList>(); | |||||
|
||||||
const TabNavigator = () => { | ||||||
const isDarkMode = useColorScheme() === 'dark'; | ||||||
|
||||||
return ( | ||||||
<TabStack.Navigator | ||||||
screenOptions={({route}) => ({ | ||||||
|
@@ -98,6 +103,30 @@ const TabNavigator = () => { | |||||
); | ||||||
}; | ||||||
|
||||||
const LeftHeaderButton = ({tintColor}: {tintColor?: string}) => { | ||||||
const nav = useNavigation(); | ||||||
const config = useConfig(); | ||||||
|
||||||
if (!config.data?.birdseye.enabled) { | ||||||
return null; | ||||||
} | ||||||
|
||||||
return ( | ||||||
<TouchableOpacity | ||||||
onPress={() => { | ||||||
nav.navigate('Birdseye'); | ||||||
}}> | ||||||
<BirdseyeIcon | ||||||
height={24} | ||||||
width={24} | ||||||
fill={tintColor} | ||||||
fillSecondary={tintColor} | ||||||
style={{marginTop: 2}} | ||||||
/> | ||||||
</TouchableOpacity> | ||||||
); | ||||||
}; | ||||||
|
||||||
const RightHeaderButton = ({tintColor}: {tintColor?: string}) => { | ||||||
const navigation = useNavigation(); | ||||||
|
||||||
|
@@ -134,6 +163,7 @@ export const RootNavigation = () => { | |||||
options={{ | ||||||
headerBackTitle: 'Back', | ||||||
headerTitle: 'Bird Watcher - Frigate', | ||||||
headerLeft: props => LeftHeaderButton(props as {tintColor: string}), | ||||||
headerRight: props => | ||||||
RightHeaderButton(props as {tintColor: string}), | ||||||
headerTintColor: isDarkMode | ||||||
|
@@ -156,6 +186,13 @@ export const RootNavigation = () => { | |||||
options={{presentation: 'modal', headerTransparent: false}} | ||||||
/> | ||||||
<Stack.Screen name="Onboarding" component={OnBoardingScreen} /> | ||||||
<Stack.Screen | ||||||
name="Birdseye" | ||||||
component={BirdseyeScreen} | ||||||
options={{ | ||||||
headerBackTitle: 'Home', | ||||||
}} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Last nit - I think this should actually be presented in a Modal since the button to access is in the nav header. It feels a bit weird that it slides in as a card now. I'm okay with adding this later too, but wanted to call it out. |
||||||
/> | ||||||
</Stack.Navigator> | ||||||
</NavigationContainer> | ||||||
); | ||||||
|
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,29 @@ | ||
import {useConfig} from '@api'; | ||
import {BaseText, WebRTCView} from '@components'; | ||
|
||
export const BirdseyeScreen = () => { | ||
const config = useConfig(); | ||
|
||
if (config.isLoading) { | ||
return <BaseText>Loading ...</BaseText>; | ||
} | ||
|
||
if (config.isError) { | ||
return <BaseText>Failed to load frigate config</BaseText>; | ||
} | ||
|
||
if (!config.data?.birdseye.enabled) { | ||
return <BaseText>Birdseye is not enabled</BaseText>; | ||
} | ||
|
||
if (!config.data?.birdseye.restream) { | ||
return ( | ||
<BaseText> | ||
Restream must be enabled so that the birdseye feed is served through | ||
WebRTC. Please update your Frigate config. | ||
</BaseText> | ||
); | ||
} | ||
|
||
return <WebRTCView cameraName="birdseye" />; | ||
}; |
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 @@ | ||
export * from './BirdseyeScreen'; |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from './HomeScreen'; | ||
export * from './homeScreen'; | ||
export * from './LiveViewScreen'; | ||
export * from './EventsScreen'; | ||
export * from './SettingsScreen'; | ||
// | ||
export * from './onboardingScreen'; | ||
export * from './BirdseyeScreen'; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we can use is like this in the component.