-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallpaper): allow change wallpaper from settings
- Loading branch information
Showing
25 changed files
with
363 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.monitor { | ||
height: 144px; | ||
width: 256px; | ||
border-radius: 12px; | ||
background-color: var(--color-persist-gray-800); | ||
padding: 8px; | ||
|
||
.screen { | ||
position: relative; | ||
border-radius: 8px; | ||
background: linear-gradient( | ||
40deg, | ||
var(--color-blue-500) 2%, | ||
var(--color-blue-300) 60%, | ||
var(--color-blue-100) 100% | ||
); | ||
width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
|
||
.wallpaper { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
position: absolute; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { convertFileSrc } from '@tauri-apps/api/core'; | ||
import { PropsWithChildren } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { newSelectors } from '../../modules/shared/store/app/reducer'; | ||
|
||
import cs from './index.module.css'; | ||
|
||
interface Props extends PropsWithChildren {} | ||
|
||
export function Monitor({ children }: Props) { | ||
const wallpaper = useSelector(newSelectors.wallpaper); | ||
|
||
return ( | ||
<div className={cs.monitor}> | ||
<div className={cs.screen}> | ||
{wallpaper ? <img className={cs.wallpaper} src={convertFileSrc(wallpaper)} /> : null} | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
} |
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
38 changes: 38 additions & 0 deletions
38
src/apps/settings/modules/general/main/infra/Wallpaper.tsx
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Monitor } from '../../../../components/monitor'; | ||
import { SettingsOption } from '../../../../components/SettingsBox'; | ||
import { invoke } from '@tauri-apps/api/core'; | ||
import { Button } from 'antd'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useDispatch } from 'react-redux'; | ||
|
||
import { dialog } from '../../../shared/tauri/infra'; | ||
|
||
import { RootActions } from '../../../shared/store/app/reducer'; | ||
|
||
export function Wallpaper() { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
|
||
async function loadWallpaper() { | ||
const file = await dialog.open({ | ||
title: t('general.wallpaper.select'), | ||
filters: [{ name: 'images', extensions: ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tif', 'tiff'] }], | ||
}); | ||
|
||
if (!file) { | ||
return; | ||
} | ||
|
||
await invoke('state_set_wallpaper', { path: file.path }); | ||
dispatch(RootActions.setWallpaper(file.path)); | ||
} | ||
|
||
return ( | ||
<> | ||
<SettingsOption> | ||
<Monitor /> | ||
<Button onClick={loadWallpaper} size="middle">{t('general.wallpaper.select')}</Button> | ||
</SettingsOption> | ||
</> | ||
); | ||
} |
Oops, something went wrong.