83 lines
3.8 KiB
JavaScript
83 lines
3.8 KiB
JavaScript
|
export default class V2C_ThemeCard extends BDV2.reactComponent {
|
||
|
|
||
|
constructor(props) {
|
||
|
super(props);
|
||
|
this.setInitialState();
|
||
|
this.onChange = this.onChange.bind(this);
|
||
|
this.reload = this.reload.bind(this);
|
||
|
}
|
||
|
|
||
|
setInitialState() {
|
||
|
this.state = {
|
||
|
checked: themeCookie[this.props.theme.name],
|
||
|
reloads: 0
|
||
|
};
|
||
|
}
|
||
|
|
||
|
// componentDidMount() {
|
||
|
// BDEvents.on("theme-reloaded", this.onReload);
|
||
|
// }
|
||
|
|
||
|
// componentWillUnmount() {
|
||
|
// BDEvents.off("theme-reloaded", this.onReload);
|
||
|
// }
|
||
|
|
||
|
onReload(themeName) {
|
||
|
if (themeName !== this.props.theme.name) return;
|
||
|
this.setState({reloads: this.state.reloads + 1});
|
||
|
}
|
||
|
|
||
|
reload() {
|
||
|
const theme = this.props.theme.name;
|
||
|
const error = themeModule.reloadTheme(theme);
|
||
|
if (error) mainCore.showToast(`Could not reload ${bdthemes[theme].name}. Check console for details.`, {type: "error"});
|
||
|
else mainCore.showToast(`${bdthemes[theme].name} v${bdthemes[theme].version} has been reloaded.`, {type: "success"});
|
||
|
// this.setState(this.state);
|
||
|
this.props.theme = bdthemes[theme];
|
||
|
this.onReload(this.props.theme.name);
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
let {theme} = this.props;
|
||
|
let name = theme.name;
|
||
|
let description = theme.description;
|
||
|
let version = theme.version;
|
||
|
let author = theme.author;
|
||
|
let website = bdthemes[name].website;
|
||
|
let source = bdthemes[name].source;
|
||
|
|
||
|
return BDV2.react.createElement("li", {"data-name": name, "data-version": version, "className": "settings-closed ui-switch-item"},
|
||
|
BDV2.react.createElement("div", {className: "bda-header"},
|
||
|
BDV2.react.createElement("span", {className: "bda-header-title"},
|
||
|
BDV2.react.createElement("span", {className: "bda-name"}, name),
|
||
|
" v",
|
||
|
BDV2.react.createElement("span", {className: "bda-version"}, version),
|
||
|
" by ",
|
||
|
BDV2.react.createElement("span", {className: "bda-author"}, author)
|
||
|
),
|
||
|
BDV2.react.createElement("div", {className: "bda-controls"},
|
||
|
!settingsCookie["fork-ps-5"] && BDV2.react.createElement(V2Components.TooltipWrap(V2Components.ReloadIcon, {color: "black", side: "top", text: "Reload"}), {className: "bd-reload-card", onClick: this.reload}),
|
||
|
BDV2.react.createElement("label", {className: "ui-switch-wrapper ui-flex-child", style: {flex: "0 0 auto"}},
|
||
|
BDV2.react.createElement("input", {checked: this.state.checked, onChange: this.onChange, className: "ui-switch-checkbox", type: "checkbox"}),
|
||
|
BDV2.react.createElement("div", {className: this.state.checked ? "ui-switch checked" : "ui-switch"})
|
||
|
)
|
||
|
)
|
||
|
),
|
||
|
BDV2.react.createElement("div", {className: "bda-description-wrap scroller-wrap fade"},
|
||
|
BDV2.react.createElement("div", {className: "bda-description scroller"}, description)
|
||
|
),
|
||
|
(website || source) && BDV2.react.createElement("div", {className: "bda-footer"},
|
||
|
BDV2.react.createElement("span", {className: "bda-links"},
|
||
|
website && BDV2.react.createElement("a", {className: "bda-link", href: website, target: "_blank"}, "Website"),
|
||
|
website && source && " | ",
|
||
|
source && BDV2.react.createElement("a", {className: "bda-link", href: source, target: "_blank"}, "Source")
|
||
|
)
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
onChange() {
|
||
|
this.setState({checked: !this.state.checked});
|
||
|
themeModule.toggleTheme(this.props.theme.name);
|
||
|
}
|
||
|
}
|