From a1b6aa673226315db24bf470e65d852731869f63 Mon Sep 17 00:00:00 2001
From: austinried <4966622+austinried@users.noreply.github.com>
Date: Mon, 19 Jul 2021 22:23:33 +0900
Subject: [PATCH] added nothing here message for empty lists
---
app/components/NothingHere.tsx | 33 +++++++++++++++++++++++++++
app/components/SongItem.tsx | 8 ++-----
app/screens/AlbumView.tsx | 39 +++++++++++++++++++-------------
app/screens/Home.tsx | 37 +++++++++++++++++++++---------
app/screens/PlaylistView.tsx | 41 ++++++++++++++++++++++------------
app/styles/font.ts | 1 +
6 files changed, 113 insertions(+), 46 deletions(-)
create mode 100644 app/components/NothingHere.tsx
diff --git a/app/components/NothingHere.tsx b/app/components/NothingHere.tsx
new file mode 100644
index 0000000..8d0ecda
--- /dev/null
+++ b/app/components/NothingHere.tsx
@@ -0,0 +1,33 @@
+import font from '@app/styles/font'
+import React from 'react'
+import { Text, View, StyleSheet } from 'react-native'
+import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
+
+const NothingHere = React.memo<{
+ height?: number
+ width?: number
+}>(({ height, width }) => {
+ height = height || 200
+ width = width || 200
+
+ return (
+
+
+ Nothing here...
+
+ )
+})
+
+const styles = StyleSheet.create({
+ container: {
+ justifyContent: 'center',
+ alignItems: 'center',
+ opacity: 0.25,
+ },
+ text: {
+ fontFamily: font.lightItalic,
+ color: 'white',
+ },
+})
+
+export default NothingHere
diff --git a/app/components/SongItem.tsx b/app/components/SongItem.tsx
index dee9357..dc9c4b9 100644
--- a/app/components/SongItem.tsx
+++ b/app/components/SongItem.tsx
@@ -6,7 +6,6 @@ import { useAtomValue } from 'jotai/utils'
import React from 'react'
import { GestureResponderEvent, StyleSheet, Text, View } from 'react-native'
import IconFA from 'react-native-vector-icons/FontAwesome'
-import IconMat from 'react-native-vector-icons/MaterialIcons'
import CoverArt from './CoverArt'
import PressableOpacity from './PressableOpacity'
@@ -33,10 +32,7 @@ const SongItem: React.FC<{
-
-
-
-
+
@@ -76,7 +72,7 @@ const styles = StyleSheet.create({
controls: {
flexDirection: 'row',
alignItems: 'center',
- marginLeft: 10,
+ marginLeft: 16,
},
more: {
marginLeft: 8,
diff --git a/app/screens/AlbumView.tsx b/app/screens/AlbumView.tsx
index 914e97b..bd7505b 100644
--- a/app/screens/AlbumView.tsx
+++ b/app/screens/AlbumView.tsx
@@ -2,6 +2,7 @@ import Button from '@app/components/Button'
import CoverArt from '@app/components/CoverArt'
import GradientBackground from '@app/components/GradientBackground'
import ImageGradientScrollView from '@app/components/ImageGradientScrollView'
+import NothingHere from '@app/components/NothingHere'
import SongItem from '@app/components/SongItem'
import { albumAtomFamily } from '@app/state/music'
import { useSetQueue } from '@app/state/trackplayer'
@@ -22,6 +23,27 @@ const AlbumDetails: React.FC<{
return <>>
}
+ const Songs = () => (
+ <>
+
+
+
+ {album.songs
+ .sort((a, b) => {
+ if (b.track && a.track) {
+ return a.track - b.track
+ } else {
+ return a.title.localeCompare(b.title)
+ }
+ })
+ .map(s => (
+ setQueue(album.songs, album.name, s.id)} />
+ ))}
+
+ >
+ )
+
return (
-
-
-
- {album.songs
- .sort((a, b) => {
- if (b.track && a.track) {
- return a.track - b.track
- } else {
- return a.title.localeCompare(b.title)
- }
- })
- .map(s => (
- setQueue(album.songs, album.name, s.id)} />
- ))}
-
+ {album.songs.length > 0 ? : }
)
diff --git a/app/screens/Home.tsx b/app/screens/Home.tsx
index 0b81f5c..6d26ba2 100644
--- a/app/screens/Home.tsx
+++ b/app/screens/Home.tsx
@@ -1,5 +1,6 @@
import CoverArt from '@app/components/CoverArt'
import GradientScrollView from '@app/components/GradientScrollView'
+import NothingHere from '@app/components/NothingHere'
import PressableOpacity from '@app/components/PressableOpacity'
import { AlbumListItem } from '@app/models/music'
import { homeListsAtom, homeListsUpdatingAtom, useUpdateHomeLists } from '@app/state/music'
@@ -44,19 +45,29 @@ const Category = React.memo<{
name?: string
data: AlbumListItem[]
}>(({ name, data }) => {
+ const Albums = () => (
+
+ {data.map(album => (
+
+ ))}
+
+ )
+
+ const Nothing = () => (
+
+
+
+ )
+
return (
{name}
-
- {data.map(album => (
-
- ))}
-
+ {data.length > 0 ? : }
)
})
@@ -110,6 +121,12 @@ const styles = StyleSheet.create({
paddingHorizontal: 20,
marginTop: 4,
},
+ nothingHereContent: {
+ width: '100%',
+ height: 190,
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
artScroll: {
marginTop: 10,
height: 190,
diff --git a/app/screens/PlaylistView.tsx b/app/screens/PlaylistView.tsx
index 55a5b7f..3c26182 100644
--- a/app/screens/PlaylistView.tsx
+++ b/app/screens/PlaylistView.tsx
@@ -2,6 +2,7 @@ import Button from '@app/components/Button'
import CoverArt from '@app/components/CoverArt'
import GradientBackground from '@app/components/GradientBackground'
import ImageGradientScrollView from '@app/components/ImageGradientScrollView'
+import NothingHere from '@app/components/NothingHere'
import SongItem from '@app/components/SongItem'
import { playlistAtomFamily } from '@app/state/music'
import { useSetQueue } from '@app/state/trackplayer'
@@ -22,6 +23,19 @@ const PlaylistDetails: React.FC<{
return <>>
}
+ const Songs = () => (
+ <>
+
+
+
+ {playlist.songs.map((s, index) => (
+ setQueue(playlist.songs, playlist.name, s.id)} />
+ ))}
+
+ >
+ )
+
return (
{playlist.name}
{playlist.comment ? {playlist.comment} : <>>}
-
-
-
- {playlist.songs.map((s, index) => (
- setQueue(playlist.songs, playlist.name, s.id)}
- />
- ))}
-
+ {playlist.songs.length > 0 ? : }
)
@@ -99,9 +101,14 @@ const styles = StyleSheet.create({
height: 160,
width: 160,
},
- controls: {
+ songsContainer: {
+ width: '100%',
marginTop: 18,
+ alignItems: 'center',
+ },
+ controls: {
flexDirection: 'row',
+ marginTop: 20,
},
songs: {
marginTop: 26,
@@ -112,6 +119,12 @@ const styles = StyleSheet.create({
alignItems: 'center',
paddingTop: 100,
},
+ nothingContainer: {
+ height: 400,
+ backgroundColor: 'green',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
})
export default React.memo(PlaylistView)
diff --git a/app/styles/font.ts b/app/styles/font.ts
index 9cd554f..c7d4b69 100644
--- a/app/styles/font.ts
+++ b/app/styles/font.ts
@@ -2,6 +2,7 @@ enum font {
regular = 'Metropolis-Regular',
semiBold = 'Metropolis-SemiBold',
bold = 'Metropolis-Bold',
+ lightItalic = 'Metropolis-SemiBoldItalic',
}
export default font