Skip to content

Commit

Permalink
Merge pull request #88 from IBM/issue-83-icon-width
Browse files Browse the repository at this point in the history
Fix: custom icon width for pop-up icons not working properly
  • Loading branch information
Johny authored May 30, 2022
2 parents d838434 + f43cee6 commit 2ab4b5d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 49 deletions.
11 changes: 5 additions & 6 deletions Notification Agent Popups/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@
<objects>
<viewController identifier="popUpViewController" storyboardIdentifier="popUpViewController" id="XfG-lQ-9wD" customClass="PopUpViewController" customModule="IBM_Notifier_Popup" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="529" height="129"/>
<rect key="frame" x="0.0" y="0.0" width="529" height="128"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vWd-KW-45q">
<rect key="frame" x="23" y="55" width="60" height="60"/>
<rect key="frame" x="23" y="54" width="60" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" identifier="iconHeight" id="0O6-CR-q6S"/>
<constraint firstAttribute="width" constant="60" identifier="iconWidth" id="Jvn-G7-sZe"/>
Expand Down Expand Up @@ -752,9 +752,8 @@ DQ
<action selector="didClickedHelpButton:" target="XfG-lQ-9wD" id="Z2Y-Or-hKJ"/>
</connections>
</button>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="9" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="750" detachesHiddenViews="YES" id="Pyp-Ls-xUg">
<rect key="frame" x="106" y="54" width="400" height="61"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<stackView orientation="vertical" alignment="leading" spacing="9" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="750" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Pyp-Ls-xUg">
<rect key="frame" x="106" y="54" width="400" height="60"/>
</stackView>
</subviews>
<constraints>
Expand Down Expand Up @@ -790,7 +789,7 @@ DQ
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="229"/>
<point key="canvasLocation" x="74.5" y="228.5"/>
</scene>
</scenes>
<resources>
Expand Down
44 changes: 24 additions & 20 deletions Notification Agent Popups/Views/PopUpViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -177,54 +183,54 @@ 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)
self.shouldAllowCancel = progressBarAccessoryView.isUserInterruptionAllowed
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])
}
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 {
NALogger.shared.log("Error while creating accessory view: %{public}@", [error.localizedDescription])
}
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 {
Expand All @@ -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
}
}

Expand Down
42 changes: 21 additions & 21 deletions Notification Agent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand All @@ -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 = "";
Expand All @@ -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";
Expand All @@ -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 = "";
Expand All @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand All @@ -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)";
Expand Down Expand Up @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand All @@ -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)";
Expand Down Expand Up @@ -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" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
],
Expand Down

0 comments on commit 2ab4b5d

Please sign in to comment.