fix(Desktop): Hide an unsupported option to Share an item
This commit is contained in:
parent
d92a16d09e
commit
846b71ab28
|
@ -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,16 +52,20 @@ suspend fun createShareAction(
|
||||||
translator: TranslatorScope,
|
translator: TranslatorScope,
|
||||||
text: String,
|
text: String,
|
||||||
navigate: (NavigationIntent) -> Unit,
|
navigate: (NavigationIntent) -> Unit,
|
||||||
) = FlatItemAction(
|
): FlatItemAction? = if (CurrentPlatform.hasShareFeature()) {
|
||||||
leading = icon(Icons.Outlined.Share),
|
FlatItemAction(
|
||||||
trailing = {
|
leading = icon(Icons.Outlined.Share),
|
||||||
ChevronIcon()
|
trailing = {
|
||||||
},
|
ChevronIcon()
|
||||||
title = Res.string.text_action_share_with_title.wrap(),
|
},
|
||||||
onClick = {
|
title = Res.string.text_action_share_with_title.wrap(),
|
||||||
val intent = NavigationIntent.NavigateToShare(
|
onClick = {
|
||||||
text = text,
|
val intent = NavigationIntent.NavigateToShare(
|
||||||
)
|
text = text,
|
||||||
navigate(intent)
|
)
|
||||||
},
|
navigate(intent)
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.artemchep.keyguard.platform
|
||||||
|
|
||||||
|
fun Platform.hasShareFeature(): Boolean = when (this) {
|
||||||
|
is Platform.Mobile -> true
|
||||||
|
is Platform.Desktop -> false
|
||||||
|
}
|
Loading…
Reference in New Issue