-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
252d896
commit cc4cca7
Showing
8 changed files
with
170 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" /> | ||
<uses-permission | ||
android:name="android.permission.READ_EXTERNAL_STORAGE" | ||
android:maxSdkVersion="32" /> | ||
|
||
<application | ||
android:name=".MainApplication" | ||
android:label="@string/app_name" | ||
android:icon="@mipmap/ic_launcher" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:allowBackup="false" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:name=".MainApplication" | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" | ||
android:launchMode="singleTask" | ||
android:windowSoftInputMode="adjustResize" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" | ||
android:exported="true" | ||
android:launchMode="singleTask" | ||
android:windowSoftInputMode="adjustResize"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "MusicLibraryExample", | ||
"displayName": "MusicLibraryExample" | ||
"name": "MusicLibraryExample", | ||
"displayName": "MusicLibraryExample" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
const path = require('path'); | ||
const pak = require('../package.json'); | ||
const path = require("path"); | ||
const pak = require("../package.json"); | ||
|
||
module.exports = { | ||
presets: ['module:@react-native/babel-preset'], | ||
plugins: [ | ||
[ | ||
'module-resolver', | ||
{ | ||
extensions: ['.tsx', '.ts', '.js', '.json'], | ||
alias: { | ||
[pak.name]: path.join(__dirname, '..', pak.source), | ||
}, | ||
}, | ||
presets: ["module:@react-native/babel-preset"], | ||
plugins: [ | ||
[ | ||
"module-resolver", | ||
{ | ||
extensions: [".tsx", ".ts", ".js", ".json"], | ||
alias: { | ||
[pak.name]: path.join(__dirname, "..", pak.source), | ||
}, | ||
}, | ||
], | ||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
preset: 'react-native', | ||
preset: "react-native", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
{ | ||
"name": "react-native-music-library-example", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"android": "react-native run-android", | ||
"ios": "react-native run-ios", | ||
"start": "react-native start", | ||
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a", | ||
"build:ios": "cd ios && xcodebuild -workspace MusicLibraryExample.xcworkspace -scheme MusicLibraryExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO" | ||
}, | ||
"dependencies": { | ||
"react": "18.2.0", | ||
"react-native": "0.73.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.20.0", | ||
"@babel/preset-env": "^7.20.0", | ||
"@babel/runtime": "^7.20.0", | ||
"@react-native/babel-preset": "0.73.21", | ||
"@react-native/metro-config": "0.73.5", | ||
"@react-native/typescript-config": "0.73.1", | ||
"babel-plugin-module-resolver": "^5.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
"name": "react-native-music-library-example", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"android": "react-native run-android", | ||
"ios": "react-native run-ios", | ||
"start": "react-native start", | ||
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a", | ||
"build:ios": "cd ios && xcodebuild -workspace MusicLibraryExample.xcworkspace -scheme MusicLibraryExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO" | ||
}, | ||
"dependencies": { | ||
"react": "18.2.0", | ||
"react-native": "0.73.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.20.0", | ||
"@babel/preset-env": "^7.20.0", | ||
"@babel/runtime": "^7.20.0", | ||
"@react-native/babel-preset": "0.73.21", | ||
"@react-native/metro-config": "0.73.5", | ||
"@react-native/typescript-config": "0.73.1", | ||
"babel-plugin-module-resolver": "^5.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
const path = require('path'); | ||
const pak = require('../package.json'); | ||
const path = require("path"); | ||
const pak = require("../package.json"); | ||
|
||
module.exports = { | ||
dependencies: { | ||
[pak.name]: { | ||
root: path.join(__dirname, '..'), | ||
dependencies: { | ||
[pak.name]: { | ||
root: path.join(__dirname, ".."), | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,92 @@ | ||
import * as React from "react"; | ||
import React from "react"; | ||
import { FlatList, Image, PermissionsAndroid, StyleSheet, Text, View } from "react-native"; | ||
import { loadMusicFiles } from "react-native-music-library"; | ||
import type { MusicFile } from "../../src/NativeMusicLibrary"; | ||
|
||
import { StyleSheet, Text, View } from "react-native"; | ||
import { multiply } from "react-native-music-library"; | ||
export default function App() { | ||
const [files, setFiles] = React.useState<MusicFile[]>([]); | ||
|
||
const result = multiply(3, 7); | ||
const getPermissions = async () => { | ||
const permission = await PermissionsAndroid.request( | ||
PermissionsAndroid.PERMISSIONS.READ_MEDIA_AUDIO!, | ||
); | ||
return permission === PermissionsAndroid.RESULTS.GRANTED; | ||
}; | ||
|
||
const loadFiles = async () => { | ||
const hasPermission = await getPermissions(); | ||
if (!hasPermission) { | ||
console.log("don't have permission"); | ||
return; | ||
} | ||
const response = await loadMusicFiles(); | ||
setFiles(response); | ||
}; | ||
|
||
React.useEffect(() => { | ||
loadFiles(); | ||
}, []); | ||
|
||
export default function App() { | ||
return ( | ||
<View style={styles.container}> | ||
<Text>Result: {result}</Text> | ||
<FlatList | ||
data={files} | ||
contentContainerStyle={styles.listContent} | ||
renderItem={({ item }) => ( | ||
<View key={item.id} style={styles.itemBox}> | ||
{item.artwork ? ( | ||
<Image source={{ uri: item.artwork }} style={styles.coverBox} /> | ||
) : ( | ||
<View style={styles.coverBox} /> | ||
)} | ||
<View style={styles.infoBox}> | ||
<Text style={styles.title}>{item.title}</Text> | ||
<Text style={styles.album}>{item.album}</Text> | ||
</View> | ||
</View> | ||
)} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
backgroundColor: "#FFFFFF", | ||
flex: 1, | ||
}, | ||
listContent: { | ||
padding: 16, | ||
}, | ||
itemBox: { | ||
backgroundColor: "#FFFFFF", | ||
borderColor: "#EFEFEF", | ||
borderRadius: 16, | ||
borderWidth: 1, | ||
elevation: 5, | ||
flexDirection: "row", | ||
gap: 8, | ||
padding: 8, | ||
shadowColor: "#7F7F7F", | ||
width: "100%", | ||
}, | ||
coverBox: { | ||
backgroundColor: "#333333", | ||
borderRadius: 8, | ||
height: 56, | ||
width: 56, | ||
}, | ||
infoBox: { | ||
flex: 1, | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}, | ||
box: { | ||
width: 60, | ||
height: 60, | ||
marginVertical: 20, | ||
title: { | ||
fontSize: 16, | ||
fontWeight: "500", | ||
}, | ||
album: { | ||
fontSize: 12, | ||
fontStyle: "italic", | ||
fontWeight: "300", | ||
}, | ||
}); |