Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 5 update, keyboard issue resolved, Unwanted warnings fixed #332

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Spring/DesignableTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import UIKit
@IBInspectable var firstSelectedImage: UIImage? {
didSet {
if let image = firstSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]!
var tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[0].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -56,7 +56,7 @@ import UIKit
@IBInspectable var secondSelectedImage: UIImage? {
didSet {
if let image = secondSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]!
var tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[1].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -65,7 +65,7 @@ import UIKit
@IBInspectable var thirdSelectedImage: UIImage? {
didSet {
if let image = thirdSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]!
var tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[2].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -74,7 +74,7 @@ import UIKit
@IBInspectable var fourthSelectedImage: UIImage? {
didSet {
if let image = fourthSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]!
var tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[3].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -83,7 +83,7 @@ import UIKit
@IBInspectable var fifthSelectedImage: UIImage? {
didSet {
if let image = fifthSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]!
var tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[4].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -92,9 +92,11 @@ import UIKit
override func viewDidLoad() {
super.viewDidLoad()

for item in self.tabBar.items as [UITabBarItem]! {
if let image = item.image {
item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
if let arr = self.tabBar.items as [UITabBarItem]? {
for item in arr {
if let image = item.image {
item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Spring/KeyboardLayoutConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
if let userInfo = notification.userInfo {
if let frameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
let frame = frameValue.cgRectValue
keyboardVisibleHeight = frame.size.height

let bottomSafeAreaInset = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
keyboardVisibleHeight = frame.size.height - bottomSafeAreaInset
}

self.updateConstant()
Expand Down
4 changes: 2 additions & 2 deletions Spring/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public extension UIView {
static let Tag = 1000
}

public func showLoading() {
func showLoading() {

if self.viewWithTag(LoadingViewConstants.Tag) != nil {
// If loading view is already found in current view hierachy, do nothing
Expand All @@ -68,7 +68,7 @@ public extension UIView {
})
}

public func hideLoading() {
func hideLoading() {

if let loadingXibView = self.viewWithTag(LoadingViewConstants.Tag) {
loadingXibView.alpha = 1
Expand Down
6 changes: 3 additions & 3 deletions Spring/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import UIKit

public extension String {
public var length: Int { return self.characters.count }
var length: Int { return self.count }

public func toURL() -> NSURL? {
func toURL() -> NSURL? {
return NSURL(string: self)
}
}
Expand Down Expand Up @@ -73,7 +73,7 @@ public extension UIColor {
let scanner = Scanner(string: hex)
var hexValue: CUnsignedLongLong = 0
if scanner.scanHexInt64(&hexValue) {
switch (hex.characters.count) {
switch (hex.count) {
case 3:
red = CGFloat((hexValue & 0xF00) >> 8) / 15.0
green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0
Expand Down
2 changes: 1 addition & 1 deletion Spring/UnwindSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
import UIKit

public extension UIViewController {
@IBAction public func unwindToViewController (_ segue: UIStoryboardSegue){}
@IBAction func unwindToViewController (_ segue: UIStoryboardSegue){}
}
46 changes: 21 additions & 25 deletions SpringApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
181F7BD822D3785100A45C51 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
181F7BD922D3785100A45C51 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
1A4FDA2A1A6E44270099D309 /* LoadingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = "<group>"; };
1A4FDA2B1A6E44270099D309 /* LoadingView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LoadingView.xib; sourceTree = "<group>"; };
1A4FDA331A6E44780099D309 /* Spring.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Spring.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -413,20 +415,20 @@
TargetAttributes = {
1A4FDA321A6E44780099D309 = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
1A4FDA3C1A6E44780099D309 = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
TestTargetID = 9641173A1A5BE90A000E3A5A;
};
9641173A1A5BE90A000E3A5A = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
9641174F1A5BE90A000E3A5A = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
TestTargetID = 9641173A1A5BE90A000E3A5A;
};
};
Expand All @@ -436,8 +438,8 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
en,
);
mainGroup = 964117321A5BE90A000E3A5A;
productRefGroup = 9641173C1A5BE90A000E3A5A /* Products */;
Expand Down Expand Up @@ -580,6 +582,7 @@
isa = PBXVariantGroup;
children = (
964117451A5BE90A000E3A5A /* Base */,
181F7BD822D3785100A45C51 /* en */,
);
name = Main.storyboard;
sourceTree = "<group>";
Expand All @@ -588,6 +591,7 @@
isa = PBXVariantGroup;
children = (
9641174A1A5BE90A000E3A5A /* Base */,
181F7BD922D3785100A45C51 /* en */,
);
name = LaunchScreen.xib;
sourceTree = "<group>";
Expand All @@ -610,13 +614,12 @@
);
INFOPLIST_FILE = Spring/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -634,14 +637,13 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Spring/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -660,8 +662,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp";
};
name = Debug;
Expand All @@ -675,8 +676,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp";
};
name = Release;
Expand Down Expand Up @@ -784,12 +784,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SpringApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -799,13 +798,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SpringApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -822,8 +820,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp";
};
name = Debug;
Expand All @@ -837,8 +834,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp";
};
name = Release;
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>
25 changes: 25 additions & 0 deletions SpringApp/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
Expand Down Expand Up @@ -36,6 +46,16 @@
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
Expand Down Expand Up @@ -77,6 +97,11 @@
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
1 change: 1 addition & 0 deletions SpringApp/OptionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protocol OptionsViewControllerDelegate: class {
func ySliderChanged(_ sender: AnyObject)
func rotateSliderChanged(_ sender: AnyObject)
func resetButtonPressed(_ sender: AnyObject)

}

class OptionsViewController: UIViewController {
Expand Down
1 change: 1 addition & 0 deletions SpringApp/SpringViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView
SpringAnimation.spring(duration: 0.7, animations: {
self.view.transform = CGAffineTransform(scaleX: 0.935, y: 0.935)
})

UIApplication.shared.setStatusBarStyle(UIStatusBarStyle.lightContent, animated: true)
}

Expand Down
1 change: 1 addition & 0 deletions SpringApp/en.lproj/LaunchScreen.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

42 changes: 42 additions & 0 deletions SpringApp/en.lproj/Main.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

/* Class = "UILabel"; text = "x: 0"; ObjectID = "8i2-8d-Gyo"; */
"8i2-8d-Gyo.text" = "x: 0";

/* Class = "UILabel"; text = "y: 0"; ObjectID = "8kG-Ub-7Gx"; */
"8kG-Ub-7Gx.text" = "y: 0";

/* Class = "UILabel"; text = "Scale: 1"; ObjectID = "PFw-Jb-2Xm"; */
"PFw-Jb-2Xm.text" = "Scale: 1";

/* Class = "UITextView"; text = "layer.animation = \"shake\""; ObjectID = "QYe-M8-GcU"; */
"QYe-M8-GcU.text" = "layer.animation = \"shake\"";

/* Class = "UILabel"; text = "Rotate: 0"; ObjectID = "Sss-g7-hcA"; */
"Sss-g7-hcA.text" = "Rotate: 0";

/* Class = "UIButton"; normalTitle = "Reset"; ObjectID = "WbE-Ar-bLf"; */
"WbE-Ar-bLf.normalTitle" = "Reset";

/* Class = "UIButton"; normalTitle = "Code"; ObjectID = "XZL-Vb-0wq"; */
"XZL-Vb-0wq.normalTitle" = "Code";

/* Class = "UIButton"; normalTitle = "Options"; ObjectID = "hQw-No-MzG"; */
"hQw-No-MzG.normalTitle" = "Options";

/* Class = "UILabel"; text = "Force: 1"; ObjectID = "hZO-3H-UCU"; */
"hZO-3H-UCU.text" = "Force: 1";

/* Class = "UILabel"; text = "Code"; ObjectID = "jUx-Gp-qoT"; */
"jUx-Gp-qoT.text" = "Code";

/* Class = "UILabel"; text = "Velocity: 0.7"; ObjectID = "kqf-ZO-435"; */
"kqf-ZO-435.text" = "Velocity: 0.7";

/* Class = "UILabel"; text = "Delay: 0"; ObjectID = "nfx-rk-xQP"; */
"nfx-rk-xQP.text" = "Delay: 0";

/* Class = "UILabel"; text = "Damping: 0.7"; ObjectID = "rM7-dW-gD1"; */
"rM7-dW-gD1.text" = "Damping: 0.7";

/* Class = "UILabel"; text = "Duration: 1"; ObjectID = "xk2-sC-g25"; */
"xk2-sC-g25.text" = "Duration: 1";