mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-16 09:04:45 +01:00
begin progress bar element
This commit is contained in:
@@ -12,8 +12,7 @@ interface IState {
|
||||
}
|
||||
|
||||
export default class BigButton extends React.Component<IProps, IState> {
|
||||
|
||||
constructor(props: { text: string, onClick: () => any, id: string }) {
|
||||
constructor(props: IProps) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
|
||||
0
src/ui/components/common/ProgressBar.css
Normal file
0
src/ui/components/common/ProgressBar.css
Normal file
52
src/ui/components/common/ProgressBar.tsx
Normal file
52
src/ui/components/common/ProgressBar.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import React from 'react'
|
||||
|
||||
interface IProps {
|
||||
path: string,
|
||||
downloadManager: any,
|
||||
}
|
||||
|
||||
interface IState {
|
||||
progress: number,
|
||||
status: string,
|
||||
total: number,
|
||||
}
|
||||
|
||||
export default class ProgressBar extends React.Component<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
progress: 0,
|
||||
status: '',
|
||||
total: this.props.downloadManager.getDownloadProgress(this.props.path).total,
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Periodically check the progress of passed file path
|
||||
const intv = setInterval(() => {
|
||||
const prog = this.props.downloadManager.getDownloadProgress(this.props.path)
|
||||
this.setState({
|
||||
progress: prog.progress,
|
||||
status: prog.status,
|
||||
})
|
||||
|
||||
if (prog.status === 'finished') {
|
||||
clearInterval(intv)
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="ProgressBar">
|
||||
<div className="InnerProgress" style={{
|
||||
width: `${this.state.progress / this.state.total}%`,
|
||||
}}></div>
|
||||
<div className="ProgressText">
|
||||
{this.state.status}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user