listening for rotation
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
37372c5487
commit
3eeb6f5dcb
@ -50,10 +50,10 @@ public class RadioBoxGroup: Control<DefaultRadioBoxGroupModel>, SelectorGroupSel
|
||||
private var mainStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
$0.alignment = .fill
|
||||
$0.distribution = .fill
|
||||
$0.spacing = 10
|
||||
$0.spacing = 12
|
||||
}
|
||||
}()
|
||||
|
||||
@ -83,6 +83,20 @@ public class RadioBoxGroup: Control<DefaultRadioBoxGroupModel>, SelectorGroupSel
|
||||
mainStackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||
mainStackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
|
||||
mainStackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
||||
|
||||
NotificationCenter.default
|
||||
.publisher(for: UIDevice.orientationDidChangeNotification)
|
||||
.sink() { [weak self] _ in
|
||||
UIView.animate(withDuration: 1.0) {
|
||||
if UIDevice.current.orientation.isPortrait {
|
||||
self?.mainStackView.axis = .vertical
|
||||
self?.mainStackView.distribution = .fill
|
||||
} else {
|
||||
self?.mainStackView.axis = .horizontal
|
||||
self?.mainStackView.distribution = .fillEqually
|
||||
}
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
open override func shouldUpdateView(viewModel: ModelType) -> Bool {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user