-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from enteraname74/develop
v0.9.0
- Loading branch information
Showing
363 changed files
with
6,801 additions
and
4,919 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,7 @@ database.db | |
|
||
.kotlin | ||
|
||
desktopApp/*.log | ||
desktopApp/*.log | ||
|
||
features/filemanager/build | ||
features/playback/build |
7 changes: 7 additions & 0 deletions
7
core-ui/src/commonMain/kotlin/com/github/enteraname74/soulsearching/coreui/ext/FloatExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.enteraname74.soulsearching.coreui.ext | ||
|
||
fun Float.coerceForProgressBar(): Float = | ||
this.coerceIn( | ||
minimumValue = 0f, | ||
maximumValue = 1f, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../commonMain/kotlin/com/github/enteraname74/soulsearching/coreui/loading/LoadingManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.github.enteraname74.soulsearching.coreui.loading | ||
|
||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
|
||
class LoadingManager { | ||
private val _state: MutableStateFlow<Boolean> = MutableStateFlow(false) | ||
val state: StateFlow<Boolean> = _state.asStateFlow() | ||
|
||
fun startLoading() { | ||
_state.value = true | ||
} | ||
|
||
fun stopLoading() { | ||
_state.value = false | ||
} | ||
|
||
suspend fun withLoading( | ||
block: suspend () -> Unit | ||
) { | ||
startLoading() | ||
block() | ||
stopLoading() | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...commonMain/kotlin/com/github/enteraname74/soulsearching/coreui/loading/LoadingScaffold.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.github.enteraname74.soulsearching.coreui.loading | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import com.github.enteraname74.soulsearching.coreui.SoulCircularProgressIndicator | ||
import com.github.enteraname74.soulsearching.coreui.UiConstants | ||
import com.github.enteraname74.soulsearching.coreui.ext.disableFocus | ||
|
||
@Composable | ||
fun LoadingScaffold( | ||
loadingManager: LoadingManager, | ||
content: @Composable (isLoading: Boolean) -> Unit, | ||
) { | ||
val state: Boolean by loadingManager.state.collectAsState() | ||
|
||
Box( | ||
modifier = Modifier | ||
.fillMaxSize(), | ||
) { | ||
content(state) | ||
AnimatedVisibility( | ||
visible = state, | ||
enter = fadeIn( | ||
animationSpec = tween( | ||
durationMillis = UiConstants.AnimationDuration.short | ||
) | ||
), | ||
exit = fadeOut( | ||
animationSpec = tween( | ||
durationMillis = UiConstants.AnimationDuration.short | ||
) | ||
), | ||
) { | ||
LoadingView() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun LoadingView() { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(Color.Black.copy(alpha = 0.75f)) | ||
.disableFocus(), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
SoulCircularProgressIndicator() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...i/src/commonMain/kotlin/com/github/enteraname74/soulsearching/coreui/menu/SoulMenuBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.github.enteraname74.soulsearching.coreui.menu | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import com.github.enteraname74.soulsearching.coreui.UiConstants | ||
import com.github.enteraname74.soulsearching.coreui.theme.color.SoulSearchingColorTheme | ||
|
||
@Composable | ||
internal fun SoulMenuBody( | ||
title: String, | ||
text: String?, | ||
titleMaxLines: Int = 1, | ||
textMaxLines: Int = 2, | ||
titleColor: Color = SoulSearchingColorTheme.colorScheme.onPrimary, | ||
textColor: Color = SoulSearchingColorTheme.colorScheme.subPrimaryText, | ||
) { | ||
Column( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalArrangement = Arrangement.SpaceBetween | ||
) { | ||
Text( | ||
text = title, | ||
color = titleColor, | ||
style = UiConstants.Typography.bodyTitle, | ||
maxLines = titleMaxLines, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
text?.let { | ||
Text( | ||
text = text, | ||
color = textColor, | ||
style = UiConstants.Typography.bodySmall, | ||
maxLines = textMaxLines, | ||
overflow = TextOverflow.Ellipsis | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...src/commonMain/kotlin/com/github/enteraname74/soulsearching/coreui/menu/SoulMenuExpand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.github.enteraname74.soulsearching.coreui.menu | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.core.animateFloatAsState | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.ArrowDropDown | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.rotate | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.github.enteraname74.soulsearching.coreui.UiConstants | ||
import com.github.enteraname74.soulsearching.coreui.ext.clickableIf | ||
import com.github.enteraname74.soulsearching.coreui.image.SoulIcon | ||
import com.github.enteraname74.soulsearching.coreui.theme.color.SoulSearchingColorTheme | ||
|
||
@Composable | ||
fun SoulMenuExpand( | ||
title: String, | ||
subTitle: String, | ||
clickAction: () -> Unit, | ||
clickEnabled: Boolean = true, | ||
isExpanded: Boolean, | ||
padding: Dp = UiConstants.Spacing.veryLarge, | ||
containerColor: Color = SoulSearchingColorTheme.colorScheme.secondary, | ||
textColor: Color = SoulSearchingColorTheme.colorScheme.onSecondary, | ||
subTextColor: Color = SoulSearchingColorTheme.colorScheme.subSecondaryText, | ||
content: @Composable () -> Unit, | ||
) { | ||
val rotation by animateFloatAsState(targetValue = if (isExpanded) 180f else 0f) | ||
|
||
Column( | ||
modifier = Modifier | ||
.background( | ||
color = containerColor, | ||
shape = RoundedCornerShape(size = RoundedCornerShapeValue) | ||
) | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.clickableIf(enabled = clickEnabled) { | ||
clickAction() | ||
} | ||
.padding(padding), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.SpaceBetween | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.weight(1f), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy(UiConstants.Spacing.large) | ||
) { | ||
SoulMenuBody( | ||
title = title, | ||
text = subTitle, | ||
titleColor = textColor, | ||
textColor = subTextColor, | ||
) | ||
} | ||
SoulIcon( | ||
tint = textColor, | ||
icon = Icons.Filled.ArrowDropDown, | ||
contentDescription = null, | ||
modifier = Modifier.rotate(rotation), | ||
) | ||
} | ||
AnimatedVisibility( | ||
visible = isExpanded | ||
) { | ||
content() | ||
} | ||
} | ||
} | ||
|
||
private val RoundedCornerShapeValue: Dp = 10.dp |
Oops, something went wrong.