-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
387 lines (367 loc) · 9.65 KB
/
index.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import YouTube from 'react-native-youtube';
import {
AppRegistry,
StyleSheet,
Text,
Image,
ScrollView,
WebView,
View
} from 'react-native';
const dummyData = {
artistName: 'SOICHI TERADA',
recordTitle: 'FAR EAST RECORDINGS 2',
label: 'FAR EAST RECORDING',
year: '1993',
catNumber: 'FER-06867',
country: 'JAPAN',
genres: ['ELECTRONIC', 'HOUSE', 'DOWNTEMPO'],
albumArt: {uri: 'https://img.discogs.com/U6hp6dszbIbVhiuZiglnZ-mx_44=/fit-in/600x600/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-1115377-1372077464-8414.jpeg.jpg'},
tracklist: [
{duration: "8:13", position: "A1", type_: "track", title: "Good Times"},
{duration: "6:08", position: "A2", type_: "track", title: "A Warm Summer Night"},
{duration: "6:46", position: "A3", type_: "track", title: "My Feet Keep Dancing"},
{duration: "4:42", position: "B1", type_: "track", title: "My Forbidden Lover"},
{duration: "2:55", position: "B2", type_: "track", title: "Can't Stand To Love You"},
{duration: "4:05", position: "B3", type_: "track", title: "Will You Cry (When You Hear This Song)"},
{duration: "4:10", position: "B4", type_: "track", title: "What About Me"}
],
};
// fetch('https://api.discogs.com/releases/249504', {
// method: 'GET',
// headers: {
// 'Authorization': 'Discogs key=bWKHfQaBHYvrwvSpYjzm, secret=yoyZnCsHFDmBWWRcWNXNZGwJsJHTMUMm',
// }
// })
// .then((response) => response.json())
// .then((responseJson) => {
// console.log(responseJson);
// })
// .catch((error) => {
// console.error(error);
// });
function parseRecordData(recordJSON){
let recordData = {
artistName: recordJSON.artists[0].name.toUpperCase(),
recordTitle: recordJSON.title.toUpperCase(),
label: recordJSON.labels[0].name.toUpperCase(),
year: recordJSON.released_formatted.toUpperCase(),
catNumber: recordJSON.labels[0].catno,
country: recordJSON.country,
genres: recordJSON.genres.map(function(x) { return x.toUpperCase() }),
albumArt: {uri: recordJSON.images[0].uri},
tracklist: recordJSON.tracklist,
}
return recordData;
};
function getRecordByID(release_id) {
let curr = 'USD';
let url = 'https://api.discogs.com/releases/' + release_id + '?curr_abbr=' + curr;
console.log('url= ' + url);
let options = {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': 'Rekkid Discogs App',
},
};
fetch(url, options)
.then((response) => response.json())
.then((responseJson) => {
// console.log('JSON = ' + responseJson.title);
let recordData = parseRecordData(responseJson);
this.setState({ recordData: recordData });
})
.catch((error) => {
console.error(error);
});
// return responseObject;
}
export default class Rekkid extends Component {
render() {
return (
<RecordView/>
);
}
}
function getOauth() {
let consumer_key = 'bWKHfQaBHYvrwvSpYjzm';
let consumer_secret = 'yoyZnCsHFDmBWWRcWNXNZGwJsJHTMUMm';
let request_token_url = 'https://api.discogs.com/oauth/request_token';
let authorize_url = 'https://www.discogs.com/oauth/authorize';
let access_token_url = 'https://api.discogs.com/oauth/access_token';
let user_agent = 'Rekkid Discogs App';
}
class RecordView extends Component {
constructor() {
super();
this.state = {recordData: dummyData}; // default text
//Release JSON fetch
let release_id = 249504;
let curr = 'USD';
let url = 'https://api.discogs.com/releases/' + release_id + '?curr_abbr=' + curr;
console.log('url= ' + url);
let options = {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': 'Rekkid Discogs App',
},
};
fetch(url, options)
.then((response) => response.json())
.then((responseJson) => {
// console.log('JSON = ' + responseJson.title);
let recordData = parseRecordData(responseJson);
this.setState({ recordData: recordData });
})
.catch((error) => {
console.error(error);
});
}
render() {
const { recordData } = this.state;
return (
<View style={{
flex: 1,
flexDirection: 'column',
backgroundColor: '#1f1f1f',
}}>
<RecordTitleView
artistName={recordData.artistName}
recordTitle={recordData.recordTitle}
label={recordData.label}
catNumber={recordData.catNumber}
country={recordData.country}
year={recordData.year}
genres={recordData.genres}
/>
<RecordImageView albumArt={recordData.albumArt}/>
<RecordPriceView />
<ScrollView style = {{flex:1.0}}>
<RecordTracklistView tracklist={recordData.tracklist}/>
</ScrollView>
<RecordPlayView style ={{flex:0.1}}/>
</View>
);
}
};
class RecordTitleView extends Component {
render() {
const {
recordTitle,
label,
catNumber,
country,
year,
genres,
artistName
} = this.props;
return (
<View style={{flex:0.5, paddingTop: 25,backgroundColor: '#1f1f1f'}}>
<Text style={styles.artistName}>
{artistName}
</Text>
<Text style={styles.albumName}>
{recordTitle}
</Text>
<Text style={styles.albumInfo}>
{label + ' ' + catNumber + ' ' + country + ', ' + year}
</Text>
<Text style={styles.genreInfo}>
{genres.join(', ')}
</Text>
</View>
);
}
};
class RecordImageView extends Component {
render() {
return (
<View style={styles.albumArtWrapper}>
<Image
style={styles.albumArt}
source={this.props.albumArt}
/>
</View>
);
}
};
class RecordPlayView extends Component {
render() {
return (
<View style={styles.buttonWrapper}>
<Image style={styles.button}
source={require('./img/play.png')} />
</View>
);
}
};
class RecordPriceView extends Component {
render() {
return (
<View style={{flex:0.30, paddingTop:15, backgroundColor: '#1f1f1f'}}>
<View style={styles.priceInfoWrapper}>
<View style={styles.verticalPriceAlign, {backgroundColor: '#1f1f1f'}}>
<Text style = {styles.dimText}>
LOW
</Text>
<Text style = {styles.priceText}>
$10
</Text>
</View>
<View style={styles.verticalPriceAlign, {backgroundColor: '#1f1f1f'}}>
<Text style = {styles.dimText}>
MED
</Text>
<Text style = {styles.priceText}>
$22
</Text>
</View>
<View style={styles.verticalPriceAlign, {backgroundColor: '#1f1f1f'}}>
<Text style = {styles.dimText}>
HIGH
</Text>
<Text style = {styles.priceText}>
$64
</Text>
</View>
</View>
</View>
);
}
};
class RecordTracklistView extends Component {
render() {
return (
<View style={{flex:0.50, backgroundColor: '#1f1f1f'}} >
{this.props.tracklist.map((track, arrIndex) => {
return (
<View key={arrIndex} style={styles.trackInfoWrapper}>
<Text style = {styles.trackText}>
{track.position}
</Text>
<Text style = {styles.trackText}>
{track.title.toUpperCase()}
</Text>
</View>
);
})}
</View>
);
}
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#1f1f1f',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#ffffff',
marginBottom: 5,
},
artistName: {
textAlign: 'center',
fontSize: 30,
fontFamily: 'Helvetica-Bold',
color: '#ffffff',
},
albumName:{
textAlign: 'center',
fontSize: 16,
fontFamily: 'Helvetica-Bold',
color: '#ffffff',
},
albumInfo:{
textAlign: 'center',
fontSize: 10,
fontFamily: 'Helvetica-Bold',
color: '#ffffff',
},
genreInfo:{
textAlign: 'center',
fontSize: 10,
fontFamily: 'Helvetica-Bold',
color: '#ffffff',
},
albumArtWrapper:{
flex:1.5,
backgroundColor: '#1f1f1f',
alignItems: 'center',
justifyContent: 'center',
},
albumArt:{
height:250,
width:250,
},
buttonWrapper:{
padding: 10,
backgroundColor: '#1f1f1f',
alignItems: 'center',
justifyContent: 'center',
},
button:{
width: 50,
height: 50,
},
dimText:{
fontSize: 15,
textAlign: 'center',
color: '#6f6c6c',
fontFamily: 'Helvetica-Bold',
},
priceInfoWrapper:{
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
backgroundColor:'#1f1f1f',
marginLeft:60,
marginRight:60,
},
trackInfoWrapper:{
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
backgroundColor:'#1f1f1f',
marginLeft:60,
marginRight:60,
},
verticalPriceAlign:{
flex: 2,
flexDirection: 'column',
justifyContent: 'space-between',
backgroundColor:'#1f1f1f',
},
priceText:{
padding:10,
fontSize: 15,
textAlign: 'center',
color: '#ffffff',
fontFamily: 'Helvetica-Bold',
},
greyText:{
color:'#6f6c6c'
},
trackText:{
padding:10,
fontSize: 15,
textAlign: 'center',
color: '#ffffff',
fontFamily: 'Helvetica-Bold',
},
});
AppRegistry.registerComponent('Rekkid', () => Rekkid);