Skip to content

Commit

Permalink
Merge pull request #3 from GetStream/feature/core-state
Browse files Browse the repository at this point in the history
Implement core-uistate module to generate restartable and skippable UI states based on KSP
  • Loading branch information
skydoves authored Aug 16, 2022
2 parents f95ce89 + 4f47ac1 commit dea428e
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 55 deletions.
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ subprojects {
"-Xopt-in=androidx.compose.material3.ExperimentalMaterial3Api",
"-Xopt-in=androidx.lifecycle.compose.ExperimentalLifecycleComposeApi"
)
kotlinOptions.freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
project.buildDir.absolutePath + "/compose_metrics"
)
kotlinOptions.freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
project.buildDir.absolutePath + "/compose_metrics"
)
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
12 changes: 0 additions & 12 deletions core-data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.serialization")
id("kotlin-kapt")
id("com.google.devtools.ksp")
id("dagger.hilt.android.plugin")
}

Expand All @@ -21,24 +20,13 @@ android {
}
}

kotlin {
sourceSets.configureEach {
kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
}
}

dependencies {
api(project(":core-model"))
api(project(":core-network"))
api(project(":core-database"))

api(Dependencies.streamClient)

api(Dependencies.coroutines)

api(Dependencies.hiltAndroid)
kapt(Dependencies.hiltCompiler)

implementation(Dependencies.sealedXCore)
ksp(Dependencies.sealedXProcessor)
}
7 changes: 0 additions & 7 deletions core-designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER
}

packagingOptions {
resources.excludes.add("META-INF/LICENSE.txt")
resources.excludes.add("META-INF/NOTICE.txt")
resources.excludes.add("LICENSE.txt")
resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions core-model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ android {
}

dependencies {
api(Dependencies.streamClient)
api(Dependencies.kotlinSerializationJson)
}
1 change: 1 addition & 0 deletions core-uistate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions core-uistate/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
}

android {
compileSdk = Configurations.compileSdk

defaultConfig {
minSdk = Configurations.minSdk
targetSdk = Configurations.targetSdk
}

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

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER
}
}

kotlin {
sourceSets.configureEach {
kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
}
}

dependencies {
implementation(project(":core-model"))

implementation(Dependencies.composeRuntime)

implementation(Dependencies.sealedXCore)
ksp(Dependencies.sealedXProcessor)
}
2 changes: 2 additions & 0 deletions core-uistate/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.getstream.whatsappclone.uistate" />
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@
* limitations under the License.
*/

package io.getstream.whatsappclone.data.model
package io.getstream.whatsappclone.uistate

import androidx.compose.runtime.Immutable
import com.skydoves.sealedx.core.Extensive
import com.skydoves.sealedx.core.annotations.ExtensiveModel
import com.skydoves.sealedx.core.annotations.ExtensiveSealed
import io.getstream.chat.android.client.models.Channel
import io.getstream.whatsappclone.model.WhatsAppUserExtensive

