Skip to content

Commit

Permalink
Use Swipe
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-ramotar committed May 11, 2024
1 parent ec90734 commit f05095f
Show file tree
Hide file tree
Showing 19 changed files with 939 additions and 76 deletions.
1 change: 1 addition & 0 deletions experimental/sample/scoop/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation(libs.ktor.negotiation)

implementation(libs.compose.webview.multiplatform)
implementation(project(":experimental:sample:scoop:xplat:foundation:designSystem"))

implementation(project(":experimental:market"))
implementation(project(":experimental:market:warehouse"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.twotone.Home
import androidx.compose.material.icons.twotone.Person
import androidx.compose.material.icons.twotone.Search
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.remember
Expand All @@ -14,7 +20,7 @@ import com.slack.circuit.foundation.*
import me.tatarka.inject.annotations.Inject
import monster.scoop.android.app.di.CoreComponent
import monster.scoop.android.app.di.create
import monster.scoop.android.app.theme.ScoopTheme
import monster.scoop.xplat.foundation.designSystem.theme.AppTheme


@Inject
Expand Down Expand Up @@ -42,8 +48,17 @@ class MainActivity : ComponentActivity() {
val navigator = rememberCircuitNavigator(backStack)

CircuitCompositionLocals(circuit) {
ScoopTheme {
Scaffold { innerPadding ->

AppTheme(true) {
Scaffold(
bottomBar = {
BottomAppBar {
Icon(Icons.TwoTone.Home, "Home")
Icon(Icons.TwoTone.Search, "Search")
Icon(Icons.TwoTone.Person, "Person")
}
}
) { innerPadding ->
NavigableCircuitContent(
navigator,
backStack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
import me.tatarka.inject.annotations.Inject
import monster.scoop.xplat.feat.homeTab.api.HomeTab
import monster.scoop.xplat.feat.homeTab.impl.HomeTabUi
import monster.scoop.xplat.feat.homeTab.impl.ui.HomeTabUi
import monster.scoop.xplat.foundation.di.UserScope

@Inject
Expand Down
5 changes: 5 additions & 0 deletions experimental/sample/scoop/tooling/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ gradlePlugin {
id = "plugin.scoop.kotlin.multiplatform"
implementationClass = "monster.scoop.tooling.plugins.KotlinMultiplatformConventionPlugin"
}

register("kotlinComposeMultiplatformPlugin") {
id = "plugin.scoop.kotlin.compose.multiplatform"
implementationClass = "monster.scoop.tooling.plugins.KotlinComposeMultiplatformConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package monster.scoop.tooling.plugins

import com.android.build.gradle.LibraryExtension
import monster.scoop.tooling.extensions.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.configurationcache.extensions.capitalized
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import monster.scoop.tooling.extensions.configureKotlin
import monster.scoop.tooling.extensions.libs

class KotlinComposeMultiplatformConventionPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
with(pluginManager) {
apply("org.jetbrains.kotlin.multiplatform")
}

version = libs.findVersion("scoop")

extensions.configure<KotlinMultiplatformExtension> {
applyDefaultHierarchyTemplate()

if (pluginManager.hasPlugin("com.android.library")) {
androidTarget()
}

jvm()

iosX64()
iosArm64()
iosSimulatorArm64()

targets.all {
compilations.all {
compilerOptions.configure {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}

targets.withType<KotlinNativeTarget>().configureEach {
compilations.configureEach {
compilerOptions.configure {
freeCompilerArgs.add("-Xallocator=custom")
freeCompilerArgs.add("-XXLanguage:+ImplicitSignedToUnsignedIntegerConversion")
freeCompilerArgs.add("-Xadd-light-debug=enable")

freeCompilerArgs.addAll(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlinx.cinterop.ExperimentalForeignApi",
"-opt-in=kotlinx.cinterop.BetaInteropApi",

)
}
}
}

configureKotlin()

}

extensions.configure<LibraryExtension> {
buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.findVersion("compose-compiler").get().toString()
}
}

}
}


private fun Project.addKspDependencyForAllTargets(
configurationNameSuffix: String,
dependencyNotation: Any,
) {
val kmpExtension = extensions.getByType<KotlinMultiplatformExtension>()
dependencies {
kmpExtension.targets
.asSequence()
.filter { target ->
target.platformType != KotlinPlatformType.common
}
.forEach { target ->
add(
"ksp${target.targetName.capitalized()}$configurationNameSuffix",
dependencyNotation,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
apply("org.jetbrains.kotlin.multiplatform")
}

version = libs.findVersion("trails")
version = libs.findVersion("scoop")

extensions.configure<KotlinMultiplatformExtension> {
applyDefaultHierarchyTemplate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ kotlin {

android {
namespace = "monster.scoop.xplat.common.market"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ kotlin {

android {
namespace = "monster.scoop.xplat.domain.story.api"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ dependencies {

android {
namespace = "monster.scoop.xplat.domain.story.impl"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ kotlin {
implementation(compose.material3)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinInject.runtime)
implementation(compose.materialIconsExtended)

api(project(":experimental:market:warehouse"))
api(project(":experimental:sample:scoop:xplat:common:market"))
Expand All @@ -27,6 +28,8 @@ kotlin {
implementation(libs.coil.compose)
implementation(libs.coil.network)
implementation(libs.ktor.core)
implementation(libs.swipe)
implementation(compose.components.uiToolingPreview)
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package monster.scoop.xplat.feat.homeTab.impl.ui


import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import me.tatarka.inject.annotations.Inject
import monster.scoop.xplat.feat.homeTab.api.HomeTab
import monster.scoop.xplat.feat.homeTab.impl.ui.compose.HomeTabFeed

@Inject
class HomeTabUi : HomeTab.Ui {
@Composable
override fun Content(state: HomeTab.State, modifier: Modifier) {
Column {
if (state.stories.isEmpty()) {
// Show loading indicator
} else {
HomeTabFeed(state.stories)
}
}
}
}
Loading

0 comments on commit f05095f

Please sign in to comment.