From 1f0bf371094010f751f903937a600931ef7ea205 Mon Sep 17 00:00:00 2001 From: Renard Date: Mon, 30 Sep 2019 22:11:19 -0300 Subject: Añadidos: Settings ✨ --- src/Settings.js | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 src/Settings.js (limited to 'src/Settings.js') diff --git a/src/Settings.js b/src/Settings.js new file mode 100644 index 0000000..f5f298d --- /dev/null +++ b/src/Settings.js @@ -0,0 +1,169 @@ +import React, { Component } from "react"; +import { Dropdown, Checkbox, Modal, Header, Input } from "semantic-ui-react"; + +const notificationSounds = [ + { key: "bed", value: "bed", text: "Bed squeak" }, + { key: "bongchime", value: "bongchime", text: "Bongchime" }, + { key: "boombang", value: "boombang", text: "Boom bang!" }, + { key: "chime", value: "chime", text: "Chime" }, + { key: "dootdoot", value: "dootdoot", text: "Mr Skeltal - Doot doot" }, + { key: "iqc", value: "iqc", text: "Notificación IQC" }, + { key: "msn", value: "msn", text: "Notificación MSN" }, + { key: "manscream", value: "manscream", text: "Man Scream (Loud)" }, + { + key: "messageforme", + value: "messageforme", + text: "IT Crowd - Message for me!" + }, + { key: "nootnoot", value: "nootnoot", text: "Pengu - noot noot" }, + { key: "ohwahahahahah", value: "ohwahahahahah", text: "Oh wah ah ah ah!" }, + { key: "pincheputita", value: "pincheputita", text: "Pinche putita" }, + { key: "idk", value: "idk", text: "??? Pájaro" }, + { key: "whoa", value: "whoa", text: "Woow" } +]; + +class SettingsModal extends Component { + constructor(props) { + super(props); + this.state = { + homeSound: "msn", + threadSound: "dootdoot", + nightMode: true, + notifyOnHome: true, + notifyOnThread: true, + autoUpdateThreads: true, + showAvatars: true, + postPassword: "" + }; + this.handleChange = this.handleChange.bind(this); + this.toggleSetting = this.toggleSetting.bind(this); + } + + componentDidMount() { + let settings = JSON.parse(localStorage.getItem("settings")); + this.setState({ + homeSound: settings.homeSound, + threadSound: settings.threadSound, + nightMode: settings.nightMode, + notifyOnHome: settings.notifyOnHome, + notifyOnThread: settings.notifyOnThread, + autoUpdateThreads: settings.autoUpdateThreads, + showAvatars: settings.showAvatars, + postPassword: settings.postPassword + }); + } + + handleChange(e, { name, value }) { + this.setState({ [name]: value }, () => { + new Audio( + `https://bienvenidoainternet.org/static/sfx/${ + name === "threadSound" ? this.state.threadSound : this.state.homeSound + }.ogg` + ).play(); + this.saveSettings(); + }); + } + + toggleSetting(e, { name, checked }) { + this.setState({ [name]: checked }, () => { + this.props.handler(this.state.nightMode); + this.saveSettings(); + }); + } + + saveSettings() { + localStorage.setItem("settings", JSON.stringify(this.state)); + } + + render() { + const { + homeSound, + threadSound, + nightMode, + autoUpdateThreads, + notifyOnHome, + notifyOnThread, + postPassword, + showAvatars + } = this.state; + return ( + + Configuración + + +
+ Apariencia +
+ + +
+ Comportamiento +
+ + +
+ Sonido de notificación:{" "} + +
+ + +
+ Sonido de notificación :{" "} + +
+
+ Posteo +
+ +
+
+
+ ); + } +} + +export default SettingsModal; -- cgit v1.2.1-18-gbd029