Коммит 46dd101d создал по автору Radch-enko's avatar Radch-enko
Просмотр файлов

Refactor: remove unused theme files and add new settings management

- Deleted redundant theme files (`Color.kt`, `Theme.kt`, `Theme.android.kt`).
- Introduced `SettingsComponent` and related UI elements (`GridRooms`, `CardRoom`) for room management.
- Added vector drawable resources for icons: `arrow_to_right`, `tv`, `allert`, and `power_socket`.
- Enhanced Gradle build scripts with new dependencies (`settings`, `slf4j-android`) and packaging configurations.
- Integrated new API key management via `BuildKonfig`.
- Updated `MainComponent` to handle empty settings gracefully and improved modal window navigation.
владелец 80853b0a
......@@ -2,6 +2,7 @@ import band.effective.office.backend.libs
plugins {
id("band.effective.office.client.kmp.library")
id("org.jetbrains.kotlin.plugin.serialization")
}
kotlin {
......
......@@ -42,4 +42,4 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
\ Нет новой строки в конце файла
}
......@@ -40,6 +40,7 @@ kotlin {
implementation(libs.napier)
implementation(libs.settings)
implementation(project(":clients:tablet:core:ui"))
implementation(project(":clients:tablet:feature:main"))
......@@ -50,11 +51,11 @@ kotlin {
implementation(project(":clients:tablet:core:data"))
implementation(project(":clients:tablet:core:domain"))
}
androidMain.dependencies {
implementation(compose.uiTooling)
implementation(libs.androidx.activityCompose)
implementation(libs.koin.android)
implementation("org.slf4j:slf4j-android:1.7.36")
}
}
}
......@@ -82,10 +83,17 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}
}
packaging {
resources {
excludes += "/META-INF/INDEX.LIST"
}
}
}
val apiUrlRelease: String = gradleLocalProperties(rootDir, providers).getProperty("api.url.release")
val apiUrlDebug: String = gradleLocalProperties(rootDir, providers).getProperty("api.url.debug")
val apiKey: String = gradleLocalProperties(rootDir, providers).getProperty("apiKey")
buildkonfig {
packageName = "band.effective.office.tablet"
......@@ -102,5 +110,11 @@ buildkonfig {
"API_URL_DEBUG",
apiUrlDebug,
)
buildConfigField(
com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING,
"API_KEY",
apiKey,
)
}
}
......@@ -11,9 +11,7 @@ class AppActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
val root = RootComponent(componentContext = defaultComponentContext())
setContent { App(root) }
}
}
package band.effective.office.tablet
import android.app.Application
import band.effective.office.tablet.core.domain.model.SettingsManager
import band.effective.office.tablet.di.KoinInitializer
import com.russhwolf.settings.SharedPreferencesSettings
class App : Application() {
......@@ -9,5 +11,13 @@ class App : Application() {
super.onCreate()
LoggerInitializer().init()
KoinInitializer().init()
SettingsManager.init(
SharedPreferencesSettings(
this.getSharedPreferences(
"settings",
MODE_PRIVATE
)
)
)
}
}
\ Нет новой строки в конце файла
package band.effective.office.tablet.theme
import android.app.Activity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowInsetsControllerCompat
@Composable
internal actual fun SystemAppearance(isDark: Boolean) {
val view = LocalView.current
LaunchedEffect(isDark) {
val window = (view.context as Activity).window
WindowInsetsControllerCompat(window, window.decorView).apply {
isAppearanceLightStatusBars = isDark
isAppearanceLightNavigationBars = isDark
}
}
}
\ Нет новой строки в конце файла
package band.effective.office.tablet
import androidx.compose.runtime.Composable
import band.effective.office.tablet.theme.AppTheme
import band.effective.office.tablet.core.ui.theme.AppTheme
import band.effective.office.tablet.root.Root
import band.effective.office.tablet.root.RootComponent
import com.arkivanov.decompose.ComponentContext
@Composable
fun App(rootComponent: RootComponent) {
......
......@@ -9,4 +9,7 @@ val appModule = module {
single(qualifier = named("ApiUrl")) {
if (isDebug) BuildKonfig.API_URL_DEBUG else BuildKonfig.API_URL_RELEASE
}
single<String>(qualifier = named("ApiKey")) {
BuildKonfig.API_KEY
}
}
\ Нет новой строки в конце файла
......@@ -7,6 +7,7 @@ import com.arkivanov.decompose.router.stack.ChildStack
import com.arkivanov.decompose.router.stack.StackNavigation
import com.arkivanov.decompose.router.stack.childStack
import com.arkivanov.decompose.router.stack.push
import com.arkivanov.decompose.router.stack.replaceAll
import com.arkivanov.decompose.value.Value
import kotlinx.serialization.Serializable
......@@ -38,7 +39,15 @@ class RootComponent(
}
is Config.Settings -> {
Child.SettingsChild(SettingsComponent(componentContext = componentContext))
Child.SettingsChild(SettingsComponent(
componentContext = componentContext,
onExitApp = {
// TODO
},
onMainScreen = {
navigation.replaceAll(Config.Main)
},
))
}
}
......
package band.effective.office.tablet.theme
import androidx.compose.ui.graphics.Color
//generated by https://materialkolor.com
//Color palette was taken here: https://coolors.co/palette/e63946-f1faee-a8dadc-457b9d-1d3557
internal val Seed = Color(0xFF1D3557)
internal val PrimaryLight = Color(0xFF485F84)
internal val OnPrimaryLight = Color(0xFFFFFFFF)
internal val PrimaryContainerLight = Color(0xFFD5E3FF)
internal val OnPrimaryContainerLight = Color(0xFF30476A)
internal val SecondaryLight = Color(0xFF2B6485)
internal val OnSecondaryLight = Color(0xFFFFFFFF)
internal val SecondaryContainerLight = Color(0xFFC7E7FF)
internal val OnSecondaryContainerLight = Color(0xFF064C6B)
internal val TertiaryLight = Color(0xFF356668)
internal val OnTertiaryLight = Color(0xFFFFFFFF)
internal val TertiaryContainerLight = Color(0xFFB9ECEE)
internal val OnTertiaryContainerLight = Color(0xFF1A4E50)
internal val ErrorLight = Color(0xFFBB152C)
internal val OnErrorLight = Color(0xFFFFFFFF)
internal val ErrorContainerLight = Color(0xFFFFDAD8)
internal val OnErrorContainerLight = Color(0xFF410007)
internal val BackgroundLight = Color(0xFFF9F9F9)
internal val OnBackgroundLight = Color(0xFF1A1C1C)
internal val SurfaceLight = Color(0xFFF9F9F9)
internal val OnSurfaceLight = Color(0xFF1A1C1C)
internal val SurfaceVariantLight = Color(0xFFDCE5D9)
internal val OnSurfaceVariantLight = Color(0xFF404941)
internal val OutlineLight = Color(0xFF717970)
internal val OutlineVariantLight = Color(0xFFC0C9BE)
internal val ScrimLight = Color(0xFF000000)
internal val InverseSurfaceLight = Color(0xFF2F3131)
internal val InverseOnSurfaceLight = Color(0xFFF0F1F1)
internal val InversePrimaryLight = Color(0xFFB0C7F1)
internal val SurfaceDimLight = Color(0xFFDADADA)
internal val SurfaceBrightLight = Color(0xFFF9F9F9)
internal val SurfaceContainerLowestLight = Color(0xFFFFFFFF)
internal val SurfaceContainerLowLight = Color(0xFFF3F3F4)
internal val SurfaceContainerLight = Color(0xFFEEEEEE)
internal val SurfaceContainerHighLight = Color(0xFFE8E8E8)
internal val SurfaceContainerHighestLight = Color(0xFFE2E2E2)
internal val PrimaryDark = Color(0xFFB0C7F1)
internal val OnPrimaryDark = Color(0xFF183153)
internal val PrimaryContainerDark = Color(0xFF30476A)
internal val OnPrimaryContainerDark = Color(0xFFD5E3FF)
internal val SecondaryDark = Color(0xFF98CDF2)
internal val OnSecondaryDark = Color(0xFF00344C)
internal val SecondaryContainerDark = Color(0xFF064C6B)
internal val OnSecondaryContainerDark = Color(0xFFC7E7FF)
internal val TertiaryDark = Color(0xFF9ECFD1)
internal val OnTertiaryDark = Color(0xFF003739)
internal val TertiaryContainerDark = Color(0xFF1A4E50)
internal val OnTertiaryContainerDark = Color(0xFFB9ECEE)
internal val ErrorDark = Color(0xFFFFB3B1)
internal val OnErrorDark = Color(0xFF680011)
internal val ErrorContainerDark = Color(0xFF92001C)
internal val OnErrorContainerDark = Color(0xFFFFDAD8)
internal val BackgroundDark = Color(0xFF121414)
internal val OnBackgroundDark = Color(0xFFE2E2E2)
internal val SurfaceDark = Color(0xFF121414)
internal val OnSurfaceDark = Color(0xFFE2E2E2)
internal val SurfaceVariantDark = Color(0xFF404941)
internal val OnSurfaceVariantDark = Color(0xFFC0C9BE)
internal val OutlineDark = Color(0xFF8A9389)
internal val OutlineVariantDark = Color(0xFF404941)
internal val ScrimDark = Color(0xFF000000)
internal val InverseSurfaceDark = Color(0xFFE2E2E2)
internal val InverseOnSurfaceDark = Color(0xFF2F3131)
internal val InversePrimaryDark = Color(0xFF485F84)
internal val SurfaceDimDark = Color(0xFF121414)
internal val SurfaceBrightDark = Color(0xFF37393A)
internal val SurfaceContainerLowestDark = Color(0xFF0C0F0F)
internal val SurfaceContainerLowDark = Color(0xFF1A1C1C)
internal val SurfaceContainerDark = Color(0xFF1E2020)
internal val SurfaceContainerHighDark = Color(0xFF282A2B)
internal val SurfaceContainerHighestDark = Color(0xFF333535)
package band.effective.office.tablet.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.*
private val LightColorScheme = lightColorScheme(
primary = PrimaryLight,
onPrimary = OnPrimaryLight,
primaryContainer = PrimaryContainerLight,
onPrimaryContainer = OnPrimaryContainerLight,
secondary = SecondaryLight,
onSecondary = OnSecondaryLight,
secondaryContainer = SecondaryContainerLight,
onSecondaryContainer = OnSecondaryContainerLight,
tertiary = TertiaryLight,
onTertiary = OnTertiaryLight,
tertiaryContainer = TertiaryContainerLight,
onTertiaryContainer = OnTertiaryContainerLight,
error = ErrorLight,
onError = OnErrorLight,
errorContainer = ErrorContainerLight,
onErrorContainer = OnErrorContainerLight,
background = BackgroundLight,
onBackground = OnBackgroundLight,
surface = SurfaceLight,
onSurface = OnSurfaceLight,
surfaceVariant = SurfaceVariantLight,
onSurfaceVariant = OnSurfaceVariantLight,
outline = OutlineLight,
outlineVariant = OutlineVariantLight,
scrim = ScrimLight,
inverseSurface = InverseSurfaceLight,
inverseOnSurface = InverseOnSurfaceLight,
inversePrimary = InversePrimaryLight,
surfaceDim = SurfaceDimLight,
surfaceBright = SurfaceBrightLight,
surfaceContainerLowest = SurfaceContainerLowestLight,
surfaceContainerLow = SurfaceContainerLowLight,
surfaceContainer = SurfaceContainerLight,
surfaceContainerHigh = SurfaceContainerHighLight,
surfaceContainerHighest = SurfaceContainerHighestLight,
)
private val DarkColorScheme = darkColorScheme(
primary = PrimaryDark,
onPrimary = OnPrimaryDark,
primaryContainer = PrimaryContainerDark,
onPrimaryContainer = OnPrimaryContainerDark,
secondary = SecondaryDark,
onSecondary = OnSecondaryDark,
secondaryContainer = SecondaryContainerDark,
onSecondaryContainer = OnSecondaryContainerDark,
tertiary = TertiaryDark,
onTertiary = OnTertiaryDark,
tertiaryContainer = TertiaryContainerDark,
onTertiaryContainer = OnTertiaryContainerDark,
error = ErrorDark,
onError = OnErrorDark,
errorContainer = ErrorContainerDark,
onErrorContainer = OnErrorContainerDark,
background = BackgroundDark,
onBackground = OnBackgroundDark,
surface = SurfaceDark,
onSurface = OnSurfaceDark,
surfaceVariant = SurfaceVariantDark,
onSurfaceVariant = OnSurfaceVariantDark,
outline = OutlineDark,
outlineVariant = OutlineVariantDark,
scrim = ScrimDark,
inverseSurface = InverseSurfaceDark,
inverseOnSurface = InverseOnSurfaceDark,
inversePrimary = InversePrimaryDark,
surfaceDim = SurfaceDimDark,
surfaceBright = SurfaceBrightDark,
surfaceContainerLowest = SurfaceContainerLowestDark,
surfaceContainerLow = SurfaceContainerLowDark,
surfaceContainer = SurfaceContainerDark,
surfaceContainerHigh = SurfaceContainerHighDark,
surfaceContainerHighest = SurfaceContainerHighestDark,
)
internal val LocalThemeIsDark = compositionLocalOf { mutableStateOf(true) }
@Composable
internal fun AppTheme(
content: @Composable () -> Unit
) {
val systemIsDark = isSystemInDarkTheme()
val isDarkState = remember(systemIsDark) { mutableStateOf(systemIsDark) }
CompositionLocalProvider(
LocalThemeIsDark provides isDarkState
) {
val isDark by isDarkState
SystemAppearance(!isDark)
MaterialTheme(
colorScheme = if (isDark) DarkColorScheme else LightColorScheme,
content = { Surface(content = content) }
)
}
}
@Composable
internal expect fun SystemAppearance(isDark: Boolean)
......@@ -23,7 +23,6 @@ import kotlinx.serialization.json.Json
* Implementation of the BookingApi interface
*/
class BookingApiImpl(
private val baseUrl: String,
private val collector: Collector<String> = Collector("")
) : BookingApi {
......@@ -32,7 +31,7 @@ class BookingApiImpl(
override suspend fun getBooking(id: String): Either<ErrorResponse, BookingResponseDTO> {
return when (val result = HttpRequestUtil.request<BookingResponseDTO>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -51,7 +50,7 @@ class BookingApiImpl(
): Either<ErrorResponse, List<BookingResponseDTO>> {
return when (val result = HttpRequestUtil.request<List<BookingResponseDTO>>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -72,7 +71,7 @@ class BookingApiImpl(
): Either<ErrorResponse, List<BookingResponseDTO>> {
return when (val result = HttpRequestUtil.request<List<BookingResponseDTO>>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -93,7 +92,7 @@ class BookingApiImpl(
override suspend fun createBooking(bookingInfo: BookingRequestDTO): Either<ErrorResponse, BookingResponseDTO> {
return when (val result = HttpRequestUtil.request<BookingResponseDTO>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.POST
) {
contentType(ContentType.Application.Json)
......@@ -110,7 +109,7 @@ class BookingApiImpl(
): Either<ErrorResponse, BookingResponseDTO> {
return when (val result = HttpRequestUtil.request<BookingResponseDTO>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.PUT
) {
url {
......@@ -128,7 +127,7 @@ class BookingApiImpl(
override suspend fun deleteBooking(bookingId: String): Either<ErrorResponse, SuccessResponse> {
return when (val result = HttpRequestUtil.request<SuccessResponse>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.DELETE
) {
url {
......@@ -155,7 +154,7 @@ class BookingApiImpl(
): Either<ErrorResponse, List<BookingResponseDTO>> {
return when (val result = HttpRequestUtil.request<List<BookingResponseDTO>>(
client = client,
url = "$baseUrl/api/v1/bookings",
url = "/api/v1/bookings",
method = HttpRequestUtil.Method.GET
) {
url {
......
......@@ -20,7 +20,6 @@ import kotlinx.coroutines.flow.map
* Implementation of the UserApi interface
*/
class UserApiImpl(
private val baseUrl: String,
private val collector: Collector<String> = Collector("")
) : UserApi {
......@@ -29,7 +28,7 @@ class UserApiImpl(
override suspend fun getUser(id: String): Either<ErrorResponse, UserDTO> {
return when (val result = HttpRequestUtil.request<UserDTO>(
client = client,
url = "$baseUrl/api/v1/users",
url = "/api/v1/users",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -44,7 +43,7 @@ class UserApiImpl(
override suspend fun getUsers(tag: String): Either<ErrorResponse, List<UserDTO>> {
return when (val result = HttpRequestUtil.request<List<UserDTO>>(
client = client,
url = "$baseUrl/api/v1/users",
url = "/api/v1/users",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -59,7 +58,7 @@ class UserApiImpl(
override suspend fun updateUser(user: UserDTO): Either<ErrorResponse, UserDTO> {
return when (val result = HttpRequestUtil.request<UserDTO>(
client = client,
url = "$baseUrl/api/v1/users",
url = "/api/v1/users",
method = HttpRequestUtil.Method.PUT
) {
contentType(ContentType.Application.Json)
......@@ -76,7 +75,7 @@ class UserApiImpl(
override suspend fun getUserByEmail(email: String): Either<ErrorResponse, UserDTO> {
return when (val result = HttpRequestUtil.request<UserDTO>(
client = client,
url = "$baseUrl/api/v1/users",
url = "/api/v1/users",
method = HttpRequestUtil.Method.GET
) {
url {
......
......@@ -17,7 +17,6 @@ import kotlinx.coroutines.flow.map
* Implementation of the WorkspaceApi interface
*/
class WorkspaceApiImpl(
private val baseUrl: String,
private val collector: Collector<String> = Collector("")
) : WorkspaceApi {
......@@ -43,7 +42,7 @@ class WorkspaceApiImpl(
): Either<ErrorResponse, List<WorkspaceDTO>> {
return when (val result = HttpRequestUtil.request<List<WorkspaceDTO>>(
client = client,
url = "$baseUrl/api/v1/workspaces",
url = "/api/v1/workspaces",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -69,7 +68,7 @@ class WorkspaceApiImpl(
): Either<ErrorResponse, List<WorkspaceDTO>> {
return when (val result = HttpRequestUtil.request<List<WorkspaceDTO>>(
client = client,
url = "$baseUrl/api/v1/workspaces",
url = "/api/v1/workspaces",
method = HttpRequestUtil.Method.GET
) {
url {
......@@ -91,7 +90,7 @@ class WorkspaceApiImpl(
override suspend fun getZones(): Either<ErrorResponse, List<WorkspaceZoneDTO>> {
return when (val result = HttpRequestUtil.request<List<WorkspaceZoneDTO>>(
client = client,
url = "$baseUrl/api/v1/workspaces/zones",
url = "/api/v1/workspaces/zones",
method = HttpRequestUtil.Method.GET
)) {
is HttpRequestUtil.Result.Success -> Either.Success(result.data)
......
......@@ -13,9 +13,9 @@ import band.effective.office.tablet.core.data.repository.LocalEventStoreReposito
import band.effective.office.tablet.core.data.repository.NetworkEventRepository
import band.effective.office.tablet.core.data.repository.OrganizerRepositoryImpl
import band.effective.office.tablet.core.domain.repository.BookingRepository
import band.effective.office.tablet.core.domain.repository.EventManagerRepository
import band.effective.office.tablet.core.domain.repository.LocalBookingRepository
import band.effective.office.tablet.core.domain.repository.OrganizerRepository
import org.koin.core.qualifier.named
import org.koin.dsl.module
/**
......@@ -29,17 +29,11 @@ val dataModule = module {
factory { Collector("") }
// API implementations
single<BookingApi> {
BookingApiImpl(baseUrl = get(named("ApiUrl")))
}
single<BookingApi> { BookingApiImpl() }
single<UserApi> {
UserApiImpl(baseUrl = get(named("ApiUrl")))
}
single<UserApi> { UserApiImpl() }
single<WorkspaceApi> {
WorkspaceApiImpl(baseUrl = get(named("ApiUrl")))
}
single<WorkspaceApi> { WorkspaceApiImpl() }
// Repository implementations
single<OrganizerRepository> {
......@@ -54,7 +48,7 @@ val dataModule = module {
LocalEventStoreRepository()
}
single {
single<EventManagerRepository> {
EventManager(networkEventRepository = get(), localEventStoreRepository = get())
}
}
......@@ -2,18 +2,27 @@ package band.effective.office.tablet.core.data.network
import io.github.aakira.napier.Napier
import io.ktor.client.HttpClient
import io.ktor.client.plugins.DefaultRequest
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.Logging
import io.ktor.http.HttpHeaders
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.koin.core.qualifier.named
/**
* HTTP client provider that creates a configured HttpClient instance
*/
object HttpClientProvider {
object HttpClientProvider : KoinComponent {
private val apiKey by inject<String>(named("ApiKey"))
private val apiUrl by inject<String>(named("ApiUrl"))
/**
* Creates a configured HttpClient instance
* @return HttpClient instance with timeout, content negotiation, and logging configurations
......@@ -31,10 +40,19 @@ object HttpClientProvider {
prettyPrint = true
})
}
install(DefaultRequest) {
headers.append(HttpHeaders.Authorization, "Bearer $apiKey")
url(apiUrl)
}
install(Logging) {
logger = object : Logger {
override fun log(message: String) {
Napier.d(message)
Napier.log(
priority = io.github.aakira.napier.LogLevel.WARNING,
tag = "HttpClient",
null,
message,
)
}
}
level = LogLevel.ALL
......
......@@ -7,6 +7,7 @@ import band.effective.office.tablet.core.domain.map
import band.effective.office.tablet.core.domain.model.EventInfo
import band.effective.office.tablet.core.domain.model.RoomInfo
import band.effective.office.tablet.core.domain.repository.BookingRepository
import band.effective.office.tablet.core.domain.repository.EventManagerRepository
import band.effective.office.tablet.core.domain.repository.LocalBookingRepository
import band.effective.office.tablet.core.domain.unbox
import kotlinx.coroutines.CoroutineScope
......@@ -17,7 +18,7 @@ import kotlinx.coroutines.launch
class EventManager(
private val networkEventRepository: BookingRepository,
private val localEventStoreRepository: LocalBookingRepository
) {
) : EventManagerRepository {
private val scope = CoroutineScope(Dispatchers.IO)
init {
......@@ -28,9 +29,9 @@ class EventManager(
}
}
fun getEventsFlow() = localEventStoreRepository.subscribeOnUpdates()
override fun getEventsFlow() = localEventStoreRepository.subscribeOnUpdates()
suspend fun refreshData(): Either<ErrorWithData<List<RoomInfo>>, List<RoomInfo>> {
override suspend fun refreshData(): Either<ErrorWithData<List<RoomInfo>>, List<RoomInfo>> {
val save = localEventStoreRepository.getRoomsInfo().unbox(
errorHandler = { it.saveData }
)
......@@ -43,7 +44,7 @@ class EventManager(
return roomInfos
}
suspend fun createBooking(roomName: String, eventInfo: EventInfo): Either<ErrorResponse, EventInfo> {
override suspend fun createBooking(roomName: String, eventInfo: EventInfo): Either<ErrorResponse, EventInfo> {
val loadingEvent = eventInfo.copy(isLoading = true)
val roomInfo = getRoomByName(roomName)
?: return Either.Error(ErrorResponse(404, "Couldn't find a room with name $roomName"))
......@@ -63,7 +64,7 @@ class EventManager(
return response
}
suspend fun updateBooking(roomName: String, eventInfo: EventInfo): Either<ErrorResponse, EventInfo> {
override suspend fun updateBooking(roomName: String, eventInfo: EventInfo): Either<ErrorResponse, EventInfo> {
val loadingEvent = eventInfo.copy(isLoading = true)
val oldEvent = localEventStoreRepository.getBooking(eventInfo) as? Either.Success
?: return Either.Error(ErrorResponse(404, "Old event with id ${eventInfo.id} wasn't found"))
......@@ -85,7 +86,7 @@ class EventManager(
return response
}
suspend fun deleteBooking(roomName: String, eventInfo: EventInfo): Either<ErrorResponse, String> {
override suspend fun deleteBooking(roomName: String, eventInfo: EventInfo): Either<ErrorResponse, String> {
val loadingEvent = eventInfo.copy(isLoading = true)
val roomInfo = getRoomByName(roomName)
?: return Either.Error(ErrorResponse(404, "Couldn't find a room with name $roomName"))
......@@ -103,7 +104,7 @@ class EventManager(
return response
}
suspend fun getRoomsInfo(): Either<ErrorWithData<List<RoomInfo>>, List<RoomInfo>> {
override suspend fun getRoomsInfo(): Either<ErrorWithData<List<RoomInfo>>, List<RoomInfo>> {
val roomInfos = localEventStoreRepository.getRoomsInfo()
if (roomInfos as? Either.Error != null
&& roomInfos.error.saveData.isNullOrEmpty()
......@@ -113,18 +114,18 @@ class EventManager(
return roomInfos
}
suspend fun getCurrentRoomInfos(): Either<ErrorWithData<List<RoomInfo>>, List<RoomInfo>> {
override suspend fun getCurrentRoomInfos(): Either<ErrorWithData<List<RoomInfo>>, List<RoomInfo>> {
return localEventStoreRepository.getRoomsInfo()
}
suspend fun getRoomNames(): List<String> {
override suspend fun getRoomNames(): List<String> {
val rooms = getRoomsInfo().unbox(
errorHandler = { it.saveData }
)
return rooms?.map { it.name } ?: listOf(RoomInfo.defaultValue.name)
}
suspend fun getRoomByName(roomName: String): RoomInfo? {
override suspend fun getRoomByName(roomName: String): RoomInfo? {
val rooms = localEventStoreRepository.getRoomsInfo().unbox(
errorHandler = { it.saveData }
)
......
......@@ -4,7 +4,9 @@ import kotlin.time.Clock
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kotlinx.serialization.Serializable
@Serializable
data class EventInfo(
val startTime: LocalDateTime,
val finishTime: LocalDateTime,
......
package band.effective.office.tablet.core.domain.model
import kotlinx.serialization.Serializable
@Serializable
data class Organizer(val fullName: String, val id: String, val email: String?) {
companion object {
val default = Organizer(
......
package band.effective.office.tablet.core.domain.model
import kotlinx.serialization.Serializable
@Serializable
data class RoomInfo(
val name: String,
val capacity: Int,
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать