-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
291 additions
and
14 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
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
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
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
6 changes: 6 additions & 0 deletions
6
...onMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/about/AboutComponent.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,6 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.about | ||
|
||
import dev.datlag.aniflow.ui.navigation.DialogComponent | ||
|
||
interface AboutComponent : DialogComponent { | ||
} |
78 changes: 78 additions & 0 deletions
78
...ommonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/about/AboutDialog.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,78 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.about | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import com.mikepenz.aboutlibraries.Libs | ||
import dev.datlag.aniflow.LocalEdgeToEdge | ||
import dev.datlag.aniflow.SharedRes | ||
import dev.datlag.aniflow.common.merge | ||
import dev.datlag.aniflow.ui.navigation.screen.home.dialog.about.component.LibraryCard | ||
import dev.icerock.moko.resources.compose.readTextAsState | ||
import dev.icerock.moko.resources.compose.stringResource | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun AboutDialog(component: AboutComponent) { | ||
val sheetState = rememberModalBottomSheetState() | ||
val (insets, bottomPadding) = if (LocalEdgeToEdge.current) { | ||
WindowInsets( | ||
left = 0, | ||
top = 0, | ||
right = 0, | ||
bottom = 0 | ||
) to BottomSheetDefaults.windowInsets.only(WindowInsetsSides.Bottom).asPaddingValues() | ||
} else { | ||
BottomSheetDefaults.windowInsets to PaddingValues() | ||
} | ||
|
||
ModalBottomSheet( | ||
onDismissRequest = component::dismiss, | ||
windowInsets = insets, | ||
sheetState = sheetState | ||
) { | ||
val libsJson by SharedRes.assets.aboutlibraries_json.readTextAsState() | ||
val libs = remember(libsJson) { | ||
libsJson?.let { json -> | ||
Libs.Builder().withJson(json).build() | ||
} | ||
} | ||
val libsList = remember(libs) { | ||
libs?.libraries.orEmpty() | ||
} | ||
|
||
LazyColumn( | ||
modifier = Modifier.fillMaxWidth(), | ||
contentPadding = bottomPadding.merge(PaddingValues(16.dp)), | ||
verticalArrangement = Arrangement.spacedBy(8.dp) | ||
) { | ||
item { | ||
Text( | ||
modifier = Modifier.fillParentMaxWidth(), | ||
text = stringResource(SharedRes.strings.open_source_licenses), | ||
style = MaterialTheme.typography.headlineMedium, | ||
fontWeight = FontWeight.Bold, | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
item { | ||
Text( | ||
modifier = Modifier.fillParentMaxWidth().padding(vertical = 16.dp), | ||
text = stringResource(SharedRes.strings.open_source_licenses_text), | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
items(libsList, key = { it.uniqueId }) { | ||
LibraryCard(it) | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/about/AboutDialogComponent.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,24 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.about | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.arkivanov.decompose.ComponentContext | ||
import dev.datlag.aniflow.common.onRender | ||
import org.kodein.di.DI | ||
|
||
class AboutDialogComponent( | ||
componentContext: ComponentContext, | ||
override val di: DI, | ||
private val onDismiss: () -> Unit | ||
) : AboutComponent, ComponentContext by componentContext { | ||
|
||
@Composable | ||
override fun render() { | ||
onRender { | ||
AboutDialog(this) | ||
} | ||
} | ||
|
||
override fun dismiss() { | ||
onDismiss() | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...kotlin/dev/datlag/aniflow/ui/navigation/screen/home/dialog/about/component/LibraryCard.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,91 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.about.component | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import com.mikepenz.aboutlibraries.entity.Library | ||
import dev.datlag.aniflow.other.Constants | ||
|
||
@OptIn(ExperimentalLayoutApi::class) | ||
@Composable | ||
fun LibraryCard( | ||
library: Library | ||
) { | ||
val uriHandler = LocalUriHandler.current | ||
val website = library.website?.ifBlank { null } ?: library.scm?.url?.ifBlank { null } | ||
|
||
ElevatedCard( | ||
onClick = { | ||
if (!website.isNullOrBlank()) { | ||
uriHandler.openUri(website) | ||
} | ||
}, | ||
modifier = Modifier.fillMaxWidth(), | ||
enabled = !website.isNullOrBlank(), | ||
) { | ||
Column( | ||
modifier = Modifier.fillMaxWidth().padding(8.dp), | ||
verticalArrangement = Arrangement.spacedBy(2.dp, Alignment.CenterVertically) | ||
) { | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Text( | ||
modifier = Modifier.weight(1F), | ||
text = library.name, | ||
softWrap = true, | ||
overflow = TextOverflow.Ellipsis, | ||
maxLines = 2, | ||
fontWeight = FontWeight.Medium | ||
) | ||
library.artifactVersion?.let { | ||
Text( | ||
text = it, | ||
style = MaterialTheme.typography.bodySmall | ||
) | ||
} | ||
} | ||
Text( | ||
text = library.organization?.name?.ifBlank { null } ?: library.developers.map { it.name }.joinToString(), | ||
style = MaterialTheme.typography.bodySmall, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
softWrap = true | ||
) | ||
FlowRow( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.spacedBy(8.dp), | ||
verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.CenterVertically) | ||
) { | ||
library.licenses.forEach { lic -> | ||
val url = lic.url?.ifBlank { null } ?: lic.spdxId?.ifBlank { null }?.let { "${Constants.SPDX_LICENSE_BASE}$it" } | ||
|
||
SuggestionChip( | ||
onClick = { | ||
if (!url.isNullOrBlank()) { | ||
uriHandler.openUri(url) | ||
} | ||
}, | ||
enabled = !url.isNullOrBlank(), | ||
label = { | ||
Text(text = lic.name) | ||
}, | ||
colors = SuggestionChipDefaults.suggestionChipColors( | ||
containerColor = MaterialTheme.colorScheme.tertiary, | ||
labelColor = MaterialTheme.colorScheme.onTertiary | ||
), | ||
border = null | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
45 changes: 45 additions & 0 deletions
45
...in/dev/datlag/aniflow/ui/navigation/screen/home/dialog/settings/component/AboutSection.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,45 @@ | ||
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.defaultMinSize | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.Lightbulb | ||
import androidx.compose.material.icons.rounded.Savings | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.ColorFilter | ||
import androidx.compose.ui.unit.dp | ||
import dev.datlag.aniflow.SharedRes | ||
import dev.datlag.tooling.compose.onClick | ||
import dev.icerock.moko.resources.compose.painterResource | ||
import dev.icerock.moko.resources.compose.stringResource | ||
|
||
@Composable | ||
fun AboutSection( | ||
modifier: Modifier = Modifier, | ||
onClick: () -> Unit | ||
) { | ||
Row( | ||
modifier = modifier | ||
.defaultMinSize(minHeight = ButtonDefaults.MinHeight) | ||
.clip(MaterialTheme.shapes.medium) | ||
.onClick { | ||
onClick() | ||
}, | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy(8.dp) | ||
) { | ||
Icon( | ||
imageVector = Icons.Rounded.Lightbulb, | ||
contentDescription = null, | ||
) | ||
Text(text = stringResource(SharedRes.strings.open_source_licenses)) | ||
} | ||
} |
Empty file.
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
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
Oops, something went wrong.