2024-07-20 17:19:10 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import ChatViewModel from "../../ViewModel/chatViewModel";
|
2024-07-20 18:10:42 +02:00
|
|
|
import { Color } from "../../ViewModel/colors";
|
2024-07-20 18:49:05 +02:00
|
|
|
import { DeletableListItem } from "../Components/deletableListItem";
|
2024-07-20 17:19:10 +02:00
|
|
|
import { translations } from "../translations";
|
|
|
|
|
|
|
|
|
|
export function SettingsPage(chatViewModel: ChatViewModel) {
|
2024-07-20 18:49:05 +02:00
|
|
|
const secondaryChannelConverter: React.StateItemConverter<string> = (
|
|
|
|
|
secondaryChannel: string
|
|
|
|
|
) => {
|
|
|
|
|
return DeletableListItem(secondaryChannel, <span></span>, () => {
|
|
|
|
|
chatViewModel.removeSecondaryChannel(secondaryChannel);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-20 17:19:10 +02:00
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div class="toolbar">
|
|
|
|
|
<span>{translations.chatPage.settings.settingsHeadline}</span>
|
|
|
|
|
</div>
|
2024-07-20 17:30:36 +02:00
|
|
|
<div class="content">
|
|
|
|
|
<label class="tile flex-no">
|
2024-07-20 19:18:19 +02:00
|
|
|
<span class="icon">forum</span>
|
2024-07-20 17:30:36 +02:00
|
|
|
<div>
|
|
|
|
|
<span>{translations.chatPage.settings.primaryChannelLabel}</span>
|
|
|
|
|
<input
|
|
|
|
|
bind:value={chatViewModel.primaryChannelInput}
|
|
|
|
|
on:enter={chatViewModel.setPrimaryChannel}
|
|
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="flex-row justify-end width-input">
|
|
|
|
|
<button
|
|
|
|
|
class="width-50"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.settings.setPrimaryChannelButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={chatViewModel.setPrimaryChannel}
|
|
|
|
|
toggle:disabled={chatViewModel.cannotSetPrimaryChannel}
|
|
|
|
|
>
|
|
|
|
|
{translations.general.setButton}
|
|
|
|
|
<span class="icon">check</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2024-07-20 18:10:42 +02:00
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-20 18:49:05 +02:00
|
|
|
<div class="flex-row width-input margin-bottom">
|
|
|
|
|
<input
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.settings.newSecondaryChannelAudioLabel
|
|
|
|
|
}
|
|
|
|
|
placeholder={
|
|
|
|
|
translations.chatPage.settings.newSecondaryChannelPlaceholder
|
|
|
|
|
}
|
|
|
|
|
bind:value={chatViewModel.newSecondaryChannelInput}
|
|
|
|
|
on:enter={chatViewModel.addSecondaryChannel}
|
|
|
|
|
></input>
|
|
|
|
|
<button
|
|
|
|
|
class="primary"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.settings.addSecondaryChannelButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={chatViewModel.addSecondaryChannel}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">add</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-07-20 18:10:42 +02:00
|
|
|
<div
|
2024-07-20 18:49:05 +02:00
|
|
|
class="flex-column gap width-input"
|
|
|
|
|
children:append={[
|
|
|
|
|
chatViewModel.secondaryChannels,
|
|
|
|
|
secondaryChannelConverter,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-20 19:18:19 +02:00
|
|
|
<label class="tile flex-no">
|
|
|
|
|
<span class="icon">key</span>
|
|
|
|
|
<div>
|
|
|
|
|
<span>{translations.chatPage.settings.encryptionKeyLabel}</span>
|
|
|
|
|
<input
|
|
|
|
|
bind:value={chatViewModel.encryptionKeyInput}
|
|
|
|
|
on:enter={chatViewModel.setEncryptionKey}
|
|
|
|
|
set:type={chatViewModel.encryptionKeyInputType}
|
|
|
|
|
></input>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="flex-row justify-end width-input">
|
|
|
|
|
<button
|
|
|
|
|
class="width-50"
|
|
|
|
|
aria-label={
|
|
|
|
|
translations.chatPage.settings.setEncryptionKeyButtonAudioLabel
|
|
|
|
|
}
|
|
|
|
|
on:click={chatViewModel.setEncryptionKey}
|
|
|
|
|
toggle:disabled={chatViewModel.cannotSetEncryptionKey}
|
|
|
|
|
>
|
|
|
|
|
{translations.general.setButton}
|
|
|
|
|
<span class="icon">check</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<label class="inline">
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
bind:checked={chatViewModel.shouldShowEncryptionKey}
|
|
|
|
|
></input>
|
|
|
|
|
{translations.chatPage.settings.showEncryptionKey}
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-20 18:49:05 +02:00
|
|
|
<div class="flex-row gap width-input">
|
2024-07-20 18:10:42 +02:00
|
|
|
{...Object.values(Color).map((color) => {
|
|
|
|
|
const isSelected = React.createProxyState(
|
|
|
|
|
[chatViewModel.color],
|
|
|
|
|
() => chatViewModel.color.value == color
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
function setColor() {
|
|
|
|
|
chatViewModel.setColor(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
color={color}
|
|
|
|
|
class="fill-color width-100 flex"
|
|
|
|
|
style="height: 2rem"
|
|
|
|
|
toggle:selected={isSelected}
|
|
|
|
|
on:click={setColor}
|
|
|
|
|
></button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
2024-07-20 17:30:36 +02:00
|
|
|
</div>
|
2024-07-20 17:19:10 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|