react-native-album-display 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useState, useEffect, useMemo } from 'react';
|
2
|
-
import { View, Image, StyleSheet, Dimensions, Animated, Button } from 'react-native';
|
2
|
+
import { SafeAreaView, View, Image, StyleSheet, Dimensions, Animated, Button, BackHandler } from 'react-native';
|
3
3
|
import { Divider } from '@rneui/themed';
|
4
4
|
import AlbumBasicData from './albumDetailsSubcomponents/AlbumBasicData';
|
5
5
|
import AlbumTracklist from './albumDetailsSubcomponents/AlbumTracklist';
|
@@ -17,6 +17,17 @@ const AlbumDetails = ({ album, close }) => {
|
|
17
17
|
setRatings(album.ratings || []); // Reinicia las calificaciones cuando cambia el álbum
|
18
18
|
}, [album]);
|
19
19
|
|
20
|
+
useEffect(() => {
|
21
|
+
const backAction = () => {
|
22
|
+
close(); // Cierra el modal cuando se presiona "atrás"
|
23
|
+
return true; // Evita el comportamiento por defecto de Android
|
24
|
+
};
|
25
|
+
|
26
|
+
const backHandler = BackHandler.addEventListener('hardwareBackPress', backAction);
|
27
|
+
|
28
|
+
return () => backHandler.remove(); // Limpia el event listener al desmontar
|
29
|
+
}, []);
|
30
|
+
|
20
31
|
const initialTopContainerHeight = height * 0.4;
|
21
32
|
const compressedTopContainerHeight = height * 0.1;
|
22
33
|
|
@@ -39,7 +50,7 @@ const AlbumDetails = ({ album, close }) => {
|
|
39
50
|
});
|
40
51
|
|
41
52
|
return (
|
42
|
-
<
|
53
|
+
<SafeAreaView style={styles.container}>
|
43
54
|
<Button onPress={close} title="Close" style={styles.closeButton} />
|
44
55
|
<Animated.View style={[styles.topContainer, { height: topContainerHeight }]}>
|
45
56
|
{album.coverUrl ?
|
@@ -76,18 +87,15 @@ const AlbumDetails = ({ album, close }) => {
|
|
76
87
|
], { useNativeDriver: false })}
|
77
88
|
scrollEventThrottle={16}
|
78
89
|
/>
|
79
|
-
</
|
90
|
+
</SafeAreaView>
|
80
91
|
);
|
81
92
|
};
|
82
93
|
|
83
94
|
const styles = StyleSheet.create({
|
84
95
|
container: {
|
85
96
|
flex: 1,
|
86
|
-
padding: 10,
|
87
97
|
width: '100%',
|
88
98
|
borderRadius: 10,
|
89
|
-
// Yo quitaría este backgroundColor para que el usuario pueda poner el suyo
|
90
|
-
backgroundColor: '#1c1c1c'
|
91
99
|
},
|
92
100
|
topContainer: {
|
93
101
|
flexDirection: 'row',
|
package/components/CoverGroup.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { View, StyleSheet, SafeAreaView, ScrollView } from 'react-native';
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
import { Button, View, StyleSheet, SafeAreaView, ScrollView } from 'react-native';
|
3
3
|
import CoverComponent from './CoverComponent';
|
4
4
|
import AlbumDetails from './AlbumDetails';
|
5
5
|
|
@@ -14,27 +14,36 @@ const styles = StyleSheet.create({
|
|
14
14
|
}
|
15
15
|
});
|
16
16
|
|
17
|
-
const CoverGroup = ({ albums, isListView }) => {
|
18
|
-
|
17
|
+
const CoverGroup = ({ albums, isListView = false }) => {
|
18
|
+
const [listView, setListView] = React.useState();
|
19
19
|
const [openModal, setOpenModal] = React.useState(false);
|
20
20
|
const [selectedAlbum, setSelectedAlbum] = React.useState(null);
|
21
21
|
|
22
|
+
// Sincronizar listView con isListView si cambia
|
23
|
+
useEffect(() => {
|
24
|
+
setListView(isListView);
|
25
|
+
}, [isListView]);
|
26
|
+
|
22
27
|
return (
|
23
28
|
<SafeAreaView style={styles.container}>
|
24
|
-
{openModal
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
{!openModal ? (
|
30
|
+
<>
|
31
|
+
<Button onPress={() => setListView(!listView)} title="Change view" />
|
32
|
+
<ScrollView
|
33
|
+
contentContainerStyle={styles.scrollView}
|
34
|
+
horizontal={listView}>
|
35
|
+
{albums.map((album, index) => (
|
36
|
+
<View key={index}>
|
37
|
+
<CoverComponent album={album} onPress={() => { setOpenModal(true); setSelectedAlbum(album); }} />
|
38
|
+
</View>
|
39
|
+
))}
|
40
|
+
</ScrollView>
|
41
|
+
</>
|
42
|
+
) : (
|
43
|
+
<AlbumDetails album={selectedAlbum} close={() => setOpenModal(false)} />
|
44
|
+
)}
|
36
45
|
</SafeAreaView>
|
37
46
|
);
|
38
47
|
};
|
39
48
|
|
40
|
-
export default CoverGroup;
|
49
|
+
export default CoverGroup;
|
@@ -9,7 +9,7 @@ const AlbumBasicData = ({ album }) => {
|
|
9
9
|
return (
|
10
10
|
<View style={styles.container}>
|
11
11
|
<Text style={[styles.albumTitle, { fontSize: getFontSize(album.title, 25) }]}>{album.title}</Text>
|
12
|
-
<Text style={[styles.artist, , { fontSize: getFontSize(album.artist,
|
12
|
+
<Text style={[styles.artist, , { fontSize: getFontSize(album.artist, 17) }]}>{album.artist}</Text>
|
13
13
|
</View>
|
14
14
|
);
|
15
15
|
};
|
@@ -29,7 +29,6 @@ const styles = StyleSheet.create({
|
|
29
29
|
artist: {
|
30
30
|
fontSize: 17,
|
31
31
|
color: '#fa586a',
|
32
|
-
textDecorationLine: 'underline',
|
33
32
|
},
|
34
33
|
});
|
35
34
|
|