Skip to content

Commit

Permalink
local_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Saboten758 committed Aug 30, 2023
1 parent cee1d64 commit 85151ac
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 34 deletions.
12 changes: 10 additions & 2 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ import { Alert, Linking, ToastAndroid } from "react-native";
import axios from "axios";
import SystemNavigationBar from "react-native-system-navigation-bar";

import { addTracks, setupPlayer } from "./Screens/trackplayer";
import TrackPlayer from "react-native-track-player";

const App=()=>{

const [latestVersion, setLatestVersion] = useState("");
const currentVersion = "1.3";
const currentVersion = "1.4";
SystemNavigationBar.setNavigationColor('#3D3C49')
useEffect(() => {
const init = async () => {
await setupPlayer()
const queue = await TrackPlayer.getQueue();
if(queue.length <= 0) {
await addTracks();
}
axios.get("https://api.github.com/repos/Saboten758/Lemon_Player/releases/latest")
.then(response => {
const latestRelease = response.data;
setLatestVersion(latestRelease.tag_name);

if (latestRelease.tag_name !== currentVersion) {

Alert.alert("Your app is not up to date!",`Please update to the latest version from Github!\nCurrent Version: ${currentVersion}\nLatest Stable Version: ${latestRelease.tag_name}`,[{text:'Open Github',onPress: ()=>Linking.openURL("https:github.com/Saboten758/Lemon_Player/releases/latest")},{text:'Cancel'}]);
Alert.alert("Your app is not up to date!",`Please update to the latest version from Github!\n\nCurrent Version: ${currentVersion}\nLatest Stable Version: ${latestRelease.tag_name}`,[{text:'Open Github',onPress: ()=>Linking.openURL("https:github.com/Saboten758/Lemon_Player/releases/latest")},{text:'Cancel'}]);
}
else{
ToastAndroid.showWithGravity("Your App is upto date!",1000,9)
Expand Down
8 changes: 8 additions & 0 deletions Navigators/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import Games from "../Screens/Games";
import Manga from "../Screens/Manga";
import Web2 from "../Others/Web2";
import Shows from "../Screens/Shows";
import Music2 from "../Screens/Music2";
import Listz from "../Screens/List";

const Stack=createNativeStackNavigator();

Expand Down Expand Up @@ -47,7 +49,13 @@ const Root=()=>{
headerShown:false

}}/>


<Stack.Screen name="Music2" component={Music2} options={{
headerShown:false

}}/>

<Stack.Screen name="Gran" component={Gran} options={{
headerShown:false

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ A chill app where you play music from Live Radio Stations, get vaporwaved by the
This will start the Metro bundler and launch the project on an emulator or connected device.
## Screenshots
<div style="text-align:center"><img src="https://i.imgur.com/Cg35TkR.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
<div style="text-align:center"><img src="https://i.imgur.com/00mpQpY.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Radio<br/>
<div style="text-align:center"><img src="https://i.imgur.com/xmrcmpL.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Explore Page<br/>
<img src="https://i.imgur.com/vKg1Fao.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Different RSS feeds<br/>
<img src="https://i.imgur.com/WQ6r7Nt.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Plaza Radio & J1 Radio<br/>
<img src="https://i.imgur.com/I9jzpHz.jpg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Radio & Local Music<br/>
<img src="https://i.imgur.com/xMVEbG4.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Manga Page<br/>
<img src="https://i.imgur.com/v2kvu5O.jpeg" width="320" height="700" style="display: block; margin: 0 auto" ><br/>
Expand Down
5 changes: 3 additions & 2 deletions Screens/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ const Explore=()=>{
</View>
</View>
<View style={{alignItems:'center',flex:1,backgroundColor:'#ffffe6'}}>
<FlatList
{x.length!=0&&(<FlatList
data={x}
ListHeaderComponent={hed}
ItemSeparatorComponent={sep}
renderItem={({item}) => <Item title={item} />}

/>
/>)}
{x.length==0&&(<Text style={styles.txt3}>SOURCE CANT BE FETCHED </Text>)}
</View>
</>

Expand Down
69 changes: 56 additions & 13 deletions Screens/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
import { useNavigation } from "@react-navigation/native";
import React, { useEffect } from "react";
import { View,StyleSheet,Text, Dimensions, TouchableOpacity } from "react-native";
import React, { useEffect, useState } from "react";
import { ImageBackground,StyleSheet,Text, Dimensions, TouchableOpacity, ToastAndroid, useWindowDimensions, ScrollView } from "react-native";
import { Card } from "react-native-paper";
import SystemNavigationBar from "react-native-system-navigation-bar";
import TrackPlayer, { RepeatMode } from "react-native-track-player";
import Icon from 'react-native-vector-icons/AntDesign';
import DocumentPicker from 'react-native-document-picker'

const Home=()=>{


const open = async () => {
try {


const result = await DocumentPicker.pick({
transitionStyle:'partialCurl',
type: [DocumentPicker.types.audio],

});

const x=result[0]['uri']

await TrackPlayer.add([
{
id:String(result[0]['name']),
url: x,
artist:"Added From Local Storage",
title:String(result[0]['name']),
artwork:require('../assets/default.jpg'),
duration:0,

},

]);
await TrackPlayer.setRepeatMode(RepeatMode.Queue);

ToastAndroid.show(`${result[0]['name']} was added to playlist!`,ToastAndroid.SHORT)
} catch (error) {
if (DocumentPicker.isCancel(error)) {
console.log('User cancelled the document picker.');
} else {
console.log('Error selecting document:', error);
}
}
};
useEffect( ()=>{SystemNavigationBar.navigationShow()},[])

const nav=useNavigation()
return(

<View style={styles.container}>
<Text style={styles.head}>Radio</Text>
<ScrollView contentContainerStyle={{flexGrow: 1}} >
<ImageBackground source={require('../assets/city_dark.gif')}style={styles.container}>
<Text style={styles.head}>Music & Radio</Text>
<Card>
<Card.Cover
source={require('../assets/city_dark.gif')}
source={require('../assets/zoom.gif')}
style={[styles.city,{width:Dimensions.get("screen").width-40}]}
/>
</Card>
<TouchableOpacity style={styles.button}onPress={()=>{nav.navigate('Music')}}><Text style={styles.txt}>Plaza Radio & More</Text><Icon name="play" color={'#cccccc'} size={15}style={{marginStart:5}}/></TouchableOpacity>

</View>
<TouchableOpacity style={[styles.button,{marginTop:30}]}onPress={()=>{nav.navigate('Music')}}><Text style={styles.txt}>Music Player </Text><Icon name="play" color={'#cccccc'} size={25}style={{marginStart:5}}/></TouchableOpacity>
<TouchableOpacity style={styles.button}onPress={open}><Text style={styles.txt}>Add Songs From Local Storage </Text><Icon name="select1" color={'#cccccc'} size={25}style={{marginStart:5}}/></TouchableOpacity>
</ImageBackground>
</ScrollView>
)
}

Expand All @@ -40,20 +80,23 @@ const styles=StyleSheet.create({
fontSize:56,
},
txt:{
fontSize:14,
fontWeight:'bold',
fontSize:18,
flexWrap:'wrap',
fontFamily:'BebasNeue-Regular',
color:'#AD8C9C'
},
button:{

borderRadius:20,
flexDirection:'row',
backgroundColor:'black',
alignItems:'center',
justifyContent:'center',
height:80,
width:120,
elevation:4,
width:280,
padding:10,
margin:20
marginBottom:20,
},
city:{
height:240,
Expand Down
32 changes: 18 additions & 14 deletions Screens/Music.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useEffect, useState } from 'react';
import {ImageBackground,SafeAreaView,StyleSheet,Text,View,FlatList,ActivityIndicator,TouchableOpacity, Dimensions, useWindowDimensions} from 'react-native';
import {ImageBackground,SafeAreaView,StyleSheet,Text,View,FlatList,ActivityIndicator,TouchableOpacity, Dimensions, useWindowDimensions, ToastAndroid} from 'react-native';
import TrackPlayer, {
useTrackPlayerEvents,
usePlaybackState,
useProgress,
Event,
State
} from 'react-native-track-player';
import Icon from 'react-native-vector-icons/FontAwesome';
import Icon from 'react-native-vector-icons/Ionicons';
import { setupPlayer, addTracks,Night } from './trackplayer';
import { Card } from 'react-native-paper';
import axios from 'axios';
Expand Down Expand Up @@ -114,8 +114,9 @@ import axios from 'axios';
await TrackPlayer.reset();
queue.sort(() => Math.random() - 0.5);
await TrackPlayer.add(queue);

loadPlaylist()
ToastAndroid.show("Rolled a Dice!",ToastAndroid.SHORT)
}
const window=useWindowDimensions()
return(
Expand Down Expand Up @@ -155,22 +156,25 @@ import axios from 'axios';
<View style={{flexDirection: 'row',
flexWrap: 'wrap', alignItems: 'center'}}>
<Icon.Button
name="arrow-left"
name="play-skip-back"
size={28}
backgroundColor="transparent"
color={'#eeccff'}
onPress={() => TrackPlayer.skipToPrevious()}/>
<Icon.Button
name={playerState == State.Playing ? 'pause' : 'play'}
size={40}
backgroundColor="transparent"

onPress={handlePlayPress}/>
<Icon.Button
name="arrow-right"
name="play-skip-forward"
size={28}
color={'#eeccff'}
backgroundColor="transparent"
onPress={() => TrackPlayer.skipToNext()}/>
<Icon.Button
name="random"
name="dice"
size={28}
backgroundColor="transparent"
onPress={onShuffle}/>
Expand All @@ -179,7 +183,7 @@ import axios from 'axios';
}

const Music=()=>{

const window=useWindowDimensions()
const [isPlayerReady, setIsPlayerReady] = useState(false);
const [back,setBack]=useState("")
Expand Down Expand Up @@ -208,8 +212,8 @@ const Music=()=>{
async function setup() {
let isSetup = await setupPlayer();

const queue = await TrackPlayer.getQueue();
if(isSetup && queue.length <= 0) {
const queue = await TrackPlayer.getQueue();
if(isSetup && queue.length <= 0) { //safety net ;p
await addTracks();
}

Expand All @@ -229,9 +233,9 @@ const Music=()=>{


return (

<ImageBackground source={pick?require('../assets/mood.gif'):require('../assets/smoke.gif')}
style={styles.container}>
<ImageBackground style={styles.container}source={pick?require('../assets/mood.gif'):require('../assets/smoke.gif')}
>

<Card>
<Card.Cover
Expand All @@ -249,11 +253,11 @@ const Music=()=>{

const styles = StyleSheet.create({
container: {
position:'relative',

flex: 1,
justifyContent: 'center',
alignItems:"center",
padding: 10,
padding:10,
backgroundColor: '#a8c0c8',


Expand Down
Loading

0 comments on commit 85151ac

Please sign in to comment.