Skip to content

Commit d11748a

Browse files
authored
Merge pull request #262 from estd20xx/features
Features
2 parents 4849542 + 3fcd678 commit d11748a

File tree

22 files changed

+341
-89
lines changed

22 files changed

+341
-89
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ export class PayloadService extends ApiService {
114114
list_count: albumDetails.list_count,
115115
list_type: albumDetails.list_type,
116116
songs: albumDetails.list.map((current) => {
117+
/**
118+
*
119+
* id: string
120+
title: string
121+
artist: string
122+
artwork: string
123+
url: string
124+
*/
117125
return {
118126
id: current.id,
119127
title: current.title.replaceAll(""", '"'),

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.

src/components/Player/Control.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ import { TouchableOpacity, View } from "react-native"
55
import { FAB } from "react-native-paper"
66
import { PlaybackState, State } from "react-native-track-player"
77
import { Icons } from "../../constants/Icon"
8+
import { useSongChange } from "../../hooks/useSongChange"
89
import { applicationService } from "../../services/Tuneify.service"
910
import { InitialCentralQueue } from "../../store/slices/Queue.slice"
1011
interface ControlersProps {
11-
nextAndPrevious: (is: boolean) => void
1212
isRepeat: boolean
13-
isShuffle: boolean
1413
playbackState:
1514
| PlaybackState
1615
| {
1716
state: undefined
1817
}
1918
applicationQueue: InitialCentralQueue
2019
dispatch: Dispatch<UnknownAction>
20+
isShuffle: boolean
2121
toggleShuffle: () => void
2222
}
2323
const Control: React.FC<ControlersProps> = ({
24-
nextAndPrevious,
2524
isRepeat,
26-
isShuffle,
2725
playbackState,
2826
applicationQueue,
29-
toggleShuffle,
30-
dispatch
27+
dispatch,
28+
isShuffle,
29+
toggleShuffle
3130
}) => {
31+
const [previous, next] = useSongChange(isShuffle)
3232
return (
3333
<View className="h-18 w-full flex items-center justify-evenly flex-row mt-3">
3434
<View className="h-full flex items-center flex-row justify-around pl-2 w-[20%]">
@@ -40,7 +40,7 @@ const Control: React.FC<ControlersProps> = ({
4040
</TouchableOpacity>
4141
</View>
4242
<View className="h-full w-[60%] flex items-center justify-evenly flex-row">
43-
<TouchableOpacity onPress={() => nextAndPrevious(false)}>
43+
<TouchableOpacity onPress={() => previous()}>
4444
<Icons.KeyboardDown name="skip-previous" color={"white"} size={35} />
4545
</TouchableOpacity>
4646
<FAB
@@ -55,7 +55,7 @@ const Control: React.FC<ControlersProps> = ({
5555
loading={playbackState.state === State.Loading}
5656
style={{ backgroundColor: "#ff8216", borderRadius: 50 }}
5757
/>
58-
<TouchableOpacity onPress={() => nextAndPrevious(true)}>
58+
<TouchableOpacity onPress={() => next()}>
5959
<Icons.KeyboardDown name="skip-next" color={"white"} size={35} />
6060
</TouchableOpacity>
6161
</View>

src/components/Player/MusicPlayer.tsx

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ import { useDownloadProgress } from "../../hooks/useDownloadProgress"
3737
import { useLyricsView } from "../../hooks/useLyricsView"
3838
import { usePlayer } from "../../hooks/usePlayer"
3939
import { usePlaylist } from "../../hooks/usePlaylistSlide"
40-
import { useShuffle } from "../../hooks/useShuffle"
4140
import { useTimer } from "../../hooks/useTimer"
4241
import { StoreSongTypes } from "../../Interfaces/tuneifySlice.interface"
4342
import { musicService } from "../../services/localMedia.service"
4443
import { applicationService } from "../../services/Tuneify.service"
4544
import { getSongsLyrics } from "../../store/actions/lyrics.action"
4645

4746
import { welcomeSong } from "../../constants/welcome"
47+
import { useShuffle } from "../../hooks/useShuffle"
4848
import {
4949
changeApplicationSetup,
5050
tunifyChild
@@ -76,33 +76,39 @@ const MAX_TRANSLATE_Y = -SCREEN_HEIGHT + offSet
7676
const MIN_TRANSLATE_Y = -BOTTOM_TAB_BAR_HEIGHT - 10
7777

7878
const TuneifyPlayer = () => {
79-
const [enableGesture, setEnableGesture] = useState(true)
79+
const dispatch = useAppDispatch()
80+
const [
81+
isPlayer,
82+
togglePlayer,
83+
enableGesture,
84+
toggleGesture,
85+
showFullPlayer,
86+
toggleFullScreen,
87+
showMiniPlayer,
88+
toggleMiniPlayer
89+
] = usePlayer()
8090

81-
const [isPlayer, togglePlayer] = usePlayer()
8291
const translateY = useSharedValue(MIN_TRANSLATE_Y)
8392
const Zindex = useSharedValue(20)
84-
const [showFullPlayer, setShowFullPlayer] = useState(false)
85-
const [showMiniPlayer, setShowMiniPlayer] = useState(true)
86-
93+
const [isShuffle, toggleShuffle] = useShuffle()
8794
const favourite = TypedSelectorHook(tuneifyFavourites)
8895
const lyrics = TypedSelectorHook(storedLyrics)
8996
const [isLyricsView, toggleLyricsView] = useLyricsView()
9097
const [timer, toggleTimer, isTimerModal, toggleModal, value, setTimerValue] =
9198
useTimer()
92-
const [isShuffle, toggleShuffle] = useShuffle()
99+
93100
const [downloadProgress, updateDownloadValue] = useDownloadProgress()
94101
const [isPlaylist, togglePlayist] = usePlaylist()
95102
const progress = useProgress()
96103
const [flip] = useState(new CustomAnimated.Value(0))
97104

98-
const dispatch = useAppDispatch()
99105
const playbackState: PlaybackState | { state: undefined } = usePlaybackState()
100106
const applicationQueue = TypedSelectorHook(centralQueue)
101107
const playerState = TypedSelectorHook(tunifyChild)
102108

103109
useDerivedValue(() => {
104-
runOnJS(setShowMiniPlayer)(translateY.value > MIN_TRANSLATE_Y - 40)
105-
runOnJS(setShowFullPlayer)(translateY.value < MIN_TRANSLATE_Y - 40)
110+
runOnJS(toggleMiniPlayer)(translateY.value > MIN_TRANSLATE_Y - 40)
111+
runOnJS(toggleFullScreen)(translateY.value < MIN_TRANSLATE_Y - 40)
106112
}, [translateY])
107113

108114
const gestureHandler = useAnimatedGestureHandler({
@@ -189,17 +195,6 @@ const TuneifyPlayer = () => {
189195
const backAnimatedStyle = {
190196
transform: [{ rotateY: backInterpolate }]
191197
}
192-
const nextAndPrevious = async (isNext: boolean) => {
193-
if (isShuffle) {
194-
const index = (await TrackPlayer.getQueue()).length
195-
const random = Math.floor(Math.random() * index)
196-
await TrackPlayer.skip(random)
197-
return
198-
}
199-
200-
isNext ? await TrackPlayer.skipToNext() : await TrackPlayer.skipToPrevious()
201-
}
202-
203198
const checkFavAvailable = (currentId: string): boolean => {
204199
if (
205200
favourite.favouriteData.filter((liked: any) => liked.id == currentId)
@@ -383,9 +378,9 @@ const TuneifyPlayer = () => {
383378
<Show isVisible={lyrics.data.lyrics?.length > 15}>
384379
<ScrollView showsVerticalScrollIndicator={false}>
385380
<Pressable
386-
onTouchStart={(e) => setEnableGesture(false)}
387-
onTouchMove={() => setEnableGesture(true)}
388-
onTouchEnd={() => setEnableGesture(true)}
381+
onTouchStart={(e) => toggleGesture(false)}
382+
onTouchMove={() => toggleGesture(true)}
383+
onTouchEnd={() => toggleGesture(true)}
389384
>
390385
<Text className="text-white text-base leading-8 flex items-center justify-center font-['300']">
391386
{lyrics.data.lyrics?.replaceAll("<br>", "\n")}
@@ -403,7 +398,6 @@ const TuneifyPlayer = () => {
403398
<SongInfo currentTrack={applicationQueue.data.song} />
404399
<PlayerInfo progress={progress} />
405400
<Control
406-
nextAndPrevious={nextAndPrevious}
407401
isRepeat={applicationQueue.isRepeat}
408402
playbackState={playbackState}
409403
applicationQueue={applicationQueue}

src/components/Player/SideModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const SideModal: React.FC<Props> = ({ isVisible, togglePlayist, song }) => {
4848
<Modal
4949
isVisible={isVisible}
5050
onBackButtonPress={togglePlayist}
51-
className="w-full h-screen relative -left-5 bg-red-500"
51+
className="w-full h-screen relative -left-5"
5252
>
5353
<Show isVisible={isInput}>
5454
<View className="bg-[#313c56c6] h-36 w-full absolute top-10 rounded-md items-center justify-center blur-lg z-30">
@@ -73,9 +73,9 @@ const SideModal: React.FC<Props> = ({ isVisible, togglePlayist, song }) => {
7373
</View>
7474
</View>
7575
</Show>
76-
<View className="w-full h-[70%] bg-white absolute bottom-0 rounded-t-3xl border-t-2 border-slate-300">
76+
<View className="w-full h-[70%] bg-slate-950 absolute bottom-0 rounded-t-3xl border-t-2 border-slate-300">
7777
<View className="w-full p-2 overflow-hidden z-10">
78-
<Text className="text-2xl font-['500'] border-b-2 border-gray-300 text-black mb-2 self-center">
78+
<Text className="text-2xl font-['500'] border-b-2 border-gray-300 text-white mb-2 self-center">
7979
Playlists
8080
</Text>
8181
<ScrollView showsVerticalScrollIndicator={false}>

src/components/Search/Category.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ type Props = {
77
}
88
const Category: React.FC<Props> = ({ categoryData }) => {
99
const [category, updateCategory] = useSearchCategory()
10-
console.log(category)
1110
return (
1211
<View className="w-full flex items-center justify-start flex-row py-2 pl-2">
1312
{Object.keys(categoryData || {}).map((current, index) => {
Lines changed: 123 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
import React, { memo } from "react"
2-
import { View } from "react-native"
3-
import { audioBookImageBaseUrl } from "../../api/base/constrants"
4-
import { Docs } from "../../screens/Home/Albums"
1+
import React, { memo, useEffect } from "react"
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"
16+
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"
524
import Header from "../DetailsScreen/Header"
625
interface AudioBookData {
726
key: string
@@ -15,15 +34,113 @@ export interface AudioBookDetailsProps {
1534
}
1635
const AudioBookDetails: React.FC<AudioBookDetailsProps> = ({ route }) => {
1736
const { audios } = route.params
37+
const dispatch = useAppDispatch()
38+
const audioBookChapters = TypedSelectorHook(audioBookDetailsWithChapters)
39+
const applicationQueue = TypedSelectorHook(centralQueue)
40+
41+
const changeQueueState = async (index: number, song: StoreSongTypes) => {
42+
try {
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)
59+
} catch (error) {
60+
console.log(error)
61+
}
62+
}
63+
64+
useEffect(() => {
65+
dispatch(
66+
audioBookDetails.getAudioBookDetails({
67+
identifier: audios.identifier,
68+
creator: audios.creator
69+
})
70+
)
71+
}, [])
1872
return (
19-
<View>
73+
<ScrollView showsVerticalScrollIndicator={false}>
2074
<Header
2175
title={audios.title}
2276
artwork={audioBookImageBaseUrl.concat(audios.identifier)}
2377
type={"Audio Book"}
2478
desc={audios.description}
2579
/>
26-
</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>
27144
)
28145
}
29146
export default memo(AudioBookDetails)

0 commit comments

Comments
 (0)