Skip to content

Commit

Permalink
Version 1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctdewaters committed May 18, 2018
1 parent ba9b0c4 commit 97e47cd
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 62 deletions.
2 changes: 1 addition & 1 deletion MemoriesKit_watchOS/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
12 changes: 6 additions & 6 deletions Music Memories.xcodeproj/project.pbxproj
Expand Up @@ -1296,7 +1296,7 @@
TARGETED_DEVICE_FAMILY = 4;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1326,7 +1326,7 @@
TARGETED_DEVICE_FAMILY = 4;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Release;
};
Expand Down Expand Up @@ -1555,7 +1555,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Debug;
};
Expand All @@ -1576,7 +1576,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Release;
};
Expand All @@ -1598,7 +1598,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Debug;
};
Expand All @@ -1620,7 +1620,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Release;
};
Expand Down
Expand Up @@ -32,7 +32,7 @@
<key>Music Memories-watchOS.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>13</integer>
</dict>
<key>Music Memories.xcscheme</key>
<dict>
Expand Down
21 changes: 21 additions & 0 deletions iOS/Assets.xcassets/Logos/logo500White.imageset/Contents.json
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "logo500White.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 41 additions & 21 deletions iOS/Home/HomeViewController.swift
Expand Up @@ -17,24 +17,16 @@ class HomeViewController: UICollectionViewController, UICollectionViewDelegateFl
//MARK: - Properties
var retrievedMemories = [MKMemory]()
@IBOutlet weak var settingsButton: UIBarButtonItem!

weak var selectedMemory: MKMemory?
var selectedCell: MemoryCell? {
if let selectedIndex = self.selectedIndex {
return self.collectionView?.cellForItem(at: IndexPath(item: selectedIndex + 1, section: 0)) as? MemoryCell
}
return nil
}

///The index of the selected memory.
var selectedIndex: Int?

//MARK: - `UIViewController` overrides.
override func viewDidLoad() {
super.viewDidLoad()
//Set global variable.
homeVC = self

//Register for peek and pop.
self.registerForPreviewing(with: self, sourceView: self.collectionView!)

//Setup the navigation bar.
self.setupNavigationBar()

Expand Down Expand Up @@ -188,23 +180,16 @@ class HomeViewController: UICollectionViewController, UICollectionViewDelegateFl
if let cell = collectionView.cellForItem(at: indexPath) as? MemoryCell {
cell.removeHighlight()

self.selectedIndex = indexPath.item - 1
self.selectedMemory = self.retrievedMemories[indexPath.item - 1]
self.performSegue(withIdentifier: "openMemory", sender: self)
MemoryViewController.shared?.memory = self.retrievedMemories[indexPath.item - 1]
self.navigationController?.pushViewController(MemoryViewController.shared!, animated: true)
}
}

//MARK: - Segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)

if segue.identifier == "openMemory" {
//Setup the memory view controller.
let destinationVC = segue.destination as! MemoryViewController
destinationVC.memory = self.selectedMemory
self.selectedMemory = nil
}
else if segue.identifier == "createMemory" {
if segue.identifier == "createMemory" {

}
}
Expand Down Expand Up @@ -292,3 +277,38 @@ class HomeViewController: UICollectionViewController, UICollectionViewDelegateFl
self.reload()
}
}

//MARK: - `UIViewControllerPreviewingDelegate`.
extension HomeViewController: UIViewControllerPreviewingDelegate {

//Peek
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
//Get the index path for the cell at the passed point.
guard let indexPath = collectionView?.indexPathForItem(at: location) else {
return nil
}

guard let cell = collectionView?.cellForItem(at: indexPath) else {
return nil

}

//Set the shared memory view controller's memory property.
MemoryViewController.shared?.memory = self.retrievedMemories[indexPath.item - 1]
MemoryViewController.shared?.isPreviewing = true

//Set the source rect.
previewingContext.sourceRect = cell.frame

return MemoryViewController.shared
}

