Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing content view in action sheet #262

Merged
merged 2 commits into from May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion Example/Base.lproj/Main.storyboard
Expand Up @@ -486,7 +486,24 @@ running Xcode 7's UI tests</string>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="1 button with accessibility identifier (actionSheet)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="gd0-3a-OKQ">
<rect key="frame" x="16" y="0.0" width="289" height="43.5"/>
<rect key="frame" x="16" y="0.0" width="288" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="F6m-rP-ePd" style="IBUITableViewCellStyleDefault" id="hv8-gm-oYG">
<rect key="frame" x="0.0" y="545" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hv8-gm-oYG" id="3Ix-Zc-CkQ">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="action sheet custom view" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="F6m-rP-ePd">
<rect key="frame" x="16" y="0.0" width="288" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
Expand Down
15 changes: 15 additions & 0 deletions Example/TestsViewController.swift
Expand Up @@ -78,6 +78,21 @@ class TestsViewController: UITableViewController {
alert.addAction(action)
alert.present()

case 11:
let alert = AlertController(title: "Title", message: "Message", preferredStyle: .actionSheet)
let contentView = alert.contentView
let spinner = UIActivityIndicatorView(activityIndicatorStyle: .gray)
spinner.translatesAutoresizingMaskIntoConstraints = false
spinner.startAnimating()
contentView.addSubview(spinner)
spinner.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true
spinner.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true
spinner.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
let action = AlertAction(title: "Cancel", style: .normal)
action.accessibilityIdentifier = "cancel"
alert.addAction(action)
alert.present()

default: break
}
}
Expand Down
7 changes: 7 additions & 0 deletions SDCAlertView UI Tests/SDCAlertView_UI_Tests.swift
Expand Up @@ -138,4 +138,11 @@ class SDCAlertView_UI_Tests: XCTestCase {
XCTAssertTrue(buttonWithIdentifier("button").exists)
self.tapButtonWithIdentifier("button")
}

func testActionSheetWithCustomView() {
self.showAlertAtIndex(11)
XCTAssertTrue(XCUIApplication().activityIndicators["In progress"].exists)
XCTAssertTrue(buttonWithIdentifier("button").exists)
self.tapButtonWithIdentifier("cancel")
}
}
1 change: 1 addition & 0 deletions Source/Views/ActionSheetView.swift
Expand Up @@ -63,6 +63,7 @@ final class ActionSheetView: UIView, AlertControllerViewRepresentable {
let noTextProvided = self.title?.string.isEmpty != false && self.message?.string.isEmpty != false
let contentViewProvided = self.contentView.subviews.count > 0
self.labelsContainer.isHidden = noTextProvided || contentViewProvided
self.contentView.isHidden = !contentViewProvided
}

func addDragTapBehavior() {
Expand Down