From 8c9854dd906cadeb2acea71c0960d80a51a8712b Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 9 Jan 2020 14:03:36 +1100 Subject: [PATCH] Settings onClick functionality --- js/modules/signal.js | 4 - stylesheets/_session.scss | 1 - ts/components/MainViewController.tsx | 138 +++++++++++------- .../settings/SessionSettingListItem.tsx | 16 +- 4 files changed, 98 insertions(+), 61 deletions(-) diff --git a/js/modules/signal.js b/js/modules/signal.js index b9656f62a..2e2946858 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -54,9 +54,6 @@ const { } = require('../../ts/components/DevicePairingDialog'); const { AddServerDialog } = require('../../ts/components/AddServerDialog'); -const { - SessionSettings, -} = require('../../ts/components/session/SessionSettings'); const { SessionToast } = require('../../ts/components/session/SessionToast'); const { SessionToggle } = require('../../ts/components/session/SessionToggle'); const { SessionModal } = require('../../ts/components/session/SessionModal'); @@ -272,7 +269,6 @@ exports.setup = (options = {}) => { InviteFriendsDialog, GroupInvitation, BulkEdit, - SessionSettings, SessionToast, SessionToggle, SessionConfirm, diff --git a/stylesheets/_session.scss b/stylesheets/_session.scss index e84eeddd7..dd6472452 100644 --- a/stylesheets/_session.scss +++ b/stylesheets/_session.scss @@ -919,7 +919,6 @@ label { &-item { font-size: 15px; - font-weight: bold; color: $session-color-white; background-color: $session-shade-1; diff --git a/ts/components/MainViewController.tsx b/ts/components/MainViewController.tsx index d5cbdb462..0a616d578 100644 --- a/ts/components/MainViewController.tsx +++ b/ts/components/MainViewController.tsx @@ -3,31 +3,64 @@ import ReactDOM from 'react-dom'; import { SessionSettingListItem, SessionSettingType } from './session/settings/SessionSettingListItem'; -// interface State { -// } +import { SessionSettingCategory } from './session/LeftPaneSettingSection'; +import { SessionButtonColor } from './session/SessionButton'; -// interface Props { -// } -// export class LeftPane extends React.Component { -// public state = { -// }; +// Grab initial values from database on startup +const localSettings = [ + { + id: "typingIndicators", + title: "Typing Indicators", + description: "See and share when messages are being typed. This setting is optional and applies to all conversations.", + type: SessionSettingType.Toggle, + category: SessionSettingCategory.Privacy, + value: false, + }, + { + id: "screenLock", + title: "Screen Lock", + description: "Unlock Loki Session using your password. Visit notification settings to customise.", + type: SessionSettingType.Toggle, + category: SessionSettingCategory.Privacy, + value: true, + }, + { + id: "screenSecurity", + title: "Screen Security", + description: "Prevent Loki Session previews from appearing in desktop notifications.", + type: SessionSettingType.Toggle, + category: SessionSettingCategory.Privacy, + value: false, + }, + { + id: "linkPreviews", + title: "Send Link Previews", + description: "Supported for imgur, Instagram, Pinterest, Reddit and YouTube.", + type: SessionSettingType.Toggle, + category: SessionSettingCategory.Privacy, + value: true, + }, + { + id: "screenSecurity", + title: "Screen Security", + description: "Prevent Loki Session previews from appearing in desktop notifications.", + category: SessionSettingCategory.Privacy, + type: SessionSettingType.Toggle, + value: false, + }, + { + id: "clearConversationHistory", + title: "Clear Conversation History", + category: SessionSettingCategory.Privacy, + type: SessionSettingType.Button, + value: false, + buttonText: 'Clear', + buttonColor: SessionButtonColor.Danger, + }, +]; -// public constructor(props: any) { -// super(props); -// } - - -// public render(): JSX.Element { -// return ( -//
-// Lorem ipsum dolor sit amet consectetur, adipisicing elit. Debitis, pariatur dicta placeat corporis similique modi quod veritatis voluptatum impedit tempore voluptas nostrum magni aspernatur iure, labore ipsam odit possimus exercitationem? -//
-// ); -// } - -// } export class MainViewController { public static renderMessageView() { @@ -51,39 +84,42 @@ export class MainViewController { public static renderSettingsView() { const element = (
- - - - - alert("Cleaaarred!") } - /> + { localSettings.map(setting => { + return ( + { + SettingsManager.updateSetting(setting); + }} + buttonText = { setting.buttonText || undefined } + buttonColor = { setting.buttonColor || undefined } + /> + ); + }) }
); ReactDOM.render(element, document.getElementById('main-view')); } +} + + +export class SettingsManager { + public static updateSetting({ id, type, value } ) { + if (type === SessionSettingType.Toggle){ + alert(`You clicked a toggle with ID: ${id}`); + + // Manage toggle events + + + return; + } + + alert('you clicked something else'); + + return; + } } \ No newline at end of file diff --git a/ts/components/session/settings/SessionSettingListItem.tsx b/ts/components/session/settings/SessionSettingListItem.tsx index b8f7881e0..08f32be65 100644 --- a/ts/components/session/settings/SessionSettingListItem.tsx +++ b/ts/components/session/settings/SessionSettingListItem.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { SessionToggle } from '../SessionToggle'; -import { SessionButton, SessionButtonColor } from '../SessionButton'; +import { SessionButton, SessionButtonColor, SessionButtonType } from '../SessionButton'; + export enum SessionSettingType { @@ -15,6 +16,8 @@ interface Props { type: SessionSettingType; value: boolean | string; onClick?: any; + buttonText?: string; + buttonColor?: SessionButtonColor; } export class SessionSettingListItem extends React.Component { @@ -27,7 +30,7 @@ export class SessionSettingListItem extends React.Component { public render(): JSX.Element { - const { title, description, type, value, onClick } = this.props + const { title, description, type, value, onClick, buttonText, buttonColor } = this.props return (
@@ -45,14 +48,17 @@ export class SessionSettingListItem extends React.Component { { type === SessionSettingType.Toggle && (
- +
)} { type === SessionSettingType.Button && ( )}