2024-07-27 19:13:59 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import FileTransferViewModel, {
|
2024-07-28 00:02:17 +02:00
|
|
|
FileTransferModal,
|
2024-07-27 19:13:59 +02:00
|
|
|
FileTransferOption,
|
|
|
|
|
} from "../../ViewModel/Global/fileTransferViewModel";
|
|
|
|
|
|
|
|
|
|
import StorageModel from "../../Model/Global/storageModel";
|
|
|
|
|
import { translations } from "../translations";
|
|
|
|
|
|
2024-07-28 00:02:17 +02:00
|
|
|
export function DataTransferModalWrapper(
|
2024-07-27 19:13:59 +02:00
|
|
|
fileTransferViewModel: FileTransferViewModel
|
|
|
|
|
) {
|
2024-07-28 00:02:17 +02:00
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{DirectionSelectionModal(fileTransferViewModel)}
|
|
|
|
|
{FileSelectionModal(fileTransferViewModel)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DirectionSelectionModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.DirectionSelection
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div class="modal" toggle:open={isPresented}>
|
|
|
|
|
<div>
|
|
|
|
|
<main>
|
|
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
|
|
|
|
|
|
|
|
|
<div class="flex-column gap content-margin-bottom">
|
|
|
|
|
<button
|
|
|
|
|
class="tile"
|
|
|
|
|
on:click={fileTransferViewModel.showFileSelectionModal}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">upload</span>
|
|
|
|
|
<div>
|
|
|
|
|
<b>{translations.dataTransferModal.fromThisDeviceButton}</b>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button class="tile">
|
|
|
|
|
<span class="icon">download</span>
|
|
|
|
|
<div>
|
|
|
|
|
<b>{translations.dataTransferModal.toThisDeviceButton}</b>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
<button on:click={fileTransferViewModel.hideModal}>
|
|
|
|
|
{translations.general.closeButton}
|
|
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function FileSelectionModal(fileTransferViewModel: FileTransferViewModel) {
|
|
|
|
|
// option
|
2024-07-27 19:40:16 +02:00
|
|
|
const OptionConverter: React.StateItemConverter<FileTransferOption> = (
|
|
|
|
|
fileOption: FileTransferOption
|
|
|
|
|
) => {
|
2024-07-27 23:45:36 +02:00
|
|
|
return OptionEntry(fileOption, fileTransferViewModel);
|
2024-07-27 19:40:16 +02:00
|
|
|
};
|
|
|
|
|
|
2024-07-28 00:02:17 +02:00
|
|
|
function OptionEntry(
|
|
|
|
|
fileOption: FileTransferOption,
|
|
|
|
|
fileTransferViewModel: FileTransferViewModel
|
|
|
|
|
) {
|
|
|
|
|
const isSelected = new React.State(false);
|
|
|
|
|
isSelected.subscribeSilent((isSelected) => {
|
|
|
|
|
if (isSelected == true) {
|
|
|
|
|
fileTransferViewModel.selectedPaths.add(fileOption.path);
|
|
|
|
|
} else {
|
|
|
|
|
fileTransferViewModel.selectedPaths.remove(fileOption.path);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
function toggle() {
|
|
|
|
|
isSelected.value = !isSelected.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button class="tile" toggle:selected={isSelected} on:click={toggle}>
|
|
|
|
|
<div>
|
|
|
|
|
<b class="ellipsis">{fileOption.label}</b>
|
|
|
|
|
<span class="secondary ellipsis">
|
|
|
|
|
{StorageModel.pathComponentsToString(...fileOption.path)}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// state
|
|
|
|
|
const isPresented = React.createProxyState(
|
|
|
|
|
[fileTransferViewModel.presentedModal],
|
|
|
|
|
() =>
|
|
|
|
|
fileTransferViewModel.presentedModal.value ==
|
|
|
|
|
FileTransferModal.FileSelection
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-27 19:13:59 +02:00
|
|
|
return (
|
2024-07-28 00:02:17 +02:00
|
|
|
<div class="modal" toggle:open={isPresented}>
|
2024-07-27 19:13:59 +02:00
|
|
|
<div>
|
|
|
|
|
<main>
|
2024-07-27 23:45:36 +02:00
|
|
|
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
2024-07-27 19:13:59 +02:00
|
|
|
<span class="secondary">
|
2024-07-27 23:45:36 +02:00
|
|
|
{translations.dataTransferModal.selectionDescription}
|
2024-07-27 19:13:59 +02:00
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<hr></hr>
|
|
|
|
|
|
2024-07-27 23:45:36 +02:00
|
|
|
<h3>{translations.dataTransferModal.generalHeadline}</h3>
|
2024-07-27 19:13:59 +02:00
|
|
|
<div
|
|
|
|
|
class="flex-column gap content-margin-bottom"
|
|
|
|
|
children:append={[
|
|
|
|
|
fileTransferViewModel.generalFileOptions,
|
2024-07-27 19:40:16 +02:00
|
|
|
OptionConverter,
|
2024-07-27 19:13:59 +02:00
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
|
2024-07-27 23:45:36 +02:00
|
|
|
<h3>{translations.dataTransferModal.chatsHeadline}</h3>
|
2024-07-27 19:13:59 +02:00
|
|
|
<div
|
|
|
|
|
class="flex-column gap"
|
|
|
|
|
children:append={[
|
|
|
|
|
fileTransferViewModel.chatFileOptions,
|
2024-07-27 19:40:16 +02:00
|
|
|
OptionConverter,
|
2024-07-27 19:13:59 +02:00
|
|
|
]}
|
|
|
|
|
></div>
|
|
|
|
|
</main>
|
|
|
|
|
<div class="flex-row width-100">
|
|
|
|
|
<button
|
|
|
|
|
class="flex"
|
2024-07-28 00:02:17 +02:00
|
|
|
on:click={fileTransferViewModel.showDirectionSelectionModal}
|
2024-07-27 19:13:59 +02:00
|
|
|
>
|
2024-07-28 00:02:17 +02:00
|
|
|
{translations.general.backButton}
|
2024-07-27 19:13:59 +02:00
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="primary flex"
|
2024-07-28 00:02:17 +02:00
|
|
|
on:click={fileTransferViewModel.hideModal}
|
|
|
|
|
toggle:disabled={fileTransferViewModel.hasNoPathsSelected}
|
2024-07-27 19:13:59 +02:00
|
|
|
>
|
|
|
|
|
{translations.general.continueButton}
|
|
|
|
|
<span class="icon">arrow_forward</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|