Conversation
Galaktikkon
left a comment
There was a problem hiding this comment.
Suggestions after live-review:
- group over-segmented
typesinto one file - change design of the
control-panel - remove unnecessary
console.logs
Galaktikkon
left a comment
There was a problem hiding this comment.
Good job migrating to NativeWind. Please consider my architectural suggestions and investigate the possible code-smells that caught my eye. Try to clean the classes - especially colors. Propose a fix for the API route placement, so that it's easy to translate to production.
| <View className="w-full h-full flex justify-center items-center bg-[#191414]"> | ||
| <View className="relative w-full flex justify-center items-center"> | ||
| <Text className="text-[22px] font-roboto-mono text-white text-center my-2 z-0"> | ||
| {songLines.previousLine} | ||
| </Text> | ||
| <View className="absolute w-full h-full top-0 left-0 z-1 bg-gradient-to-b from-[rgba(25,20,20,1)] from-[75%_rgba(25,20,20,0.5)] to-[rgba(0,0,0,0)]" /> | ||
| </View> | ||
| <Text className="text-[22px] font-roboto-mono text-[#95E558] text-center my-2"> | ||
| {songLines.currentLine} | ||
| </Text> | ||
| <View className="relative w-full flex justify-center items-center"> | ||
| <Text className="text-[22px] font-roboto-mono text-white text-center my-2 z-0"> | ||
| {songLines.nextLine} | ||
| </Text> | ||
| <View className="absolute w-full h-full top-0 left-0 z-1 bg-gradient-to-t from-[rgba(25,20,20,1)] from-[75%_rgba(25,20,20,0.5)] to-[rgba(0,0,0,0)]" /> | ||
| </View> | ||
| </View> | ||
| ); | ||
| }; No newline at end of file |
There was a problem hiding this comment.
These colors should be added to the project if they are not already present.
| const KaraokeScreen = () => { | ||
| return ( | ||
| <SafeAreaView className="h-full"> | ||
| <SongViewText /> | ||
| <ControlPanel /> | ||
| </SafeAreaView> | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Use ViewLayout component for uniform view layout.
| <TouchableOpacity className="items-center" onPress={togglePanel}> | ||
| {isOpen ? <ChevronDown /> : <ChevronUp />} | ||
| </TouchableOpacity> |
| }); | ||
|
|
||
| return ( | ||
| <View className="bg-gray-300 py-2 border-t border-gray-400 justify-around items-center flex flex-col absolute w-full bottom-0"> |
| <View className="absolute w-full h-full top-0 left-0 z-1 bg-gradient-to-b from-[rgba(25,20,20,1)] from-[75%_rgba(25,20,20,0.5)] to-[rgba(0,0,0,0)]" /> | ||
| </View> | ||
| <Text className="text-[22px] font-roboto-mono text-[#95E558] text-center my-2"> | ||
| {songLines.currentLine} | ||
| </Text> | ||
| <View className="relative w-full flex justify-center items-center"> | ||
| <Text className="text-[22px] font-roboto-mono text-white text-center my-2 z-0"> | ||
| {songLines.nextLine} | ||
| </Text> | ||
| <View className="absolute w-full h-full top-0 left-0 z-1 bg-gradient-to-t from-[rgba(25,20,20,1)] from-[75%_rgba(25,20,20,0.5)] to-[rgba(0,0,0,0)]" /> |
There was a problem hiding this comment.
Fix the colors (they should be added to the project scope). Also you use from-* two times which is unnecessary and may cause unexpected behaviour.
| const { playNextSong, playPauseSong, playPreviousSong, isPlaying } = useTrackPlayer(); | ||
| return ( | ||
| <View className="flex flex-row justify-around items-center w-full"> | ||
| <TouchableOpacity className="items-center" onPress={playPreviousSong}> | ||
| <SkipBack size={32} color="black" /> | ||
| </TouchableOpacity> | ||
| <TouchableOpacity className="items-center" onPress={playPauseSong}> | ||
| {isPlaying ? <Pause size={32} color="black" /> : <Play size={32} color="black" />} | ||
| </TouchableOpacity> | ||
| <TouchableOpacity className="items-center" onPress={playNextSong}> | ||
| <SkipForward size={32} color="black" /> | ||
| </TouchableOpacity> | ||
| </View> |
There was a problem hiding this comment.
These could also be a dedicated component (like IconButton). Again try to make the button clickable area bigger for better UX.
| const playPauseSong = async () => { | ||
| if (!isTrackPlayerReady) { | ||
| console.warn('TrackPlayer is not ready yet!'); | ||
| return; | ||
| } | ||
| const state = await TrackPlayer.getState(); | ||
| if (state === State.Playing) { | ||
| TrackPlayer.pause(); | ||
| } else { | ||
| TrackPlayer.play(); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Maybe toggleSong would be a bettter name?
| const fetchedSongText = await fetchSongLyrics(youtubeUrl); | ||
| const fetchedAudioSplitterResponse = await splitAudio(youtubeUrl); | ||
| const songUrl = 'http://localhost:8080' + fetchedAudioSplitterResponse.instrumentsPath; | ||
|
|
||
| track.url = songUrl; // provide url of the file location to the track | ||
| track.songText = fetchedSongText; // provide song text to the track | ||
|
|
There was a problem hiding this comment.
This seems like a code-smell to me. I do not know the backend architecture, so please explain the songUrl purpose. Does the backend expose a specific route for this? What for? Also the root route should be saved in some file (not hardcoded), so that it can be easily swapped for the production.
| const currentSegmentIndex = songText.segments.findIndex( | ||
| (segment: SongSegment) => | ||
| currentTime >= segment.start - 0.5 && currentTime < segment.end - 0.5, | ||
| ); | ||
|
|
||
| // initial text | ||
| if (currentTime < 0.1 && currentSegmentIndex === -1) { | ||
| setSongLines({ | ||
| previousSegmentIndex: -1, | ||
| previousLine: '', | ||
| currentLine: '', | ||
| nextLine: songText.segments[0]?.text, | ||
| }); | ||
| // normal case | ||
| } else if (currentSegmentIndex !== -1) { | ||
| setSongLines({ | ||
| previousSegmentIndex: currentSegmentIndex, | ||
| previousLine: songText.segments[currentSegmentIndex - 1]?.text || '', | ||
| currentLine: songText.segments[currentSegmentIndex]?.text || '', | ||
| nextLine: songText.segments[currentSegmentIndex + 1]?.text || '', | ||
| }); | ||
| // between lines (silence) case | ||
| } else { | ||
| setSongLines({ | ||
| previousSegmentIndex: songLines.previousSegmentIndex, | ||
| previousLine: songText.segments[songLines.previousSegmentIndex]?.text || '', | ||
| currentLine: ' ', | ||
| nextLine: songText.segments[songLines.previousSegmentIndex + 1]?.text || '', | ||
| }); | ||
| } | ||
| }; |
There was a problem hiding this comment.
This logic is not straightforward. (e.g. the boolean comparison that transfers into an index - is it really an index? not a flag or state?) Please try to simplify it so that it follows KISS.
nice review, thanks for it but Wiktor done gr8 job


No description provided.