//Pop
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
let vc = viewControllerToCommit as! MemoryViewController
vc.isPreviewing = false
self.navigationController?.pushViewController(vc, animated: false)
}


}
61 changes: 51 additions & 10 deletions iOS/Memory View Controller/MemoryViewController.swift
Expand Up @@ -46,27 +46,40 @@ class MemoryViewController: UIViewController, UIGestureRecognizerDelegate {

///The blur animation property animator.
var headerBlurPropertyAnimator: UIViewPropertyAnimator?

///If true, this view controller is being previewed.
var isPreviewing = false

///The shared instance.
public static var shared = mainStoryboard.instantiateViewController(withIdentifier: "memoryVC") as? MemoryViewController

//MARK: - Resetting.
public class func reset() {
MemoryViewController.shared = nil
MemoryViewController.shared = mainStoryboard.instantiateViewController(withIdentifier: "memoryVC") as? MemoryViewController
}

//MARK: - UIViewController overrides
override func viewDidLoad() {
super.viewDidLoad()

//Set the max and min header height values.
self.minimumHeaderHeight = self.view.safeAreaInsets.top + 120
self.maximumHeaderHeight = self.view.safeAreaInsets.top + self.view.frame.width
self.minimumHeaderHeight = (Device() == .iPhoneX ? 35 : 20) + 120
self.maximumHeaderHeight = (Device() == .iPhoneX ? 35 : 20) + self.view.frame.width

// Do any additional setup after loading the view.
self.memoryCollectionView.set(withMemory: self.memory)
self.memoryCollectionView.scrollCallback = { offset in
self.collectionViewDidScroll(withOffset: offset)
}

//Reset the header blur property animator.
//Header blur property animator.
self.headerBlur.effect = nil
self.headerBlurPropertyAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear) {
self.headerBlur.effect = Settings.shared.blurEffect
if self.headerBlurPropertyAnimator == nil && !self.isPreviewing {
self.headerBlurPropertyAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear) {
self.headerBlur.effect = Settings.shared.blurEffect
}
}
self.headerBlur.effect = nil

//Set title.
self.titleTextView.text = self.memory.title ?? ""
Expand All @@ -90,14 +103,28 @@ class MemoryViewController: UIViewController, UIGestureRecognizerDelegate {
//Setup memory images display view.
self.setupMemoryImagesDisplayView()

//Header blur property animator.
if self.headerBlurPropertyAnimator == nil && !self.isPreviewing {
self.headerBlurPropertyAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear) {
self.headerBlur.effect = Settings.shared.blurEffect
}
self.headerBlur.effect = nil
}

//Add observer for MPMediaItemDidChange.
NotificationCenter.default.addObserver(self, selector: #selector(self.nowPlayingItemDidChange), name: NSNotification.Name.MPMusicPlayerControllerNowPlayingItemDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.nowPlayingItemStateDidChange), name: NSNotification.Name.MPMusicPlayerControllerPlaybackStateDidChange, object: nil)

self.memoryCollectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .bottom, animated: false)

//Light status bar style.
UIApplication.shared.statusBarStyle = .lightContent
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

Expand All @@ -123,21 +150,35 @@ class MemoryViewController: UIViewController, UIGestureRecognizerDelegate {
self.memoryImagesDisplayView = nil

//Remove the header blur property animator.
self.headerBlurPropertyAnimator?.startAnimation()
self.headerBlurPropertyAnimator?.stopAnimation(false)
self.headerBlurPropertyAnimator?.finishAnimation(at: .current)
self.headerBlurPropertyAnimator = nil

MemoryViewController.reset()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

deinit {
//Remove notification center observers.
//MARK: - Preview action items.
override var previewActionItems: [UIPreviewActionItem] {
let delete = UIPreviewAction(title: "Delete", style: .destructive) { (action, viewController) in
//Send delete message to user's Watch.
self.memory.messageToCompanionDevice(withSession: wcSession, withTransferSetting: .delete)

//Delete the memory.
self.deleteMemoryAndClose()

//Reload the home view controller.
homeVC?.reload()

viewController.dismiss(animated: true, completion: nil)
}

self.headerBlurPropertyAnimator?.stopAnimation(false)
self.headerBlurPropertyAnimator = nil
return [delete]
}

//MARK: - Memory Images Display View setup.
Expand Down
32 changes: 15 additions & 17 deletions iOS/Storyboards/Base.lproj/LaunchScreen.storyboard
Expand Up @@ -20,39 +20,37 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo500" translatesAutoresizingMaskIntoConstraints="NO" id="Rh1-ol-ivR">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="onboardingBackground" translatesAutoresizingMaskIntoConstraints="NO" id="m6u-UF-zHP">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="logo500White" translatesAutoresizingMaskIntoConstraints="NO" id="Rh1-ol-ivR">
<rect key="frame" x="107" y="326" width="160" height="160"/>
<constraints>
<constraint firstAttribute="height" constant="160" id="MuE-3K-H7M"/>
<constraint firstAttribute="width" constant="160" id="dFe-uz-fDm"/>
</constraints>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copyright (c) 2018 Collin DeWaters. All Rights Reserved" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1z7-Qo-lRq">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Copyright © 2018 Collin DeWaters. All Rights Reserved" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1z7-Qo-lRq">
<rect key="frame" x="20" y="742" width="335" height="16"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="16" id="OsZ-p0-tjj"/>
</constraints>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="9"/>
<nil key="textColor"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Rh1-ol-ivR" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4CB-5M-4y8"/>
<constraint firstItem="xb3-aO-Qok" firstAttribute="top" secondItem="1z7-Qo-lRq" secondAttribute="bottom" constant="20" id="4IM-vf-z2C"/>
<constraint firstItem="Rh1-ol-ivR" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="Kvc-se-okk"/>
<constraint firstItem="1z7-Qo-lRq" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" constant="20" id="TYU-M0-YYW"/>
<constraint firstAttribute="trailing" secondItem="1z7-Qo-lRq" secondAttribute="trailing" constant="20" id="hz0-6k-0Qr"/>
<constraint firstItem="m6u-UF-zHP" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="9wB-21-zMW"/>
<constraint firstAttribute="bottom" secondItem="m6u-UF-zHP" secondAttribute="bottom" id="Dbs-H9-hLe"/>
<constraint firstAttribute="trailing" secondItem="m6u-UF-zHP" secondAttribute="trailing" id="V5i-NE-PhK"/>
<constraint firstItem="m6u-UF-zHP" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="bHW-nr-eF5"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="52" y="374.6305418719212"/>
</scene>
</scenes>
<resources>
<image name="logo500" width="500" height="500"/>
<image name="logo500White" width="500" height="500"/>
<image name="onboardingBackground" width="1242" height="2208"/>
</resources>
</document>
3 changes: 1 addition & 2 deletions iOS/Storyboards/Base.lproj/Main.storyboard
Expand Up @@ -68,7 +68,6 @@
<connections>
<outlet property="settingsButton" destination="v6x-s1-zbn" id="zzJ-Ta-pSR"/>
<segue destination="OYs-9A-Twt" kind="presentation" identifier="homeToSettings" modalPresentationStyle="overCurrentContext" modalTransitionStyle="coverVertical" id="PlW-0f-VbR"/>
<segue destination="WgL-Tk-HDl" kind="show" identifier="openMemory" id="R1o-gs-CQG"/>
<segue destination="2mY-wB-wFR" kind="custom" identifier="createMemory" customClass="MemoryComposeSegue" customModule="Music_Memories" customModuleProvider="target" id="QST-gS-Ple"/>
</connections>
</collectionViewController>
Expand Down Expand Up @@ -288,7 +287,7 @@
<!--Memory View Controller-->
<scene sceneID="dl1-kY-iKF">
<objects>
<viewController modalPresentationStyle="overCurrentContext" id="WgL-Tk-HDl" customClass="MemoryViewController" customModule="Music_Memories" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="memoryVC" modalPresentationStyle="overCurrentContext" id="WgL-Tk-HDl" customClass="MemoryViewController" customModule="Music_Memories" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="bGJ-Cf-n61"/>
<viewControllerLayoutGuide type="bottom" id="qlh-SH-uKX"/>
Expand Down

0 comments on commit 97e47cd

Please sign in to comment.