From d04f138da466d44945ab2217f5c69da6eba765b1 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Fri, 24 Mar 2023 23:13:37 +0530 Subject: [PATCH] updating notification reset components --- VDS.xcodeproj/project.pbxproj | 12 +++++ .../Notification/Notification.swift | 53 ++++--------------- .../NotificationButtonModel.swift | 19 +++++++ .../NotificationSubTitleModel.swift | 26 +++++++++ .../Notification/NotificationTitleModel.swift | 25 +++++++++ 5 files changed, 91 insertions(+), 44 deletions(-) create mode 100644 VDS/Components/Notification/NotificationButtonModel.swift create mode 100644 VDS/Components/Notification/NotificationSubTitleModel.swift create mode 100644 VDS/Components/Notification/NotificationTitleModel.swift diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 1a695824..e62e7761 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -8,6 +8,9 @@ /* Begin PBXBuildFile section */ 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 */; }; 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 */; }; @@ -122,6 +125,9 @@ /* Begin PBXFileReference section */ 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 = ""; }; 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 = ""; }; @@ -251,6 +257,9 @@ isa = PBXGroup; children = ( 445BA07729C07B3D0036A7C5 /* Notification.swift */, + 44604ACF29CE17EC00E62B51 /* NotificationTitleModel.swift */, + 44604AD129CE180F00E62B51 /* NotificationSubTitleModel.swift */, + 44604AD329CE186A00E62B51 /* NotificationButtonModel.swift */, ); path = Notification; sourceTree = ""; @@ -775,6 +784,7 @@ 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 */, @@ -801,6 +811,7 @@ EAF7F13328A2A16500B287F5 /* AttachmentLabelAttributeModel.swift in Sources */, EA0FC2C62914222900DF80B4 /* ButtonGroup.swift in Sources */, EA89200628B526D6006B9984 /* CheckboxGroup.swift in Sources */, + 44604AD429CE186A00E62B51 /* NotificationButtonModel.swift in Sources */, EAD8D2C128BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift in Sources */, EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */, EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */, @@ -808,6 +819,7 @@ 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 */, EA5E3058295105A40082B959 /* Tilelet.swift in Sources */, diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 0e17f313..46a15ad9 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -12,16 +12,7 @@ import VDSColorTokens @objc(VDSNotification) /// 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 //-------------------------------------------------- @@ -95,8 +86,7 @@ public class Notification: View { open var buttonsView = ButtonGroup().with { $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()}} @@ -183,6 +173,13 @@ public class Notification: View { open override func reset() { super.reset() + + titleLabel.reset() + subTitleLabel.reset() + buttonsView.reset() + primaryButton.reset() + secondaryButton.reset() + type = .info typeIcon.name = .infoBold closeButton.name = .close @@ -267,37 +264,5 @@ public class Notification: View { func didClickOnCloseButton() { print("Notification close button clicked!!!") } - - ///Temporary Place holder - 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 - } - } - - 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/NotificationButtonModel.swift b/VDS/Components/Notification/NotificationButtonModel.swift new file mode 100644 index 00000000..6876aa7c --- /dev/null +++ b/VDS/Components/Notification/NotificationButtonModel.swift @@ -0,0 +1,19 @@ +// +// NotificationButtonModel.swift +// VDS +// +// Created by Nadigadda, Sumanth on 24/03/23. +// + +import Foundation + +extension Notification { + 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 + } + } +} diff --git a/VDS/Components/Notification/NotificationSubTitleModel.swift b/VDS/Components/Notification/NotificationSubTitleModel.swift new file mode 100644 index 00000000..19d4c810 --- /dev/null +++ b/VDS/Components/Notification/NotificationSubTitleModel.swift @@ -0,0 +1,26 @@ +// +// 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 new file mode 100644 index 00000000..31048b4d --- /dev/null +++ b/VDS/Components/Notification/NotificationTitleModel.swift @@ -0,0 +1,25 @@ +// +// 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 + } + } +}