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 accountUser = accountUserState?.user
|
||||||
|
|
||||||
val relayViewModel: RelayPoolViewModel = viewModel { RelayPoolViewModel() }
|
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()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
@ -105,8 +106,8 @@ fun MainTopBar(scaffoldState: ScaffoldState, accountViewModel: AccountViewModel)
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
Text(
|
Text(
|
||||||
relayPoolLiveData ?: "--/--",
|
"${connectedRelaysLiveData ?: "--"}/${availableRelaysLiveData ?: "--"}",
|
||||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
color = if (connectedRelaysLiveData == 0) Color.Red else MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||||
)
|
)
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
|
@ -6,7 +6,10 @@ import androidx.lifecycle.ViewModel
|
||||||
import com.vitorpamplona.amethyst.service.relays.RelayPool
|
import com.vitorpamplona.amethyst.service.relays.RelayPool
|
||||||
|
|
||||||
class RelayPoolViewModel: ViewModel() {
|
class RelayPoolViewModel: ViewModel() {
|
||||||
val relayPoolLiveData: LiveData<String> = Transformations.map(RelayPool.live) {
|
val connectedRelaysLiveData: LiveData<Int> = Transformations.map(RelayPool.live) {
|
||||||
it.relays.report()
|
it.relays.connectedRelays()
|
||||||
|
}
|
||||||
|
val availableRelaysLiveData: LiveData<Int> = Transformations.map(RelayPool.live) {
|
||||||
|
it.relays.availableRelays()
|
||||||
}
|
}
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue