Skip to content

Commit

Permalink
Merge branch 'release-2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Adonis Peralta committed Jul 3, 2018
2 parents a5df920 + c063a6b commit 5795e46
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CustomDesignFilePropertySpecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* **buttonTitleShadowOffsetY**: Amount of pt to offset in y direction the button title text shadow. Numeric.
* **blurBackground**: Enable/disable blurring of the background behind the RMessage. Use in conjunction with
backgroundColorAlpha. Numeric boolean [0, 1]. **Does nothing on devices running iOS7 and below.**
* **disableSpringAnimationPadding**: Enable/disable an extra padding added to the view so as to prevent a visual gap from being displayed when the message is presented with the default spring animation. You most likely want to disable the extra padding when using the following properties: { cornerRadius }.
* **disableSpringAnimationPadding**: Enable/disable an extra padding added to the view so as to prevent a visual gap from being displayed when the message is presented with the default spring animation. You most likely want to disable the extra padding when using the following properties: { cornerRadius }. Numeric boolean [0, 1]. **By default set to 0.**

Property keys are always strings, values can be string or numeric. If specifying a numeric value don't encapsulate the numeric value in a string.
[x,y] Signifies the range of values x to y that are allowed for the field.
Expand Down
5 changes: 5 additions & 0 deletions Example/DemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ - (IBAction)didTapNavbarHidden:(id)sender
self.navigationController.navigationBarHidden = !self.navigationController.navigationBarHidden;
}

- (IBAction)didTapTimedMessage:(id)sender
{
[self performSelector:@selector(didTapMessage:) withObject:nil afterDelay:3.0];
}

/*- (CGFloat)customVerticalOffsetForMessageView:(RMessageView *)messageView
{
return 88.f; // specify an additional offset here.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
24 changes: 20 additions & 4 deletions Example/RMessage/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="PwW-8b-w6J">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="PwW-8b-w6J">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -18,7 +18,7 @@
<viewControllerLayoutGuide type="bottom" id="vLh-xT-m6V"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="dND-ej-UHz">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xp9-HB-Zsl">
Expand Down Expand Up @@ -220,6 +220,14 @@
<rect key="frame" x="97" y="0.0" width="193" height="193"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jxb-9b-qED">
<rect key="frame" x="58" y="481" width="43" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Timed"/>
<connections>
<action selector="didTapTimedMessage:" destination="h0s-uL-LZy" eventType="touchUpInside" id="1eW-k1-C9u"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
Expand All @@ -236,7 +244,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="PwW-8b-w6J" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="G8g-c7-Y0C">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="barTintColor" red="1" green="1" blue="1" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</navigationBar>
Expand Down Expand Up @@ -417,6 +425,14 @@
<action selector="didTapPresentModal:" destination="h0s-uL-LZy" eventType="touchUpInside" id="E5G-dU-8sU"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9dg-6D-MEl">
<rect key="frame" x="36" y="513" width="43" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Timed"/>
<connections>
<action selector="didTapTimedMessage:" destination="1kT-B0-h7w" eventType="touchUpInside" id="OWa-u5-nPC"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
Expand Down
60 changes: 37 additions & 23 deletions Example/RMessageUITests/RootNavigationControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ - (void)setUp
hittablePredicate = [NSPredicate predicateWithFormat:@"hittable == TRUE"];
}

- (CGFloat)springAnimationPaddingForHeight:(CGFloat)height
{
return ceilf(height / 120) * -10.f;
}

- (void)showMessageFromTopByPressingButtonWithName:(NSString *)buttonName
hidingNavBar:(BOOL)hideNavBar
timeToShow:(NSTimeInterval)displayTimeout
Expand All @@ -52,7 +57,8 @@ - (void)showMessageFromTopByPressingButtonWithName:(NSString *)buttonName
[app.buttons[buttonName] tap];
XCUIElement *displayedMessage = app.otherElements[@"RMessageView"];

CGFloat expectedMsgYPosition = hideNavBar ? 0 : navBarFrame.size.height + navBarFrame.origin.y;
CGFloat springAnimationPadding = [self springAnimationPaddingForHeight:displayedMessage.frame.size.height];
CGFloat expectedMsgYPosition = hideNavBar ? springAnimationPadding : navBarFrame.size.height + navBarFrame.origin.y + springAnimationPadding;

BOOL messageDisplayed = [displayedMessage waitForExistenceWithTimeout:displayTimeout];
XCTAssert(messageDisplayed, @"%@ message failed to display", buttonName);
Expand All @@ -78,7 +84,8 @@ - (void)showBottomMessageHidingNavBar:(BOOL)hideNavBar
[app.buttons[@"Bottom"] tap];
XCUIElement *displayedMessage = app.otherElements[@"RMessageView"];

CGFloat expectedMsgYPosition = mainWindowFrame.size.height - displayedMessage.frame.size.height;
CGFloat springAnimationPadding = [self springAnimationPaddingForHeight:displayedMessage.frame.size.height];
CGFloat expectedMsgYPosition = mainWindowFrame.size.height - displayedMessage.frame.size.height - springAnimationPadding;

BOOL messageDisplayed = [displayedMessage waitForExistenceWithTimeout:displayTimeout];
XCTAssert(messageDisplayed, @"Bottom message failed to display");
Expand All @@ -101,7 +108,9 @@ - (void)showEndlessMessageHidingNavBar:(BOOL)hideNavBar timeToShow:(NSTimeInterv
[app.buttons[@"Endless"] tap];
XCUIElement *displayedMessage = app.otherElements[@"RMessageView"];

int expectedMsgYPosition = hideNavBar ? 0 : navBarFrame.size.height + navBarFrame.origin.y;
CGFloat springAnimationPadding = [self springAnimationPaddingForHeight:displayedMessage.frame.size.height];
CGFloat expectedMsgYPosition = hideNavBar ? springAnimationPadding : navBarFrame.size.height + navBarFrame.origin.y + springAnimationPadding;

BOOL messageDisplayed = [displayedMessage waitForExistenceWithTimeout:displayTimeout];
XCTAssert(messageDisplayed, @"Endless message failed to display");

Expand All @@ -114,47 +123,47 @@ - (void)showEndlessMessageHidingNavBar:(BOOL)hideNavBar timeToShow:(NSTimeInterv

- (void)testErrorMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Error" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Error" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testNormalMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Message" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Message" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testWarningMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Warning" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Warning" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testSuccessMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Success" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Success" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testLongMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Text" hidingNavBar:YES timeToShow:3.f timeToHide:15.f];
[self showMessageFromTopByPressingButtonWithName:@"Text" hidingNavBar:YES timeToShow:3.f timeToHide:20.f];
}

- (void)testButtonMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Button" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Button" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testBottomMessageNoNavBar
{
[self showBottomMessageHidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showBottomMessageHidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testCustomMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Custom design" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Custom design" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testImageMessageNoNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Custom image" hidingNavBar:YES timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Custom image" hidingNavBar:YES timeToShow:3.f timeToHide:8.f];
}

- (void)testEndlessMessageNoNavBar
Expand All @@ -164,22 +173,22 @@ - (void)testEndlessMessageNoNavBar

- (void)testErrorMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Error" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Error" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testNormalMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Message" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Message" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testWarningMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Warning" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Warning" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testSuccessMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Success" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Success" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testLongMessageWithNavBar
Expand All @@ -189,22 +198,22 @@ - (void)testLongMessageWithNavBar

- (void)testButtonMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Button" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Button" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testBottomMessageWithNavBar
{
[self showBottomMessageHidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showBottomMessageHidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testCustomMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Custom design" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Custom design" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testImageMessageWithNavBar
{
[self showMessageFromTopByPressingButtonWithName:@"Custom image" hidingNavBar:NO timeToShow:3.f timeToHide:5.f];
[self showMessageFromTopByPressingButtonWithName:@"Custom image" hidingNavBar:NO timeToShow:3.f timeToHide:8.f];
}

- (void)testEndlessMessageWithNavBar
Expand All @@ -220,8 +229,9 @@ - (void)testMessageOverNavBar
BOOL messageDisplayed = [displayedMessage waitForExistenceWithTimeout:3.f];
XCTAssert(messageDisplayed, @"Over navBar message failed to display");

CGFloat springAnimationPadding = [self springAnimationPaddingForHeight:displayedMessage.frame.size.height];
BOOL expectedMessagePositionValid = validateFloatsToScale(displayedMessage.frame.origin.y,
0.f, kMsgYPositionScale);
springAnimationPadding, kMsgYPositionScale);
XCTAssert(expectedMessagePositionValid, "Over navBar message displayed in the wrong position");

XCTestExpectation *expectation = [self expectationForPredicate:notHittablePredicate
Expand Down Expand Up @@ -260,7 +270,9 @@ - (void)testEndlessMessageDismiss

XCUIElement *displayedMessage = app.otherElements[@"RMessageView"];

int expectedMsgYPosition = navBarFrame.size.height + navBarFrame.origin.y;
CGFloat springAnimationPadding = [self springAnimationPaddingForHeight:displayedMessage.frame.size.height];
CGFloat expectedMsgYPosition = navBarFrame.size.height + navBarFrame.origin.y + springAnimationPadding;

BOOL messageDisplayed = [displayedMessage waitForExistenceWithTimeout:3.f];
XCTAssert(messageDisplayed, @"Endless message failed to display");

Expand All @@ -287,7 +299,9 @@ - (void)testTapToDismiss
[app.buttons[@"Error"] tap];
XCUIElement *displayedMessage = app.otherElements[@"RMessageView"];

int expectedMsgYPosition = navBarFrame.size.height + navBarFrame.origin.y;
CGFloat springAnimationPadding = [self springAnimationPaddingForHeight:displayedMessage.frame.size.height];
CGFloat expectedMsgYPosition = navBarFrame.size.height + navBarFrame.origin.y + springAnimationPadding;

BOOL messageDisplayed = [displayedMessage waitForExistenceWithTimeout:3.f];
XCTAssert(messageDisplayed, @"Error message failed to display");

Expand Down
Loading

0 comments on commit 5795e46

Please sign in to comment.