Skip to content

Commit

Permalink
Merge pull request #28 from whogurdevil/main
Browse files Browse the repository at this point in the history
set as waallpaper component completed
  • Loading branch information
whogurdevil authored Feb 11, 2023
2 parents 3900f97 + cd3e768 commit dc81ec1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 118 deletions.
5 changes: 5 additions & 0 deletions code/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Home from "./MyComp/Home";
import AddTask from "./MyComp/AddTask";
import ViewTask from "./MyComp/ViewTask";
import Settings from "./MyComp/Settings";
import SetWallpaper from "./MyComp/SetWallpaper"
const colors = ['#e4def2', '#e2ddd8','#eef8ef','#2d414e','#E0DFE3']

function App() {
Expand All @@ -30,6 +31,10 @@ function App() {
name="Settings"
component={Settings}
/>
<Stack.Screen
name="SetWallpaper"
component={SetWallpaper}
/>
</Stack.Navigator>
</NavigationContainer>
);
Expand Down
8 changes: 5 additions & 3 deletions code/MyComp/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AddTask from './AddTask';
import ViewTask from './ViewTask';
import {Appearance} from 'react-native';
import Settings from './Settings';

import SetWallpaper from './SetWallpaper';

const {scale} = Dimensions.get("window")
const {width, height} = Dimensions.get("screen")
Expand Down Expand Up @@ -101,14 +101,16 @@ const Home = ({navigation}) => {

</TouchableOpacity>

<TouchableOpacity style={styles.TouchableOpacity6}>
<TouchableOpacity style={styles.TouchableOpacity6}
onPress={()=>{navigation.navigate(SetWallpaper)}}
>

<View style={styles.TouchableOpacityView}>
<FontAwesome5 name='exclamation' size={iconSize} color={colors[3]}/>
</View>

<Text style={styles.TouchableOpacityText1}>
Set ToDo List as WallPaper
Set Wallpaper
</Text>

</TouchableOpacity>
Expand Down
52 changes: 13 additions & 39 deletions code/MyComp/SetWallpaper.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
import RNFS from 'react-native-fs';
import React, { useState } from 'react';

import {Dimensions} from 'react-native';
import WallPaperManager from "react-native-set-wallpaper";
const windowWidth = Math.round(Dimensions.get('window').width);
const windowHeight = Math.round(Dimensions.get('window').height);

function setWall(URL){
WallPaperManager.setWallpaper({ uri: URL }, (res) => {
console.log(res);
});
}

// import ManageWallpaper, { TYPE } from 'react-native-manage-wallpaper';
const downloadImage = async (url, path) => {
try {
const { promise } = RNFS.downloadFile({
fromUrl: url,
toFile: path,
});
const downloaded = await promise;
console.log(downloaded);
} catch (error) {
console.error(error);
}
};

function Wall() {

const url = 'https://fakeimg.pl/850x1200/000000%2C128/fff%2C255/?text=Hello%0AWorld%0AMyself%0Asangam%20arora&font_size=56';

const sourcePath = `${RNFS.DocumentDirectoryPath}/image.jpg`;
downloadImage(url, sourcePath);
const targetPath = `${RNFS.ExternalStorageDirectoryPath}/Documents/hello4.jpg`;

const moveFile = async () => {
try {
await RNFS.moveFile(sourcePath, targetPath);
console.log('File moved successfully!');
} catch (error) {
console.error(error);
}
};
moveFile();
setWall(url)
}

export default Wall
function SetWallpaper() {
const FontSize = '56'
const plainText = "Hello \n How \n Are \n You"
const Background = '000000,128'
const TextColour = 'fff,255'
const url = "https://fakeimg.pl/"+windowWidth+'x'+windowHeight+'/'+Background+'/'+TextColour+'/?font_size='+FontSize+'&text='+encodeURIComponent(plainText);
setWall(url);
}
// SetWallpaper('000000', 'fff', "56", "Hello \n How \n Are \n You");
export default SetWallpaper;
1 change: 1 addition & 0 deletions code/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<permission android:name="android.permission.RNFS.writeFile" />
<permission android:name="android.permission.RNFS.readFile" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
78 changes: 2 additions & 76 deletions code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc81ec1

Please sign in to comment.