fix(Desktop): Hide an unsupported option to Share an item

This commit is contained in:
Artem Chepurnyi 2024-11-17 09:20:30 +02:00
parent d92a16d09e
commit 846b71ab28
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
2 changed files with 25 additions and 13 deletions

View File

@ -8,6 +8,8 @@ import com.artemchep.keyguard.feature.localization.wrap
import com.artemchep.keyguard.feature.navigation.NavigationIntent import com.artemchep.keyguard.feature.navigation.NavigationIntent
import com.artemchep.keyguard.feature.navigation.state.TranslatorScope import com.artemchep.keyguard.feature.navigation.state.TranslatorScope
import com.artemchep.keyguard.feature.send.add.SendAddRoute import com.artemchep.keyguard.feature.send.add.SendAddRoute
import com.artemchep.keyguard.platform.CurrentPlatform
import com.artemchep.keyguard.platform.hasShareFeature
import com.artemchep.keyguard.res.Res import com.artemchep.keyguard.res.Res
import com.artemchep.keyguard.res.* import com.artemchep.keyguard.res.*
import com.artemchep.keyguard.ui.FlatItemAction import com.artemchep.keyguard.ui.FlatItemAction
@ -50,7 +52,8 @@ suspend fun createShareAction(
translator: TranslatorScope, translator: TranslatorScope,
text: String, text: String,
navigate: (NavigationIntent) -> Unit, navigate: (NavigationIntent) -> Unit,
) = FlatItemAction( ): FlatItemAction? = if (CurrentPlatform.hasShareFeature()) {
FlatItemAction(
leading = icon(Icons.Outlined.Share), leading = icon(Icons.Outlined.Share),
trailing = { trailing = {
ChevronIcon() ChevronIcon()
@ -62,4 +65,7 @@ suspend fun createShareAction(
) )
navigate(intent) navigate(intent)
}, },
) )
} else {
null
}

View File

@ -0,0 +1,6 @@
package com.artemchep.keyguard.platform
fun Platform.hasShareFeature(): Boolean = when (this) {
is Platform.Mobile -> true
is Platform.Desktop -> false
}