-
Notifications
You must be signed in to change notification settings - Fork 20
/
HomeDestination.kt
119 lines (104 loc) 路 4.29 KB
/
HomeDestination.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*
*/
package com.wire.android.navigation
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.ramcosta.composedestinations.spec.Direction
import com.wire.android.R
import com.wire.android.ui.common.WireBottomNavigationItemData
import com.wire.android.ui.destinations.AllConversationScreenDestination
import com.wire.android.ui.destinations.ArchiveScreenDestination
import com.wire.android.ui.destinations.CallsScreenDestination
import com.wire.android.ui.destinations.MentionScreenDestination
import com.wire.android.ui.destinations.SettingsScreenDestination
import com.wire.android.ui.destinations.VaultScreenDestination
import com.wire.android.ui.destinations.WhatsNewScreenDestination
@Suppress("LongParameterList")
sealed class HomeDestination(
@StringRes val title: Int,
@StringRes val tabName: Int = title,
@DrawableRes val icon: Int,
val isSearchable: Boolean = false,
val withNewConversationFab: Boolean = false,
val direction: Direction
) {
data object Conversations : HomeDestination(
title = R.string.conversations_screen_title,
tabName = R.string.conversations_all_tab_title,
icon = R.drawable.ic_conversation,
isSearchable = true,
withNewConversationFab = true,
direction = AllConversationScreenDestination
)
data object Calls : HomeDestination(
title = R.string.conversations_calls_tab_title,
icon = R.drawable.ic_call,
isSearchable = true,
withNewConversationFab = true,
direction = CallsScreenDestination
)
data object Mentions : HomeDestination(
title = R.string.conversations_mentions_tab_title,
icon = R.drawable.ic_mention,
isSearchable = true,
withNewConversationFab = true,
direction = MentionScreenDestination
)
data object Settings : HomeDestination(
title = R.string.settings_screen_title,
icon = R.drawable.ic_settings,
direction = SettingsScreenDestination
)
data object Vault : HomeDestination(
title = R.string.vault_screen_title,
icon = R.drawable.ic_vault,
direction = VaultScreenDestination
)
data object Archive : HomeDestination(
title = R.string.archive_screen_title,
icon = R.drawable.ic_archive,
isSearchable = true,
direction = ArchiveScreenDestination
)
data object Support : HomeDestination(
title = R.string.support_screen_title,
icon = R.drawable.ic_support,
direction = SupportScreenDestination
)
data object WhatsNew : HomeDestination(
title = R.string.whats_new_screen_title,
icon = R.drawable.ic_star,
direction = WhatsNewScreenDestination
)
val withBottomTabs: Boolean get() = bottomTabItems.contains(this)
fun toBottomNavigationItemData(notificationAmount: Long): WireBottomNavigationItemData =
WireBottomNavigationItemData(icon, tabName, notificationAmount, direction.route)
val itemName: String get() = ITEM_NAME_PREFIX + this
companion object {
// TODO uncomment when CallsScreen and MentionScreen will be implemented
// val bottomTabItems = listOf(Conversations, Calls, Mentions)
val bottomTabItems = listOf<HomeDestination>()
private const val ITEM_NAME_PREFIX = "HomeNavigationItem."
fun fromRoute(fullRoute: String): HomeDestination? =
values().find { it.direction.route.getPrimaryRoute() == fullRoute.getPrimaryRoute() }
fun values(): Array<HomeDestination> =
arrayOf(Conversations, Calls, Mentions, Settings, Vault, Archive, Support, WhatsNew)
}
}