Skip to content

Commit

Permalink
[a]: added russian localization, fixed bug with animation on hide (on…
Browse files Browse the repository at this point in the history
… pick image)
  • Loading branch information
BadKiko committed May 13, 2024
1 parent c2382c1 commit 4684400
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 19 deletions.
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
accompanist-permissions = "0.33.1-alpha"
agp = "8.2.2"
coil-compose = "2.5.0"
github-landscapist-coil = "2.2.8"
landscapist-placeholder = "2.2.8"
landscapist = "2.3.3"
kotlin = "1.9.22"
core-ktx = "1.12.0"
junit = "4.13.2"
androidx-test-ext-junit = "1.1.5"
espresso-core = "3.5.1"
lifecycle-runtime-ktx = "2.7.0"
activity-compose = "1.8.2"
material3 = "1.2.0"
compose-bom = "2024.02.00"
ui="1.6.1"
material3 = "1.2.1"
compose-bom = "2024.05.00"
ui="1.6.7"

[libraries]
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist-permissions" }
Expand All @@ -25,8 +24,8 @@ espresso-core = { group = "androidx.test.espresso", name = "espresso-core", vers
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
skydoves-landscapist-coil = { module = "com.github.skydoves:landscapist-coil", version.ref = "github-landscapist-coil" }
skydoves-landscapist-placeholder = { module = "com.github.skydoves:landscapist-placeholder", version.ref = "landscapist-placeholder" }
skydoves-landscapist-coil = { module = "com.github.skydoves:landscapist-coil", version.ref = "landscapist" }
skydoves-landscapist-placeholder = { module = "com.github.skydoves:landscapist-placeholder", version.ref = "landscapist" }
ui = { group = "androidx.compose.ui", name = "ui", version.ref = "ui" }
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import com.kiko.kige.ui.states.GalleryUIState
fun rememberKigeGalleryState(): GalleryState {
val sheetState = rememberModalBottomSheetState()
val visibleState = remember { mutableStateOf(false) }
val galleryUIState = GalleryUIState.standardGalleryUiState()

return remember {
GalleryState(sheetState, GalleryUIState(), visibleState)
GalleryState(sheetState, galleryUIState, visibleState)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import com.kiko.kige.ui.states.PermissionUIState
fun rememberKigePermissionState(): PermissionState {
val sheetState = rememberModalBottomSheetState()
val visibleState = remember { mutableStateOf(false) }
val permissionUIState = PermissionUIState.standardPermissionUiState()

return remember {
PermissionState(sheetState, visibleState, PermissionUIState())
PermissionState(sheetState, visibleState, permissionUIState)
}
}
13 changes: 8 additions & 5 deletions kige/src/main/java/com/kiko/kige/ui/components/GallerySheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
Expand All @@ -42,6 +43,7 @@ import com.kiko.kige.data.utils.GalleryUtils
import com.skydoves.landscapist.ImageOptions
import com.skydoves.landscapist.coil.CoilImage
import com.skydoves.landscapist.components.rememberImageComponent
import com.skydoves.landscapist.placeholder.shimmer.Shimmer
import com.skydoves.landscapist.placeholder.shimmer.ShimmerPlugin
import com.skydoves.landscapist.rememberDrawablePainter
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -101,16 +103,17 @@ internal fun GallerySheet(
uri
)

delay(500) // Костыль надо придумать как возвращать hide при получении изображения

rememberGalleryState.hide(coroutineScope)
delay(200) // Костыль надо придумать как возвращать hide при получении изображения
rememberKigeState.hide(coroutineScope)
}
},
component = rememberImageComponent {
// shows a shimmering effect when loading an image.
+ShimmerPlugin(
baseColor = MaterialTheme.colorScheme.secondaryContainer,
highlightColor = MaterialTheme.colorScheme.secondary
Shimmer.Resonate(
baseColor = MaterialTheme.colorScheme.secondaryContainer,
highlightColor = MaterialTheme.colorScheme.secondary
),
)
},
imageModel = { photoUri }, // loading a network image or local resource using an URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ internal fun PermissionSheet(
) {
GalleryUtils.fetchGalleryImages(LocalContext.current)
Text(
rememberKigePermissionState.permissionUIState.title,
text = rememberKigePermissionState.permissionUIState.title,
fontWeight = rememberKigePermissionState.permissionUIState.fontWeight,
fontSize = rememberKigePermissionState.permissionUIState.fontSize,
textAlign = rememberKigePermissionState.permissionUIState.textAlign
)
Text(rememberKigePermissionState.permissionUIState.contentText)

Text(
modifier = Modifier.fillMaxWidth(),
textAlign = rememberKigePermissionState.permissionUIState.textAlign,
text = rememberKigePermissionState.permissionUIState.contentText
)
Button(modifier = Modifier.fillMaxWidth(), onClick = {
coroutineScope.launch { readExternalPermission.launchPermissionRequest() }
.invokeOnCompletion {
Expand Down
12 changes: 11 additions & 1 deletion kige/src/main/java/com/kiko/kige/ui/states/GalleryUIState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ package com.kiko.kige.ui.states

import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.kiko.kige.R

data class GalleryUIState(
val title: String = "Choose image",
Expand All @@ -20,4 +23,11 @@ data class GalleryUIState(
val imagesModifier: Modifier = Modifier
.size(120.dp)
.clip(RoundedCornerShape(16.dp))
)
) {
companion object {
@Composable
fun standardGalleryUiState(): GalleryUIState {
return GalleryUIState(title = stringResource(R.string.gallery_choose_image))
}
}
}
18 changes: 16 additions & 2 deletions kige/src/main/java/com/kiko/kige/ui/states/PermissionUIState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,34 @@ package com.kiko.kige.ui.states

import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.kiko.kige.R
import org.w3c.dom.Text

data class PermissionUIState(
val title: String = "Need permission",
val fontSize: TextUnit = 18.sp,
val fontWeight: FontWeight = FontWeight.SemiBold,
val textAlign: TextAlign = TextAlign.Center,
val contentText : String = "App need request permission for gallery use",
val contentText: String = "App need request permission for gallery use",
val buttonText: String = "Give"
)
) {
companion object {
@Composable
fun standardPermissionUiState(): PermissionUIState {
return PermissionUIState(
title = stringResource(R.string.gallery_title),
contentText = stringResource(R.string.gallery_content),
buttonText = stringResource(R.string.gallery_button)
)
}
}
}
7 changes: 7 additions & 0 deletions kige/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="gallery_choose_image">Выберите изображение</string>
<string name="gallery_content">Приложению необходимо разрешение на чтение галлереи</string>
<string name="gallery_title">Необходимо разрешение</string>
<string name="gallery_button">Выдать</string>
</resources>
7 changes: 7 additions & 0 deletions kige/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="gallery_choose_image">Choose image</string>
<string name="gallery_content">App need request permission for gallery use</string>
<string name="gallery_title">Need permission</string>
<string name="gallery_button">Give</string>
</resources>

0 comments on commit 4684400

Please sign in to comment.