split out FilesItem class into own file

This commit is contained in:
Torsten Grote 2024-08-02 13:54:44 -03:00
parent 66836c875c
commit 0a10db3bba
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 46 additions and 38 deletions

View file

@ -12,44 +12,6 @@ import kotlinx.coroutines.flow.asStateFlow
import org.calyxos.backup.storage.backup.BackupSnapshot
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 {
private val allFolders = HashMap<String, FolderItem>()

View file

@ -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"
}
}
}