split out FilesItem class into own file
This commit is contained in:
parent
66836c875c
commit
0a10db3bba
2 changed files with 46 additions and 38 deletions
|
@ -12,44 +12,6 @@ import kotlinx.coroutines.flow.asStateFlow
|
||||||
import org.calyxos.backup.storage.backup.BackupSnapshot
|
import org.calyxos.backup.storage.backup.BackupSnapshot
|
||||||
import org.calyxos.backup.storage.restore.RestorableFile
|
import org.calyxos.backup.storage.restore.RestorableFile
|
||||||
|
|
||||||
public sealed interface FilesItem {
|
|
||||||
public val name: String
|
|
||||||
public val dir: String
|
|
||||||
public val level: Int
|
|
||||||
public val selected: Boolean
|
|
||||||
public val size: Long
|
|
||||||
public val lastModified: Long?
|
|
||||||
}
|
|
||||||
|
|
||||||
public data class FileItem internal constructor(
|
|
||||||
internal val file: RestorableFile,
|
|
||||||
override val level: Int,
|
|
||||||
override val selected: Boolean,
|
|
||||||
) : FilesItem {
|
|
||||||
override val name: String get() = file.name
|
|
||||||
override val dir: String get() = file.dir
|
|
||||||
override val size: Long get() = file.size
|
|
||||||
override val lastModified: Long? get() = file.lastModified
|
|
||||||
}
|
|
||||||
|
|
||||||
public data class FolderItem(
|
|
||||||
override val dir: String,
|
|
||||||
override val name: String,
|
|
||||||
override val level: Int,
|
|
||||||
val numFiles: Int,
|
|
||||||
override val size: Long,
|
|
||||||
override val lastModified: Long?,
|
|
||||||
override val selected: Boolean,
|
|
||||||
val partiallySelected: Boolean,
|
|
||||||
val expanded: Boolean,
|
|
||||||
) : FilesItem {
|
|
||||||
init {
|
|
||||||
check(selected || !partiallySelected) {
|
|
||||||
"$dir was not selected, but partially selected"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FileSelectionManager {
|
public class FileSelectionManager {
|
||||||
|
|
||||||
private val allFolders = HashMap<String, FolderItem>()
|
private val allFolders = HashMap<String, FolderItem>()
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 The Calyx Institute
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.calyxos.backup.storage.ui.restore
|
||||||
|
|
||||||
|
import org.calyxos.backup.storage.restore.RestorableFile
|
||||||
|
|
||||||
|
public sealed interface FilesItem {
|
||||||
|
public val name: String
|
||||||
|
public val dir: String
|
||||||
|
public val level: Int
|
||||||
|
public val selected: Boolean
|
||||||
|
public val size: Long
|
||||||
|
public val lastModified: Long?
|
||||||
|
}
|
||||||
|
|
||||||
|
public data class FileItem internal constructor(
|
||||||
|
internal val file: RestorableFile,
|
||||||
|
override val level: Int,
|
||||||
|
override val selected: Boolean,
|
||||||
|
) : FilesItem {
|
||||||
|
override val name: String get() = file.name
|
||||||
|
override val dir: String get() = file.dir
|
||||||
|
override val size: Long get() = file.size
|
||||||
|
override val lastModified: Long? get() = file.lastModified
|
||||||
|
}
|
||||||
|
|
||||||
|
public data class FolderItem(
|
||||||
|
override val dir: String,
|
||||||
|
override val name: String,
|
||||||
|
override val level: Int,
|
||||||
|
val numFiles: Int,
|
||||||
|
override val size: Long,
|
||||||
|
override val lastModified: Long?,
|
||||||
|
override val selected: Boolean,
|
||||||
|
val partiallySelected: Boolean,
|
||||||
|
val expanded: Boolean,
|
||||||
|
) : FilesItem {
|
||||||
|
init {
|
||||||
|
check(selected || !partiallySelected) {
|
||||||
|
"$dir was not selected, but partially selected"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue