🤬
  • ■ ■ ■ ■ ■ ■
    buildSrc/src/main/kotlin/Dependencies.kt
    skipped 19 lines
    20 20   internal const val APP_STARTUP = "1.1.1"
    21 21   internal const val LIFECYCLE = "2.6.0-alpha01"
    22 22   internal const val ROOM = "2.4.2"
     23 + internal const val SEALEDX = "1.0.0"
    23 24   
    24 25   internal const val LANDSCAPIST_GLIDE = "1.6.0"
    25 26   internal const val ACCOMPANIST = "0.25.0"
    skipped 51 lines
    77 78   const val accompanistIndicator =
    78 79   "com.google.accompanist:accompanist-pager-indicators:${Versions.ACCOMPANIST}"
    79 80   const val streamCompose = "io.getstream:stream-chat-android-compose:${Versions.STREAM_CHAT}"
     81 + const val streamClient = "io.getstream:stream-chat-android-client:${Versions.STREAM_CHAT}"
    80 82   
    81 83   const val appStartUp = "androidx.startup:startup-runtime:${Versions.APP_STARTUP}"
    82 84   const val hiltAndroid = "com.google.dagger:hilt-android:${Versions.HILT}"
    skipped 2 lines
    85 87   const val roomRuntime = "androidx.room:room-runtime:${Versions.ROOM}"
    86 88   const val roomKtx = "androidx.room:room-ktx:${Versions.ROOM}"
    87 89   const val roomCompiler = "androidx.room:room-compiler:${Versions.ROOM}"
     90 + const val sealedXCore = "com.github.skydoves:sealedx-core:${Versions.SEALEDX}"
     91 + const val sealedXProcessor = "com.github.skydoves:sealedx-processor:${Versions.SEALEDX}"
    88 92   
    89 93   const val okHttp = "com.squareup.okhttp3:okhttp:${Versions.OKHTTP}"
    90 94   const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.RETROFIT}"
    skipped 16 lines
  • ■ ■ ■ ■ ■ ■
    core-data/build.gradle.kts
    skipped 2 lines
    3 3   id("org.jetbrains.kotlin.android")
    4 4   id("org.jetbrains.kotlin.plugin.serialization")
    5 5   id("kotlin-kapt")
     6 + id("com.google.devtools.ksp")
    6 7   id("dagger.hilt.android.plugin")
    7 8  }
    8 9   
    skipped 15 lines
    24 25   }
    25 26  }
    26 27   
     28 +kotlin {
     29 + sourceSets.configureEach {
     30 + kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
     31 + }
     32 +}
     33 + 
    27 34  dependencies {
    28 35   api(project(":core-model"))
    29 36   api(project(":core-network"))
    30 37   api(project(":core-database"))
    31 38   
     39 + api(Dependencies.streamClient)
     40 + 
    32 41   api(Dependencies.coroutines)
    33 42   
    34 43   api(Dependencies.hiltAndroid)
    35 44   kapt(Dependencies.hiltCompiler)
     45 + 
     46 + implementation(Dependencies.sealedXCore)
     47 + ksp(Dependencies.sealedXProcessor)
    36 48  }
    37 49   
  • ■ ■ ■ ■ ■ ■
    core-data/src/main/kotlin/io/getstream/whatsappclone/data/model/UiState.kt
     1 +/*
     2 + * Copyright 2022 Stream.IO, Inc. All Rights Reserved.
     3 + *
     4 + * Licensed under the Apache License, Version 2.0 (the "License");
     5 + * you may not use this file except in compliance with the License.
     6 + * You may obtain a copy of the License at
     7 + *
     8 + * http://www.apache.org/licenses/LICENSE-2.0
     9 + *
     10 + * Unless required by applicable law or agreed to in writing, software
     11 + * distributed under the License is distributed on an "AS IS" BASIS,
     12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 + * See the License for the specific language governing permissions and
     14 + * limitations under the License.
     15 + */
     16 + 
     17 +package io.getstream.whatsappclone.data.model
     18 + 
     19 +import com.skydoves.sealedx.core.Extensive
     20 +import com.skydoves.sealedx.core.annotations.ExtensiveModel
     21 +import com.skydoves.sealedx.core.annotations.ExtensiveSealed
     22 +import io.getstream.chat.android.client.models.Channel
     23 +import io.getstream.whatsappclone.model.WhatsAppUserExtensive
     24 + 
     25 +@ExtensiveSealed(
     26 + models = [
     27 + ExtensiveModel(type = Channel::class, name = "WhatsAppMessage"),
     28 + ExtensiveModel(type = WhatsAppUserExtensive::class, name = "WhatsAppUser")
     29 + ]
     30 +)
     31 +sealed interface UiState {
     32 + data class Success(val data: Extensive) : UiState
     33 + object Loading : UiState
     34 + object Error : UiState
     35 +}
     36 + 
  • ■ ■ ■ ■ ■ ■
    core-model/src/main/kotlin/io/getstream/whatsappclone/model/WhatsAppUserExtensive.kt
     1 +/*
     2 + * Copyright 2022 Stream.IO, Inc. All Rights Reserved.
     3 + *
     4 + * Licensed under the Apache License, Version 2.0 (the "License");
     5 + * you may not use this file except in compliance with the License.
     6 + * You may obtain a copy of the License at
     7 + *
     8 + * http://www.apache.org/licenses/LICENSE-2.0
     9 + *
     10 + * Unless required by applicable law or agreed to in writing, software
     11 + * distributed under the License is distributed on an "AS IS" BASIS,
     12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 + * See the License for the specific language governing permissions and
     14 + * limitations under the License.
     15 + */
     16 + 
     17 +package io.getstream.whatsappclone.model
     18 + 
     19 +data class WhatsAppUserExtensive(
     20 + val whatsappUserList: List<WhatsAppUser>
     21 +)
     22 + 
  • ■ ■ ■ ■ ■ ■
    feature-calls/src/main/kotlin/io/getstream/whatsappclone/calls/WhatsAppCalls.kt
    skipped 20 lines
    21 21  import androidx.compose.runtime.Composable
    22 22  import androidx.compose.runtime.getValue
    23 23  import androidx.lifecycle.compose.collectAsStateWithLifecycle
     24 +import io.getstream.whatsappclone.data.model.WhatsAppUserUiState
    24 25  import io.getstream.whatsappclone.designsystem.component.WhatsAppError
    25 26  import io.getstream.whatsappclone.designsystem.component.WhatsAppLoadingColumn
    26 27  import io.getstream.whatsappclone.navigation.AppComposeNavigator
    skipped 15 lines
    42 43  @Composable
    43 44  private fun WhatsAppCallsScreen(
    44 45   composeNavigator: AppComposeNavigator,
    45  - whatsAppUsersUiState: WhatsAppUiState
     46 + whatsAppUsersUiState: WhatsAppUserUiState
    46 47  ) {
    47 48   when (whatsAppUsersUiState) {
    48  - WhatsAppUiState.Loading -> WhatsAppLoadingColumn()
    49  - WhatsAppUiState.Error -> WhatsAppError()
    50  - is WhatsAppUiState.Success -> {
     49 + WhatsAppUserUiState.Loading -> WhatsAppLoadingColumn()
     50 + WhatsAppUserUiState.Error -> WhatsAppError()
     51 + is WhatsAppUserUiState.Success -> {
    51 52   LazyColumn {
    52 53   items(
    53  - items = whatsAppUsersUiState.whatsAppUsers,
     54 + items = whatsAppUsersUiState.data.whatsappUserList,
    54 55   key = { it.name }
    55 56   ) {
    56 57   WhatsAppCallHistory(whatsAppUser = it) {
    skipped 8 lines
  • ■ ■ ■ ■ ■ ■
    feature-calls/src/main/kotlin/io/getstream/whatsappclone/calls/WhatsAppCallsViewModel.kt
    skipped 18 lines
    19 19  import androidx.lifecycle.ViewModel
    20 20  import androidx.lifecycle.viewModelScope
    21 21  import dagger.hilt.android.lifecycle.HiltViewModel
     22 +import io.getstream.whatsappclone.data.model.WhatsAppUserUiState
    22 23  import io.getstream.whatsappclone.data.repository.CallHistoryRepository
    23  -import io.getstream.whatsappclone.model.WhatsAppUser
     24 +import io.getstream.whatsappclone.model.WhatsAppUserExtensive
    24 25  import kotlinx.coroutines.flow.SharingStarted
    25 26  import kotlinx.coroutines.flow.StateFlow
    26 27  import kotlinx.coroutines.flow.flatMapLatest
    skipped 6 lines
    33 34   callHistoryRepository: CallHistoryRepository
    34 35  ) : ViewModel() {
    35 36   
    36  - val whatsAppUserState: StateFlow<WhatsAppUiState> =
     37 + val whatsAppUserState: StateFlow<WhatsAppUserUiState> =
    37 38   callHistoryRepository.getCallHistoryUsersStream()
    38 39   .flatMapLatest {
    39 40   if (it.isSuccess) {
    40  - flowOf(WhatsAppUiState.Success(it.getOrThrow()))
     41 + flowOf(
     42 + WhatsAppUserUiState.Success(
     43 + WhatsAppUserExtensive(it.getOrThrow())
     44 + )
     45 + )
    41 46   } else {
    42  - flowOf(WhatsAppUiState.Error)
     47 + flowOf(WhatsAppUserUiState.Error)
    43 48   }
    44 49   }
    45 50   .stateIn(
    46 51   scope = viewModelScope,
    47 52   started = SharingStarted.WhileSubscribed(5_000),
    48  - initialValue = WhatsAppUiState.Loading
     53 + initialValue = WhatsAppUserUiState.Loading
    49 54   )
    50 55  }
    51 56   
    52  -sealed interface WhatsAppUiState {
    53  - data class Success(val whatsAppUsers: List<WhatsAppUser>) : WhatsAppUiState
    54  - object Error : WhatsAppUiState
    55  - object Loading : WhatsAppUiState
    56  -}
    57  - 
  • ■ ■ ■ ■ ■
    feature-chats/build.gradle.kts
    skipped 46 lines
    47 47   implementation(project(":core-designsystem"))
    48 48   implementation(project(":core-navigation"))
    49 49   implementation(project(":core-network"))
     50 + implementation(project(":core-data"))
    50 51   
    51 52   // Stream chat Compose
    52 53   api(Dependencies.streamCompose)
    skipped 10 lines
  • ■ ■ ■ ■ ■
    feature-chats/src/main/kotlin/io/getstream/whatsappclone/chats/messages/WhatsAppMessageTopBar.kt
    skipped 38 lines
    39 39  import androidx.lifecycle.compose.collectAsStateWithLifecycle
    40 40  import com.skydoves.landscapist.glide.GlideImage
    41 41  import io.getstream.chat.android.client.ChatClient
     42 +import io.getstream.whatsappclone.data.model.WhatsAppMessageUiState
    42 43  import io.getstream.whatsappclone.designsystem.component.WhatsAppLoadingIndicator
    43 44  import io.getstream.whatsappclone.designsystem.icon.WhatsAppIcons
    44 45  import io.getstream.whatsappclone.designsystem.theme.WhatsAppCloneComposeTheme
    skipped 77 lines
    122 123   modifier = Modifier
    123 124   .size(32.dp)
    124 125   .clip(CircleShape),
    125  - imageModel = messageUiState.channel.image.takeIf { it.isNotEmpty() }
     126 + imageModel = messageUiState.data.image.takeIf { it.isNotEmpty() }
    126 127   ?: io.getstream.whatsappclone.designsystem.R.drawable.stream_logo,
    127 128   previewPlaceholder = io.getstream.whatsappclone.designsystem.R.drawable.placeholder
    128 129   )
    129 130   
    130 131   Text(
    131 132   modifier = Modifier.padding(start = 12.dp),
    132  - text = messageUiState.channel.name,
     133 + text = messageUiState.data.name,
    133 134   color = MaterialTheme.colorScheme.tertiary,
    134 135   style = MaterialTheme.typography.bodyLarge
    135 136   )
    skipped 26 lines
  • ■ ■ ■ ■ ■
    feature-chats/src/main/kotlin/io/getstream/whatsappclone/chats/messages/WhatsAppMessagesViewModel.kt
    skipped 19 lines
    20 20  import androidx.lifecycle.viewModelScope
    21 21  import dagger.hilt.android.lifecycle.HiltViewModel
    22 22  import io.getstream.chat.android.client.ChatClient
    23  -import io.getstream.chat.android.client.models.Channel
    24 23  import io.getstream.chat.android.client.utils.onError
    25 24  import io.getstream.chat.android.client.utils.onSuccess
     25 +import io.getstream.whatsappclone.data.model.WhatsAppMessageUiState
    26 26  import io.getstream.whatsappclone.network.Dispatcher
    27 27  import io.getstream.whatsappclone.network.WhatsAppDispatchers
    28 28  import kotlinx.coroutines.CoroutineDispatcher
    skipped 33 lines
    62 62   class FetchChannel(val channelId: String) : WhatsAppMessageEvent
    63 63  }
    64 64   
    65  -sealed interface WhatsAppMessageUiState {
    66  - data class Success(val channel: Channel) : WhatsAppMessageUiState
    67  - object Loading : WhatsAppMessageUiState
    68  - object Error : WhatsAppMessageUiState
    69  -}
    70  - 
  • previews/preview.mp4
    Binary file.
Please wait...
Page is in error, reload to recover