mirror of
https://github.com/anultravioletaurora/Jellify.git
synced 2026-02-09 15:49:17 -06:00
carplay stuff
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import { ListTemplate } from 'react-native-carplay'
|
||||
import uuid from 'react-native-uuid'
|
||||
|
||||
const CarPlayDiscover = () =>
|
||||
new ListTemplate({
|
||||
id: uuid.v4(),
|
||||
tabTitle: 'Discover',
|
||||
tabSystemImageName: 'globe',
|
||||
})
|
||||
const CarPlayDiscover = new ListTemplate({
|
||||
id: uuid.v4(),
|
||||
tabTitle: 'Discover',
|
||||
tabSystemImageName: 'globe',
|
||||
})
|
||||
|
||||
export default CarPlayDiscover
|
||||
|
||||
@@ -7,45 +7,42 @@ import RecentTracksTemplate from './RecentTracks'
|
||||
import RecentArtistsTemplate from './RecentArtists'
|
||||
import uuid from 'react-native-uuid'
|
||||
|
||||
const CarPlayHome = () =>
|
||||
new ListTemplate({
|
||||
id: uuid.v4(),
|
||||
title: 'Home',
|
||||
tabTitle: 'Home',
|
||||
tabSystemImageName: 'music.house.fill',
|
||||
sections: [
|
||||
{
|
||||
header: `Hi ${Client.user?.name ?? 'there'}`,
|
||||
items: [
|
||||
{ id: QueryKeys.RecentlyPlayedArtists, text: 'Recent Artists' },
|
||||
{ id: QueryKeys.RecentlyPlayed, text: 'Recently Played' },
|
||||
{ id: QueryKeys.UserPlaylists, text: 'Your Playlists' },
|
||||
],
|
||||
},
|
||||
],
|
||||
onItemSelect: async ({ index }) => {
|
||||
console.debug(`Home item selected`)
|
||||
|
||||
switch (index) {
|
||||
case 0: {
|
||||
const artists =
|
||||
queryClient.getQueryData<BaseItemDto[]>([
|
||||
QueryKeys.RecentlyPlayedArtists,
|
||||
]) ?? []
|
||||
CarPlay.pushTemplate(RecentArtistsTemplate(artists))
|
||||
break
|
||||
}
|
||||
case 1: {
|
||||
const items =
|
||||
queryClient.getQueryData<BaseItemDto[]>([QueryKeys.RecentlyPlayed]) ?? []
|
||||
CarPlay.pushTemplate(RecentTracksTemplate(items))
|
||||
break
|
||||
}
|
||||
case 2: {
|
||||
break
|
||||
}
|
||||
}
|
||||
const CarPlayHome = new ListTemplate({
|
||||
id: uuid.v4(),
|
||||
title: 'Home',
|
||||
tabTitle: 'Home',
|
||||
tabSystemImageName: 'music.house.fill',
|
||||
sections: [
|
||||
{
|
||||
header: `Hi ${Client.user?.name ?? 'there'}`,
|
||||
items: [
|
||||
{ id: QueryKeys.RecentlyPlayedArtists, text: 'Recent Artists' },
|
||||
{ id: QueryKeys.RecentlyPlayed, text: 'Recently Played' },
|
||||
{ id: QueryKeys.UserPlaylists, text: 'Your Playlists' },
|
||||
],
|
||||
},
|
||||
})
|
||||
],
|
||||
onItemSelect: async ({ index }) => {
|
||||
console.debug(`Home item selected`)
|
||||
|
||||
switch (index) {
|
||||
case 0: {
|
||||
const artists =
|
||||
queryClient.getQueryData<BaseItemDto[]>([QueryKeys.RecentlyPlayedArtists]) ?? []
|
||||
CarPlay.pushTemplate(RecentArtistsTemplate(artists))
|
||||
break
|
||||
}
|
||||
case 1: {
|
||||
const items =
|
||||
queryClient.getQueryData<BaseItemDto[]>([QueryKeys.RecentlyPlayed]) ?? []
|
||||
CarPlay.pushTemplate(RecentTracksTemplate(items))
|
||||
break
|
||||
}
|
||||
case 2: {
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default CarPlayHome
|
||||
|
||||
@@ -3,12 +3,11 @@ import CarPlayHome from './Home'
|
||||
import CarPlayDiscover from './Discover'
|
||||
import uuid from 'react-native-uuid'
|
||||
|
||||
const CarPlayNavigation = () =>
|
||||
new TabBarTemplate({
|
||||
id: uuid.v4(),
|
||||
title: 'Tabs',
|
||||
templates: [CarPlayHome(), CarPlayDiscover()],
|
||||
onTemplateSelect(template, e) {},
|
||||
})
|
||||
const CarPlayNavigation = new TabBarTemplate({
|
||||
id: uuid.v4(),
|
||||
title: 'Tabs',
|
||||
templates: [CarPlayHome, CarPlayDiscover],
|
||||
onTemplateSelect(template, e) {},
|
||||
})
|
||||
|
||||
export default CarPlayNavigation
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { NowPlayingTemplate } from 'react-native-carplay'
|
||||
import uuid from 'react-native-uuid'
|
||||
|
||||
const CarPlayNowPlaying = () =>
|
||||
new NowPlayingTemplate({
|
||||
id: uuid.v4(),
|
||||
})
|
||||
const CarPlayNowPlaying = new NowPlayingTemplate({
|
||||
id: uuid.v4(),
|
||||
})
|
||||
|
||||
export default CarPlayNowPlaying
|
||||
|
||||
@@ -28,8 +28,8 @@ const JellifyContextInitializer = () => {
|
||||
setCarPlayConnected(true)
|
||||
|
||||
if (loggedIn) {
|
||||
CarPlay.setRootTemplate(CarPlayNavigation())
|
||||
// CarPlay.pushTemplate(CarPlayNowPlaying())
|
||||
CarPlay.setRootTemplate(CarPlayNavigation)
|
||||
CarPlay.pushTemplate(CarPlayNowPlaying)
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
CarPlay.enableNowPlaying(true) // https://github.com/birkir/react-native-carplay/issues/185
|
||||
|
||||
Reference in New Issue
Block a user