From 74551214d2bf85e412a6f910c858d0f265913108 Mon Sep 17 00:00:00 2001 From: qu1ck Date: Fri, 9 Aug 2024 03:15:17 -0700 Subject: [PATCH] Add expand/collapse toggle to add torrent dialog Large window sometimes useful for torrents with lots of files Issue #219 --- src/components/modals/add.tsx | 74 +++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/src/components/modals/add.tsx b/src/components/modals/add.tsx index 977f831..4b941b0 100644 --- a/src/components/modals/add.tsx +++ b/src/components/modals/add.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Box, Button, Checkbox, Divider, Flex, Group, Menu, SegmentedControl, Text, TextInput } from "@mantine/core"; +import { ActionIcon, Box, Button, Checkbox, Divider, Flex, Group, Menu, SegmentedControl, Text, TextInput } from "@mantine/core"; import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react"; import type { ModalState, LocationData } from "./common"; import { HkModal, LimitedNamesList, TorrentLabels, TorrentLocation, useTorrentLocation } from "./common"; @@ -32,6 +32,9 @@ import { useAddTorrent, useFileTree, useTorrentAddTrackers } from "queries"; import { ConfigContext, ServerConfigContext } from "config"; import type { ServerTabsRef } from "components/servertabs"; import { bytesToHumanReadableStr, decodeMagnetLink } from "trutil"; +import { useToggle } from "@mantine/hooks"; +import * as Icon from "react-bootstrap-icons"; + const { TAURI, dialogOpen, invoke } = await import(/* webpackChunkName: "taurishim" */"taurishim"); interface AddCommonProps extends React.PropsWithChildren { @@ -570,48 +573,59 @@ export function AddTorrent(props: AddCommonModalProps) { const torrentExists = existingTorrent !== undefined; + const [fullScreen, toggleFullScreen] = useToggle(); + return (<> {!TAURI && } {shouldOpen && + fullScreen={fullScreen} + styles={{ + title: { flexGrow: 1 }, + content: { display: fullScreen ? "flex" : "block", flexDirection: "column" }, + body: { display: fullScreen ? "flex" : "block", flexDirection: "column", flexGrow: 1 }, + }} + title={ Add torrent - {TAURI && } + + {TAURI && <> + + { toggleFullScreen(); }}> + {fullScreen ? : } + + } } > {torrentExists ? Torrent already exists : } -
- - {(wantedSize > 0 || torrentData[0].files != null) && - {bytesToHumanReadableStr(wantedSize)}} - {(torrentData.length > 1 || torrentData[0].files == null) - ? <> - : <> - - - } - + + {(wantedSize > 0 || torrentData[0].files != null) && + {bytesToHumanReadableStr(wantedSize)}} {(torrentData.length > 1 || torrentData[0].files == null) ? <> - : - - - } -
+ : <> + + + } + + {(torrentData.length > 1 || torrentData[0].files == null) + ? <> + : + + + }