diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt
index b0873cc33..ebd44b425 100644
--- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt
+++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/communitydetail/CommunityDetailScreen.kt
@@ -26,6 +26,7 @@ import androidx.compose.material.icons.filled.ArrowCircleUp
import androidx.compose.material.icons.filled.ClearAll
import androidx.compose.material.icons.filled.Create
import androidx.compose.material.icons.filled.ExpandLess
+import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Sync
import androidx.compose.material.icons.filled.SyncDisabled
import androidx.compose.material.icons.outlined.AddCircleOutline
@@ -57,10 +58,14 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.input.nestedscroll.nestedScroll
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.core.model.rememberScreenModel
import cafe.adriel.voyager.core.screen.Screen
@@ -70,6 +75,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.communityInfo.CommunityInfoScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CommunityHeader
+import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomDropDown
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.FloatingActionButtonMenu
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.FloatingActionButtonMenuItem
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Option
@@ -97,6 +103,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.persistence.di.getSettingsR
import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick
import com.github.diegoberaldin.raccoonforlemmy.core.utils.rememberCallback
import com.github.diegoberaldin.raccoonforlemmy.core.utils.rememberCallbackArgs
+import com.github.diegoberaldin.raccoonforlemmy.core.utils.toLocalDp
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommentModel
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PostModel
@@ -263,6 +270,93 @@ class CommunityDetailScreen(
contentDescription = null,
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
)
+
+ // options menu
+ Box {
+ val options = listOf(
+ Option(
+ OptionId.Info,
+ stringResource(MR.strings.community_detail_info)
+ ),
+ Option(
+ OptionId.InfoInstance,
+ stringResource(MR.strings.community_detail_instance_info)
+ ),
+ Option(
+ OptionId.Block,
+ stringResource(MR.strings.community_detail_block)
+ ),
+ Option(
+ OptionId.BlockInstance,
+ stringResource(MR.strings.community_detail_block_instance)
+ ),
+ )
+ var optionsExpanded by remember { mutableStateOf(false) }
+ var optionsOffset by remember { mutableStateOf(Offset.Zero) }
+ Image(
+ modifier = Modifier.onGloballyPositioned {
+ optionsOffset = it.positionInParent()
+ }.padding(start = Spacing.s).onClick(
+ rememberCallback {
+ optionsExpanded = true
+ },
+ ),
+ imageVector = Icons.Default.MoreVert,
+ contentDescription = null,
+ colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
+ )
+ CustomDropDown(
+ expanded = optionsExpanded,
+ onDismiss = {
+ optionsExpanded = false
+ },
+ offset = DpOffset(
+ x = optionsOffset.x.toLocalDp(),
+ y = optionsOffset.y.toLocalDp(),
+ ),
+ ) {
+ options.forEach { option ->
+ Text(
+ modifier = Modifier.padding(
+ horizontal = Spacing.m,
+ vertical = Spacing.s,
+ ).onClick(
+ rememberCallback {
+ optionsExpanded = false
+ when (option.id) {
+ OptionId.BlockInstance -> model.reduce(
+ CommunityDetailMviModel.Intent.BlockInstance
+ )
+
+ OptionId.Block -> model.reduce(
+ CommunityDetailMviModel.Intent.Block
+ )
+
+ OptionId.InfoInstance -> {
+ navigationCoordinator.getRootNavigator()
+ ?.push(
+ InstanceInfoScreen(
+ url = uiState.community.instanceUrl,
+ ),
+ )
+ }
+
+ OptionId.Info -> {
+ navigationCoordinator.getBottomNavigator()
+ ?.show(
+ CommunityInfoScreen(uiState.community),
+ )
+ }
+
+ else -> Unit
+ }
+ },
+ ),
+ text = option.text,
+ )
+ }
+ }
+ }
},
navigationIcon = {
val navigator = navigationCoordinator.getRootNavigator()
@@ -381,53 +475,10 @@ class CommunityDetailScreen(
CommunityHeader(
community = uiState.community,
autoLoadImages = uiState.autoLoadImages,
- options = listOf(
- Option(
- OptionId.Info,
- stringResource(MR.strings.community_detail_info)
- ),
- Option(
- OptionId.InfoInstance,
- stringResource(MR.strings.community_detail_instance_info)
- ),
- Option(
- OptionId.Block,
- stringResource(MR.strings.community_detail_block)
- ),
- Option(
- OptionId.BlockInstance,
- stringResource(MR.strings.community_detail_block_instance)
- ),
- ),
onOpenImage = rememberCallbackArgs { url ->
navigationCoordinator.getRootNavigator()
?.push(ZoomableImageScreen(url))
},
- onOptionSelected = rememberCallbackArgs { optionId ->
- when (optionId) {
- OptionId.BlockInstance -> model.reduce(
- CommunityDetailMviModel.Intent.BlockInstance
- )
-
- OptionId.Block -> model.reduce(CommunityDetailMviModel.Intent.Block)
-
- OptionId.InfoInstance -> {
- navigationCoordinator.getRootNavigator()?.push(
- InstanceInfoScreen(
- url = uiState.community.instanceUrl,
- ),
- )
- }
-
- OptionId.Info -> {
- navigationCoordinator.getBottomNavigator()?.show(
- CommunityInfoScreen(uiState.community),
- )
- }
-
- else -> Unit
- }
- },
)
Spacer(modifier = Modifier.height(Spacing.m))
}
diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt
index 34dd7c513..d92595fac 100644
--- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt
+++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommunityHeader.kt
@@ -14,34 +14,24 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CalendarViewMonth
import androidx.compose.material.icons.filled.Group
-import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
-import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.FilterQuality
import androidx.compose.ui.layout.ContentScale
-import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.IconSize
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.utils.getPrettyNumber
import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick
import com.github.diegoberaldin.raccoonforlemmy.core.utils.rememberCallback
-import com.github.diegoberaldin.raccoonforlemmy.core.utils.toLocalDp
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
import dev.icerock.moko.resources.compose.stringResource
@@ -51,8 +41,6 @@ fun CommunityHeader(
community: CommunityModel,
modifier: Modifier = Modifier,
autoLoadImages: Boolean = true,
- options: List