Skip to content

Commit

Permalink
Window size class for position of chip (#1276)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashley Davies <[email protected]>
  • Loading branch information
ashdavies and ashdavies authored Oct 27, 2024
1 parent c9fd231 commit f9f5cb9
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
}

kotlin {
androidTarget()
androidTarget {
val jvmTarget = JvmTarget.fromTarget(libs.versions.kotlin.jvmTarget.get())
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions.jvmTarget.set(jvmTarget)
}
}

pluginManager.commonExtension {
Expand Down
4 changes: 2 additions & 2 deletions build-plugins/src/main/kotlin/io.ashdavies.kotlin.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektPlugin
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.KtlintExtension
Expand Down Expand Up @@ -38,11 +39,10 @@ extensions.configure<DetektExtension> {


tasks.withType<KotlinCompile> {
val jvmTargetVersion = libs.versions.kotlin.jvmTarget.get()

compilerOptions {
freeCompilerArgs.addAll("-Xexpect-actual-classes")
jvmTarget.set(JvmTarget.fromTarget(jvmTargetVersion))
jvmTarget.set(JvmTarget.fromTarget(libs.versions.kotlin.jvmTarget.get()))
}
}

Expand Down
2 changes: 2 additions & 0 deletions conferences-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ kotlin {
implementation(projects.sqlCompose)
implementation(projects.sqlDriver)

implementation(compose.components.resources)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.material3)
Expand All @@ -127,6 +128,7 @@ kotlin {
implementation(libs.androidx.paging.common)
implementation(libs.coil.compose)
implementation(libs.coil.network)
implementation(libs.compose.window.size)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.serialization.core)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.ashdavies.party

import android.app.Activity
import android.content.Context
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.pm.PackageInfoCompat
import com.slack.circuit.backstack.rememberSaveableBackStack
import com.slack.circuit.foundation.CircuitCompositionLocals
Expand All @@ -24,6 +26,7 @@ import io.ashdavies.io.resolveCacheDir
import io.ashdavies.material.dynamicColorScheme
import io.ashdavies.party.config.rememberCircuit
import io.ashdavies.party.home.HomeScreen
import io.ashdavies.party.material.ProvideLocalWindowSizeClass
import io.ashdavies.playground.BuildConfig
import io.ashdavies.playground.PlaygroundDatabase
import io.ashdavies.sql.ProvideTransacter
Expand All @@ -44,43 +47,46 @@ internal class MainActivity : ComponentActivity() {
}

setContent {
ConferencesApp()
ConferencesApp(this)
}
}
}

@Composable
private fun ConferencesApp(context: Context = LocalContext.current) {
private fun ConferencesApp(activity: Activity) {
ProvideHttpClient(
config = {
install(DefaultRequest) {
header("X-Android-Cert", context.getFirstSignatureOrNull())
header("X-Android-Package", context.packageName)
header("X-Android-Cert", activity.getFirstSignatureOrNull())
header("X-Android-Package", activity.packageName)
header("X-API-Key", BuildConfig.ANDROID_API_KEY)
header("User-Agent", Build.PRODUCT)
}

install(HttpCache) {
publicStorage(context.resolveCacheDir())
publicStorage(activity.resolveCacheDir())
}
},
) {
ProvideAppCheckToken {
val transacter = rememberTransacter(
schema = PlaygroundDatabase.Schema,
context = context,
context = activity,
) { PlaygroundDatabase(it) }

ProvideTransacter(transacter) {
MaterialTheme(dynamicColorScheme()) {
CircuitCompositionLocals(rememberCircuit(context)) {
CircuitCompositionLocals(rememberCircuit(activity)) {
ContentWithOverlays {
val backStack = rememberSaveableBackStack(HomeScreen)
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
ProvideLocalWindowSizeClass(calculateWindowSizeClass(activity)) {
val backStack = rememberSaveableBackStack(HomeScreen)

NavigableCircuitContent(
navigator = rememberCircuitNavigator(backStack),
backStack = backStack,
)
NavigableCircuitContent(
navigator = rememberCircuitNavigator(backStack),
backStack = backStack,
)
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions conferences-app/src/androidMain/res/values/strings.xml

This file was deleted.

23 changes: 23 additions & 0 deletions conferences-app/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="application">Playground</string>
<string name="upcoming">Upcoming</string>
<string name="profile">Profile</string>
<string name="events">Events</string>

<string name="january">Jan</string>
<string name="february">Feb</string>
<string name="march">Mar</string>
<string name="april">Apr</string>
<string name="may">May</string>
<string name="june">Jun</string>
<string name="july">Jul</string>
<string name="august">Aug</string>
<string name="september">Sep</string>
<string name="october">Oct</string>
<string name="november">Nov</string>
<string name="december">Dec</string>

<string name="call_for_papers">Call for Papers (Until %1$s)</string>
<string name="online_only">Online Only</string>
</resources>
Loading

0 comments on commit f9f5cb9

Please sign in to comment.