diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index fbdf5c5c..b2395e84 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -7,11 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 44604AD729CE196600E62B51 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD629CE196600E62B51 /* Line.swift */; }; 445BA07829C07B3D0036A7C5 /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07729C07B3D0036A7C5 /* Notification.swift */; }; - 44604AD029CE17EC00E62B51 /* NotificationTitleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604ACF29CE17EC00E62B51 /* NotificationTitleModel.swift */; }; - 44604AD229CE180F00E62B51 /* NotificationSubTitleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD129CE180F00E62B51 /* NotificationSubTitleModel.swift */; }; 44604AD429CE186A00E62B51 /* NotificationButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD329CE186A00E62B51 /* NotificationButtonModel.swift */; }; + 44604AD729CE196600E62B51 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD629CE196600E62B51 /* Line.swift */; }; 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */; }; 5FC35BE328D51405004EBEAC /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE228D51405004EBEAC /* Button.swift */; }; EA0FC2C62914222900DF80B4 /* ButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C52914222900DF80B4 /* ButtonGroup.swift */; }; @@ -125,11 +123,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 44604AD629CE196600E62B51 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; 445BA07729C07B3D0036A7C5 /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = ""; }; - 44604ACF29CE17EC00E62B51 /* NotificationTitleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationTitleModel.swift; sourceTree = ""; }; - 44604AD129CE180F00E62B51 /* NotificationSubTitleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSubTitleModel.swift; sourceTree = ""; }; 44604AD329CE186A00E62B51 /* NotificationButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationButtonModel.swift; sourceTree = ""; }; + 44604AD629CE196600E62B51 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Useable.swift; sourceTree = ""; }; 5FC35BE228D51405004EBEAC /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; EA0FC2C52914222900DF80B4 /* ButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroup.swift; sourceTree = ""; }; @@ -255,6 +251,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 445BA07629C07ABA0036A7C5 /* Notification */ = { + isa = PBXGroup; + children = ( + 445BA07729C07B3D0036A7C5 /* Notification.swift */, + 44604AD329CE186A00E62B51 /* NotificationButtonModel.swift */, + ); + path = Notification; + sourceTree = ""; + }; 44604AD529CE195300E62B51 /* Line */ = { isa = PBXGroup; children = ( @@ -263,17 +268,6 @@ path = Line; sourceTree = ""; }; - 445BA07629C07ABA0036A7C5 /* Notification */ = { - isa = PBXGroup; - children = ( - 445BA07729C07B3D0036A7C5 /* Notification.swift */, - 44604ACF29CE17EC00E62B51 /* NotificationTitleModel.swift */, - 44604AD129CE180F00E62B51 /* NotificationSubTitleModel.swift */, - 44604AD329CE186A00E62B51 /* NotificationButtonModel.swift */, - ); - path = Notification; - sourceTree = ""; - }; 5FC35BE128D513EB004EBEAC /* Button */ = { isa = PBXGroup; children = ( @@ -795,7 +789,6 @@ EA33622E2891EA3C0071C351 /* DispatchQueue+Once.swift in Sources */, EA4DB2FD28D3D0CA00103EE3 /* AnyEquatable.swift in Sources */, EAA5EEB728ECC03A003B3210 /* ToolTipLabelAttribute.swift in Sources */, - 44604AD029CE17EC00E62B51 /* NotificationTitleModel.swift in Sources */, EA5E305A29510F8B0082B959 /* EnumSubset.swift in Sources */, EA985BF7296C665E00F2FF2E /* IconName.swift in Sources */, EAF7F0AF289B144C00B287F5 /* UnderlineLabelAttribute.swift in Sources */, @@ -830,7 +823,6 @@ EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */, EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */, EA985C7D297DAED300F2FF2E /* Primitive.swift in Sources */, - 44604AD229CE180F00E62B51 /* NotificationSubTitleModel.swift in Sources */, EAB5FEF829393A7200998C17 /* ButtonGroupConstants.swift in Sources */, EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */, 44604AD729CE196600E62B51 /* Line.swift in Sources */, diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 7b6c358d..5a7f18bc 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -34,6 +34,10 @@ public class Notification: View { } } + public enum ButtonsPosition: String, CaseIterable { + case bottom, right + } + //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- @@ -51,6 +55,14 @@ public class Notification: View { $0.axis = .vertical } + private var labelButtonView = UIStackView().with { + $0.translatesAutoresizingMaskIntoConstraints = false + $0.alignment = .top + $0.distribution = .fillEqually + $0.axis = .vertical + $0.spacing = VDSLayout.Spacing.space2X.value + } + private var edgeSpacing: CGFloat { return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value } @@ -92,7 +104,6 @@ public class Notification: View { open var subTitleText: String? { 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 { @@ -107,11 +118,22 @@ public class Notification: View { } //-------------------------------------------------- - // MARK: - Modal Properties + // MARK: - Properties //-------------------------------------------------- open var type: NotificationStyle = .info { didSet{didChange()}} + var _buttonPosition: ButtonsPosition = .bottom + open var buttonPosition: ButtonsPosition { + set { + if !UIDevice.isIPad, newValue == .right { return } + _buttonPosition = newValue + buttonsView.buttonPosition = _buttonPosition == .right ? .center : .left + didChange() + } + get { _buttonPosition } + } + //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- @@ -159,8 +181,10 @@ public class Notification: View { ]) mainStackView.addArrangedSubview(typeIcon) - mainStackView.addArrangedSubview(labelsView) + mainStackView.addArrangedSubview(labelButtonView) mainStackView.addArrangedSubview(closeButton) + + labelButtonView.addArrangedSubview(labelsView) closeButton.publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in self?.didClickOnCloseButton() @@ -183,6 +207,7 @@ public class Notification: View { type = .info typeIcon.name = .infoBold closeButton.name = .close + buttonPosition = .bottom } //-------------------------------------------------- @@ -251,9 +276,10 @@ public class Notification: View { buttonsView.removeFromSuperview() } else { labelsView.setCustomSpacing(VDSLayout.Spacing.space3X.value, after: subTitleLabel) - ///This below doesn't work + buttonsView.buttons = buttons - labelsView.addArrangedSubview(buttonsView) + labelButtonView.axis = buttonPosition == .bottom ? .vertical : .horizontal + labelButtonView.addArrangedSubview(buttonsView) buttonsView .pinLeading() diff --git a/VDS/Components/Notification/NotificationSubTitleModel.swift b/VDS/Components/Notification/NotificationSubTitleModel.swift deleted file mode 100644 index 19d4c810..00000000 --- a/VDS/Components/Notification/NotificationSubTitleModel.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// NotificationSubTitleModel.swift -// VDS -// -// Created by Nadigadda, Sumanth on 24/03/23. -// - -import Foundation - -extension Notification { - public struct SubTitleModel { - public var text: String - public var textAttributes: [any LabelAttributeModel]? - public var textStyle: TextStyle = .bodySmall - public var numberOfLines: Int - - public init(text: String, - textColor: Use = .primary, - textAttributes: [any LabelAttributeModel]? = nil, - numberOfLines: Int = 0) { - self.text = text - self.textAttributes = textAttributes - self.numberOfLines = numberOfLines - } - } -} diff --git a/VDS/Components/Notification/NotificationTitleModel.swift b/VDS/Components/Notification/NotificationTitleModel.swift deleted file mode 100644 index 31048b4d..00000000 --- a/VDS/Components/Notification/NotificationTitleModel.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// NotificationTitleModel.swift -// VDS -// -// Created by Nadigadda, Sumanth on 24/03/23. -// - -import Foundation - -extension Notification { - public struct TitleModel { - public var text: String - public var textAttributes: [any LabelAttributeModel]? - public var textStyle: TextStyle = .boldBodySmall - public var numberOfLines: Int - - public init(text: String, - textAttributes: [any LabelAttributeModel]? = nil, - numberOfLines: Int = 0) { - self.text = text - self.textAttributes = textAttributes - self.numberOfLines = numberOfLines - } - } -}