-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: bump uniffi, metadata direct fetch, etc (#9)
* refactor: bump uniffi, metadata direct fetch, etc * chore: make uniffi compilable again * refactor: remove workspace * fix: conform android to refactored uniffi types * fix: it launches * chore: default chains, temporarily block parallel stuff * feat: minimal rpc address input * feat: separate screen for network manager * feat: separate screen for network manager * chore: constructor for Key * fix: network manager screen crash on key * fix: parallel stuff properly, changed jsonrpsee to tungstenite * feat: mwp siltti with bg network fetch * chore: bump rustls library; no wss for now, only ws --------- Co-authored-by: Slesarev <[email protected]>
- Loading branch information
1 parent
1beab55
commit 491b7fb
Showing
39 changed files
with
3,031 additions
and
1,577 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
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
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
37 changes: 18 additions & 19 deletions
37
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
package fi.zymologia.siltti.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.foundation.combinedClickable | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Surface | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.AddCircle | ||
import androidx.compose.material.icons.filled.CheckCircle | ||
import androidx.compose.material.icons.filled.Delete | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import fi.zymologia.siltti.uniffi.SpecsDisplay | ||
import fi.zymologia.siltti.uniffi.SpecsKey | ||
|
||
import fi.zymologia.siltti.uniffi.ChainKey | ||
import fi.zymologia.siltti.uniffi.deleteByKey | ||
import fi.zymologia.siltti.uniffi.requestUpdateByKey | ||
|
||
@OptIn(ExperimentalFoundationApi::class) | ||
@Composable | ||
fun NetworkCard( | ||
networks: MutableState<SpecsDisplay>, | ||
key: SpecsKey | ||
key: ChainKey, | ||
dbName: String, | ||
) { | ||
Surface( | ||
color = MaterialTheme.colors.primary, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(10.dp) | ||
modifier = | ||
Modifier | ||
.fillMaxWidth() | ||
.padding(10.dp), | ||
) { | ||
Row( | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
modifier = Modifier.padding(10.dp) | ||
modifier = Modifier.padding(10.dp), | ||
) { | ||
Text( | ||
networks.value.title(key) ?: "unknown", | ||
color = MaterialTheme.colors.onPrimary | ||
key.substring(0, 64), | ||
color = MaterialTheme.colors.onPrimary, | ||
modifier = Modifier.combinedClickable(onClick = { requestUpdateByKey(key, dbName) }, onLongClick = { deleteByKey(key, dbName) }), | ||
) | ||
Text("Version: " + (networks.value.version(key) ?: "metadata unknown")) | ||
// Text("Version: " + "PUT NETWORK VERSION HERE") | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
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,86 @@ | ||
package fi.zymologia.siltti.screens | ||
|
||
import android.annotation.SuppressLint | ||
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.LaunchedEffect | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.Observer | ||
import fi.zymologia.siltti.Mode | ||
import fi.zymologia.siltti.components.NetworkCard | ||
import fi.zymologia.siltti.uniffi.ChainKey | ||
import fi.zymologia.siltti.uniffi.getAllKeys | ||
import fi.zymologia.siltti.uniffi.isUpdated | ||
import fi.zymologia.siltti.uniffi.requestDefaults | ||
import fi.zymologia.siltti.uniffi.requestFullFetch | ||
import kotlinx.coroutines.delay | ||
|
||
@SuppressLint("UnrememberedMutableState") | ||
@Composable | ||
fun NetworkManager( | ||
dbName: String, | ||
setAppState: (Mode) -> Unit, | ||
) { | ||
val rpcServer = remember { mutableStateOf("") } | ||
|
||
val chainKeys = mutableStateOf(getAllKeys(dbName)) // Yes, I want it recomposed every time for now | ||
|
||
val updated = remember { mutableStateOf(false) } | ||
|
||
LaunchedEffect(updated.value) { | ||
while (!isUpdated(dbName)) { | ||
delay(1000) | ||
} | ||
chainKeys.value = getAllKeys(dbName) | ||
updated.value = !updated.value | ||
} | ||
LazyColumn { | ||
item { | ||
Button( | ||
onClick = { | ||
requestDefaults(); | ||
}, | ||
) { | ||
Text("Add defaults!") | ||
} | ||
} | ||
item{ | ||
Text("Available networks", style = MaterialTheme.typography.h4) | ||
} | ||
this.items( | ||
items = chainKeys.value, | ||
key = { it }, | ||
) { key -> | ||
NetworkCard(key, dbName) | ||
} | ||
item { | ||
TextField(value = rpcServer.value, onValueChange = { rpcServer.value = it }) | ||
} | ||
item { | ||
Button( | ||
onClick = { | ||
requestFullFetch(rpcServer.value) | ||
}, | ||
) { | ||
Text("Add new network") | ||
} | ||
} | ||
item { | ||
Button( | ||
onClick = { | ||
setAppState(Mode.Scan) | ||
}, | ||
) { | ||
Text("Back to scan") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.