Add layout options to the appearance tab

This commit is contained in:
Jorik Schellekens 2020-06-16 17:55:19 +01:00
parent b27334f448
commit 2192332968
7 changed files with 138 additions and 8 deletions

View file

@ -121,8 +121,8 @@ $irc-line-height: $font-18px;
} }
} }
.mx_EvenTile_line .mx_MessageActionBar, .mx_EventTile_line .mx_MessageActionBar,
.mx_EvenTile_line .mx_ReplyThread_wrapper { .mx_EventTile_line .mx_ReplyThread_wrapper {
display: block; display: block;
} }

View file

@ -16,6 +16,7 @@ limitations under the License.
.mx_AppearanceUserSettingsTab_fontSlider, .mx_AppearanceUserSettingsTab_fontSlider,
.mx_AppearanceUserSettingsTab_fontSlider_preview, .mx_AppearanceUserSettingsTab_fontSlider_preview,
.mx_AppearanceUserSettingsTab_Layout,
.mx_AppearanceUserSettingsTab .mx_Field { .mx_AppearanceUserSettingsTab .mx_Field {
@mixin mx_Settings_fullWidthField; @mixin mx_Settings_fullWidthField;
} }
@ -41,6 +42,14 @@ limitations under the License.
border-radius: 10px; border-radius: 10px;
padding: 0 16px 9px 16px; padding: 0 16px 9px 16px;
pointer-events: none; pointer-events: none;
.mx_EventTile_msgOption {
display: none;
}
&.mx_IRCLayout {
padding-top: 9px;
}
} }
.mx_AppearanceUserSettingsTab_fontSlider_smallText { .mx_AppearanceUserSettingsTab_fontSlider_smallText {
@ -135,3 +144,55 @@ limitations under the License.
.mx_SettingsTab_customFontSizeField { .mx_SettingsTab_customFontSizeField {
margin-left: calc($font-16px + 10px); margin-left: calc($font-16px + 10px);
} }
.mx_AppearanceUserSettingsTab_Layout_RadioButtons {
display: flex;
flex-direction: row;
color: $primary-fg-color;
.mx_AppearanceUserSettingsTab_spacer {
width: 24px;
}
> .mx_AppearanceUserSettingsTab_Layout_RadioButton {
flex-grow: 0;
flex-shrink: 1;
display: flex;
flex-direction: column;
width: 300px;
border: 1px solid $input-darker-bg-color;
border-radius: 10px;
.mx_EventTile_msgOption {
display: none;
}
.mx_AppearanceUserSettingsTab_Layout_RadioButton_preview {
flex-grow: 1;
display: flex;
align-items: center;
padding: 10px;
}
.mx_RadioButton {
flex-grow: 0;
padding: 10px;
}
.mx_EventTile_content {
margin-right: 0;
}
}
.mx_RadioButton {
border-top: 1px solid $input-darker-bg-color;
}
.mx_RadioButton_checked {
background-color: rgba($accent-color, 0.08);
}
}

View file

@ -166,7 +166,7 @@ export default createReactClass({
canReact: false, canReact: false,
canReply: false, canReply: false,
useIRCLayout: SettingsStore.getValue("feature_irc_ui"), useIRCLayout: SettingsStore.getValue("useIRCLayout"),
matrixClientIsReady: this.context && this.context.isInitialSyncComplete(), matrixClientIsReady: this.context && this.context.isInitialSyncComplete(),
}; };
@ -199,7 +199,7 @@ export default createReactClass({
this._roomView = createRef(); this._roomView = createRef();
this._searchResultsPanel = createRef(); this._searchResultsPanel = createRef();
this._layoutWatcherRef = SettingsStore.watchSetting("feature_irc_ui", null, this.onLayoutChange); this._layoutWatcherRef = SettingsStore.watchSetting("useIRCLayout", null, this.onLayoutChange);
}, },
_onReadReceiptsChange: function() { _onReadReceiptsChange: function() {
@ -546,7 +546,7 @@ export default createReactClass({
onLayoutChange: function() { onLayoutChange: function() {
this.setState({ this.setState({
useIRCLayout: SettingsStore.getValue("feature_irc_ui"), useIRCLayout: SettingsStore.getValue("useIRCLayout"),
}); });
}, },

View file

@ -36,6 +36,7 @@ export default class StyledRadioButton extends React.PureComponent<IProps, IStat
{ {
"mx_RadioButton_disabled": disabled, "mx_RadioButton_disabled": disabled,
"mx_RadioButton_enabled": !disabled, "mx_RadioButton_enabled": !disabled,
"mx_RadioButton_checked": this.props.checked,
}); });
return <label className={_className}> return <label className={_className}>
<input type='radio' disabled={disabled} {...otherProps} /> <input type='radio' disabled={disabled} {...otherProps} />

View file

@ -52,8 +52,11 @@ interface IState extends IThemeState {
customThemeUrl: string, customThemeUrl: string,
customThemeMessage: CustomThemeMessage, customThemeMessage: CustomThemeMessage,
useCustomFontSize: boolean, useCustomFontSize: boolean,
useIRCLayout: boolean,
} }
const MESSAGE_PREVIEW_TEXT = "Hey you. You're the best"
export default class AppearanceUserSettingsTab extends React.Component<IProps, IState> { export default class AppearanceUserSettingsTab extends React.Component<IProps, IState> {
private themeTimer: NodeJS.Timeout; private themeTimer: NodeJS.Timeout;
@ -67,6 +70,7 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
customThemeUrl: "", customThemeUrl: "",
customThemeMessage: {isError: false, text: ""}, customThemeMessage: {isError: false, text: ""},
useCustomFontSize: SettingsStore.getValue("useCustomFontSize"), useCustomFontSize: SettingsStore.getValue("useCustomFontSize"),
useIRCLayout: SettingsStore.getValue("useIRCLayout", null),
}; };
} }
@ -197,6 +201,16 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
this.setState({customThemeUrl: e.target.value}); this.setState({customThemeUrl: e.target.value});
}; };
private onLayoutChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
const val = e.target.value === "true";
this.setState({
useIRCLayout: val,
});
SettingsStore.setValue("useIRCLayout", null, SettingLevel.DEVICE, val);
}
private renderThemeSection() { private renderThemeSection() {
const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag"); const SettingsFlag = sdk.getComponent("views.elements.SettingsFlag");
const StyledCheckbox = sdk.getComponent("views.elements.StyledCheckbox"); const StyledCheckbox = sdk.getComponent("views.elements.StyledCheckbox");
@ -287,7 +301,8 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
<span className="mx_SettingsTab_subheading">{_t("Font size")}</span> <span className="mx_SettingsTab_subheading">{_t("Font size")}</span>
<MessagePreview <MessagePreview
className="mx_AppearanceUserSettingsTab_fontSlider_preview" className="mx_AppearanceUserSettingsTab_fontSlider_preview"
message="Hey you. You're the best" message={MESSAGE_PREVIEW_TEXT}
useIRCLayout={this.state.useIRCLayout}
/> />
<div className="mx_AppearanceUserSettingsTab_fontSlider"> <div className="mx_AppearanceUserSettingsTab_fontSlider">
<div className="mx_AppearanceUserSettingsTab_fontSlider_smallText">Aa</div> <div className="mx_AppearanceUserSettingsTab_fontSlider_smallText">Aa</div>
@ -323,6 +338,49 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
</div>; </div>;
} }
private renderLayoutSection = () => {
const StyledRadioButton = sdk.getComponent("views.elements.StyledRadioButton");
const MessagePreview = sdk.getComponent("views.elements.MessagePreview");
return <div className="mx_SettingsTab_section mx_AppearanceUserSettingsTab_Layout">
<span className="mx_SettingsTab_subheading">{_t("Message layout")}</span>
<div className="mx_AppearanceUserSettingsTab_Layout_RadioButtons" >
<div className="mx_AppearanceUserSettingsTab_Layout_RadioButton">
<MessagePreview
className="mx_AppearanceUserSettingsTab_Layout_RadioButton_preview"
message={MESSAGE_PREVIEW_TEXT}
useIRCLayout={true}
/>
<StyledRadioButton
name={"layout"}
value={true}
checked={this.state.useIRCLayout}
onChange={this.onLayoutChange}
>
{_t("Compact")}
</StyledRadioButton>
</div>
<div className="mx_AppearanceUserSettingsTab_spacer" />
<div className="mx_AppearanceUserSettingsTab_Layout_RadioButton">
<MessagePreview
className="mx_AppearanceUserSettingsTab_Layout_RadioButton_preview"
message={MESSAGE_PREVIEW_TEXT}
useIRCLayout={false}
/>
<StyledRadioButton
name={"layout"}
value={false}
checked={!this.state.useIRCLayout}
onChange={this.onLayoutChange}
>
{_t("Modern")}
</StyledRadioButton>
</div>
</div>
</div>
}
render() { render() {
return ( return (
<div className="mx_SettingsTab mx_AppearanceUserSettingsTab"> <div className="mx_SettingsTab mx_AppearanceUserSettingsTab">
@ -332,6 +390,7 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
</div> </div>
{this.renderThemeSection()} {this.renderThemeSection()}
{SettingsStore.isFeatureEnabled("feature_font_scaling") ? this.renderFontSection() : null} {SettingsStore.isFeatureEnabled("feature_font_scaling") ? this.renderFontSection() : null}
{SettingsStore.isFeatureEnabled("feature_irc_ui") ? this.renderLayoutSection() : null}
</div> </div>
); );
} }

