Skip to content

Commit

Permalink
v1.0 complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley Richards committed Nov 4, 2016
1 parent fee6100 commit a934fe4
Show file tree
Hide file tree
Showing 29 changed files with 261 additions and 111 deletions.
8 changes: 2 additions & 6 deletions ARWhatsNew/ARWhatsNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
#import <UIKit/UIKit.h>

@interface ARWhatsNew : UIViewController

-(instancetype)initCheckAppVersion;

// Background color
@property UIColor *primaryColor;
// Button background color
@property UIColor *secondaryColor;
// "Whats New", "In Version vX", "Release Notes" and version notes text color.
@property UIColor *primaryTextColor;
// Show the Release Notes
@property NSString *releaseNotes;
// Change default for button instade of 'Get Started'.
@property NSString *acceptButtonText;
// Disable "Get Started" button from being disabled until user scrolls to bottom.
@property BOOL disableReadAllRequired;

-(void)resetWhatsNew;
-(NSString*)appVersion;
-(BOOL)whatsNewAlreadyShown;
-(BOOL)whatsNewNotShown;

@end
70 changes: 48 additions & 22 deletions ARWhatsNew/ARWhatsNew.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,36 @@ @interface ARWhatsNew ()

@implementation ARWhatsNew

-(instancetype)initCheckAppVersion {
self = [super initWithNibName:NSStringFromClass([ARWhatsNew class]) bundle:nil];
if (self) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
self.modalPresentationStyle = UIModalPresentationFormSheet;
}
}
-(instancetype)init {
self.modalPresentationStyle = UIModalPresentationFormSheet;

return self;
}

-(void)viewDidLoad {
[super viewDidLoad];

if (self.primaryColor != nil) {
self.view.backgroundColor = self.primaryColor;
self.acceptButton.titleLabel.textColor = self.primaryColor;
}
if (self.secondaryColor != nil) {
self.acceptButton.backgroundColor = self.secondaryColor;
}
if (self.primaryTextColor != nil) {
self.labelWhatsNew.textColor = self.primaryTextColor;
self.labelInVersion.textColor = self.primaryTextColor;
self.labelReleaseNotes.textColor = self.primaryTextColor;
self.textViewNotes.textColor = self.primaryTextColor;
}

self.labelWhatsNew.textColor = [self readableForegroundColorForBackgroundColor:self.primaryColor];
self.labelInVersion.textColor = [self readableForegroundColorForBackgroundColor:self.primaryColor];
self.labelReleaseNotes.textColor = [self readableForegroundColorForBackgroundColor:self.primaryColor];
self.textViewNotes.textColor = [self readableForegroundColorForBackgroundColor:self.primaryColor];
[self.acceptButton setTitleColor:[self readableForegroundColorForBackgroundColor:self.secondaryColor]
forState:UIControlStateNormal];

self.textViewNotes.font = [UIFont systemFontOfSize:18];

// Set and localise visible text
[self.labelWhatsNew setText:NSLocalizedString(@"WHATS NEW",)];
[self.textViewNotes setText:[NSString stringWithFormat:NSLocalizedString(@"IN VERSION %@",), [self appVersion]]];

NSString *ver = [NSString stringWithFormat:@"IN VERSION %@", [self appVersion]];
[self.labelInVersion setText:NSLocalizedString(ver, nil)];

// Set and localise release notes in textView
[self.textViewNotes setText:NSLocalizedString(self.releaseNotes,)];
Expand All @@ -67,10 +67,27 @@ -(void)viewDidLoad {
}

[self.acceptButton setEnabled:self.disableReadAllRequired];
}

-(IBAction)GetStarted:(id)sender {
NSString *verString = [NSString stringWithFormat:@"whatsNew_%@", [self appVersion]];

[super viewDidLoad];
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:verString];
[[NSUserDefaults standardUserDefaults] synchronize];

[self dismissViewControllerAnimated:YES completion:NULL];
}

-(void)resetWhatsNew {
NSString *verString = [NSString stringWithFormat:@"whatsNew_%@", [self appVersion]];
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:verString];
[[NSUserDefaults standardUserDefaults] synchronize];
}

-(void)viewDidLayoutSubviews {
// Scrolls TextView to the top.
[self.textViewNotes setContentOffset:CGPointZero animated:NO];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
// AcceptButtonText is disabled until user reads the entire version log unless disableReadAllRequired is set to YES
Expand All @@ -79,19 +96,28 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
}
}

