added temp ButtonModel
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
05e23f7d58
commit
684a343b0f
@ -13,6 +13,15 @@ import VDSColorTokens
|
||||
/// A VDS Component that will render a view with information
|
||||
public class Notification: View {
|
||||
|
||||
public struct ButtonModel {
|
||||
public var text: String
|
||||
public var onClick: (Button) -> ()
|
||||
public init(text: String, onClick: @escaping (Button) -> Void) {
|
||||
self.text = text
|
||||
self.onClick = onClick
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Enums
|
||||
//--------------------------------------------------
|
||||
@ -87,15 +96,25 @@ public class Notification: View {
|
||||
$0.buttonPosition = .left
|
||||
}
|
||||
|
||||
#warning("we want to add only the things that are needed, everything else should be hidden, meaning don't access controls directly")
|
||||
//Text
|
||||
open var titleText: String? { didSet{didChange()}}
|
||||
|
||||
open var subTitleText: String? { didSet{didChange()}}
|
||||
|
||||
//Buttons (will need to think about this one, probably create a model and follow how Tilelet is working)
|
||||
open var primaryButton: Button? { didSet{didChange()}}
|
||||
#warning("will need to think about this one, probably create a model that has 2 props - text, onClick = (Button) -> () so we are not accessing the button directly. The only reason why I leave it open is for things like accessibility, but not for setting properties outside of this class. More or less follow how Tilelet is working, look at that, below is a temp fix until we can discuss with the guys")
|
||||
//Buttons
|
||||
open var primaryButtonModel: ButtonModel? { didSet{didChange()}}
|
||||
open var primaryButton = Button().with {
|
||||
$0.size = .small
|
||||
$0.use = .primary
|
||||
}
|
||||
|
||||
open var secondaryButton: Button? { didSet{didChange()}}
|
||||
open var secondaryButtonModel: ButtonModel? { didSet{didChange()}}
|
||||
open var secondaryButton = Button().with {
|
||||
$0.size = .small
|
||||
$0.use = .secondary
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Modal Properties
|
||||
@ -208,15 +227,23 @@ public class Notification: View {
|
||||
|
||||
private func updateButtons() {
|
||||
var buttons: [Button] = []
|
||||
if let primaryButton {
|
||||
primaryButton.size = .small
|
||||
primaryButton.use = .primary
|
||||
if let primaryButtonModel {
|
||||
primaryButton.text = primaryButtonModel.text
|
||||
primaryButton.onClickSubscriber = primaryButton
|
||||
.publisher(for: .touchUpInside)
|
||||
.sink(receiveValue: { button in
|
||||
primaryButtonModel.onClick(button)
|
||||
})
|
||||
buttons.append(primaryButton)
|
||||
}
|
||||
|
||||
if let secondaryButton {
|
||||
secondaryButton.size = .small
|
||||
secondaryButton.use = .secondary
|
||||
if let secondaryButtonModel {
|
||||
secondaryButton.text = secondaryButtonModel.text
|
||||
secondaryButton.onClickSubscriber = secondaryButton
|
||||
.publisher(for: .touchUpInside)
|
||||
.sink(receiveValue: { button in
|
||||
secondaryButtonModel.onClick(button)
|
||||
})
|
||||
buttons.append(secondaryButton)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user