Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ captures

# IntelliJ .idea folder
.idea/workspace.xml
.idea/artifacts
.idea/libraries
.idea/caches
.idea/navEditor.xml
Expand Down
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ allprojects {
google()
mavenCentral()

maven { url 'https://maven.pkg.jetbrains.space/public/p/compose/dev' }

def composeSnapshot = libs.versions.composesnapshot.get()
if (composeSnapshot.length() > 1) {
maven { url "https://androidx.dev/snapshots/builds/$composeSnapshot/artifacts/repository/" }
maven { url 'https://androidx.dev/snapshots/builds/$composeSnapshot/artifacts/repository/' }
}
}
}
Expand All @@ -78,9 +80,9 @@ subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { compile ->
kotlinOptions {
// Treat all Kotlin warnings as errors
allWarningsAsErrors = true
// Set JVM target to 1.8
jvmTarget = "1.8"
// allWarningsAsErrors = true
// Set JVM target to 11
jvmTarget = "11"
// Allow use of @OptIn
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
// Enable default methods in interfaces
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=chrisbanes
POM_DEVELOPER_NAME=Chris Banes

# From IntelliJ Project wizard!
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
compose = "1.0.3"
compose = "1.0.5"
composesnapshot = "-" # a single character = no snapshot

gradlePlugin = "7.0.2"

ktlint = "0.42.1"
kotlin = "1.5.30"
kotlin = "1.5.31"
coroutines = "1.5.2"

androidxtest = "1.4.0"
Expand Down
6 changes: 3 additions & 3 deletions internal-testutils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.kotlin.android'
}

android {
Expand All @@ -28,8 +28,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

buildFeatures {
Expand Down
33 changes: 33 additions & 0 deletions kmp/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id("org.jetbrains.compose") version "1.0.0"
id("com.android.application")
kotlin("android")
}

group = "me.chris"
version = "1.0"

dependencies {
implementation(project(":kmp:lib"))
implementation("androidx.activity:activity-compose:1.3.0")
}

android {
compileSdk = 31
defaultConfig {
applicationId = "me.chris.android"
minSdk = 24
targetSdk = 31
versionCode = 1
versionName = "1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}
15 changes: 15 additions & 0 deletions kmp/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="me.chris.android">
<application
android:allowBackup="false"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
17 changes: 17 additions & 0 deletions kmp/android/src/main/java/me/chris/android/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package me.chris.android

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
//
}
}
}
}
39 changes: 39 additions & 0 deletions kmp/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose") version "1.0.0"
}

group = "me.chris"
version = "1.0"

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
withJava()
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(project(":kmp:lib"))
implementation(compose.desktop.currentOs)
}
}
val jvmTest by getting
}
}

compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "jvm"
packageVersion = "1.0.0"
}
}
}
13 changes: 13 additions & 0 deletions kmp/desktop/src/jvmMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package me.chris.desktop

import androidx.compose.material.MaterialTheme
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application

fun main() = application {
Window(onCloseRequest = ::exitApplication) {
MaterialTheme {
//
}
}
}
65 changes: 65 additions & 0 deletions kmp/lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import org.jetbrains.compose.compose

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose") version "1.0.0"
id("com.android.library")
}

kotlin {
android()

jvm("desktop") {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}

sourceSets {
val commonMain by getting {
dependencies {
api(compose.foundation)
implementation(libs.napier)
}
}

val commonTest by getting {
dependencies {
api(libs.junit)
api(libs.truth)
api(compose("org.jetbrains.compose.ui:ui-test-junit4"))
}
}

val androidMain by getting
val androidTest by getting

val desktopMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
}
}

val desktopTest by getting
}
}

android {
compileSdk = 31
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

defaultConfig {
minSdk = 24
targetSdk = 31
}

packagingOptions {
resources.pickFirsts += "/META-INF/AL2.0"
resources.pickFirsts += "/META-INF/LGPL2.1"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
17 changes: 17 additions & 0 deletions kmp/lib/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Copyright 2021 Chris Banes
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest package="dev.chrisbanes.snapper" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2021 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.chrisbanes.snapper

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.ui.unit.dp
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

/**
* Version of [BaseSnapperFlingLazyColumnTest] which is designed to be run on device/emulators.
*/
@RunWith(Parameterized::class)
class InstrumentedSnapperFlingLazyColumnTest(
maxScrollDistanceDp: Float,
contentPadding: PaddingValues,
itemSpacingDp: Int,
reverseLayout: Boolean,
) : BaseSnapperFlingLazyColumnTest(
maxScrollDistanceDp,
contentPadding,
itemSpacingDp,
reverseLayout,
) {
companion object {
/**
* On device we only test a subset of the combined parameters.
*/
@JvmStatic
@Parameterized.Parameters(
name = "maxScrollDistanceDp={0}," +
"contentPadding={1}," +
"itemSpacing={2}," +
"reverseLayout={3}"
)
fun data() = parameterizedParams()
// maxScrollDistanceDp
.combineWithParameters(
// We add 4dp on to cater for itemSpacing
1 * (ItemSize.value + 4),
4 * (ItemSize.value + 4),
)
// contentPadding
.combineWithParameters(
PaddingValues(bottom = 32.dp), // Alignment.Top
PaddingValues(vertical = 32.dp), // Alignment.Center
PaddingValues(top = 32.dp), // Alignment.Bottom
)
// itemSpacingDp
.combineWithParameters(0, 4)
// reverseLayout
.combineWithParameters(false)
}
}
Loading