mirror of https://github.com/zlatinb/muwire
change button to connect/disconnect
parent
3de058a078
commit
7dc37e3e0d
|
@ -15,6 +15,14 @@ class ChatServerController {
|
|||
|
||||
@ControllerAction
|
||||
void disconnect() {
|
||||
model.core.eventBus.publish(new UIDisconnectChatEvent(host : model.host))
|
||||
switch(model.buttonText) {
|
||||
case "Disconnect" :
|
||||
model.buttonText = "Connect"
|
||||
model.core.eventBus.publish(new UIDisconnectChatEvent(host : model.host))
|
||||
break
|
||||
case "Connect" :
|
||||
model.connect()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ class ChatServerModel {
|
|||
Core core
|
||||
|
||||
@Observable boolean disconnectActionEnabled
|
||||
@Observable String buttonText
|
||||
@Observable ChatConnectionAttemptStatus status
|
||||
|
||||
volatile ChatLink link
|
||||
|
@ -70,6 +71,9 @@ class ChatServerModel {
|
|||
}
|
||||
|
||||
if (e.status == ChatConnectionAttemptStatus.SUCCESSFUL) {
|
||||
runInsideUIAsync {
|
||||
buttonText = "Disconnect"
|
||||
}
|
||||
ChatLink link = e.connection
|
||||
if (link == null)
|
||||
return
|
||||
|
|
|
@ -31,7 +31,7 @@ class ChatServerView {
|
|||
gridLayout(rows : 1, cols : 3)
|
||||
panel {}
|
||||
panel {
|
||||
button(text : "Disconnect", enabled : bind {model.disconnectActionEnabled}, disconnectAction)
|
||||
button(text : bind {model.buttonText}, enabled : bind {model.disconnectActionEnabled}, disconnectAction)
|
||||
}
|
||||
panel {
|
||||
label(text : "Connection Status ")
|
||||
|
|
Loading…
Reference in New Issue