/**
* Generates restartable and skippable UI states based on KSP and extensive models.
* @see (SealedX)[https://github.com/skydoves/sealedx]
*/
@ExtensiveSealed(
models = [
ExtensiveModel(type = Channel::class, name = "WhatsAppMessage"),
ExtensiveModel(type = WhatsAppUserExtensive::class, name = "WhatsAppUser")
]
)
@Immutable
sealed interface UiState {
data class Success(val data: Extensive) : UiState
object Loading : UiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
* limitations under the License.
*/

package io.getstream.whatsappclone.model
package io.getstream.whatsappclone.uistate

import androidx.compose.runtime.Immutable
import io.getstream.whatsappclone.model.WhatsAppUser

@Immutable
data class WhatsAppUserExtensive(
val whatsappUserList: List<WhatsAppUser>
)
8 changes: 1 addition & 7 deletions feature-calls/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,13 @@ android {
lint {
abortOnError = false
}

packagingOptions {
resources.excludes.add("META-INF/LICENSE.txt")
resources.excludes.add("META-INF/NOTICE.txt")
resources.excludes.add("LICENSE.txt")
resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}

dependencies {
// core modules
implementation(project(":core-designsystem"))
implementation(project(":core-navigation"))
implementation(project(":core-uistate"))
implementation(project(":core-data"))

implementation(Dependencies.composeLifecycle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import io.getstream.whatsappclone.data.model.WhatsAppUserUiState
import io.getstream.whatsappclone.designsystem.component.WhatsAppError
import io.getstream.whatsappclone.designsystem.component.WhatsAppLoadingColumn
import io.getstream.whatsappclone.navigation.AppComposeNavigator
import io.getstream.whatsappclone.navigation.WhatsAppScreens
import io.getstream.whatsappclone.uistate.WhatsAppUserUiState

@Composable
fun WhatsAppCalls(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package io.getstream.whatsappclone.calls
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import io.getstream.whatsappclone.data.model.WhatsAppUserUiState
import io.getstream.whatsappclone.data.repository.CallHistoryRepository
import io.getstream.whatsappclone.model.WhatsAppUserExtensive
import io.getstream.whatsappclone.uistate.WhatsAppUserExtensive
import io.getstream.whatsappclone.uistate.WhatsAppUserUiState
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
Expand Down
7 changes: 0 additions & 7 deletions feature-camera/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ android {
lint {
abortOnError = false
}

packagingOptions {
resources.excludes.add("META-INF/LICENSE.txt")
resources.excludes.add("META-INF/NOTICE.txt")
resources.excludes.add("LICENSE.txt")
resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}

dependencies {
Expand Down
8 changes: 1 addition & 7 deletions feature-chats/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,14 @@ android {
lint {
abortOnError = false
}

packagingOptions {
resources.excludes.add("META-INF/LICENSE.txt")
resources.excludes.add("META-INF/NOTICE.txt")
resources.excludes.add("LICENSE.txt")
resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}

dependencies {
// core modules
implementation(project(":core-designsystem"))
implementation(project(":core-navigation"))
implementation(project(":core-network"))
implementation(project(":core-uistate"))
implementation(project(":core-data"))

// Stream chat Compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.skydoves.landscapist.glide.GlideImage
import io.getstream.chat.android.client.ChatClient
import io.getstream.whatsappclone.data.model.WhatsAppMessageUiState
import io.getstream.whatsappclone.designsystem.component.WhatsAppLoadingIndicator
import io.getstream.whatsappclone.designsystem.icon.WhatsAppIcons
import io.getstream.whatsappclone.designsystem.theme.WhatsAppCloneComposeTheme
import io.getstream.whatsappclone.navigation.AppComposeNavigator
import io.getstream.whatsappclone.navigation.WhatsAppCloneComposeNavigator
import io.getstream.whatsappclone.uistate.WhatsAppMessageUiState
import kotlinx.coroutines.Dispatchers

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import io.getstream.chat.android.client.ChatClient
import io.getstream.chat.android.client.utils.onError
import io.getstream.chat.android.client.utils.onSuccess
import io.getstream.whatsappclone.data.model.WhatsAppMessageUiState
import io.getstream.whatsappclone.network.Dispatcher
import io.getstream.whatsappclone.network.WhatsAppDispatchers
import io.getstream.whatsappclone.uistate.WhatsAppMessageUiState
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand Down
7 changes: 0 additions & 7 deletions feature-status/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ android {
lint {
abortOnError = false
}

packagingOptions {
resources.excludes.add("META-INF/LICENSE.txt")
resources.excludes.add("META-INF/NOTICE.txt")
resources.excludes.add("LICENSE.txt")
resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ include(":core-model")
include(":core-network")
include(":core-database")
include(":core-data")
include(":core-uistate")
include(":feature-camera")
include(":feature-chats")
include(":feature-status")
Expand Down

0 comments on commit dea428e

Please sign in to comment.