forked from Kalapaja/siltti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kalapaja#7 from Slesarew/as-network-manager-screen
feat: separate screen for network manager
- Loading branch information
Showing
5 changed files
with
151 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 6 additions & 13 deletions
19
app/src/main/java/fi/zymologia/siltti/components/NetworkCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
app/src/main/java/fi/zymologia/siltti/screens/NetworkManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package fi.zymologia.siltti.screens | ||
|
||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextField | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import fi.zymologia.siltti.Mode | ||
import fi.zymologia.siltti.components.NetworkCard | ||
import fi.zymologia.siltti.uniffi.Selector | ||
|
||
@Composable | ||
fun NetworkManager( | ||
dbName: String, | ||
setAppState: (Mode) -> Unit, | ||
) { | ||
val networks = remember { mutableStateOf(Selector(dbName)) } | ||
|
||
val rpcServer = remember { mutableStateOf("") } | ||
|
||
LazyColumn { | ||
item { | ||
Button( | ||
onClick = { | ||
networks.value.setupDefaults(dbName) | ||
}, | ||
) { | ||
Text("Add defaults!") | ||
} | ||
} | ||
item{ | ||
Text("Available networks", style = MaterialTheme.typography.h4) | ||
} | ||
this.items( | ||
items = networks.value.getAllKeys(), | ||
key = { it }, | ||
) { key -> | ||
NetworkCard(networks, key) | ||
} | ||
item { | ||
TextField(value = rpcServer.value, onValueChange = { rpcServer.value = it }) | ||
} | ||
item { | ||
Button( | ||
onClick = { | ||
networks.value.addNewElement(rpcServer.value, dbName) | ||
}, | ||
) { | ||
Text("Add new network") | ||
} | ||
} | ||
item { | ||
Button( | ||
onClick = { | ||
setAppState(Mode.TX) | ||
}, | ||
) { | ||
Text("Back to scan") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters