Skip to content

Commit 3fcd678

Browse files
committed
fix : audioBook are playable and downloadable
1 parent 62a72d6 commit 3fcd678

File tree

15 files changed

+238
-86
lines changed

15 files changed

+238
-86
lines changed

android/app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ android {
1818
minSdkVersion rootProject.ext.minSdkVersion
1919
targetSdkVersion rootProject.ext.targetSdkVersion
2020
versionCode 8
21-
versionName "1.1.16"
22-
21+
versionName "1.1.17"
2322
}
2423
signingConfigs {
2524
debug {

src/Types/Types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ChartsResponse,
66
PlaylistResponse
77
} from "../api/interface/module.interface"
8-
import { Docs } from "../screens/Home/Albums"
8+
import { Docs } from "../screens/Home/AudioBook"
99
export interface NavigationStringsTypes {
1010
splash: string
1111
onboarding: string

src/api/service/Payload.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export class PayloadService extends ApiService {
114114
list_count: albumDetails.list_count,
115115
list_type: albumDetails.list_type,
116116
songs: albumDetails.list.map((current) => {
117-
118117
/**
119118
*
120119
* id: string

src/components/DetailsScreen/Header.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ const Header: React.FC<Props> = ({ title, artwork, type, desc }) => {
2020
</Text>
2121
</View>
2222
<Show isVisible={desc != undefined && desc.length > 10}>
23-
<Text className="px-3">
23+
<Text className="px-3 mb-2">
2424
{desc?.slice(0, isFull ? desc.length : 150)}
2525
<Pressable onPress={() => setIsFull(!isFull)}>
26-
<Text className="text-orange-400">...Tap to read more</Text>
26+
<Text className="text-orange-400">
27+
<Show isVisible={!isFull}>...Tap to read more</Show>
28+
<Show isVisible={isFull}>...Tap to read less</Show>
29+
</Text>
2730
</Pressable>
2831
</Text>
2932
</Show>

src/components/Player/BottomPlayer.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 111 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
import React, { memo, useEffect } from "react"
2-
import { View } from "react-native"
3-
import { audioBookImageBaseUrl } from "../../api/base/constrants"
4-
import { useAppDispatch } from "../../hooks/store.hook"
5-
import { Docs } from "../../screens/Home/Albums"
2+
import {
3+
ActivityIndicator,
4+
FlatList,
5+
Image,
6+
ScrollView,
7+
Text,
8+
TouchableOpacity,
9+
View
10+
} from "react-native"
11+
import TrackPlayer from "react-native-track-player"
12+
import { audioBookImageBaseUrl, screens } from "../../api/base/constrants"
13+
import { TypedSelectorHook, useAppDispatch } from "../../hooks/store.hook"
14+
import { StoreSongTypes } from "../../Interfaces/tuneifySlice.interface"
15+
import { Docs } from "../../screens/Home/AudioBook"
616
import { audioBookDetails } from "../../store/actions/audioBookDetails.action"
17+
import { audioBookDetailsWithChapters } from "../../store/slices/audioBookDetails.slice"
18+
import {
19+
centralQueue,
20+
SpecificQueue,
21+
updateQueue
22+
} from "../../store/slices/Queue.slice"
23+
import Show from "../Common/Show"
724
import Header from "../DetailsScreen/Header"
825
interface AudioBookData {
926
key: string
@@ -18,29 +35,112 @@ export interface AudioBookDetailsProps {
1835
const AudioBookDetails: React.FC<AudioBookDetailsProps> = ({ route }) => {
1936
const { audios } = route.params
2037
const dispatch = useAppDispatch()
38+
const audioBookChapters = TypedSelectorHook(audioBookDetailsWithChapters)
39+
const applicationQueue = TypedSelectorHook(centralQueue)
2140

22-
const get = async () => {
41+
const changeQueueState = async (index: number, song: StoreSongTypes) => {
2342
try {
24-
dispatch(
25-
audioBookDetails.getAudioBookDetails({ identifier: audios.identifier })
26-
)
43+
if (audioBookChapters.data) {
44+
if (applicationQueue.data.screenId != screens.favouriteScreenId) {
45+
await TrackPlayer.reset()
46+
await TrackPlayer.add(audioBookChapters.data)
47+
await TrackPlayer.skip(index)
48+
await TrackPlayer.play()
49+
const newQueue: SpecificQueue = {
50+
screenId: screens.audioBook,
51+
isPlaying: true,
52+
song: song
53+
}
54+
dispatch(updateQueue(newQueue))
55+
return
56+
}
57+
}
58+
await TrackPlayer.skip(index)
2759
} catch (error) {
2860
console.log(error)
2961
}
3062
}
3163

3264
useEffect(() => {
33-
get()
65+
dispatch(
66+
audioBookDetails.getAudioBookDetails({
67+
identifier: audios.identifier,
68+
creator: audios.creator
69+
})
70+
)
3471
}, [])
3572
return (
36-
<View>
73+
<ScrollView showsVerticalScrollIndicator={false}>
3774
<Header
3875
title={audios.title}
3976
artwork={audioBookImageBaseUrl.concat(audios.identifier)}
4077
type={"Audio Book"}
4178
desc={audios.description}
4279
/>
43-
</View>
80+
<Show isVisible={audioBookChapters.isLoading}>
81+
<ActivityIndicator className="mt-5" />
82+
</Show>
83+
<Show
84+
isVisible={
85+
!audioBookChapters.isLoading && audioBookChapters?.data != null
86+
}
87+
>
88+
<FlatList
89+
data={audioBookChapters.data}
90+
keyExtractor={(item) => item.id}
91+
initialNumToRender={3}
92+
showsVerticalScrollIndicator={false}
93+
maxToRenderPerBatch={4}
94+
contentContainerStyle={{ paddingBottom: 80 }}
95+
removeClippedSubviews={true}
96+
windowSize={10}
97+
scrollEnabled={false}
98+
renderItem={({ item, index }) => {
99+
return (
100+
<TouchableOpacity
101+
className="w-full h-16 mt-2 flex flex-row items-center"
102+
onPress={() => changeQueueState(index, item)}
103+
>
104+
<View className="h-16 w-20 pl-2">
105+
<Image
106+
source={{
107+
uri: audioBookImageBaseUrl.concat(audios.identifier)
108+
}}
109+
className="h-16 w-16"
110+
style={{
111+
borderRadius: 17
112+
}}
113+
/>
114+
</View>
115+
<View className="w-4/5 ">
116+
<Text
117+
style={{
118+
color:
119+
item.id == applicationQueue.data.song?.id
120+
? "#16FF00"
121+
: "white",
122+
fontSize: 14,
123+
fontFamily: "400"
124+
}}
125+
>
126+
{item.title.slice(0, 50)}
127+
</Text>
128+
<Text
129+
style={{
130+
fontSize: 10,
131+
color: "#d0d0d1",
132+
fontFamily: "200"
133+
}}
134+
>
135+
{item.artist}
136+
</Text>
137+
</View>
138+
</TouchableOpacity>
139+
)
140+
}}
141+
/>
142+
</Show>
143+
</ScrollView>
44144
)
45145
}
46146
export default memo(AudioBookDetails)

src/components/audioBook/HorizonTalList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from "react"
44
import { FlatList, Text, TouchableOpacity, View } from "react-native"
55
import FastImage from "react-native-fast-image"
66
import { audioBookImageBaseUrl } from "../../api/base/constrants"
7-
import { AudioBookScreenInterface } from "../../screens/Home/Albums"
7+
import { AudioBookScreenInterface } from "../../screens/Home/AudioBook"
88
import { RootStackParamList } from "../../Types/Types"
99
const HorizonTalList: React.FC<AudioBookScreenInterface> = ({
1010
title,

src/constants/screens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import CTrendingSong from "../components/TrendingSong"
1111
import BottomNavigation from "../mainNavigation/Bottom"
1212
import Favourites from "../screens/Favourites"
1313
import Home from "../screens/Home"
14-
import Albums from "../screens/Home/Albums"
1514
import Artists from "../screens/Home/Artists"
15+
import Albums from "../screens/Home/AudioBook"
1616
import Folders from "../screens/Home/Folders"
1717
import Songs from "../screens/Home/Songs"
1818
import Suggested from "../screens/Home/Suggested"

src/mainNavigation/Bottom.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"
22
import { CommonActions } from "@react-navigation/native"
33
import React, { memo } from "react"
4-
import { StyleSheet, View } from "react-native"
4+
import { View } from "react-native"
55
import { BottomNavigation } from "react-native-paper"
66
import TuneifyPlayer from "../components/Player/MusicPlayer"
77
import { TabItems } from "../constants/naviG"
@@ -13,7 +13,6 @@ const BottomTab = () => {
1313
screenOptions={{ headerShown: false }}
1414
tabBar={({ navigation, state, descriptors, insets }) => (
1515
<View>
16-
{/* <BottomPlayer /> */}
1716
<TuneifyPlayer />
1817
<BottomNavigation.Bar
1918
theme={{ colors: { secondaryContainer: "#261221" } }}
@@ -79,20 +78,4 @@ return route.name
7978
</Tab.Navigator>
8079
)
8180
}
82-
83-
const styles = StyleSheet.create({
84-
container: {
85-
flex: 1,
86-
justifyContent: "center",
87-
alignItems: "center"
88-
},
89-
bottomSheetContainer: {
90-
backgroundColor: "white",
91-
borderTopLeftRadius: 20,
92-
borderTopRightRadius: 20
93-
},
94-
content: {
95-
padding: 20
96-
}
97-
})
9881
export default memo(BottomTab)

src/screens/Home/Albums.tsx renamed to src/screens/Home/AudioBook.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export interface AudioBookScreenInterface {
2727

2828
const Albums = () => {
2929
const audioData = TypedSelectorHook(audioBooks)
30-
console.log(audioData.data[0].audios[0])
3130
const dispatch = useAppDispatch()
3231
useEffect(() => {
3332
dispatch(getAudioBooks())

0 commit comments

Comments
 (0)