Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions relisten/player/ui/player_bottom_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ import { LayoutChangeEvent, Platform, Pressable, TouchableOpacity, View } from '
import { ScrubberRow } from './player_screen';
import * as Progress from 'react-native-progress';
import AirPlayButton from 'react-native-airplay-button';
import { useNetInfo } from '@react-native-community/netinfo';

function OfflineBanner() {
return (
<View className="bg-red-800 flex flex-row justify-center items-center p-1.5">
<MaterialIcons name="cloud-off" size={20} color={'white'} style={{ marginRight: 4 }} />
<RelistenText>Offline. You can stream downloaded tracks</RelistenText>
</View>
);
}

function PlayerBottomBarContents() {
const currentTrack = useRelistenPlayerCurrentTrack();
Expand Down Expand Up @@ -93,6 +103,7 @@ function PlayerBottomBarContents() {
}

export function PlayerBottomBar() {
const isOnline = useNetInfo().isInternetReachable ?? true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This coalesces to true because the initial return will be null while the network check resolves. We only want to read true or false.

const { tabBarHeight, playerBottomBarHeight, setPlayerBottomBarHeight } =
useRelistenPlayerBottomBarContext();

Expand All @@ -115,6 +126,7 @@ export function PlayerBottomBar() {
return (
<View onLayout={onLayout} style={{ bottom: tabBarHeight, position: 'absolute', width: '100%' }}>
<View className={'w-full flex-1 p-0'}>
{!isOnline && <OfflineBanner />}
<View className="rounded-t-s w-full border-t-2 border-t-relisten-blue-700 bg-relisten-blue-800 pt-2">
<PlayerBottomBarContents />
</View>
Expand Down