forked from melod1n/fast-messenger
36a119ffa9
- In `ConversationsScreen`, removed `isNeedToScrollToTop` and `onScrolledToTop`, and refactored toolbar container color logic. Added `NoItemsView` for empty conversation lists. - In `MainGraph`, added `onMessageClicked` for navigation to message history. - In `ApiEvent`, introduced `parseOrNull` for handling unknown event types. - In `ConversationsViewModel`, removed `scrollToTop` logic and refactored error handling. - In `FriendsViewModel`, refactored error handling and introduced `onErrorConsumed` and `handleError`. - In `FriendItem`, added an icon button to initiate sending a message to a friend. - In `strings.xml`, added or updated strings for session expiration, log out, refreshing, and empty friend lists. - In `RootScreen`, added `onMessageClicked` for navigating to messages. - In `FriendsList`, added `onMessageClicked` for handling message clicks. - In `MainScreen`, removed unused `MutableSharedFlow`. - In `FriendsScreen`, added support for showing errors, added `onMessageClicked`, and replaced `hazeChild` with `hazeEffect` and `hazeSource`. - In `FriendsNavigation`, added `onMessageClicked` for handling message clicks. - In `ConversationsNavigation`, removed the unused `scrollToTopFlow` parameter. - In `ErrorView`, added text alignment. - In `NoItemsView`, added support for a button and custom text. - In `LongPollUpdatesParser`, replaced try-catch with `parseOrNull`.
63 lines
2.1 KiB
Kotlin
63 lines
2.1 KiB
Kotlin
package dev.meloda.fast.navigation
|
|
|
|
import androidx.navigation.NavGraphBuilder
|
|
import androidx.navigation.compose.composable
|
|
import dev.meloda.fast.MainViewModel
|
|
import dev.meloda.fast.conversations.navigation.Conversations
|
|
import dev.meloda.fast.friends.navigation.Friends
|
|
import dev.meloda.fast.model.BaseError
|
|
import dev.meloda.fast.model.BottomNavigationItem
|
|
import dev.meloda.fast.presentation.MainScreen
|
|
import dev.meloda.fast.profile.navigation.Profile
|
|
import dev.meloda.fast.ui.util.ImmutableList
|
|
import kotlinx.serialization.Serializable
|
|
import dev.meloda.fast.ui.R as UiR
|
|
|
|
@Serializable
|
|
object MainGraph
|
|
|
|
@Serializable
|
|
object Main
|
|
|
|
fun NavGraphBuilder.mainScreen(
|
|
onError: (BaseError) -> Unit,
|
|
onSettingsButtonClicked: () -> Unit,
|
|
onConversationClicked: (conversationId: Int) -> Unit,
|
|
onPhotoClicked: (url: String) -> Unit,
|
|
onMessageClicked: (userId: Int) -> Unit,
|
|
viewModel: MainViewModel
|
|
) {
|
|
val navigationItems = ImmutableList.of(
|
|
BottomNavigationItem(
|
|
titleResId = UiR.string.title_friends,
|
|
selectedIconResId = UiR.drawable.baseline_people_alt_24,
|
|
unselectedIconResId = UiR.drawable.outline_people_alt_24,
|
|
route = Friends,
|
|
),
|
|
BottomNavigationItem(
|
|
titleResId = UiR.string.title_conversations,
|
|
selectedIconResId = UiR.drawable.baseline_chat_24,
|
|
unselectedIconResId = UiR.drawable.outline_chat_24,
|
|
route = Conversations
|
|
),
|
|
BottomNavigationItem(
|
|
titleResId = UiR.string.title_profile,
|
|
selectedIconResId = UiR.drawable.baseline_account_circle_24,
|
|
unselectedIconResId = UiR.drawable.outline_account_circle_24,
|
|
route = Profile
|
|
)
|
|
)
|
|
|
|
composable<Main> {
|
|
MainScreen(
|
|
navigationItems = navigationItems,
|
|
onError = onError,
|
|
onSettingsButtonClicked = onSettingsButtonClicked,
|
|
onConversationItemClicked = onConversationClicked,
|
|
onPhotoClicked = onPhotoClicked,
|
|
onMessageClicked = onMessageClicked,
|
|
viewModel = viewModel
|
|
)
|
|
}
|
|
}
|