Skip to content

Commit

Permalink
Merge pull request #50 from susemi99/develop
Browse files Browse the repository at this point in the history
v3.5
  • Loading branch information
Changhoon, Jin committed Aug 1, 2019
2 parents 5a71518 + 04073b3 commit c130a31
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 68 deletions.
2 changes: 1 addition & 1 deletion GPXTracker/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "marmelroy/Zip" "1.1.0"
github "pkluz/PKHUD" "5.2.1"
github "pkluz/PKHUD" "5.3.0"
github "tid-kijyun/Kanna" "5.0.0"
18 changes: 18 additions & 0 deletions GPXTracker/Carthage/Checkouts/PKHUD/Demo/DemoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,27 @@ import UIKit
import PKHUD

class DemoViewController: UIViewController {

let hiddenTextField = UITextField(frame: CGRect.zero)


override func viewDidLoad() {
super.viewDidLoad()

view.addSubview(hiddenTextField)
HUD.registerForKeyboardNotifications()

HUD.dimsBackground = false
HUD.allowsInteraction = false
}

@IBAction func showHideKeyboard(_ sender: Any) {
if hiddenTextField.isEditing {
view.endEditing(true)
} else {
hiddenTextField.becomeFirstResponder()
}
}

@IBAction func showAnimatedSuccessHUD(_ sender: AnyObject) {
HUD.flash(.success, delay: 2.0)
Expand Down Expand Up @@ -50,6 +64,10 @@ class DemoViewController: UIViewController {
print("License Obtained.")
}
}

deinit {
HUD.deregisterFromKeyboardNotifications()
}

/*
Expand Down
2 changes: 1 addition & 1 deletion GPXTracker/Carthage/Checkouts/PKHUD/Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.2.0</string>
<string>5.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
85 changes: 52 additions & 33 deletions GPXTracker/Carthage/Checkouts/PKHUD/Demo/Storyboard.storyboard

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions GPXTracker/Carthage/Checkouts/PKHUD/PKHUD.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'PKHUD'
s.module_name = 'PKHUD'
s.version = '5.2.0'
s.version = '5.2.2'
s.summary = 'A Swift 3 based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8 and up'
s.homepage = 'https://github.com/pkluz/PKHUD'
s.license = 'MIT'
Expand All @@ -12,5 +12,5 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/pkluz/PKHUD.git', :tag => s.version.to_s }
s.source_files = 'PKHUD/**/*.{h,swift}'
s.resource_bundle = { 'PKHUDResources' => 'PKHUD/*.xcassets' }
s.swift_version = '4.2'
s.swift_version = '5.0'
end
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = NSExceptional;
TargetAttributes = {
12CE19F01E25784C0062D873 = {
Expand All @@ -345,16 +345,17 @@
};
F996321D19514FD8001F73CA = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = F99631F719514FAC001F73CA /* Build configuration list for PBXProject "PKHUD" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = F99631F319514FAC001F73CA;
productRefGroup = F99631FD19514FAC001F73CA /* Products */;
Expand Down Expand Up @@ -522,6 +523,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -579,6 +581,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -636,7 +639,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -651,7 +654,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -678,8 +681,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -703,8 +705,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
14 changes: 9 additions & 5 deletions GPXTracker/Carthage/Checkouts/PKHUD/PKHUD/FrameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ internal class FrameView: UIVisualEffectView {

internal init() {
super.init(effect: UIBlurEffect(style: .light))
commonInit()
DispatchQueue.main.async {
self.commonInit()
}
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
DispatchQueue.main.async {
self.commonInit()
}
}

fileprivate func commonInit() {
private func commonInit() {
backgroundColor = UIColor(white: 0.8, alpha: 0.36)
layer.cornerRadius = 9.0
layer.masksToBounds = true

contentView.addSubview(self.content)
contentView.addSubview(content)

let offset = 20.0

Expand All @@ -45,7 +49,7 @@ internal class FrameView: UIVisualEffectView {
addMotionEffect(group)
}

fileprivate var _content = UIView()
private var _content = UIView()
internal var content: UIView {
get {
return _content
Expand Down
9 changes: 9 additions & 0 deletions GPXTracker/Carthage/Checkouts/PKHUD/PKHUD/HUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ public final class HUD {
HUD.show(content, onView: view)
HUD.hide(afterDelay: delay, completion: completion)
}

// MARK: Keyboard Methods
public static func registerForKeyboardNotifications() {
PKHUD.sharedHUD.registerForKeyboardNotifications()
}

public static func deregisterFromKeyboardNotifications() {
PKHUD.sharedHUD.deregisterFromKeyboardNotifications()
}

// MARK: Private methods
fileprivate static func contentView(_ content: HUDContentType) -> UIView {
Expand Down
2 changes: 1 addition & 1 deletion GPXTracker/Carthage/Checkouts/PKHUD/PKHUD/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.2.0</string>
<string>5.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
8 changes: 8 additions & 0 deletions GPXTracker/Carthage/Checkouts/PKHUD/PKHUD/PKHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ open class PKHUD: NSObject {
animatingContentView.stopAnimation?()
}
}

internal func registerForKeyboardNotifications() {
container.registerForKeyboardNotifications()
}

internal func deregisterFromKeyboardNotifications() {
container.deregisterFromKeyboardNotifications()
}

// MARK: Timer callbacks

Expand Down
72 changes: 70 additions & 2 deletions GPXTracker/Carthage/Checkouts/PKHUD/PKHUD/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import UIKit
/// The window used to display the PKHUD within. Placed atop the applications main window.
internal class ContainerView: UIView {

private var keyboardIsVisible = false
private var keyboardHeight: CGFloat = 0.0

internal let frameView: FrameView
internal init(frameView: FrameView = FrameView()) {
self.frameView = frameView
Expand All @@ -36,13 +39,15 @@ internal class ContainerView: UIView {
internal override func layoutSubviews() {
super.layoutSubviews()

frameView.center = center
frameView.center = calculateHudCenter()
backgroundView.frame = bounds
}



internal func showFrameView() {
layer.removeAllAnimations()
frameView.center = center
frameView.center = calculateHudCenter()
frameView.alpha = 1.0
isHidden = false
}
Expand Down Expand Up @@ -101,4 +106,67 @@ internal class ContainerView: UIView {
backgroundView.alpha = 0.0
}
}

// MARK: Notifications
internal func registerForKeyboardNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillBeHidden(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}

internal func deregisterFromKeyboardNotifications() {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}

// MARK: Triggered Functions
@objc private func keyboardWillShow(notification: NSNotification) {
keyboardIsVisible = true
guard let userInfo = notification.userInfo else {
return
}
if let keyboardHeight = (userInfo[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height {
self.keyboardHeight = keyboardHeight
}
if !self.isHidden {
if let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber,
let curve = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber {
animateHUDWith(duration: duration.doubleValue,
curve: UIView.AnimationCurve(rawValue: curve.intValue) ?? UIView.AnimationCurve.easeInOut,
toLocation: calculateHudCenter())
}
}
}

@objc private func keyboardWillBeHidden(notification: NSNotification) {
keyboardIsVisible = false
if !self.isHidden {
guard let userInfo = notification.userInfo else {
return
}
if let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber,
let curve = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber {
animateHUDWith(duration: duration.doubleValue,
curve: UIView.AnimationCurve(rawValue: curve.intValue) ?? UIView.AnimationCurve.easeInOut,
toLocation: calculateHudCenter())
}
}
}

// MARK: - Helpers
private func animateHUDWith(duration: Double, curve: UIView.AnimationCurve, toLocation location: CGPoint) {
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationDuration(TimeInterval(duration))
UIView.setAnimationCurve(curve)
frameView.center = location
UIView.commitAnimations()
}

private func calculateHudCenter() -> CGPoint {
if !keyboardIsVisible {
return center
} else {
let yLocation = (frame.height - keyboardHeight) / 2
return CGPoint(x: center.x, y: yLocation)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>5.2.0</string>
<string>5.2.2</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
4 changes: 2 additions & 2 deletions GPXTracker/GPXTracker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.4</string>
<string>3.5</string>
<key>CFBundleVersion</key>
<string>3.4</string>
<string>3.5</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
Expand Down
8 changes: 8 additions & 0 deletions GPXTracker/GPXTracker/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class MapViewController: UIViewController, CLLocationManagerDelegate, MKMapViewD
}

@IBAction func goToStartPin(_ sender: Any) {
if startPins.count == 0 {
return
}

moveTo(location: startPins[startPinIndex].coordinate)

startPinIndex += 1
Expand All @@ -112,6 +116,10 @@ class MapViewController: UIViewController, CLLocationManagerDelegate, MKMapViewD
}

@IBAction func goToEndPin(_ sender: Any) {
if endPins.count == 0 {
return
}

moveTo(location: endPins[endPinIndex].coordinate)

endPinIndex += 1
Expand Down
Loading

0 comments on commit c130a31

Please sign in to comment.