diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/MainActivity.kt b/devmenu/src/main/java/com/megboyzz/devmenu/MainActivity.kt index 56b508b..421a887 100644 --- a/devmenu/src/main/java/com/megboyzz/devmenu/MainActivity.kt +++ b/devmenu/src/main/java/com/megboyzz/devmenu/MainActivity.kt @@ -4,8 +4,10 @@ import android.content.Intent import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigator import com.megboyzz.devmenu.ui.components.MainScaffold +import com.megboyzz.devmenu.ui.screens.HomeScreen class MainActivity : ComponentActivity() { @@ -15,6 +17,7 @@ class MainActivity : ComponentActivity() { val intent = Intent(this, gameActivityClass) startActivity(intent) + finish() } @@ -31,17 +34,8 @@ class MainActivity : ComponentActivity() { } setContent { - BottomSheetNavigator { - - } - - MainScaffold( - onSettingsClick = { /*TODO*/ }, - onSearchValueChanged = {}, - onFloatingButtonClick = ::runGame - ) { - + Navigator(HomeScreen(::runGame)) } } } diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/ContextMenu.kt b/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/ContextMenuState.kt similarity index 86% rename from devmenu/src/main/java/com/megboyzz/devmenu/ui/components/ContextMenu.kt rename to devmenu/src/main/java/com/megboyzz/devmenu/ui/components/ContextMenuState.kt index cad40bd..503e1dc 100644 --- a/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/ContextMenu.kt +++ b/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/ContextMenuState.kt @@ -27,10 +27,10 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.megboyzz.devmenu.R import com.megboyzz.devmenu.ui.asPainter +import com.megboyzz.devmenu.ui.entities.FsElementModel @Composable fun ClickableMenuPosition( @@ -95,23 +95,27 @@ fun FsElementInContextMenu( } } +enum class ContextMenuState { + Main, + Delete, + Props +} @Composable fun FileContextMenu( - name: String, - type: ElementType, + fsElementEntity: FsElementModel, onRemoveElement: () -> Unit, onUpdateType: (ElementType) -> ElementType? ) { - var innerType by remember { mutableStateOf(type) } - var isMain by remember { mutableStateOf(true) } + var innerType by remember { mutableStateOf(fsElementEntity.type) } + var state by remember { mutableStateOf(ContextMenuState.Main) } CoreFileContextMenu { - FsElementInContextMenu(name = name, type = type) + FsElementInContextMenu(name = fsElementEntity.name, type = fsElementEntity.type) Divider() - AnimatedBoxForContextMenuContent(isVisible = isMain){ + AnimatedBoxForContextMenuContent(isVisible = state == ContextMenuState.Main){ AnimatedBoxForContextMenuContent(isVisible = innerType == ElementType.isFile) { ClickableMenuPosition( name = "Заменить", @@ -155,11 +159,11 @@ fun FileContextMenu( ClickableMenuPosition( name = "Удалить", icon = R.drawable.trash.asPainter(), - onClick = { isMain = !isMain } + onClick = { state = ContextMenuState.Delete } ) } - AnimatedBoxForContextMenuContent(isVisible = !isMain) { + AnimatedBoxForContextMenuContent(isVisible = state == ContextMenuState.Delete) { ClickableMenuPosition( name = "Удалить", icon = R.drawable.trash.asPainter(), @@ -167,12 +171,25 @@ fun FileContextMenu( ) RemoveFileButtonsGroup( onDelete = onRemoveElement, - onCancel = { isMain = !isMain } + onCancel = { state = ContextMenuState.Main } ) } + + AnimatedBoxForContextMenuContent(isVisible = state == ContextMenuState.Props) { + ClickableMenuPosition( + name = "Свойства", + icon = R.drawable.info.asPainter(), + withEnd = false, + ) + RemoveButton(text = "Назад") { + state = ContextMenuState.Main + } + } } } + + @Composable fun AnimatedBoxForContextMenuContent( isVisible: Boolean, @@ -253,17 +270,3 @@ fun CoreFileContextMenu( } } } - - -@Preview -@Composable -fun ClicablePreview() { - - FileContextMenu( - name = "my_file.txt", - type = ElementType.isFile, - onRemoveElement = {}, - onUpdateType = {null} - ) - -} \ No newline at end of file diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Files.kt b/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Files.kt index a512032..9dbbc8e 100644 --- a/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Files.kt +++ b/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Files.kt @@ -1,34 +1,17 @@ package com.megboyzz.devmenu.ui.components -import android.widget.Toast -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.combinedClickable -import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.ripple.rememberRipple -import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.megboyzz.devmenu.R -import com.megboyzz.devmenu.ui.asPainter -import com.megboyzz.devmenu.ui.theme.DevMenuTheme +import com.megboyzz.devmenu.ui.entities.FsElementModel @Composable fun FsElement( - name: String, - type: ElementType, + fsElementEntity: FsElementModel, onClick: () -> Unit, onLongPressClick: () -> Unit ) { @@ -41,28 +24,7 @@ fun FsElement( onLongClick = onLongPressClick ) ) { - FsElementIcon(type = type) - Text(text = name) + FsElementIcon(type = fsElementEntity.type) + Text(text = fsElementEntity.name) } -} - -@Preview -@Composable -fun FileIcon() { - - val context = LocalContext.current - - Box( - modifier = Modifier - .fillMaxSize() - .background(Color.White) - ) { - FsElement( - name = "my_file.txt", - type = ElementType.isReplaced, - onLongPressClick = {Toast.makeText(context, "long!", Toast.LENGTH_SHORT).show()}, - onClick = {Toast.makeText(context, "one!", Toast.LENGTH_SHORT).show()} - ) - } - } \ No newline at end of file diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Scaffold.kt b/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Scaffold.kt index f78ad73..e4c64fd 100644 --- a/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Scaffold.kt +++ b/devmenu/src/main/java/com/megboyzz/devmenu/ui/components/Scaffold.kt @@ -45,12 +45,13 @@ import com.megboyzz.devmenu.ui.theme.DevMenuTheme @Composable fun MainScaffold( onSettingsClick: () -> Unit, + searchValue: String, onSearchValueChanged: (String) -> Unit, onFloatingButtonClick: () -> Unit, content: @Composable (PaddingValues) -> Unit ) { - var searchValue by remember { mutableStateOf("") } + var searchValue by remember { mutableStateOf(searchValue) } Scaffold( @@ -151,6 +152,7 @@ fun ScaffoldPreview() { MainScaffold( onSettingsClick = { /*TODO*/ }, onSearchValueChanged = {}, + searchValue = "", onFloatingButtonClick = { /*TODO*/ } ) { diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/ui/entities/FsElementModel.kt b/devmenu/src/main/java/com/megboyzz/devmenu/ui/entities/FsElementModel.kt new file mode 100644 index 0000000..303d277 --- /dev/null +++ b/devmenu/src/main/java/com/megboyzz/devmenu/ui/entities/FsElementModel.kt @@ -0,0 +1,11 @@ +package com.megboyzz.devmenu.ui.entities + +import com.megboyzz.devmenu.ui.components.ElementType +import java.util.Date + +data class FsElementModel( + val name: String, + val type: ElementType, + val size: Long, + val date: Date +) diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/ui/screens/FileContextMenuScreen.kt b/devmenu/src/main/java/com/megboyzz/devmenu/ui/screens/FileContextMenuScreen.kt new file mode 100644 index 0000000..aaadbff --- /dev/null +++ b/devmenu/src/main/java/com/megboyzz/devmenu/ui/screens/FileContextMenuScreen.kt @@ -0,0 +1,24 @@ +package com.megboyzz.devmenu.ui.screens + +import androidx.compose.runtime.Composable +import cafe.adriel.voyager.core.screen.Screen +import com.megboyzz.devmenu.ui.components.FileContextMenu +import com.megboyzz.devmenu.ui.entities.FsElementModel + +class FileContextMenuScreen( + private val fsElementModel: FsElementModel, + private val onRemoveFile: () -> Unit, +) : Screen { + @Composable + override fun Content() { + + + + FileContextMenu( + fsElementEntity = fsElementModel, + onRemoveElement = onRemoveFile, + onUpdateType = {null} + ) + + } +} \ No newline at end of file diff --git a/devmenu/src/main/java/com/megboyzz/devmenu/ui/screens/HomeScreen.kt b/devmenu/src/main/java/com/megboyzz/devmenu/ui/screens/HomeScreen.kt new file mode 100644 index 0000000..2138e07 --- /dev/null +++ b/devmenu/src/main/java/com/megboyzz/devmenu/ui/screens/HomeScreen.kt @@ -0,0 +1,57 @@ +package com.megboyzz.devmenu.ui.screens + +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 cafe.adriel.voyager.core.screen.Screen +import cafe.adriel.voyager.navigator.bottomSheet.LocalBottomSheetNavigator +import com.megboyzz.devmenu.ui.components.ElementType +import com.megboyzz.devmenu.ui.components.FsElement +import com.megboyzz.devmenu.ui.components.MainScaffold +import com.megboyzz.devmenu.ui.entities.FsElementModel +import java.util.Date + +class HomeScreen( + private val onFloatingButtonClick: () -> Unit +): Screen { + @Composable + override fun Content() { + + val bottomSheetNavigator = LocalBottomSheetNavigator.current + + var searchValue by remember{ mutableStateOf("") } + + val fsElementModel = FsElementModel( + name = "my_txt.txt", + type = ElementType.isHidden, + size = 123, + date = Date() + ) + + + + MainScaffold( + onSettingsClick = { /*TODO Переход к настройкам */ }, + onSearchValueChanged = { searchValue = it }, + searchValue = searchValue, + onFloatingButtonClick = onFloatingButtonClick + ) { + FsElement( + fsElementEntity = fsElementModel, + onClick = { /*TODO*/ }, + onLongPressClick = { + bottomSheetNavigator.show( + FileContextMenuScreen( + fsElementModel = fsElementModel, + onRemoveFile = {} + ) + ) + } + ) + } + + } + +} \ No newline at end of file