Skip to content

Commit b22f5c6

Browse files
committed
new look and added filter and delayed start
1 parent 2c838e1 commit b22f5c6

11 files changed

+195
-65
lines changed

App/Components/Song.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React from 'react'
2-
import { TouchableOpacity, Text, View } from 'react-native'
3-
import styles from './Styles/SongStyle'
2+
import { View } from 'react-native'
43
import { getFormattedTime } from '../Lib/TimeLib'
5-
import { List, ListItem, Avatar } from 'react-native-elements'
4+
import { ListItem, Avatar } from 'react-native-elements'
65

76
const Song = ({song, file, onPress}) => (
87
<ListItem
9-
avatar={<Avatar small rounded title={song.genre.substring(0,2).toUpperCase()} activeOpacity={0.7} />}
8+
avatar={<Avatar small rounded title={song.genre.substring(0, 2).toUpperCase()} activeOpacity={0.7} />}
109
onPress={() => onPress()}
1110
key={song.title}
12-
rightIcon={<View/>}
11+
rightIcon={<View />}
1312
badge={{value: getFormattedTime(song.duration)}}
1413
title={`Artist:${song.artist} title:${song.title}`}
1514
subtitle={`${song.genre}:${getFormattedTime(song.duration)}`}

App/Containers/MusicPlayerScreen.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,38 @@ import React from 'react'
22
import { View } from 'react-native'
33
import SongList from '../Containers/SongList'
44
import { connect } from 'react-redux'
5-
import styles from './Styles/MusicPlayerScreenStyle'
65
import PlayerArea from '../Containers/PlayerArea'
7-
import Filter from './../Components/Filter'
86
import { SearchBar } from 'react-native-elements'
97
import R from 'ramda'
108

119
class MusicPlayer extends React.Component {
12-
constructor(props) {
10+
constructor (props) {
1311
super(props)
1412
this.state = {
1513
searchTerm: '',
1614
currentlyDisplayed: []
1715
}
1816
}
19-
componentWillReceiveProps(props){
17+
componentWillReceiveProps (props) {
2018
this.setState({currentlyDisplayed: props.songs})
2119
}
22-
filterDisplayed(text) {
23-
this.setState
24-
({
25-
searchTerm: text,
26-
currentlyDisplayed: this.props.songs
27-
})
28-
29-
this.setState({currentlyDisplayed: this.props.songs})
20+
filterDisplayed (text) {
21+
const songContains = (a, p, v) => R.path(['metadata', p], a).toLowerCase().indexOf(text.toLowerCase()) > -1
22+
const currentlyDisplayed = this.props.songs
23+
.filter(song =>
24+
songContains(song, 'title') ||
25+
songContains(song, 'artist') ||
26+
songContains(song, 'genre')
27+
)
28+
this.setState({currentlyDisplayed})
3029
}
3130
render () {
3231
const songs = this.state.currentlyDisplayed || []
3332
return (
34-
<View style={styles.container}>
35-
<SearchBar round onChangeText={text => this.filterDisplayed(text)} placeholder='Type Here...' />
33+
<View style={{flex: 1, backgroundColor: 'white'}}>
34+
<SearchBar round onChangeText={text => this.filterDisplayed(text)} placeholder='Type Here...' />
3635
<SongList songs={songs} />
37-
<PlayerArea />
36+
<PlayerArea style={{marginTop: -20}} />
3837
</View>
3938
)
4039
}

App/Containers/PlayerArea.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import Icon from 'react-native-vector-icons/FontAwesome'
55
import PlayerActions from '../Redux/PlayerRedux'
66
import { Colors } from '../Themes/'
77
import styles from './Styles/PlayerAreaStyle'
8-
import PlayPause from '../Components/PlayPause'
98

109
const textStyle = {
1110
fontSize: 25,
12-
color: Colors.bloodOrange
11+
color: Colors.snow
1312
}
1413

1514
const PlayerArea = ({ playing, play, pause, stop, metadata }) => (
@@ -23,20 +22,23 @@ const PlayerArea = ({ playing, play, pause, stop, metadata }) => (
2322
{metadata && metadata.artist}
2423
</Text>
2524
</View>
26-
<TouchableOpacity
25+
</View>
26+
<TouchableOpacity
2727
activeOpacity={1.0}
28-
onPress={() => setTimeout(play, 5000)}
28+
style={styles.delayedstart}
29+
onPress={() => setTimeout(play, 2000)}
2930
>
30-
<Text style={textStyle}>Delayed Start</Text>
31+
{ playing
32+
? <View />
33+
: <Icon size={30} name={'play-circle-o'} color='#fff' />
34+
}
3135
</TouchableOpacity>
32-
33-
</View>
3436
<TouchableOpacity
3537
activeOpacity={1.0}
3638
onPress={playing ? pause : play}
3739
style={styles.playpause}
3840
>
39-
<PlayPause size={200} playing={playing} />
41+
<Icon size={30} name={playing ? 'pause' : 'play'} color='#fff' />
4042
</TouchableOpacity>
4143
<TouchableOpacity
4244
playing={playing}

App/Containers/SongList.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import React from 'react'
2-
import { ScrollView, Text, View, KeyboardAvoidingView } from 'react-native'
2+
import { ScrollView, View } from 'react-native'
33
import { connect } from 'react-redux'
44
import Song from '../Components/Song'
55
import styles from './Styles/SongListStyle'
66
import PlayerActions from '../Redux/PlayerRedux'
7-
import { List, ListItem } from 'react-native-elements'
7+
import { List } from 'react-native-elements'
88

99
class SongList extends React.Component {
1010
render () {
11-
const { songs, setSong, style = {} } = this.props
11+
const { songs, setSong } = this.props
1212
return (
1313
<View style={[styles.container]}>
1414
<ScrollView>
15-
<List>
15+
<List>
1616
{songs.map((song, index) =>
1717
<Song onPress={() => setSong(song)} key={index} song={song.metadata} />
1818
)}
19-
</List>
19+
</List>
2020
</ScrollView>
2121
</View>
2222
)
+13-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { StyleSheet } from 'react-native'
2-
import { Colors } from '../../Themes/'
32

43
export default StyleSheet.create({
54
container: {
@@ -8,29 +7,32 @@ export default StyleSheet.create({
87
paddingTop: 20,
98
paddingLeft: 25,
109
paddingRight: 25,
11-
borderRadius: 5,
12-
backgroundColor: '#d7cec7'
10+
backgroundColor: 'rgba(0, 0, 0, 0.8)'
1311
},
1412
stop: {
15-
borderRadius: 50,
1613
justifyContent: 'center',
1714
alignItems: 'center',
1815
height: 100,
1916
width: 100,
20-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
17+
backgroundColor: 'rgba(0, 0, 0, 0)',
2118
position: 'absolute',
2219
right: 0,
23-
bottom: 10
20+
bottom: 6
21+
},
22+
delayedstart: {
23+
backgroundColor: 'rgba(0, 0, 0, 0)',
24+
position: 'absolute',
25+
right: 130,
26+
bottom: 40
2427
},
2528
playpause: {
26-
borderRadius: 200/2,
27-
backgroundColor: 'rgba(0, 0, 0, 0.1)',
29+
backgroundColor: 'rgba(0, 0, 0, 0)',
2830
position: 'absolute',
29-
right: 40,
30-
bottom: -40
31+
right: 90,
32+
bottom: 40
3133
},
3234
textStyle: {
3335
fontSize: 25,
34-
color: '#76323f'
36+
color: 'rgba(255, 255, 255, 1)'
3537
}
3638
})

App/Containers/Styles/RootContainerStyles.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {StyleSheet} from 'react-native'
2-
import {Fonts, Metrics, Colors} from '../../Themes/'
2+
import {Fonts, Colors} from '../../Themes/'
33

44
export default StyleSheet.create({
55
applicationView: {
@@ -14,8 +14,8 @@ export default StyleSheet.create({
1414
welcome: {
1515
fontSize: 20,
1616
textAlign: 'center',
17-
fontFamily: Fonts.type.base,
18-
margin: Metrics.baseMargin
17+
fontFamily: Fonts.type.base
18+
1919
},
2020
myImage: {
2121
width: 200,

App/Containers/Styles/SongListStyle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StyleSheet } from 'react-native'
2-
import { Colors, Metrics } from '../../Themes/'
2+
import { Colors } from '../../Themes/'
33

44
export default StyleSheet.create({
55
container: {

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
* Standard compliant React Native App Utilizing [Ignite](https://github.com/infinitered/ignite)
55

6-
![play-pause animation](https://github.com/tristola/musicplayer/blob/master/player.gif)
6+
![play-pause animation](https://github.com/tristola/musicplayer/blob/master/player.png)
77

88
## :arrow_up: How to Setup
99

player.gif

-657 KB
Binary file not shown.

player.png

68.5 KB
Loading

0 commit comments

Comments
 (0)