Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Flisar authored and Michael Flisar committed Nov 12, 2024
1 parent ffcd1d1 commit 27d2d59
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 27 deletions.
2 changes: 1 addition & 1 deletion demo/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.parcelize)
id("compose-changelog")
id("io.github.mflisar.composechangelog.gradle-plugin")
}

val version = "1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion demo/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.compose)
id("compose-changelog")
id("io.github.mflisar.composechangelog.gradle-plugin")
}

val version = "1.0.6"
Expand Down
4 changes: 2 additions & 2 deletions gradle-plugin/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {

gradlePlugin {
plugins {
create("com.michaelflisar.composechangelog.gradle.plugin") {
id = "compose-changelog"
create("$groupID.gradle-plugin") {
id = "$groupID.gradle-plugin"
implementationClass = "com.michaelflisar.composechangelog.gradle.plugin.ClassLoaderPlugin"
}
//isAutomatedPublishing = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.michaelflisar.composechangelog

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.res.stringResource
import com.michaelflisar.composechangelog.classes.ChangelogData
import com.michaelflisar.composechangelog.classes.DataItemRelease
import com.michaelflisar.composechangelog.composables.Changelog
import com.michaelflisar.composechangelog.internal.ChangelogParserUtil

actual typealias Context = android.content.Context
Expand All @@ -17,6 +25,43 @@ internal actual fun LocalContext(): Context {
return androidx.compose.ui.platform.LocalContext.current
}

@Composable
internal actual fun ShowChangelogDialog(
visible: MutableState<Boolean>,
data: ChangelogData,
setup: ChangelogSetup,
onDismiss: () -> Unit
) {
AlertDialog(
onDismissRequest = {
onDismiss()
visible.value = false
},
title = {
Text(text = setup.texts.dialogTitle)
},
text = {
Changelog(data, setup)
},
confirmButton = {
TextButton(
onClick = {
onDismiss()
visible.value = false
}) {
Text(setup.texts.dialogButtonDismiss)
}
}
)
}

@Composable
internal actual fun LazyScrollContainer(state: LazyListState, content: LazyListScope.() -> Unit) {
LazyColumn(state = state) {
content()
}
}

internal actual suspend fun ChangelogUtil.read(
context: Context,
changelogID: ChangelogID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.michaelflisar.composechangelog

import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import com.michaelflisar.composechangelog.classes.ChangelogData
import com.michaelflisar.composechangelog.classes.DataItemRelease

Expand All @@ -13,6 +16,17 @@ expect fun stringOk() : String
@Composable
internal expect fun LocalContext(): Context

@Composable
internal expect fun ShowChangelogDialog(
visible: MutableState<Boolean>,
data: ChangelogData,
setup: ChangelogSetup,
onDismiss: () -> Unit
)

@Composable
internal expect fun LazyScrollContainer(state: LazyListState, content: LazyListScope.() -> Unit)

internal expect suspend fun ChangelogUtil.read(
context: Context,
changelogID: ChangelogID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.michaelflisar.composechangelog

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -15,7 +12,6 @@ import com.michaelflisar.composechangelog.classes.ChangelogData
import com.michaelflisar.composechangelog.classes.DataItem
import com.michaelflisar.composechangelog.classes.DataItemRelease
import com.michaelflisar.composechangelog.classes.ShowChangelog
import com.michaelflisar.composechangelog.composables.Changelog
import com.michaelflisar.composechangelog.interfaces.IChangelogFilter
import com.michaelflisar.composechangelog.interfaces.IChangelogStateSaver
import kotlinx.coroutines.Dispatchers
Expand All @@ -40,25 +36,13 @@ fun ShowChangelogDialog(
if (data != null && !data.isEmpty()) {
val openDialog = remember { mutableStateOf(true) }
if (openDialog.value) {
AlertDialog(
onDismissRequest = {
ShowChangelogDialog(
visible = openDialog,
data = data,
setup = setup,
onDismiss = {
onDismiss()
openDialog.value = false
},
title = {
Text(text = setup.texts.dialogTitle)
},
text = {
Changelog(data, setup)
},
confirmButton = {
TextButton(
onClick = {
onDismiss()
openDialog.value = false
}) {
Text(setup.texts.dialogButtonDismiss)
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.michaelflisar.composechangelog.composables

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.michaelflisar.composechangelog.ChangelogSetup
import com.michaelflisar.composechangelog.LazyScrollContainer
import com.michaelflisar.composechangelog.classes.ChangelogData

@Composable
Expand All @@ -18,7 +18,7 @@ fun Changelog(
val releases = changelog.releases

var idMore = -1
LazyColumn(
LazyScrollContainer(
state = rememberLazyListState()
) {
releases.forEachIndexed { index, item ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
package com.michaelflisar.composechangelog

import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogWindow
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.rememberDialogState
import com.michaelflisar.composechangelog.classes.ChangelogData
import com.michaelflisar.composechangelog.classes.DataItemRelease
import com.michaelflisar.composechangelog.composables.Changelog
import com.michaelflisar.composechangelog.internal.ChangelogParserUtil
import java.io.File

Expand All @@ -19,6 +37,49 @@ internal actual fun LocalContext(): Context {
return NoContext
}

@Composable
internal actual fun ShowChangelogDialog(
visible: MutableState<Boolean>,
data: ChangelogData,
setup: ChangelogSetup,
onDismiss: () -> Unit
) {
DialogWindow(
visible = visible.value,
title = setup.texts.dialogTitle,
onCloseRequest = { visible.value = false },
state = rememberDialogState(
position = WindowPosition(Alignment.Center),
width = 600.dp,
height = 400.dp
)
) {
Column(
modifier = Modifier.padding(16.dp)
) {
Changelog(data, setup)
}
}
}

@Composable
internal actual fun LazyScrollContainer(state: LazyListState, content: LazyListScope.() -> Unit) {
Box {
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.padding(end = 8.dp),
state = state
) {
content()
}
VerticalScrollbar(
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter(state)
)
}
}

internal actual suspend fun ChangelogUtil.read(
context: Context,
changelogID: ChangelogID,
Expand Down

0 comments on commit 27d2d59

Please sign in to comment.