feat: minMode into god object
This commit is contained in:
parent
96882e5c84
commit
215e2d3ad7
7 changed files with 39 additions and 26 deletions
|
@ -4,8 +4,8 @@ import androidx.compose.foundation.shape.CornerSize
|
|||
import androidx.compose.material.BottomAppBar
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.bar.NormalFileBottomRow
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.bar.SmallFileBottomRow
|
||||
import xyz.atnrch.wrench.ui.UIColors
|
||||
import xyz.atnrch.wrench.watcher.Watcher
|
||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||
|
@ -13,7 +13,7 @@ import java.nio.file.Path
|
|||
|
||||
@Composable
|
||||
fun AppBottomBar(
|
||||
state: WindowState,
|
||||
minMode: Boolean,
|
||||
watcherManager: WatcherManager,
|
||||
watcher: Watcher,
|
||||
currentClick: Int,
|
||||
|
@ -25,5 +25,10 @@ fun AppBottomBar(
|
|||
CornerSize(percent = 50)
|
||||
),
|
||||
backgroundColor = UIColors.DARK
|
||||
) { NormalFileBottomRow(state, watcherManager, watcher, currentClick, outputs, onCurrentClick) }
|
||||
) {
|
||||
if (minMode)
|
||||
NormalFileBottomRow(watcherManager, watcher, currentClick, outputs, onCurrentClick)
|
||||
else
|
||||
SmallFileBottomRow(watcherManager, watcher, currentClick, outputs, onCurrentClick)
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import androidx.compose.material.TabRow
|
|||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.components.filemanager.FileManagerDisplay
|
||||
import xyz.atnrch.wrench.components.server.ServerManagerDisplay
|
||||
import xyz.atnrch.wrench.ui.UIColors
|
||||
|
@ -15,7 +14,7 @@ import java.nio.file.Path
|
|||
|
||||
@Composable
|
||||
fun WatcherDisplay(
|
||||
state: WindowState,
|
||||
minMode: Boolean,
|
||||
watcherManager: WatcherManager,
|
||||
currentClick: Int,
|
||||
outputs: MutableList<Path>,
|
||||
|
@ -24,7 +23,6 @@ fun WatcherDisplay(
|
|||
tabTitles: List<String>,
|
||||
onTabChange: (id: Int) -> Unit
|
||||
) {
|
||||
|
||||
Column {
|
||||
TabRow(
|
||||
selectedTabIndex = tabIndex,
|
||||
|
@ -38,7 +36,7 @@ fun WatcherDisplay(
|
|||
}
|
||||
}
|
||||
when (tabIndex) {
|
||||
0 -> FileManagerDisplay(state, watcherManager, currentClick, outputs, onEntryClick)
|
||||
0 -> FileManagerDisplay(minMode, watcherManager, currentClick, outputs, onEntryClick)
|
||||
1 -> ServerManagerDisplay()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.compose.material.Scaffold
|
|||
import androidx.compose.material.ScaffoldState
|
||||
import androidx.compose.material.rememberScaffoldState
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.FloatingButton
|
||||
import xyz.atnrch.wrench.components.filemanager.top.TopBar
|
||||
|
@ -23,20 +24,36 @@ fun WrenchScaffold(state: WindowState) {
|
|||
val snackBarDataHolder = SnackBarDataHolder(scaffoldState, rememberCoroutineScope())
|
||||
val watcherManager = remember { WatcherManager(entries) }
|
||||
val watcher = remember { Watcher(watcherManager, snackBarDataHolder) }
|
||||
var currentClick by remember { mutableStateOf(-1) }
|
||||
var tabIndex by remember { mutableStateOf(0) }
|
||||
val tabTitles = listOf("File Manager", "Servers")
|
||||
|
||||
var currentClick by remember { mutableStateOf(-1) }
|
||||
var tabIndex by remember { mutableStateOf(0) }
|
||||
var minMode by remember { mutableStateOf(false) }
|
||||
|
||||
minMode = state.size.width <= 600.dp
|
||||
if(!minMode) {
|
||||
println("MODE: NORMAL MODE")
|
||||
} else {
|
||||
println("MODE: MINMODE")
|
||||
}
|
||||
Scaffold(
|
||||
scaffoldState = scaffoldState,
|
||||
topBar = { TopBar() },
|
||||
floatingActionButton = { if(tabIndex == 0) FloatingButton(watcherManager) },
|
||||
floatingActionButton = { if (tabIndex == 0) FloatingButton(watcherManager) },
|
||||
isFloatingActionButtonDocked = true,
|
||||
backgroundColor = UIColors.PRIMARY,
|
||||
bottomBar = { if(tabIndex == 0) AppBottomBar(state, watcherManager, watcher, currentClick, outputs) { currentClick = it } }
|
||||
bottomBar = {
|
||||
if (tabIndex == 0) AppBottomBar(
|
||||
minMode,
|
||||
watcherManager,
|
||||
watcher,
|
||||
currentClick,
|
||||
outputs
|
||||
) { currentClick = it }
|
||||
}
|
||||
) {
|
||||
WatcherDisplay(
|
||||
state,
|
||||
minMode,
|
||||
watcherManager,
|
||||
currentClick,
|
||||
outputs,
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.components.filemanager.center.empty.DefaultDisplay
|
||||
import xyz.atnrch.wrench.components.filemanager.center.input.InputEntries
|
||||
import xyz.atnrch.wrench.components.filemanager.center.output.OutputEntries
|
||||
|
@ -18,13 +17,13 @@ import java.nio.file.Path
|
|||
|
||||
@Composable
|
||||
fun FileManagerDisplay(
|
||||
state: WindowState,
|
||||
minMode: Boolean,
|
||||
watcherManager: WatcherManager,
|
||||
currentClick: Int,
|
||||
outputs: MutableList<Path>,
|
||||
onEntryClick: (id: Int) -> Unit
|
||||
) {
|
||||
if (state.size.width <= 600.dp) {
|
||||
if (minMode) {
|
||||
Column(
|
||||
modifier = Modifier.padding(0.dp, 0.dp, 0.dp, 55.dp),
|
||||
verticalArrangement = Arrangement.Top,
|
||||
|
|
|
@ -16,13 +16,11 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.ui.UIColors
|
||||
import xyz.atnrch.wrench.watcher.Watcher
|
||||
|
||||
@Composable
|
||||
fun MoveFilesButton(
|
||||
state: WindowState,
|
||||
watcher: Watcher
|
||||
) {
|
||||
Button(
|
||||
|
|
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.width
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.AddOutputButton
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.MoveFilesButton
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.RemoveOutputButton
|
||||
|
@ -15,7 +14,6 @@ import java.nio.file.Path
|
|||
|
||||
@Composable
|
||||
fun NormalFileBottomRow(
|
||||
state: WindowState,
|
||||
watcherManager: WatcherManager,
|
||||
watcher: Watcher,
|
||||
currentClick: Int,
|
||||
|
@ -23,7 +21,7 @@ fun NormalFileBottomRow(
|
|||
onCurrentClick: (Int) -> Unit,
|
||||
) {
|
||||
Spacer(Modifier.width(10.dp))
|
||||
MoveFilesButton(state, watcher)
|
||||
MoveFilesButton(watcher)
|
||||
if (currentClick != -1) {
|
||||
Spacer(Modifier.width(10.dp))
|
||||
AddOutputButton(watcherManager, outputs, currentClick)
|
||||
|
|
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.width
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.AddOutputButton
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.MoveFilesButton
|
||||
import xyz.atnrch.wrench.components.filemanager.bottom.RemoveOutputButton
|
||||
|
@ -15,19 +14,18 @@ import java.nio.file.Path
|
|||
|
||||
@Composable
|
||||
fun SmallFileBottomRow(
|
||||
state: WindowState,
|
||||
watcherManager: WatcherManager,
|
||||
watcher: Watcher,
|
||||
currentClick: Int,
|
||||
outputs: MutableList<Path>,
|
||||
onCurrentClick: (Int) -> Unit,
|
||||
) {
|
||||
Spacer(Modifier.width(10.dp))
|
||||
MoveFilesButton(state, watcher)
|
||||
Spacer(Modifier.width(5.dp))
|
||||
MoveFilesButton(watcher)
|
||||
if (currentClick != -1) {
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Spacer(Modifier.width(5.dp))
|
||||
AddOutputButton(watcherManager, outputs, currentClick)
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Spacer(Modifier.width(5.dp))
|
||||
RemoveOutputButton(watcherManager, outputs, currentClick, onCurrentClick)
|
||||
}
|
||||
}
|
Reference in a new issue