diff --git a/Notification Agent Popups/Base.lproj/Main.storyboard b/Notification Agent Popups/Base.lproj/Main.storyboard index 2fa2fa1..d3e8356 100644 --- a/Notification Agent Popups/Base.lproj/Main.storyboard +++ b/Notification Agent Popups/Base.lproj/Main.storyboard @@ -686,11 +686,11 @@ - + - + @@ -752,9 +752,8 @@ DQ - - - + + @@ -790,7 +789,7 @@ DQ - + diff --git a/Notification Agent Popups/Views/PopUpViewController.swift b/Notification Agent Popups/Views/PopUpViewController.swift index bcc5d7e..40e3f27 100644 --- a/Notification Agent Popups/Views/PopUpViewController.swift +++ b/Notification Agent Popups/Views/PopUpViewController.swift @@ -90,6 +90,12 @@ class PopUpViewController: NSViewController { /// Set the title and the description of the popup if defined. private func configureMainLabels() { + if let subtitle = notificationObject?.subtitle { + let maxSubtitleHeight: CGFloat = !(notificationObject.accessoryViews?.isEmpty ?? true) ? 200 : 450 + let textView = MarkdownTextView(withText: subtitle.localized, maxViewHeight: maxSubtitleHeight) + textView.setAccessibilityLabel("popup_accessibility_label_subtitle".localized) + self.popupElementsStackView.insertView(textView, at: 0, in: .top) + } if let title = notificationObject?.title { let titleLabel = NSTextField(wrappingLabelWithString: title.localized) titleLabel.translatesAutoresizingMaskIntoConstraints = false @@ -103,12 +109,8 @@ class PopUpViewController: NSViewController { titleLabel.font = .boldSystemFont(ofSize: fontSize) } self.popupElementsStackView.insertView(titleLabel, at: 0, in: .top) - } - if let subtitle = notificationObject?.subtitle { - let maxSubtitleHeight: CGFloat = !(notificationObject.accessoryViews?.isEmpty ?? true) ? 200 : 450 - let textView = MarkdownTextView(withText: subtitle.localized, maxViewHeight: maxSubtitleHeight) - textView.setAccessibilityLabel("popup_accessibility_label_subtitle".localized) - self.popupElementsStackView.insertView(textView, at: 0, in: .center) + let fitHeight: CGFloat = titleLabel.sizeThatFits(NSSize(width: popupElementsStackView.bounds.width, height: 0)).height + titleLabel.heightAnchor.constraint(equalToConstant: fitHeight).isActive = true } } @@ -136,11 +138,15 @@ class PopUpViewController: NSViewController { // Set icon width and height if specified if let iconWidthAsString = notificationObject.iconWidth, let customWidth = NumberFormatter().number(from: iconWidthAsString) { + iconViewWidth.isActive = false iconViewWidth.constant = CGFloat(truncating: customWidth) + iconViewWidth.isActive = true } if let iconHeightAsString = notificationObject.iconHeight, let customHeight = NumberFormatter().number(from: iconHeightAsString) { + iconViewHeight.isActive = false iconViewHeight.constant = CGFloat(truncating: customHeight) + iconViewHeight.isActive = true } if iconViewHeight.constant != iconViewWidth.constant { iconView.imageScaling = .scaleAxesIndependently @@ -177,13 +183,13 @@ class PopUpViewController: NSViewController { let timerAccessoryView = TimerAccessoryView(withTimeInSeconds: time, label: accessoryView.payload ?? "") timerAccessoryView.translatesAutoresizingMaskIntoConstraints = false timerAccessoryView.timerDelegate = self - self.popupElementsStackView.insertView(timerAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(timerAccessoryView, at: 0, in: .center) case .whitebox: let markdownTextView = MarkdownTextView(withText: accessoryView.payload ?? "", drawsBackground: true) - self.popupElementsStackView.insertView(markdownTextView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(markdownTextView, at: 0, in: .center) case .progressbar: let progressBarAccessoryView = ProgressBarAccessoryView(accessoryView.payload) - self.popupElementsStackView.insertView(progressBarAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(progressBarAccessoryView, at: 0, in: .center) progressBarAccessoryView.progressBarDelegate = self progressBarAccessoryView.delegate = self self.accessoryViews.append(progressBarAccessoryView) @@ -191,17 +197,17 @@ class PopUpViewController: NSViewController { case .image: guard let media = accessoryView.media, media.image != nil else { return } let imageAccessoryView = ImageAccessoryView(with: media) - self.popupElementsStackView.insertView(imageAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(imageAccessoryView, at: 0, in: .center) case .video: guard let media = accessoryView.media, media.player != nil else { return } let videoAccessoryView = VideoAccessoryView(with: media) videoAccessoryView.delegate = self - self.popupElementsStackView.insertView(videoAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(videoAccessoryView, at: 0, in: .center) case .input, .securedinput, .secureinput: do { let inputAccessoryView = try InputAccessoryView(with: accessoryView.payload ?? "", isSecure: accessoryView.type == .securedinput || accessoryView.type == .secureinput) inputAccessoryView.delegate = self - self.popupElementsStackView.insertView(inputAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(inputAccessoryView, at: 0, in: .center) self.accessoryViews.append(inputAccessoryView) } catch { NALogger.shared.log("Error while creating accessory view: %{public}@", [error.localizedDescription]) @@ -209,7 +215,7 @@ class PopUpViewController: NSViewController { case .dropdown: do { let dropDownAccessoryView = try DropDownAccessoryView(with: accessoryView.payload ?? "") - self.popupElementsStackView.insertView(dropDownAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(dropDownAccessoryView, at: 0, in: .center) dropDownAccessoryView.delegate = self self.accessoryViews.append(dropDownAccessoryView) } catch { @@ -217,14 +223,14 @@ class PopUpViewController: NSViewController { } case .html: let htmlAccessoryView = HTMLAccessoryView(withText: accessoryView.payload ?? "", drawsBackground: false) - self.popupElementsStackView.insertView(htmlAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(htmlAccessoryView, at: 0, in: .center) case .htmlwhitebox: let htmlAccessoryView = HTMLAccessoryView(withText: accessoryView.payload ?? "", drawsBackground: true) - self.popupElementsStackView.insertView(htmlAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(htmlAccessoryView, at: 0, in: .center) case .checklist: do { let checklistAccessoryView = try CheckListAccessoryView(with: accessoryView.payload ?? "") - self.popupElementsStackView.insertView(checklistAccessoryView, at: 0, in: .bottom) + self.popupElementsStackView.insertView(checklistAccessoryView, at: 0, in: .center) checklistAccessoryView.delegate = self self.accessoryViews.append(checklistAccessoryView) } catch { @@ -235,10 +241,8 @@ class PopUpViewController: NSViewController { /// Check the stack view distribution based on the number of the arrangedSubviews. private func checkStackViewLayout() { - if self.popupElementsStackView.arrangedSubviews.count == 1 { - self.popupElementsStackView.distribution = .equalSpacing - } else { - self.popupElementsStackView.distribution = .gravityAreas + if self.accessoryViews.isEmpty { + self.popupElementsStackView.distribution = .fillEqually } } diff --git a/Notification Agent.xcodeproj/project.pbxproj b/Notification Agent.xcodeproj/project.pbxproj index 0966724..1ea2d50 100644 --- a/Notification Agent.xcodeproj/project.pbxproj +++ b/Notification Agent.xcodeproj/project.pbxproj @@ -1350,7 +1350,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Alerts/Info.plist"; @@ -1359,7 +1359,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.alert; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1378,7 +1378,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Alerts/Info.plist"; @@ -1387,7 +1387,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.alert; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1406,7 +1406,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Popups/Info.plist"; @@ -1415,7 +1415,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.popup; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1434,7 +1434,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Popups/Info.plist"; @@ -1443,7 +1443,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.popup; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1462,7 +1462,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Onboarding/Info.plist"; @@ -1471,7 +1471,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.onboarding; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1489,7 +1489,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Onboarding/Info.plist"; @@ -1498,7 +1498,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.onboarding; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1516,7 +1516,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Banners/Info.plist"; @@ -1525,7 +1525,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.banner; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1544,7 +1544,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Banners/Info.plist"; @@ -1553,7 +1553,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier.banner; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1689,7 +1689,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Core/Info.plist"; @@ -1698,7 +1698,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1716,7 +1716,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Notification Agent Core/Info.plist"; @@ -1725,7 +1725,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 2.7.0; + MARKETING_VERSION = 2.7.1; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.ibm.cio.notifier; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1799,7 +1799,7 @@ repositoryURL = "https://github.com/SimonFairbairn/SwiftyMarkdown"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.2.3; + minimumVersion = 1.2.4; }; }; B9A1425625D68DC500E87AD6 /* XCRemoteSwiftPackageReference "Swift-JWT" */ = { diff --git a/Notification Agent.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Notification Agent.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6846c7c..41d38db 100644 --- a/Notification Agent.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Notification Agent.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SimonFairbairn/SwiftyMarkdown", "state" : { - "revision" : "5b0a1e76332a633726f9f9a00b4bbd840166bccf", - "version" : "1.2.3" + "revision" : "dde451ab4ed9b77b328e21baa471fdfa0cf61369", + "version" : "1.2.4" } } ],