Skip to content

Commit

Permalink
Desktop Capabilities Added (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0adkll authored Aug 20, 2023
1 parent c295548 commit bc011c3
Show file tree
Hide file tree
Showing 31 changed files with 509 additions and 167 deletions.
95 changes: 46 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,59 +145,56 @@ jobs:
path: |
**/build/test-results/*
# desktop:
# needs: [code-style]
# runs-on: ubuntu-latest
# timeout-minutes: 60
desktop:
needs: [code-style]
runs-on: ubuntu-latest
timeout-minutes: 60
# env:
# ORG_GRADLE_PROJECT_TIVI_TMDB_API_KEY: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TMDB_API_KEY }}
# ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_ID: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_ID }}
# ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_SECRET: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_SECRET }}
# ORG_GRADLE_PROJECT_REMOTE_BUILD_CACHE_URL: ${{ secrets.ORG_GRADLE_PROJECT_REMOTE_BUILD_CACHE_URL }}
# ORG_GRADLE_PROJECT_REMOTE_BUILD_CACHE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_REMOTE_BUILD_CACHE_USERNAME }}
# ORG_GRADLE_PROJECT_REMOTE_BUILD_CACHE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_REMOTE_BUILD_CACHE_PASSWORD }}
#
# steps:
# - uses: actions/checkout@v3
#
# - name: Validate Gradle Wrapper
# uses: gradle/wrapper-validation-action@v1
#
# - name: set up JDK
# uses: actions/setup-java@v3
# with:
# distribution: 'zulu'
# java-version: 17
#
# - uses: gradle/gradle-build-action@v2
# with:
# cache-disabled: true
#
# - name: Build Desktop App
# run: ./gradlew jvmTest :desktop-app:package
#
# - name: Upload build outputs
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: desktop-build-binaries
# path: desktop-app/build/compose/binaries
#
# - name: Upload reports
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: desktop-reports
# path: |
# **/build/reports/*
#
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: desktop-test-results
# path: |
# **/build/test-results/*

steps:
- uses: actions/checkout@v3

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- uses: gradle/gradle-build-action@v2
with:
cache-disabled: true

- name: Build Desktop App
run: ./gradlew jvmTest :desktopApp:package

- name: Upload build outputs
if: always()
uses: actions/upload-artifact@v3
with:
name: desktop-build-binaries
path: desktop-app/build/compose/binaries

- name: Upload reports
if: always()
uses: actions/upload-artifact@v3
with:
name: desktop-reports
path: |
**/build/reports/*
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: desktop-test-results
path: |
**/build/test-results/*
# ios-app:
# needs: [code-style]
Expand Down
2 changes: 1 addition & 1 deletion common/compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import app.deckbox.convention.addKspDependencyForCommon

plugins {
alias(libs.plugins.composeMultiplatform)
id("app.deckbox.android.library")
id("app.deckbox.multiplatform")
id("app.deckbox.compose")
alias(libs.plugins.ksp)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package app.deckbox.common.compose.theme

import android.app.Activity
import androidx.compose.material3.ColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

@Composable
actual fun ApplyStatusBar(useDarkColors: Boolean, colorScheme: ColorScheme) {
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = useDarkColors
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,35 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import app.deckbox.core.model.Type

val md_theme_light_primary = Color(0xFF006494)
val md_theme_light_onPrimary = Color(0xFFffffff)
val md_theme_light_primaryContainer = Color(0xFFc8e6ff)
val md_theme_light_onPrimaryContainer = Color(0xFF001e31)
val md_theme_light_secondary = Color(0xFF795900)
val md_theme_light_onSecondary = Color(0xFFffffff)
val md_theme_light_secondaryContainer = Color(0xFFffdf99)
val md_theme_light_onSecondaryContainer = Color(0xFF261a00)
val md_theme_light_tertiary = Color(0xFF65597b)
val md_theme_light_onTertiary = Color(0xFFffffff)
val md_theme_light_tertiaryContainer = Color(0xFFecdcff)
val md_theme_light_onTertiaryContainer = Color(0xFF201634)
val md_theme_light_error = Color(0xFFba1b1b)
val md_theme_light_errorContainer = Color(0xFFffdad4)
val md_theme_light_onError = Color(0xFFffffff)
val md_theme_light_onErrorContainer = Color(0xFF410001)
val md_theme_light_background = Color(0xFFfcfcff)
val md_theme_light_onBackground = Color(0xFF1a1c1e)
val md_theme_light_surface = Color(0xFFfcfcff)
val md_theme_light_onSurface = Color(0xFF1a1c1e)
val md_theme_light_surfaceVariant = Color(0xFFdee3ea)
val md_theme_light_onSurfaceVariant = Color(0xFF41474d)
val md_theme_light_outline = Color(0xFF72787e)
val md_theme_light_inverseOnSurface = Color(0xFFf0f0f3)
val md_theme_light_inverseSurface = Color(0xFF2f3032)
val md_theme_light_inversePrimary = Color(0xFF8bceff)
val md_theme_light_shadow = Color(0xFF000000)
val md_theme_light_primary = Color(0xFF006493)
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
val md_theme_light_primaryContainer = Color(0xFFCAE6FF)
val md_theme_light_onPrimaryContainer = Color(0xFF001E30)
val md_theme_light_secondary = Color(0xFF785900)
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
val md_theme_light_secondaryContainer = Color(0xFFFFDF9E)
val md_theme_light_onSecondaryContainer = Color(0xFF261A00)
val md_theme_light_tertiary = Color(0xFFB50577)
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
val md_theme_light_tertiaryContainer = Color(0xFFFFD8E7)
val md_theme_light_onTertiaryContainer = Color(0xFF3D0025)
val md_theme_light_error = Color(0xFFBA1A1A)
val md_theme_light_onError = Color(0xFFFFFFFF)
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
val md_theme_light_onErrorContainer = Color(0xFF410002)
val md_theme_light_outline = Color(0xFF72787E)
val md_theme_light_background = Color(0xFFFCFCFF)
val md_theme_light_onBackground = Color(0xFF1A1C1E)
val md_theme_light_surface = Color(0xFFF9F9FC)
val md_theme_light_onSurface = Color(0xFF1A1C1E)
val md_theme_light_surfaceVariant = Color(0xFFDDE3EA)
val md_theme_light_onSurfaceVariant = Color(0xFF41474D)
val md_theme_light_inverseSurface = Color(0xFF2E3133)
val md_theme_light_inverseOnSurface = Color(0xFFF0F0F3)
val md_theme_light_inversePrimary = Color(0xFF8DCDFF)
val md_theme_light_surfaceTint = Color(0xFF006493)
val md_theme_light_outlineVariant = Color(0xFFC1C7CE)
val md_theme_light_scrim = Color(0xFF000000)

val DeckBoxLightColors = lightColorScheme(
primary = md_theme_light_primary,
Expand All @@ -49,49 +51,53 @@ val DeckBoxLightColors = lightColorScheme(
tertiaryContainer = md_theme_light_tertiaryContainer,
onTertiaryContainer = md_theme_light_onTertiaryContainer,
error = md_theme_light_error,
errorContainer = md_theme_light_errorContainer,
onError = md_theme_light_onError,
errorContainer = md_theme_light_errorContainer,
onErrorContainer = md_theme_light_onErrorContainer,
outline = md_theme_light_outline,
background = md_theme_light_background,
onBackground = md_theme_light_onBackground,
surface = md_theme_light_surface,
onSurface = md_theme_light_onSurface,
surfaceVariant = md_theme_light_surfaceVariant,
onSurfaceVariant = md_theme_light_onSurfaceVariant,
outline = md_theme_light_outline,
inverseOnSurface = md_theme_light_inverseOnSurface,
inverseSurface = md_theme_light_inverseSurface,
inverseOnSurface = md_theme_light_inverseOnSurface,
inversePrimary = md_theme_light_inversePrimary,
// shadow = md_theme_light_shadow,
surfaceTint = md_theme_light_surfaceTint,
outlineVariant = md_theme_light_outlineVariant,
scrim = md_theme_light_scrim,
)

val md_theme_dark_primary = Color(0xFF8bceff)
val md_theme_dark_onPrimary = Color(0xFF003450)
val md_theme_dark_primaryContainer = Color(0xFF004b71)
val md_theme_dark_onPrimaryContainer = Color(0xFFc8e6ff)
val md_theme_dark_secondary = Color(0xFFfabd00)
val md_theme_dark_onSecondary = Color(0xFF402d00)
val md_theme_dark_secondaryContainer = Color(0xFF5c4300)
val md_theme_dark_onSecondaryContainer = Color(0xFFffdf99)
val md_theme_dark_tertiary = Color(0xFFcfbfe8)
val md_theme_dark_onTertiary = Color(0xFF362b4b)
val md_theme_dark_tertiaryContainer = Color(0xFF4d4162)
val md_theme_dark_onTertiaryContainer = Color(0xFFecdcff)
val md_theme_dark_error = Color(0xFFffb4a9)
val md_theme_dark_errorContainer = Color(0xFF930006)
val md_theme_dark_onError = Color(0xFF680003)
val md_theme_dark_onErrorContainer = Color(0xFFffdad4)
val md_theme_dark_background = Color(0xFF1a1c1e)
val md_theme_dark_onBackground = Color(0xFFe2e2e5)
val md_theme_dark_surface = Color(0xFF1a1c1e)
val md_theme_dark_onSurface = Color(0xFFe2e2e5)
val md_theme_dark_surfaceVariant = Color(0xFF41474d)
val md_theme_dark_onSurfaceVariant = Color(0xFFc1c7ce)
val md_theme_dark_outline = Color(0xFF8b9198)
val md_theme_dark_inverseOnSurface = Color(0xFF1a1c1e)
val md_theme_dark_inverseSurface = Color(0xFFe2e2e5)
val md_theme_dark_inversePrimary = Color(0xFF006494)
val md_theme_dark_shadow = Color(0xFF000000)
val md_theme_dark_primary = Color(0xFF8DCDFF)
val md_theme_dark_onPrimary = Color(0xFF00344F)
val md_theme_dark_primaryContainer = Color(0xFF004B70)
val md_theme_dark_onPrimaryContainer = Color(0xFFCAE6FF)
val md_theme_dark_secondary = Color(0xFFFABD00)
val md_theme_dark_onSecondary = Color(0xFF3F2E00)
val md_theme_dark_secondaryContainer = Color(0xFF5B4300)
val md_theme_dark_onSecondaryContainer = Color(0xFFFFDF9E)
val md_theme_dark_tertiary = Color(0xFFFFAFD2)
val md_theme_dark_onTertiary = Color(0xFF63003F)
val md_theme_dark_tertiaryContainer = Color(0xFF8B005A)
val md_theme_dark_onTertiaryContainer = Color(0xFFFFD8E7)
val md_theme_dark_error = Color(0xFFFFB4AB)
val md_theme_dark_onError = Color(0xFF690005)
val md_theme_dark_errorContainer = Color(0xFF93000A)
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
val md_theme_dark_outline = Color(0xFF8B9198)
val md_theme_dark_background = Color(0xFF1A1C1E)
val md_theme_dark_onBackground = Color(0xFFE2E2E5)
val md_theme_dark_surface = Color(0xFF111416)
val md_theme_dark_onSurface = Color(0xFFC6C6C9)
val md_theme_dark_surfaceVariant = Color(0xFF41474D)
val md_theme_dark_onSurfaceVariant = Color(0xFFC1C7CE)
val md_theme_dark_inverseSurface = Color(0xFFE2E2E5)
val md_theme_dark_inverseOnSurface = Color(0xFF1A1C1E)
val md_theme_dark_inversePrimary = Color(0xFF006493)
val md_theme_dark_surfaceTint = Color(0xFF8DCDFF)
val md_theme_dark_outlineVariant = Color(0xFF41474D)
val md_theme_dark_scrim = Color(0xFF000000)

val DeckBoxDarkColors = darkColorScheme(
primary = md_theme_dark_primary,
Expand All @@ -107,24 +113,25 @@ val DeckBoxDarkColors = darkColorScheme(
tertiaryContainer = md_theme_dark_tertiaryContainer,
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
error = md_theme_dark_error,
errorContainer = md_theme_dark_errorContainer,
onError = md_theme_dark_onError,
errorContainer = md_theme_dark_errorContainer,
onErrorContainer = md_theme_dark_onErrorContainer,
outline = md_theme_dark_outline,
background = md_theme_dark_background,
onBackground = md_theme_dark_onBackground,
surface = md_theme_dark_surface,
onSurface = md_theme_dark_onSurface,
surfaceVariant = md_theme_dark_surfaceVariant,
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
outline = md_theme_dark_outline,
inverseOnSurface = md_theme_dark_inverseOnSurface,
inverseSurface = md_theme_dark_inverseSurface,
inverseOnSurface = md_theme_dark_inverseOnSurface,
inversePrimary = md_theme_dark_inversePrimary,
// shadow = md_theme_dark_shadow,
surfaceTint = md_theme_dark_surfaceTint,
outlineVariant = md_theme_dark_outlineVariant,
scrim = md_theme_dark_scrim,
)

val seed = Color(0xFF03a9f4)
val error = Color(0xFFba1b1b)

object PokemonTypeColor {
val Colorless = Color(0xFFE7E3D4)
Expand Down Expand Up @@ -165,6 +172,7 @@ object PokemonTypeColor {
Type.UNKNOWN,
Type.COLORLESS,
-> Colorless.copy(alpha = 0.20f)

else -> toColor().copy(alpha = 0.20f)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.deckbox.common.compose.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable

Expand All @@ -10,10 +11,15 @@ fun DeckBoxTheme(
useDynamicColors: Boolean = false,
content: @Composable () -> Unit,
) {
val colorScheme = colorScheme(useDarkColors, useDynamicColors)
ApplyStatusBar(useDarkColors, colorScheme)
MaterialTheme(
colorScheme = colorScheme(useDarkColors, useDynamicColors),
colorScheme = colorScheme,
typography = DeckBoxTypography,
shapes = DeckBoxShapes,
content = content,
)
}

@Composable
expect fun ApplyStatusBar(useDarkColors: Boolean, colorScheme: ColorScheme)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun PokemonCardBack(
) {
// compose.component.resources is currently borked on iOS targets until compose-mp 1.5.0+
// So we just check and omit if that is the case
if (currentPlatform != Platform.IOS) {
if (currentPlatform == Platform.ANDROID) {
Image(
painter = painterResource(type.resourceName),
contentDescription = LocalStrings.current.cardPlaceholderContentDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import app.cash.paging.compose.itemKey
import app.deckbox.core.coroutines.LoadState
import app.deckbox.core.model.Card
import com.valentinilk.shimmer.shimmer
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.roundToInt

private const val DefaultColumns = 4
Expand Down Expand Up @@ -139,7 +139,7 @@ fun ShimmerLoadingGrid(
val cardHeight = cardWidth / CardAspectRatio

// Compute rows
val rows = ceil(maxHeight.toPx() / (cardHeight + DefaultVerticalItemSpacing.toPx())).roundToInt()
val rows = floor(maxHeight.toPx() / cardHeight).roundToInt()

Column(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.deckbox.common.compose.theme

import androidx.compose.material3.ColorScheme
import androidx.compose.runtime.Composable

@Composable
actual fun ApplyStatusBar(
useDarkColors: Boolean,
colorScheme: ColorScheme,
) {
// Do nothing
}
Loading

0 comments on commit bc011c3

Please sign in to comment.