Нормальная модульная структура

This commit is contained in:
Roman Pytkov
2024-11-01 22:34:08 +03:00
parent b95666789c
commit 09210ff6f4
38 changed files with 381 additions and 49 deletions

View File

@@ -1,4 +0,0 @@
package com.github.nullptroma.wallenc.domain
class MyClass {
}

View File

@@ -0,0 +1,6 @@
package com.github.nullptroma.wallenc.domain.models
interface IDirectory {
val metaInfo: IMetaInfo
val elementsCount: Int
}

View File

@@ -0,0 +1,5 @@
package com.github.nullptroma.wallenc.domain.models
interface IFile {
val metaInfo: IMetaInfo
}

View File

@@ -0,0 +1,14 @@
package com.github.nullptroma.wallenc.domain.models
import java.net.URI
import java.time.LocalDateTime
interface IMetaInfo {
val name: String
val size: Int
val isDeleted: Boolean
val isHidden: Boolean
val lastModified: LocalDateTime
val path: URI
}

View File

@@ -0,0 +1,16 @@
package com.github.nullptroma.wallenc.domain.storage
import kotlinx.coroutines.flow.StateFlow
interface IStorage {
val size: StateFlow<Int>
val numberOfFiles: StateFlow<Int>
val uuid: String
val name: StateFlow<String>
val totalSpace: StateFlow<Int?>
val availableSpace: StateFlow<Int?>
val isAvailable: StateFlow<Boolean>
val accessor: IStorageAccessor
suspend fun rename(newName: String)
}

View File

@@ -0,0 +1,32 @@
package com.github.nullptroma.wallenc.domain.storage
import com.github.nullptroma.wallenc.domain.models.IDirectory
import com.github.nullptroma.wallenc.domain.models.IFile
import com.github.nullptroma.wallenc.domain.utils.DataPackage
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import java.net.URI
interface IStorageAccessor {
val isAvailable: StateFlow<Boolean>
val filesUpdates: SharedFlow<IFile>
val dirsUpdates: SharedFlow<IDirectory>
suspend fun getAllFiles(): List<IFile>
suspend fun getFiles(path: URI): List<IFile>
fun getFilesStream(path: URI): Flow<DataPackage<IFile>>
suspend fun getAllDirs(): List<IDirectory>
suspend fun getDirs(path: URI): List<IDirectory>
fun getDirsStream(path: URI): Flow<DataPackage<IDirectory>>
suspend fun touchFile(path: URI)
suspend fun touchDir(path: URI)
suspend fun delete(path: URI)
suspend fun getFileInfo(path: URI)
suspend fun getDirInfo(path: URI)
suspend fun openWrite(path: URI)
suspend fun openRead(path: URI)
suspend fun moveToTrash(path: URI)
}

View File

@@ -0,0 +1,7 @@
package com.github.nullptroma.wallenc.domain.usecases
import com.github.nullptroma.wallenc.domain.models.IMetaInfo
class TestUseCase (val meta: IMetaInfo, val id: Int) {
}

View File

@@ -0,0 +1,8 @@
package com.github.nullptroma.wallenc.domain.utils
open class DataPackage<T>(
val data: T,
val hasNext: Boolean? = false,
val isLoading: Boolean? = false,
val isError: Boolean? = false
)

View File

@@ -0,0 +1,7 @@
package com.github.nullptroma.wallenc.domain.utils
class DataPage<T>(
list: List<T>,
val pageLength: Int,
val pageNumber: Int
) : DataPackage<List<T>>(list)