kopia lustrzana https://github.com/vitorpamplona/amethyst
Better info about relays in the Top Nav bar
rodzic
5859ae2c52
commit
353046b451
|
@ -53,7 +53,8 @@ fun MainTopBar(scaffoldState: ScaffoldState, accountViewModel: AccountViewModel)
|
|||
val accountUser = accountUserState?.user
|
||||
|
||||
val relayViewModel: RelayPoolViewModel = viewModel { RelayPoolViewModel() }
|
||||
val relayPoolLiveData by relayViewModel.relayPoolLiveData.observeAsState()
|
||||
val connectedRelaysLiveData by relayViewModel.connectedRelaysLiveData.observeAsState()
|
||||
val availableRelaysLiveData by relayViewModel.availableRelaysLiveData.observeAsState()
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
|
@ -105,8 +106,8 @@ fun MainTopBar(scaffoldState: ScaffoldState, accountViewModel: AccountViewModel)
|
|||
},
|
||||
actions = {
|
||||
Text(
|
||||
relayPoolLiveData ?: "--/--",
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
"${connectedRelaysLiveData ?: "--"}/${availableRelaysLiveData ?: "--"}",
|
||||
color = if (connectedRelaysLiveData == 0) Color.Red else MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
|
||||
IconButton(
|
||||
|
|
|
@ -6,7 +6,10 @@ import androidx.lifecycle.ViewModel
|
|||
import com.vitorpamplona.amethyst.service.relays.RelayPool
|
||||
|
||||
class RelayPoolViewModel: ViewModel() {
|
||||
val relayPoolLiveData: LiveData<String> = Transformations.map(RelayPool.live) {
|
||||
it.relays.report()
|
||||
val connectedRelaysLiveData: LiveData<Int> = Transformations.map(RelayPool.live) {
|
||||
it.relays.connectedRelays()
|
||||
}
|
||||
val availableRelaysLiveData: LiveData<Int> = Transformations.map(RelayPool.live) {
|
||||
it.relays.availableRelays()
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue