Fixing layout issues with premium on ipad.

This commit is contained in:
Samuel Clay 2017-11-16 16:47:01 -08:00
parent dd35142dce
commit 9663f0ff3e
4 changed files with 53 additions and 24 deletions

View file

@ -638,8 +638,9 @@
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[masterContainerViewController dismissViewControllerAnimated:NO completion:nil];
self.modalNavigationController.modalPresentationStyle = UIModalPresentationPageSheet;
premiumNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[masterContainerViewController presentViewController:premiumNavigationController animated:YES completion:nil];
[self.premiumViewController.view setNeedsLayout];
} else {
[navController presentViewController:self.premiumNavigationController animated:YES completion:nil];
}

View file

@ -54,11 +54,6 @@
target: self
action: @selector(closeDialog:)];
[self.navigationItem setLeftBarButtonItem:cancelButton];
UIBarButtonItem *restoreButton = [[UIBarButtonItem alloc] initWithTitle: @"Restore"
style: UIBarButtonItemStylePlain
target: self
action: @selector(restorePurchase:)];
[self.navigationItem setRightBarButtonItem:restoreButton];
self.productsTable.tableFooterView = [UIView new];
self.reasonsTable.tableFooterView = [self makeShilohCell];
@ -67,9 +62,29 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIBarButtonItem *restoreButton = [[UIBarButtonItem alloc] initWithTitle: @"Restore"
style: UIBarButtonItemStylePlain
target: self
action: @selector(restorePurchase:)];
[self.navigationItem setRightBarButtonItem:restoreButton];
self.navigationItem.title = appDelegate.isPremium ? @"Premium Account" : @"Upgrade to Premium";
[self loadProducts];
[self updateTheme];
[confettiView setNeedsLayout];
[confettiView startConfetti];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[confettiView setNeedsLayout];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[confettiView stopConfetti];
}
- (void)closeDialog:(id)sender {
@ -114,8 +129,7 @@
if (appDelegate.isPremium) {
freeView.hidden = YES;
premiumView.hidden = NO;
[confettiView stopConfetti];
[confettiView startConfetti];
self.navigationItem.rightBarButtonItem = nil;
if (appDelegate.premiumExpire != 0) {
NSDate *date = [NSDate dateWithTimeIntervalSince1970:appDelegate.premiumExpire];
@ -157,6 +171,9 @@
}
- (IBAction)restorePurchase:(id)sender {
productsTable.hidden = YES;
spinner.hidden = NO;
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
@ -171,9 +188,11 @@
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
[self finishTransaction:transaction];
break;
return;
}
}
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
@ -209,6 +228,8 @@
NSLog(@"Transaction state -> Cancelled");
//the user cancelled the payment ;(
}
[self informError:@"Transaction failed!"];
productsTable.hidden = NO;
spinner.hidden = YES;
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
@ -233,7 +254,7 @@
appDelegate.url];
NSDictionary *params = @{
@"receipt": [receipt base64EncodedStringWithOptions:0],
@"transaction_identifier": transaction.transactionIdentifier,
@"transaction_identifier": transaction.originalTransaction.transactionIdentifier,
@"product_identifier": transaction.payment.productIdentifier,
};
@ -249,6 +270,7 @@
}
[self loadProducts];
[appDelegate reloadFeedsView:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"Failed to send receipt: %@", params);
productsTable.hidden = NO;

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<device id="ipad9_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
@ -32,17 +32,17 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vys-ne-LmS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<subviews>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="yBE-Kx-Lyj">
<rect key="frame" x="177.5" y="113" width="20" height="20"/>
<rect key="frame" x="374" y="113" width="20" height="20"/>
</activityIndicatorView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="fn0-sC-cuM">
<rect key="frame" x="0.0" y="175" width="375" height="492"/>
<rect key="frame" x="0.0" y="175" width="768" height="849"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="dataSource" destination="-1" id="Hc6-OJ-jhm"/>
@ -50,7 +50,7 @@
</connections>
</tableView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1000" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="0Bc-Oc-gNV">
<rect key="frame" x="0.0" y="95" width="375" height="56"/>
<rect key="frame" x="0.0" y="95" width="768" height="56"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="56" id="Gta-B6-eUD"/>
@ -61,13 +61,13 @@
</connections>
</tableView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" text="Thank you so much for going premium!" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bVF-I1-nis">
<rect key="frame" x="24" y="18" width="327" height="23"/>
<rect key="frame" x="24" y="18" width="720" height="23"/>
<fontDescription key="fontDescription" name="GothamNarrow-Medium" family="Gotham Narrow" pointSize="19"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" text="Your contribution helps keep NewsBlur humming." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wHV-Eo-ith">
<rect key="frame" x="24" y="53" width="327" height="18"/>
<rect key="frame" x="24" y="53" width="720" height="18"/>
<fontDescription key="fontDescription" name="GothamNarrow-Medium" family="Gotham Narrow" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -93,16 +93,16 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rCC-u8-EID">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TFM-k9-HJ2" customClass="SAConfettiView" customModule="NewsBlur" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mVi-67-VUL">
<rect key="frame" x="24" y="182" width="327" height="304"/>
<rect key="frame" x="24" y="400" width="720" height="225.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Thank you for going premium!" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ueU-QC-PqI">
<rect key="frame" x="0.0" y="0.0" width="327" height="101.5"/>
<rect key="frame" x="0.0" y="0.0" width="720" height="51.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="42"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -110,7 +110,7 @@
<size key="shadowOffset" width="0.0" height="1"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Your premium subscription will renew on December 31st, 2018" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kSd-jt-UJ6">
<rect key="frame" x="0.0" y="245.5" width="327" height="58.5"/>
<rect key="frame" x="0.0" y="195.5" width="720" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>

View file

@ -47,7 +47,7 @@ public class SAConfettiView: UIView, CAAnimationDelegate {
@objc public func startConfetti() -> Void {
emitter = CAEmitterLayer()
emitter.emitterPosition = CGPoint(x: frame.size.width / 2.0, y: 0)
emitter.emitterPosition = CGPoint(x: self.center.x, y: 0)
emitter.emitterShape = kCAEmitterLayerLine
emitter.emitterSize = CGSize(width: 40.0, height: 1)
@ -68,6 +68,12 @@ public class SAConfettiView: UIView, CAAnimationDelegate {
emitter.add(animation, forKey: "confettis")
}
override public func layoutSubviews() {
super.layoutSubviews()
emitter.emitterPosition = CGPoint(x: self.center.x, y: 0)
}
@objc public func stopConfetti() {
emitter?.birthRate = 0
}