Skip to content

Commit

Permalink
initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Oct 31, 2023
1 parent cae2d46 commit 32e4369
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @datl4g
52 changes: 52 additions & 0 deletions .github/workflows/dependecy-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check Dependency Versions
on:
push:

jobs:
dependency-versions:
runs-on: ubuntu-latest

permissions:
checks: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Check Dependency Versions
run: ./gradlew dependencyUpdates

- name: Publish version results
run: |
ruby << 'EOF' | gh api -X POST '/repos/${{ github.repository }}/check-runs' --input -
require 'json'
report = {
name: ENV.fetch('REPORT_CHECK_NAME'),
head_sha: ENV.fetch('REPORT_SHA'),
status: 'completed',
conclusion: ENV.fetch('REPORT_CONCLUSION'),
output: {
title: ENV.fetch('REPORT_CHECK_OUTPUT_TITLE'),
summary: File.read(ENV.fetch('REPORT_CHECK_OUTPUT_SUMMARY_FILE')),
},
}
puts report.to_json
EOF
env:
REPORT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
GITHUB_TOKEN: ${{ github.token }}
REPORT_CHECK_NAME: Version Results
REPORT_CHECK_OUTPUT_TITLE: ${{ github.event.repository.updated_at }}
REPORT_CHECK_OUTPUT_SUMMARY_FILE: build/dependencyUpdates/report.md
REPORT_CONCLUSION: ${{ job.status }}
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ private fun runWindow() {
LifecycleController(lifecycle, windowState)

CompositionLocalProvider(
LocalLifecycleOwner provides lifecycleOwner
LocalLifecycleOwner provides lifecycleOwner,
LocalWindow provides this.window
) {
App(di) {
root.render()
Expand Down
3 changes: 2 additions & 1 deletion app/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ kotlin {

dependencies {
api(compose.desktop.currentOs)

api(libs.coroutines.swing)
api(libs.context.menu)
api(libs.window.styler)
}
}
val iosX64Main by getting
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.datlag.burningseries

import androidx.compose.runtime.Composable

@Composable
actual fun SystemProvider(content: @Composable () -> Unit) {
}
19 changes: 12 additions & 7 deletions app/shared/src/commonMain/kotlin/dev/datlag/burningseries/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ fun App(
colors = MaterialTheme.colorScheme.toLegacyColors(systemDarkTheme),
shapes = MaterialTheme.shapes.toLegacyShapes()
) {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
contentColor = MaterialTheme.colorScheme.onBackground
) {
content()
SystemProvider {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
contentColor = MaterialTheme.colorScheme.onBackground
) {
content()
}
}
}
}
}
}
}

@Composable
expect fun SystemProvider(content: @Composable () -> Unit)
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package dev.datlag.burningseries

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalContextMenuRepresentation
import androidx.compose.foundation.text.LocalTextContextMenu
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.awt.ComposeWindow
import com.dzirbel.contextmenu.ContextMenuColors
import com.dzirbel.contextmenu.MaterialContextMenuRepresentation
import com.dzirbel.contextmenu.MaterialTextContextMenu
import com.mayakapps.compose.windowstyler.WindowBackdrop
import com.mayakapps.compose.windowstyler.WindowCornerPreference
import com.mayakapps.compose.windowstyler.WindowFrameStyle
import com.mayakapps.compose.windowstyler.WindowStyleManager

val LocalWindow = compositionLocalOf<ComposeWindow> { error("No window state provided") }

@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class)
@Composable
actual fun SystemProvider(content: @Composable () -> Unit) {
val backgroundColor = MaterialTheme.colorScheme.background
val onBackgroundColor = MaterialTheme.colorScheme.onBackground
val backdrop = WindowBackdrop.Solid(backgroundColor)

WindowStyle(
backdropType = backdrop,
frameStyle = WindowFrameStyle(
borderColor = backgroundColor,
titleBarColor = backgroundColor,
captionColor = onBackgroundColor,
cornerPreference = WindowCornerPreference.ROUNDED
)
)

CompositionLocalProvider(
LocalContextMenuRepresentation provides MaterialContextMenuRepresentation(colors = ContextMenuColors(MaterialTheme.colorScheme)),
LocalTextContextMenu provides MaterialTextContextMenu,
) {
content()
}
}

@Composable
private fun WindowStyle(
window: ComposeWindow = LocalWindow.current,
isDarkTheme: Boolean = LocalDarkMode.current,
backdropType: WindowBackdrop = WindowBackdrop.Default,
frameStyle: WindowFrameStyle = WindowFrameStyle()
) {
val manager = remember(isDarkTheme) { WindowStyleManager(
window = window,
isDarkTheme = isDarkTheme,
backdropType = backdropType,
frameStyle = frameStyle
) }

LaunchedEffect(isDarkTheme) {
manager.isDarkTheme = isDarkTheme
}

LaunchedEffect(backdropType) {
manager.backdropType = backdropType
}
}

@Composable
fun ContextMenuColors(scheme: ColorScheme = MaterialTheme.colorScheme) = ContextMenuColors(
surface = scheme.surface,
text = scheme.onSurface,
icon = scheme.onSurface,
divider = scheme.onSurfaceVariant,
shortcutText = scheme.onSurfaceVariant
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.datlag.burningseries

import androidx.compose.runtime.Composable

@Composable
actual fun SystemProvider(content: @Composable () -> Unit) {
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ android = "8.1.2"
android-core = "1.12.0"
appcompat = "1.6.1"
compose = "1.5.3"
context-menu = "0.2.0"
coroutines = "1.7.3"
datastore = "1.0.0"
decompose = "2.1.3-compose-experimental"
Expand Down Expand Up @@ -43,6 +44,7 @@ activity-compose = { group = "androidx.activity", name = "activity-compose", ver
android = { group = "androidx.core", name = "core-ktx", version.ref = "android-core" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
compose-ui-util = { group = "org.jetbrains.compose.ui", name = "ui-util", version.ref = "compose" }
context-menu = { group = "io.github.dzirbel", name = "compose-material-context-menu", version.ref = "context-menu" }
coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
coroutines-swing = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-swing", version.ref = "coroutines" }
Expand Down

0 comments on commit 32e4369

Please sign in to comment.