-(IBAction)GetStarted:(id)sender {
NSString *verString = [NSString stringWithFormat:@"whatsNew_%@", [self appVersion]];
- (UIColor *)readableForegroundColorForBackgroundColor:(UIColor*)backgroundColor {
size_t count = CGColorGetNumberOfComponents(backgroundColor.CGColor);
const CGFloat *componentColors = CGColorGetComponents(backgroundColor.CGColor);

[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:verString];
[[NSUserDefaults standardUserDefaults] synchronize];
CGFloat darknessScore = 0;
if (count == 2) {
darknessScore = (((componentColors[0]*255) * 299) + ((componentColors[0]*255) * 587) + ((componentColors[0]*255) * 114)) / 1000;
} else if (count == 4) {
darknessScore = (((componentColors[0]*255) * 299) + ((componentColors[1]*255) * 587) + ((componentColors[2]*255) * 114)) / 1000;
}

[self dismissViewControllerAnimated:YES completion:NULL];
if (darknessScore >= 125) {
return [UIColor blackColor];
}

return [UIColor whiteColor];
}

-(NSString *)appVersion {
return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
}
-(BOOL)whatsNewAlreadyShown {
-(BOOL)whatsNewNotShown {
return ![[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"whatsNew_%@", [self appVersion]]] boolValue];
}

Expand Down
43 changes: 20 additions & 23 deletions ARWhatsNew/ARWhatsNew.xib
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="NO">
<dependencies>
<deployment identifier="iOS"/>
<deployment version="1792" identifier="iOS"/>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ARWhatsNew">
<connections>
<outlet property="getStartedButton" destination="PAQ-9Z-oMG" id="QHx-Pg-iDy"/>
<outlet property="acceptButton" destination="PAQ-9Z-oMG" id="8J2-wI-3hr"/>
<outlet property="labelInVersion" destination="sKp-T3-Vay" id="Tnf-Rb-cXv"/>
<outlet property="labelReleaseNotes" destination="QN7-Ue-rFX" id="mda-kY-qe1"/>
<outlet property="labelWhatsNew" destination="uuB-je-Q9U" id="WBC-JA-XLd"/>
Expand All @@ -21,61 +18,61 @@
</connections>
</placeholder>
<view contentMode="scaleToFill" id="Zi1-2U-d1w">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="WHATS NEW" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uuB-je-Q9U">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="WHATS NEW" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uuB-je-Q9U">
<rect key="frame" x="16" y="21" width="343" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="oH8-ap-Xvn"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="42"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PAQ-9Z-oMG">
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PAQ-9Z-oMG">
<rect key="frame" x="0.0" y="612" width="375" height="55"/>
<color key="backgroundColor" red="0.1137254909" green="0.49803921579999999" blue="0.80392158030000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.12201892584562302" green="0.57733255624771118" blue="0.84165352582931519" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="2ik-gi-ovB"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="22"/>
<state key="normal" title="GET STARTED">
<color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</state>
<state key="disabled">
<color key="titleColor" red="0.10588235410000001" green="0.094117648900000003" blue="0.098039217289999994" alpha="0.2471104452" colorSpace="calibratedRGB"/>
<color key="titleColor" red="0.14122495055198669" green="0.12479942291975021" blue="0.12983161211013794" alpha="0.2471104452" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="GetStarted:" destination="-1" eventType="touchDown" id="g62-yv-E2v"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="RELEASE NOTES" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QN7-Ue-rFX">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="RELEASE NOTES" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QN7-Ue-rFX">
<rect key="frame" x="16" y="110" width="343" height="33"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="nco-ik-Qlg"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="20"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" indicatorStyle="white" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IFB-qp-h2f">
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" showsHorizontalScrollIndicator="NO" indicatorStyle="white" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IFB-qp-h2f">
<rect key="frame" x="8" y="143" width="360" height="460"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="18"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<connections>
<outlet property="delegate" destination="Zi1-2U-d1w" id="sIl-mt-yKN"/>
<outlet property="delegate" destination="-1" id="kP5-s7-nmZ"/>
</connections>
</textView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="IN VERSION" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sKp-T3-Vay">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="IN VERSION" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sKp-T3-Vay">
<rect key="frame" x="16" y="67" width="343" height="24"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="20"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.13333334029999999" green="0.58039218189999997" blue="0.93333333730000001" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.14484882354736328" green="0.6540873646736145" blue="0.94786173105239868" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="uuB-je-Q9U" firstAttribute="centerX" secondItem="Zi1-2U-d1w" secondAttribute="centerX" id="2Sa-Yp-YPk"/>
<constraint firstItem="sKp-T3-Vay" firstAttribute="centerX" secondItem="IFB-qp-h2f" secondAttribute="centerX" id="5KY-IW-INL"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
D119382E1DCA157400A1B8C3 /* ARWhatsNew_Example */ = {
isa = PBXGroup;
children = (
D11938401DCA157400A1B8C3 /* Info.plist */,
D119384C1DCA15B200A1B8C3 /* Launch Screen.storyboard */,
D119383B1DCA157400A1B8C3 /* Assets.xcassets */,
D11938321DCA157400A1B8C3 /* AppDelegate.h */,
D11938331DCA157400A1B8C3 /* AppDelegate.m */,
D11938351DCA157400A1B8C3 /* ViewController.h */,
D11938361DCA157400A1B8C3 /* ViewController.m */,
D11938381DCA157400A1B8C3 /* Main.storyboard */,
D119383B1DCA157400A1B8C3 /* Assets.xcassets */,
D119384C1DCA15B200A1B8C3 /* Launch Screen.storyboard */,
D11938401DCA157400A1B8C3 /* Info.plist */,
D11938461DCA158B00A1B8C3 /* ARWhatsNew */,
D119382F1DCA157400A1B8C3 /* Supporting Files */,
);
Expand Down Expand Up @@ -322,6 +322,7 @@
D11938451DCA157400A1B8C3 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "1"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Loading

0 comments on commit a934fe4

Please sign in to comment.