diff --git a/src-tauri/lang/en.json b/src-tauri/lang/en.json index ff8f8e4..f8fd599 100644 --- a/src-tauri/lang/en.json +++ b/src-tauri/lang/en.json @@ -38,6 +38,7 @@ }, "components": { "select_file": "Select file or folder...", + "select_folder": "Select folder...", "download": "Download" }, "news": { diff --git a/src/resources/icons/game.svg b/src/resources/icons/game.svg new file mode 100644 index 0000000..adf8ea0 --- /dev/null +++ b/src/resources/icons/game.svg @@ -0,0 +1,15 @@ + +Created with Fabric.js 1.7.22 + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 7e9e280..510a776 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -13,6 +13,8 @@ import MiniDialog from './components/MiniDialog' import DownloadList from './components/common/DownloadList' import Downloads from './components/menu/Downloads' import NewsSection from './components/news/NewsSection' +import Game from './components/menu/Game' + import RightBar from './components/RightBar' import { getConfigOption, setConfigOption } from '../utils/configuration' import { invoke } from '@tauri-apps/api' @@ -27,6 +29,7 @@ interface IState { optionsOpen: boolean; miniDownloadsOpen: boolean; downloadsOpen: boolean; + gameDownloadsOpen: boolean; bgFile: string; } @@ -40,6 +43,7 @@ class App extends React.Component { optionsOpen: false, miniDownloadsOpen: false, downloadsOpen: false, + gameDownloadsOpen: false, bgFile: 'https://webstatic.hoyoverse.com/upload/event/2020/11/04/7fd661b5184e1734f91f628b6f89a31f_7367318474207189623.png', } @@ -93,6 +97,7 @@ class App extends React.Component { this.setState({ optionsOpen: !this.state.optionsOpen }) }} downFunc={() => this.setState({ downloadsOpen: !this.state.downloadsOpen })} + gameFunc={() => this.setState({ gameDownloadsOpen: !this.state.gameDownloadsOpen })} /> @@ -135,6 +140,16 @@ class App extends React.Component { ) : null } + { + // Game downloads menu + this.state.gameDownloadsOpen ? ( + this.setState({ gameDownloadsOpen: false })} + /> + ) : null + } +
diff --git a/src/ui/components/TopBar.tsx b/src/ui/components/TopBar.tsx index d9a7d2d..426dbf1 100644 --- a/src/ui/components/TopBar.tsx +++ b/src/ui/components/TopBar.tsx @@ -5,15 +5,16 @@ import closeIcon from '../../resources/icons/close.svg' import minIcon from '../../resources/icons/min.svg' import cogBtn from '../../resources/icons/cog.svg' import downBtn from '../../resources/icons/download.svg' +import gameBtn from '../../resources/icons/game.svg' -import Tr, { translate } from '../../utils/language' +import Tr from '../../utils/language' import './TopBar.css' -import { listen } from '@tauri-apps/api/event' interface IProps { optFunc: () => void; downFunc: () => void; + gameFunc: () => void; } interface IState { @@ -62,6 +63,9 @@ export default class TopBar extends React.Component {
downloads
+
+ game +
) diff --git a/src/ui/components/common/DirInput.tsx b/src/ui/components/common/DirInput.tsx index 5ae73ed..badc2a9 100644 --- a/src/ui/components/common/DirInput.tsx +++ b/src/ui/components/common/DirInput.tsx @@ -8,9 +8,11 @@ import './DirInput.css' interface IProps { value?: string + clearable?: boolean onChange?: (value: string) => void extensions?: string[] readonly?: boolean + placeholder?: string } interface IState { @@ -24,23 +26,33 @@ export default class DirInput extends React.Component { this.state = { value: props.value || '', - placeholder: 'Select file or folder...', + placeholder: this.props.placeholder || 'Select file or folder...', } this.handleIconClick = this.handleIconClick.bind(this) } static getDerivedStateFromProps(props: IProps, state: IState) { - if (!props.value || state.value !== '') return state + const newState = state - return { value: props.value || '' } + if (props.value && state.value === '') { + newState.value = props.value || '' + } + + if (props.placeholder) { + newState.placeholder = props.placeholder + } + + return newState } async componentDidMount() { - const translation = await translate('components.select_file') - this.setState( { - placeholder: translation - }) + if (!this.props.placeholder) { + const translation = await translate('components.select_file') + this.setState( { + placeholder: translation + }) + } } async handleIconClick() { @@ -66,7 +78,7 @@ export default class DirInput extends React.Component { { this.setState({ value: text }) diff --git a/src/ui/components/menu/Game.css b/src/ui/components/menu/Game.css new file mode 100644 index 0000000..12ef254 --- /dev/null +++ b/src/ui/components/menu/Game.css @@ -0,0 +1,28 @@ +.GameDownloadMenu { + width: 40%; + height: 40%; +} + +.GameDownload { + padding: 18px; +} + +.GameDownload .BigButton { + height: 50px; +} + +.GameDownloadDir { + width: 70%; +} + +.GameDownloadDir .DirInput { + width: 100%; +} + +.GameDownloadDir .DirInput .TextInputWrapper { + width: 100%; +} + +.GameDownloadDir .DirInput .TextInputWrapper input { + width: 80%; +} \ No newline at end of file diff --git a/src/ui/components/menu/Game.tsx b/src/ui/components/menu/Game.tsx new file mode 100644 index 0000000..2eb7c46 --- /dev/null +++ b/src/ui/components/menu/Game.tsx @@ -0,0 +1,58 @@ +import React from 'react' +import Menu from './Menu' +import Tr, { translate } from '../../../utils/language' +import DownloadHandler from '../../../utils/download' + +import './Game.css' +import DirInput from '../common/DirInput' +import BigButton from '../common/BigButton' + +interface IProps { + closeFn: () => void; + downloadManager: DownloadHandler; +} + +interface IState { + gameDownloading: boolean; + gameDownloadFolder: string; + dirPlaceholder: string; +} + +export default class Downloads extends React.Component { + constructor(props: IProps) { + super(props) + + this.state = { + gameDownloading: false, + gameDownloadFolder: '', + dirPlaceholder: '' + } + } + + async componentDidMount() { + this.setState({ + dirPlaceholder: await translate('components.select_folder') + }) + } + + downloadGame() { + console.log('Download!') + } + + render() { + return ( + +
+ Download Game +
+ +
+ this.setState({ + gameDownloading: true, + gameDownloadFolder: value + })}/> +
+
+ ) + } +} \ No newline at end of file