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