mirror of
https://github.com/bitgapp/eqMac.git
synced 2024-11-22 22:32:17 +03:00
made resizable decision controlled by UI
This commit is contained in:
parent
68489a00c1
commit
8f79b0ffbb
@ -97,7 +97,7 @@ class UI: StoreSubscriber {
|
||||
}
|
||||
|
||||
static var isResizable: Bool {
|
||||
return false
|
||||
return state.resizable
|
||||
}
|
||||
|
||||
static var domain = Constants.UI_ENDPOINT_URL.host!
|
||||
|
@ -204,6 +204,20 @@ class UIDataBus: DataBus {
|
||||
self.isShownChangedListener = UI.isShownChanged.on { isShown in
|
||||
self.send(to: "/shown", data: JSON([ "isShown": isShown ]))
|
||||
}
|
||||
|
||||
self.on(.GET, "/resizable") { _, _ in
|
||||
return [ "resizable": self.state.resizable ]
|
||||
}
|
||||
|
||||
self.on(.POST, "/resizable") { data, _ in
|
||||
guard let resizable = data["resizable"] as? Bool else {
|
||||
throw "Invalid 'resizable' parameter, must be a boolean."
|
||||
}
|
||||
|
||||
Application.dispatchAction(UIAction.setResizable(resizable))
|
||||
|
||||
return "Resizable parameter has been set"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ struct UIState: State {
|
||||
var maxHeight: Double?
|
||||
var maxWidth: Double?
|
||||
@DefaultFalse var fromUI = false
|
||||
@DefaultFalse var resizable = false
|
||||
}
|
||||
|
||||
enum UIAction: Action {
|
||||
@ -57,6 +58,7 @@ enum UIAction: Action {
|
||||
case setMinWidth(Double)
|
||||
case setMaxHeight(Double?)
|
||||
case setMaxWidth(Double?)
|
||||
case setResizable(Bool)
|
||||
}
|
||||
|
||||
func UIStateReducer(action: Action, state: UIState?) -> UIState {
|
||||
@ -89,6 +91,8 @@ func UIStateReducer(action: Action, state: UIState?) -> UIState {
|
||||
state.maxHeight = maxHeight
|
||||
case .setMaxWidth(let maxWidth)?:
|
||||
state.maxWidth = maxWidth
|
||||
case .setResizable(let resizable)?:
|
||||
state.resizable = resizable
|
||||
case .none:
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user