|
|
|
@ -1,8 +1,6 @@
|
|
|
|
|
package example.imageviewer.view |
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.Image |
|
|
|
|
import androidx.compose.foundation.background |
|
|
|
|
import androidx.compose.foundation.horizontalScroll |
|
|
|
|
import androidx.compose.foundation.* |
|
|
|
|
import androidx.compose.foundation.layout.Box |
|
|
|
|
import androidx.compose.foundation.layout.Column |
|
|
|
|
import androidx.compose.foundation.layout.Row |
|
|
|
@ -12,22 +10,20 @@ import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.layout.height |
|
|
|
|
import androidx.compose.foundation.layout.size |
|
|
|
|
import androidx.compose.foundation.layout.width |
|
|
|
|
import androidx.compose.foundation.rememberScrollState |
|
|
|
|
import androidx.compose.foundation.ScrollState |
|
|
|
|
import androidx.compose.foundation.interaction.MutableInteractionSource |
|
|
|
|
import androidx.compose.foundation.interaction.collectIsHoveredAsState |
|
|
|
|
import androidx.compose.foundation.shape.CircleShape |
|
|
|
|
import androidx.compose.material.CircularProgressIndicator |
|
|
|
|
import androidx.compose.material.MaterialTheme |
|
|
|
|
import androidx.compose.material.Surface |
|
|
|
|
import androidx.compose.material.Text |
|
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
|
import androidx.compose.runtime.mutableStateOf |
|
|
|
|
import androidx.compose.runtime.getValue |
|
|
|
|
import androidx.compose.runtime.remember |
|
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
import androidx.compose.ui.draw.clip |
|
|
|
|
import androidx.compose.ui.ExperimentalComposeUiApi |
|
|
|
|
import androidx.compose.ui.graphics.Color |
|
|
|
|
import androidx.compose.ui.graphics.ImageBitmap |
|
|
|
|
import androidx.compose.ui.graphics.painter.Painter |
|
|
|
|
import androidx.compose.ui.input.key.Key |
|
|
|
|
import androidx.compose.ui.input.key.key |
|
|
|
@ -36,14 +32,12 @@ import androidx.compose.ui.input.key.KeyEventType
|
|
|
|
|
import androidx.compose.ui.input.key.onPreviewKeyEvent |
|
|
|
|
import androidx.compose.ui.layout.ContentScale |
|
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
|
import androidx.compose.ui.window.WindowSize |
|
|
|
|
import example.imageviewer.core.FilterType |
|
|
|
|
import example.imageviewer.model.AppState |
|
|
|
|
import example.imageviewer.model.ContentState |
|
|
|
|
import example.imageviewer.model.ScreenType |
|
|
|
|
import example.imageviewer.ResString |
|
|
|
|
import example.imageviewer.style.DarkGray |
|
|
|
|
import example.imageviewer.style.DarkGreen |
|
|
|
|
import example.imageviewer.style.Foreground |
|
|
|
|
import example.imageviewer.style.MiniatureColor |
|
|
|
|
import example.imageviewer.style.TranslucentBlack |
|
|
|
@ -74,7 +68,8 @@ fun ToolBar(
|
|
|
|
|
text: String, |
|
|
|
|
content: ContentState |
|
|
|
|
) { |
|
|
|
|
val backButtonHover = remember { mutableStateOf(false) } |
|
|
|
|
val backButtonInteractionSource = remember { MutableInteractionSource() } |
|
|
|
|
val backButtonHover by backButtonInteractionSource.collectIsHoveredAsState() |
|
|
|
|
Surface( |
|
|
|
|
color = MiniatureColor, |
|
|
|
|
modifier = Modifier.height(44.dp) |
|
|
|
@ -87,16 +82,9 @@ fun ToolBar(
|
|
|
|
|
) { |
|
|
|
|
Tooltip(ResString.back) { |
|
|
|
|
Clickable( |
|
|
|
|
modifier = Modifier.hover( |
|
|
|
|
onEnter = { |
|
|
|
|
backButtonHover.value = true |
|
|
|
|
false |
|
|
|
|
}, |
|
|
|
|
onExit = { |
|
|
|
|
backButtonHover.value = false |
|
|
|
|
false |
|
|
|
|
}) |
|
|
|
|
.background(color = if (backButtonHover.value) TranslucentBlack else Transparent), |
|
|
|
|
modifier = Modifier |
|
|
|
|
.hoverable(backButtonInteractionSource) |
|
|
|
|
.background(color = if (backButtonHover) TranslucentBlack else Transparent), |
|
|
|
|
onClick = { |
|
|
|
|
if (content.isContentReady()) { |
|
|
|
|
content.restoreMainImage() |
|
|
|
@ -145,33 +133,27 @@ fun FilterButton(
|
|
|
|
|
type: FilterType, |
|
|
|
|
modifier: Modifier = Modifier.size(38.dp) |
|
|
|
|
) { |
|
|
|
|
val filterButtonHover = remember { mutableStateOf(false) } |
|
|
|
|
Box( |
|
|
|
|
modifier = Modifier.background(color = Transparent).clip(CircleShape) |
|
|
|
|
) { |
|
|
|
|
Tooltip("$type") { |
|
|
|
|
Clickable( |
|
|
|
|
modifier = Modifier.hover( |
|
|
|
|
onEnter = { |
|
|
|
|
filterButtonHover.value = true |
|
|
|
|
false |
|
|
|
|
}, |
|
|
|
|
onExit = { |
|
|
|
|
filterButtonHover.value = false |
|
|
|
|
false |
|
|
|
|
}) |
|
|
|
|
.background(color = if (filterButtonHover.value) TranslucentBlack else Transparent), |
|
|
|
|
onClick = { content.toggleFilter(type)} |
|
|
|
|
) { |
|
|
|
|
Image( |
|
|
|
|
getFilterImage(type = type, content = content), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
val interactionSource = remember { MutableInteractionSource() } |
|
|
|
|
val filterButtonHover by interactionSource.collectIsHoveredAsState() |
|
|
|
|
Box( |
|
|
|
|
modifier = Modifier.background(color = Transparent).clip(CircleShape) |
|
|
|
|
) { |
|
|
|
|
Tooltip("$type") { |
|
|
|
|
Clickable( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.hoverable(interactionSource) |
|
|
|
|
.background(color = if (filterButtonHover) TranslucentBlack else Transparent), |
|
|
|
|
onClick = { content.toggleFilter(type)} |
|
|
|
|
) { |
|
|
|
|
Image( |
|
|
|
|
getFilterImage(type = type, content = content), |
|
|
|
|
contentDescription = null, |
|
|
|
|
modifier |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Spacer(Modifier.width(20.dp)) |
|
|
|
|
} |
|
|
|
|
Spacer(Modifier.width(20.dp)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|