Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public val LocalAppUiEnvironment: ProvidableCompositionLocal<AppUiEnvironment> =

public class AppUiEnvironment(
public val screenCloser: () -> Unit,
public val canNavigateBack: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.bartwell.kick.core.presentation

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable

@Composable
public fun BackOrCloseButton(
onBack: () -> Unit,
) {
val uiEnvironment = LocalAppUiEnvironment.current
val canGoBack = uiEnvironment.canNavigateBack
val action = if (canGoBack) onBack else uiEnvironment.screenCloser
val icon = if (canGoBack) Icons.AutoMirrored.Outlined.ArrowBack else Icons.Outlined.Close
val description = if (canGoBack) "Back" else "Close"

IconButton(onClick = action) {
Icon(imageVector = icon, contentDescription = description)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package ru.bartwell.kick.runtime.core.component
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.extensions.compose.stack.Children
import com.arkivanov.decompose.extensions.compose.stack.animation.slide
import com.arkivanov.decompose.extensions.compose.stack.animation.stackAnimation
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.component.RootComponent
import ru.bartwell.kick.core.presentation.AppUiEnvironment
import ru.bartwell.kick.core.presentation.LocalAppUiEnvironment
Expand All @@ -21,7 +23,11 @@ internal fun RootContent(
component: RootComponent,
modifier: Modifier = Modifier,
) {
val environment = AppUiEnvironment(screenCloser = screenCloser())
val stack by component.stack.subscribeAsState()
val environment = AppUiEnvironment(
screenCloser = screenCloser(),
canNavigateBack = stack.backStack.isNotEmpty(),
)
CompositionLocalProvider(LocalAppUiEnvironment provides environment) {
Children(
stack = component.stack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.ArrowUpward
import androidx.compose.material.icons.filled.Description
import androidx.compose.material.icons.filled.Folder
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.AssistChip
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
Expand All @@ -43,6 +41,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.data.platformContext
import ru.bartwell.kick.core.presentation.BackOrCloseButton
import ru.bartwell.kick.core.presentation.ErrorAlert
import ru.bartwell.kick.module.explorer.feature.list.util.FileSystemUtils
import ru.bartwell.kick.module.explorer.feature.list.util.KnownFolder
Expand Down Expand Up @@ -70,9 +69,7 @@ internal fun FileExplorerContent(
Text(text = state.folderName, maxLines = 1)
},
navigationIcon = {
IconButton(onClick = { component.onBackClick() }) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackClick)
}
)
KnownFoldersRow(component = component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.outlined.ContentCopy
import androidx.compose.material.icons.outlined.History
Expand Down Expand Up @@ -38,6 +37,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.data.platformContext
import ru.bartwell.kick.core.presentation.BackOrCloseButton

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -63,9 +63,7 @@ internal fun FirebaseCloudMessagingContent(
TopAppBar(
title = { Text("Firebase Cloud Messaging") },
navigationIcon = {
IconButton(onClick = component::onBackPressed, modifier = Modifier.testTag("back")) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackPressed)
},
actions = {
IconButton(onClick = { isMenuExpanded = true }, modifier = Modifier.testTag("menu_button")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.ClearAll
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.filled.FilterList
Expand All @@ -33,6 +32,7 @@ import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.data.Platform
import ru.bartwell.kick.core.data.platformContext
import ru.bartwell.kick.core.presentation.BackOrCloseButton
import ru.bartwell.kick.core.presentation.ErrorBox
import ru.bartwell.kick.core.util.PlatformUtils
import ru.bartwell.kick.module.logging.core.data.LogLevel
Expand All @@ -52,9 +52,7 @@ internal fun LogViewerContent(
TopAppBar(
title = { Text("Logging") },
navigationIcon = {
IconButton(onClick = component::onBackPressed) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackPressed)
},
actions = {
IconButton(onClick = component::onFilterClick, modifier = Modifier.testTag("filter_toggle")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
Expand All @@ -33,6 +29,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.data.platformContext
import ru.bartwell.kick.core.presentation.BackOrCloseButton
import ru.bartwell.kick.core.ui.ExposedDropdownMenuBox
import ru.bartwell.kick.module.overlay.core.store.OverlayStore

Expand Down Expand Up @@ -61,12 +58,7 @@ internal fun OverlayContent(
TopAppBar(
title = { Text("Overlay") },
navigationIcon = {
IconButton(onClick = { component.onBackClick() }) {
Icon(
imageVector = Icons.AutoMirrored.Outlined.ArrowBack,
contentDescription = "Back"
)
}
BackOrCloseButton(onBack = component::onBackClick)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.ClearAll
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.LockOpen
Expand All @@ -40,6 +39,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.presentation.BackOrCloseButton
import ru.bartwell.kick.core.presentation.ErrorBox
import ru.bartwell.kick.module.ktor3.core.persist.RequestEntity
import ru.bartwell.kick.module.ktor3.feature.detail.extension.formatDuration
Expand All @@ -60,9 +60,7 @@ internal fun RequestsListContent(
TopAppBar(
title = { Text("Network Requests") },
navigationIcon = {
IconButton(onClick = component::onBackPressed) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackPressed)
},
actions = {
IconButton(onClick = component::onSearchClick, modifier = Modifier.testTag("search_toggle")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.ExpandLess
import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material.icons.filled.Save
Expand Down Expand Up @@ -42,6 +41,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.presentation.BackOrCloseButton
import ru.bartwell.kick.core.ui.ExposedDropdownMenuBox
import ru.bartwell.kick.module.controlpanel.data.ActionType
import ru.bartwell.kick.module.controlpanel.data.ControlPanelItem
Expand All @@ -60,9 +60,7 @@ internal fun ControlPanelContent(
TopAppBar(
title = { Text("Control Panel") },
navigationIcon = {
IconButton(onClick = component::onBackPressed, modifier = Modifier.testTag("back")) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackPressed)
},
actions = {
IconButton(onClick = component::onSavePressed, modifier = Modifier.testTag("save")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
Expand All @@ -23,6 +19,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.presentation.BackOrCloseButton

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -36,9 +33,7 @@ public fun SettingsListContent(
TopAppBar(
title = { Text("Storages") },
navigationIcon = {
IconButton(onClick = component::onBackPressed, modifier = Modifier.testTag("back")) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackPressed)
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.EditNote
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand All @@ -22,6 +21,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.presentation.BackOrCloseButton
import ru.bartwell.kick.core.presentation.ErrorBox

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -36,9 +36,7 @@ internal fun TablesListContent(
TopAppBar(
title = { Text("Tables") },
navigationIcon = {
IconButton(onClick = component::onBackPressed) {
Icon(imageVector = Icons.AutoMirrored.Outlined.ArrowBack, contentDescription = "Back")
}
BackOrCloseButton(onBack = component::onBackPressed)
},
actions = {
IconButton(onClick = component::onQueryClick) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ package ru.bartwell.kick.module.layout.feature.settings.presentation

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
Expand All @@ -23,6 +19,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import ru.bartwell.kick.core.data.platformContext
import ru.bartwell.kick.core.presentation.BackOrCloseButton

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand All @@ -46,12 +43,7 @@ internal fun LayoutContent(
TopAppBar(
title = { Text("Layout") },
navigationIcon = {
IconButton(onClick = { component.onBackClick() }) {
Icon(
imageVector = Icons.AutoMirrored.Outlined.ArrowBack,
contentDescription = "Back"
)
}
BackOrCloseButton(onBack = component::onBackClick)
}
)
}
Expand Down