refactor: button name and remove watcher action for now

This commit is contained in:
aro 2022-11-27 18:44:29 +01:00
parent 3008a2a5ef
commit ace8974d3b
2 changed files with 8 additions and 5 deletions

View file

@ -1,6 +1,8 @@
package xyz.atnrch.wrench.components package xyz.atnrch.wrench.components
import androidx.compose.material.Scaffold import androidx.compose.material.Scaffold
import androidx.compose.material.ScaffoldState
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.* import androidx.compose.runtime.*
import xyz.atnrch.wrench.components.center.AddButton import xyz.atnrch.wrench.components.center.AddButton
import xyz.atnrch.wrench.components.top.TopBar import xyz.atnrch.wrench.components.top.TopBar
@ -10,16 +12,18 @@ import xyz.atnrch.wrench.watcher.WatcherManager
@Composable @Composable
fun WrenchScaffold() { fun WrenchScaffold() {
val scaffoldState: ScaffoldState = rememberScaffoldState()
val entries: MutableMap<Int, WatcherEntry> = remember { mutableStateMapOf() } val entries: MutableMap<Int, WatcherEntry> = remember { mutableStateMapOf() }
val watcherManager = remember { WatcherManager(entries) } val watcherManager = remember { WatcherManager(entries) }
val watcher = remember { Watcher(watcherManager) } val watcher = remember { Watcher(watcherManager) }
var buttonState by remember { mutableStateOf(false) } var watcherState by remember { mutableStateOf(false) }
Scaffold( Scaffold(
scaffoldState = scaffoldState,
topBar = { TopBar() }, topBar = { TopBar() },
floatingActionButton = { AddButton(watcherManager) }, floatingActionButton = { AddButton(watcherManager) },
isFloatingActionButtonDocked = true, isFloatingActionButtonDocked = true,
bottomBar = { BottomAppBar(watcher, buttonState) { buttonState = it } } bottomBar = { BottomAppBar(watcher, watcherState) { watcherState = it } }
) { WatcherDisplay(watcherManager) } ) { WatcherDisplay(watcherManager) }
} }

View file

@ -3,7 +3,6 @@ package xyz.atnrch.wrench.watcher
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.swing.Swing import kotlinx.coroutines.swing.Swing
import xyz.atnrch.wrench.logger.Logger import xyz.atnrch.wrench.logger.Logger
import java.nio.file.Files
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
class Watcher(private val watcherManager: WatcherManager) { class Watcher(private val watcherManager: WatcherManager) {
@ -14,7 +13,7 @@ class Watcher(private val watcherManager: WatcherManager) {
private var coroutineScope = CoroutineScope(Dispatchers.Swing) private var coroutineScope = CoroutineScope(Dispatchers.Swing)
fun start() { fun start() {
if(WATCHING) return if (WATCHING) return
coroutineScope.launch { coroutineScope.launch {
WATCHING = true WATCHING = true
@ -23,7 +22,7 @@ class Watcher(private val watcherManager: WatcherManager) {
delay(TimeUnit.SECONDS.toMillis(5)) delay(TimeUnit.SECONDS.toMillis(5))
for (entry: WatcherEntry in watcherManager.getEntries().values) { for (entry: WatcherEntry in watcherManager.getEntries().values) {
entry.map.forEach { entry.map.forEach {
Files.copy(entry.file.toPath(), it.toAbsolutePath()) //Files.copy(entry.file.toPath(), it.toAbsolutePath())
} }
} }
} }