View file

@ -434,7 +434,7 @@
"Try out new ways to ignore people (experimental)": "Try out new ways to ignore people (experimental)", "Try out new ways to ignore people (experimental)": "Try out new ways to ignore people (experimental)",
"Use the improved room list (in development - refresh to apply changes)": "Use the improved room list (in development - refresh to apply changes)", "Use the improved room list (in development - refresh to apply changes)": "Use the improved room list (in development - refresh to apply changes)",
"Support adding custom themes": "Support adding custom themes", "Support adding custom themes": "Support adding custom themes",
"Use IRC layout": "Use IRC layout", "Enable IRC layout option in the appearance tab": "Enable IRC layout option in the appearance tab",
"Show info about bridges in room settings": "Show info about bridges in room settings", "Show info about bridges in room settings": "Show info about bridges in room settings",
"Font size": "Font size", "Font size": "Font size",
"Use custom size": "Use custom size", "Use custom size": "Use custom size",
@ -483,6 +483,7 @@
"How fast should messages be downloaded.": "How fast should messages be downloaded.", "How fast should messages be downloaded.": "How fast should messages be downloaded.",
"Manually verify all remote sessions": "Manually verify all remote sessions", "Manually verify all remote sessions": "Manually verify all remote sessions",
"IRC display name width": "IRC display name width", "IRC display name width": "IRC display name width",
"Use IRC layout": "Use IRC layout",
"Collecting app version information": "Collecting app version information", "Collecting app version information": "Collecting app version information",
"Collecting logs": "Collecting logs", "Collecting logs": "Collecting logs",
"Uploading report": "Uploading report", "Uploading report": "Uploading report",
@ -779,6 +780,9 @@
"Custom theme URL": "Custom theme URL", "Custom theme URL": "Custom theme URL",
"Add theme": "Add theme", "Add theme": "Add theme",
"Theme": "Theme", "Theme": "Theme",
"Message layout": "Message layout",
"Compact": "Compact",
"Modern": "Modern",
"Customise your appearance": "Customise your appearance", "Customise your appearance": "Customise your appearance",
"Appearance Settings only affect this Riot session.": "Appearance Settings only affect this Riot session.", "Appearance Settings only affect this Riot session.": "Appearance Settings only affect this Riot session.",
"Flair": "Flair", "Flair": "Flair",

View file

@ -152,7 +152,7 @@ export const SETTINGS = {
}, },
"feature_irc_ui": { "feature_irc_ui": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS, supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Use IRC layout'), displayName: _td('Enable IRC layout option in the appearance tab'),
default: false, default: false,
isFeature: true, isFeature: true,
}, },
@ -549,4 +549,9 @@ export const SETTINGS = {
displayName: _td("IRC display name width"), displayName: _td("IRC display name width"),
default: 80, default: 80,
}, },
"useIRCLayout": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td("Use IRC layout"),
default: false,
},
}; };