Skip to content

Commit 11c6494

Browse files
committed
removed hardcoded compose navigator from composable.
1 parent b4fdc4b commit 11c6494

File tree

12 files changed

+57
-34
lines changed

12 files changed

+57
-34
lines changed

app/src/main/kotlin/io/getstream/whatsappclone/navigation/WhatsAppNavigation.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package io.getstream.whatsappclone.navigation
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.material3.Scaffold
2121
import androidx.compose.ui.Modifier
22-
import androidx.hilt.navigation.compose.hiltViewModel
2322
import androidx.navigation.NavGraphBuilder
2423
import androidx.navigation.compose.composable
2524
import io.getstream.whatsappclone.calls.info.WhatsAppCallHistoryInfo
@@ -28,8 +27,7 @@ import io.getstream.whatsappclone.model.WhatsAppUser
2827
import io.getstream.whatsappclone.ui.WhatsAppTabPager
2928
import io.getstream.whatsappclone.ui.WhatsAppTopBar
3029

31-
fun NavGraphBuilder.whatsAppHomeNavigation(
32-
) {
30+
fun NavGraphBuilder.whatsAppHomeNavigation() {
3331
composable(route = WhatsAppScreens.Home.name) {
3432
Scaffold(topBar = { WhatsAppTopBar() }) { padding ->
3533
WhatsAppTabPager(
@@ -44,9 +42,9 @@ fun NavGraphBuilder.whatsAppHomeNavigation(
4442
) {
4543
val channelId = it.arguments?.getString("channelId") ?: return@composable
4644
WhatsAppMessages(
47-
channelId = channelId,
45+
channelId = channelId
4846

49-
)
47+
)
5048
}
5149

5250
composable(
@@ -57,7 +55,7 @@ fun NavGraphBuilder.whatsAppHomeNavigation(
5755
?: return@composable
5856

5957
WhatsAppCallHistoryInfo(
60-
whatsAppUser = whatsAppUser,
61-
)
58+
whatsAppUser = whatsAppUser
59+
)
6260
}
6361
}

app/src/main/kotlin/io/getstream/whatsappclone/ui/WhatsAppTabPager.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import io.getstream.whatsappclone.designsystem.component.WhatsAppCloneBackground
3838
import io.getstream.whatsappclone.designsystem.icon.WhatsAppIcons
3939
import io.getstream.whatsappclone.designsystem.theme.WHITE200
4040
import io.getstream.whatsappclone.designsystem.theme.getTabPrimaryColor
41-
import io.getstream.whatsappclone.navigation.AppComposeNavigator
4241
import io.getstream.whatsappclone.navigation.TOP_LEVEL_DESTINATIONS
4342
import io.getstream.whatsappclone.navigation.WhatsAppPage
4443
import io.getstream.whatsappclone.navigation.WhatsAppPagerContent

features/calls/src/main/kotlin/io/getstream/whatsappclone/calls/WhatsAppCalls.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun WhatsAppCalls(
4242
@Composable
4343
private fun WhatsAppCallsScreen(
4444
whatsAppUsersUiState: WhatsAppUserUiState,
45-
onHistoryItemClick: (WhatsAppUser) -> Unit,
45+
onHistoryItemClick: (WhatsAppUser) -> Unit
4646
) {
4747
when (whatsAppUsersUiState) {
4848
WhatsAppUserUiState.Loading -> WhatsAppLoadingColumn()

features/calls/src/main/kotlin/io/getstream/whatsappclone/calls/WhatsAppCallsViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import io.getstream.whatsappclone.navigation.AppComposeNavigator
2626
import io.getstream.whatsappclone.navigation.WhatsAppScreens
2727
import io.getstream.whatsappclone.uistate.WhatsAppUserExtensive
2828
import io.getstream.whatsappclone.uistate.WhatsAppUserUiState
29+
import javax.inject.Inject
2930
import kotlinx.coroutines.flow.StateFlow
3031
import kotlinx.coroutines.flow.flatMapLatest
3132
import kotlinx.coroutines.flow.flowOf
3233
import kotlinx.coroutines.flow.stateIn
33-
import javax.inject.Inject
3434

3535
@HiltViewModel
3636
class WhatsAppCallsViewModel @Inject constructor(

features/calls/src/main/kotlin/io/getstream/whatsappclone/calls/info/WhatsAppCallHistoryInfo.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import androidx.compose.runtime.Composable
2323
import androidx.compose.ui.Modifier
2424
import androidx.hilt.navigation.compose.hiltViewModel
2525
import io.getstream.whatsappclone.model.WhatsAppUser
26-
import io.getstream.whatsappclone.navigation.AppComposeNavigator
2726

2827
@Composable
2928
fun WhatsAppCallHistoryInfo(

features/calls/src/main/kotlin/io/getstream/whatsappclone/calls/info/WhatsAppCallHistoryInfoBody.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import androidx.compose.ui.Modifier
2828
import androidx.compose.ui.draw.clip
2929
import androidx.compose.ui.unit.dp
3030
import androidx.constraintlayout.compose.ConstraintLayout
31-
import androidx.hilt.navigation.compose.hiltViewModel
3231
import com.skydoves.landscapist.glide.GlideImage
3332
import io.getstream.whatsappclone.designsystem.R
3433
import io.getstream.whatsappclone.designsystem.icon.WhatsAppIcons
@@ -41,7 +40,7 @@ import java.util.Date
4140
@Composable
4241
fun WhatsAppCallHistoryInfoBody(
4342
modifier: Modifier,
44-
whatsAppUser: WhatsAppUser,
43+
whatsAppUser: WhatsAppUser
4544

4645
) {
4746
ConstraintLayout(modifier = modifier.padding(12.dp)) {

features/calls/src/main/kotlin/io/getstream/whatsappclone/calls/info/WhatsAppCallHistoryTopBar.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import androidx.compose.ui.unit.dp
3232
import io.getstream.whatsappclone.calls.R
3333
import io.getstream.whatsappclone.designsystem.icon.WhatsAppIcons
3434
import io.getstream.whatsappclone.designsystem.theme.WhatsAppCloneComposeTheme
35-
import io.getstream.whatsappclone.navigation.AppComposeNavigator
36-
import io.getstream.whatsappclone.navigation.WhatsAppCloneComposeNavigator
3735

3836
@Composable
3937
fun WhatsAppCallHistoryTopBar(
@@ -44,10 +42,10 @@ fun WhatsAppCallHistoryTopBar(
4442
navigationIcon = {
4543
Icon(
4644
modifier = Modifier
47-
.size(26.dp)
48-
.clickable {
49-
onBackClick()
50-
},
45+
.size(26.dp)
46+
.clickable {
47+
onBackClick()
48+
},
5149
imageVector = WhatsAppIcons.ArrowBack,
5250
tint = MaterialTheme.colorScheme.tertiary,
5351
contentDescription = null
@@ -93,7 +91,8 @@ private fun WhatsAppCallHistoryTopBarPreview() {
9391
@Composable
9492
private fun WhatsAppCallHistoryTopBarDarkPreview() {
9593
WhatsAppCloneComposeTheme(darkTheme = true) {
96-
WhatsAppCallHistoryTopBar(onBackClick = {}
94+
WhatsAppCallHistoryTopBar(
95+
onBackClick = {}
9796
)
9897
}
9998
}

features/calls/src/main/kotlin/io/getstream/whatsappclone/calls/info/WhatsAppCallHistoryViewModel.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2023 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+
117
package io.getstream.whatsappclone.calls.info
218

319
import androidx.lifecycle.ViewModel
@@ -10,7 +26,6 @@ class WhatsAppCallHistoryViewModel @Inject constructor(
1026
private val composeNavigator: AppComposeNavigator
1127
) : ViewModel() {
1228

13-
1429
fun navigateUp() {
1530
composeNavigator.navigateUp()
1631
}
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2023 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+
117
package io.getstream.whatsappclone.chats.channels
218

319
import androidx.lifecycle.ViewModel
@@ -8,13 +24,10 @@ import javax.inject.Inject
824

925
@HiltViewModel
1026
class WhatsChannelsViewModel @Inject constructor(
11-
private val composeNavigator: AppComposeNavigator,
27+
private val composeNavigator: AppComposeNavigator
1228
) : ViewModel() {
1329

14-
1530
fun navigateToMessages(channelId: String) {
1631
composeNavigator.navigate(WhatsAppScreens.Messages.createRoute(channelId))
1732
}
18-
19-
2033
}

features/chats/src/main/kotlin/io/getstream/whatsappclone/chats/messages/WhatsAppMessageTopBar.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ fun WhatsAppMessageTopBar(
4646
messageUiState: WhatsAppMessageUiState,
4747
onBackClick: () -> Unit
4848
) {
49-
50-
5149
SmallTopAppBar(
5250
modifier = Modifier.fillMaxWidth(),
5351
navigationIcon = {

0 commit comments

Comments
 (0)