Skip to content

Commit ada953a

Browse files
committed
refactored look and feel
1 parent 8aac7c2 commit ada953a

9 files changed

+57
-28
lines changed

App/Components/Song.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import React from 'react'
2-
import { TouchableOpacity, Text } from 'react-native'
2+
import { TouchableOpacity, Text, View } from 'react-native'
33
import styles from './Styles/SongStyle'
44
import { getFormattedTime } from '../Lib/TimeLib'
5+
import { List, ListItem, Avatar } from 'react-native-elements'
56

67
const Song = ({song, file, onPress}) => (
7-
<TouchableOpacity onPress={onPress} style={styles.container}>
8-
<Text style={styles.text}>{song.genre}</Text>
9-
<Text style={styles.text}>{song.artist}</Text>
10-
<Text style={styles.text}>{song.title}</Text>
11-
<Text style={styles.text}>{getFormattedTime(song.duration)}</Text>
12-
</TouchableOpacity>
8+
<ListItem
9+
avatar={<Avatar small rounded title={song.genre.substring(0,2).toUpperCase()} activeOpacity={0.7} />}
10+
onPress={() => onPress()}
11+
key={song.title}
12+
rightIcon={<View/>}
13+
badge={{value: getFormattedTime(song.duration)}}
14+
title={`Artist:${song.artist} title:${song.title}`}
15+
subtitle={`${song.genre}:${getFormattedTime(song.duration)}`}
16+
/>
1317
)
1418

1519
export default Song

App/Components/Styles/SongStyle.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export default StyleSheet.create({
55
container: {
66
flex: 1,
77
flexDirection: 'row',
8-
paddingTop: Metrics.baseMargin
8+
paddingTop: Metrics.baseMargin,
9+
borderBottomColor: 'rgba(0, 0, 0, 1)',
10+
borderBottomWidth: StyleSheet.hairlineWidth
911
},
1012
text: {
1113
flex: 1,

App/Containers/MusicPlayerScreen.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,35 @@ import { connect } from 'react-redux'
55
import styles from './Styles/MusicPlayerScreenStyle'
66
import PlayerArea from '../Containers/PlayerArea'
77
import Filter from './../Components/Filter'
8+
import { SearchBar } from 'react-native-elements'
9+
import R from 'ramda'
10+
811
class MusicPlayer extends React.Component {
12+
constructor(props) {
13+
super(props)
14+
this.state = {
15+
searchTerm: '',
16+
currentlyDisplayed: []
17+
}
18+
}
19+
componentWillReceiveProps(props){
20+
this.setState({currentlyDisplayed: props.songs})
21+
}
22+
filterDisplayed(text) {
23+
this.setState
24+
({
25+
searchTerm: text,
26+
currentlyDisplayed: this.props.songs
27+
})
28+
29+
this.setState({currentlyDisplayed: this.props.songs})
30+
}
931
render () {
32+
const songs = this.state.currentlyDisplayed || []
1033
return (
1134
<View style={styles.container}>
12-
<SongList style={{paddingBottom: 60}} />
35+
<SearchBar round onChangeText={text => this.filterDisplayed(text)} placeholder='Type Here...' />
36+
<SongList songs={songs} />
1337
<PlayerArea />
1438
</View>
1539
)

App/Containers/PlayerArea.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const PlayerArea = ({ playing, play, pause, stop, metadata }) => (
2727
activeOpacity={1.0}
2828
onPress={() => setTimeout(play, 5000)}
2929
>
30-
<Text style={{textStyle}}>Delayed Start</Text>
30+
<Text style={textStyle}>Delayed Start</Text>
3131
</TouchableOpacity>
3232

3333
</View>

App/Containers/SongList.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,27 @@ 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'
78

89
class SongList extends React.Component {
910
render () {
1011
const { songs, setSong, style = {} } = this.props
1112
return (
12-
<View style={[styles.container, style]}>
13-
<View style={{flex: 0.1, flexDirection: 'row'}}>
14-
<Text style={styles.text}>Genre</Text>
15-
<Text style={styles.text}>Artist</Text>
16-
<Text style={styles.text}>Title</Text>
17-
<Text style={styles.text}>Duration</Text>
18-
</View>
13+
<View style={[styles.container]}>
1914
<ScrollView>
20-
<KeyboardAvoidingView behavior='position'>
15+
<List>
2116
{songs.map((song, index) =>
2217
<Song onPress={() => setSong(song)} key={index} song={song.metadata} />
2318
)}
24-
</KeyboardAvoidingView>
19+
</List>
2520
</ScrollView>
2621
</View>
2722
)
2823
}
2924
}
3025

3126
const mapStateToProps = (state) => {
32-
const { songs = [] } = state.songs
33-
return { songs }
27+
return { }
3428
}
3529

3630
const mapDispatchToProps = (dispatch) => {

App/Containers/Styles/MusicPlayerScreenStyle.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ export default StyleSheet.create({
1212
color: Colors.snow
1313
},
1414
songlist: {
15-
paddingBottom: 10
1615
}
1716
})

App/Containers/Styles/PlayerAreaStyle.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@ import { Colors } from '../../Themes/'
44
export default StyleSheet.create({
55
container: {
66
flexDirection: 'row',
7-
height: 120,
7+
height: 100,
88
paddingTop: 20,
99
paddingLeft: 25,
1010
paddingRight: 25,
1111
borderRadius: 5,
1212
backgroundColor: '#d7cec7'
1313
},
1414
stop: {
15+
borderRadius: 50,
16+
justifyContent: 'center',
17+
alignItems: 'center',
18+
height: 100,
19+
width: 100,
20+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
1521
position: 'absolute',
16-
right: 25,
17-
bottom: 40
22+
right: 0,
23+
bottom: 10
1824
},
1925
playpause: {
20-
backgroundColor: 'rgba(255, 255, 255, 0.0)',
26+
borderRadius: 200/2,
27+
backgroundColor: 'rgba(0, 0, 0, 0.1)',
2128
position: 'absolute',
2229
right: 40,
2330
bottom: -40

App/Containers/Styles/SongListStyle.js

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { Colors, Metrics } from '../../Themes/'
44
export default StyleSheet.create({
55
container: {
66
flex: 1,
7-
paddingLeft: 40,
8-
paddingTop: Metrics.doubleBaseMargin,
97
backgroundColor: 'rgba(0, 0, 0, 0)'
108
},
119
text: {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"react-native-config": "^0.2.1",
3737
"react-native-device-info": "^0.10.0",
3838
"react-native-drawer": "^2.3.0",
39+
"react-native-elements": "^0.17.0",
3940
"react-native-fs": "^2.1.0-rc.1",
4041
"react-native-i18n": "^1.0.0",
4142
"react-native-media-meta": "0.0.5",

0 commit comments

Comments
 (0)