diff --git a/.swiftlint.yml b/.swiftlint.yml index 79213f2..9685f23 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -20,5 +20,6 @@ excluded: # paths to ignore during linting. Takes precedence over `included`. disabled_rules: # rule identifiers to exclude from running - trailing_whitespace + - identifier_name line_length: 130 diff --git a/FlyoverKit.xcodeproj/project.pbxproj b/FlyoverKit.xcodeproj/project.pbxproj index 13de818..23acbdd 100644 --- a/FlyoverKit.xcodeproj/project.pbxproj +++ b/FlyoverKit.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 3D5D662E203F45BA00A45E6C /* .jazzy.yaml in Resources */ = {isa = PBXBuildFile; fileRef = 3D5D662C203F45BA00A45E6C /* .jazzy.yaml */; }; 3D5D6631203F45D100A45E6C /* .swift-version in Resources */ = {isa = PBXBuildFile; fileRef = 3D5D662F203F45D000A45E6C /* .swift-version */; }; 3D5D6632203F45D100A45E6C /* Cartfile.private in Resources */ = {isa = PBXBuildFile; fileRef = 3D5D6630203F45D000A45E6C /* Cartfile.private */; }; + 3D76D7BE2048BC1D003BCD41 /* SplitScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D76D7BD2048BC1D003BCD41 /* SplitScreenViewController.swift */; }; 3D8DB858203DD904008A079D /* FlyoverKit.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 3D8DB856203DD903008A079D /* FlyoverKit.podspec */; }; 3D8DB859203DD904008A079D /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 3D8DB857203DD903008A079D /* README.md */; }; 3D8F94AE203D804F006E7659 /* FlyoverKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D8F94A4203D804F006E7659 /* FlyoverKit.framework */; }; @@ -26,9 +27,9 @@ 3D8F94DC203D85FE006E7659 /* FlyoverKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D8F94A4203D804F006E7659 /* FlyoverKit.framework */; }; 3D8F94DD203D85FE006E7659 /* FlyoverKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3D8F94A4203D804F006E7659 /* FlyoverKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 3D8F94E3203D8612006E7659 /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D8F94E2203D8612006E7659 /* SnapKit.framework */; }; - 3D8F94E9203D86A8006E7659 /* ConfigurationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94E6203D86A8006E7659 /* ConfigurationTableViewCell.swift */; }; - 3D8F94EA203D86A8006E7659 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94E7203D86A8006E7659 /* Configuration.swift */; }; - 3D8F94EB203D86A8006E7659 /* ConfigurationTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94E8203D86A8006E7659 /* ConfigurationTableView.swift */; }; + 3D8F94E9203D86A8006E7659 /* FlyoverConfigurationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94E6203D86A8006E7659 /* FlyoverConfigurationTableViewCell.swift */; }; + 3D8F94EA203D86A8006E7659 /* FlyoverConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94E7203D86A8006E7659 /* FlyoverConfiguration.swift */; }; + 3D8F94EB203D86A8006E7659 /* FlyoverConfigurationTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94E8203D86A8006E7659 /* FlyoverConfigurationTableView.swift */; }; 3D8F94ED203D86B2006E7659 /* UIColor+Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94EC203D86B2006E7659 /* UIColor+Main.swift */; }; 3D8F94EF203D86BB006E7659 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8F94EE203D86BB006E7659 /* ViewController.swift */; }; 3DB39A4D203D9C7E00E00B2D /* FlyoverMapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB39A4C203D9C7E00E00B2D /* FlyoverMapView.swift */; }; @@ -82,6 +83,7 @@ 3D5D662C203F45BA00A45E6C /* .jazzy.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .jazzy.yaml; sourceTree = SOURCE_ROOT; }; 3D5D662F203F45D000A45E6C /* .swift-version */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ".swift-version"; sourceTree = SOURCE_ROOT; }; 3D5D6630203F45D000A45E6C /* Cartfile.private */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Cartfile.private; sourceTree = SOURCE_ROOT; }; + 3D76D7BD2048BC1D003BCD41 /* SplitScreenViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitScreenViewController.swift; sourceTree = ""; }; 3D8DB856203DD903008A079D /* FlyoverKit.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FlyoverKit.podspec; sourceTree = SOURCE_ROOT; }; 3D8DB857203DD903008A079D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; 3D8F94A4203D804F006E7659 /* FlyoverKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FlyoverKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -98,9 +100,9 @@ 3D8F94D5203D849D006E7659 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 3D8F94D7203D849D006E7659 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3D8F94E2203D8612006E7659 /* SnapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SnapKit.framework; path = Carthage/Build/iOS/SnapKit.framework; sourceTree = ""; }; - 3D8F94E6203D86A8006E7659 /* ConfigurationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurationTableViewCell.swift; sourceTree = ""; }; - 3D8F94E7203D86A8006E7659 /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = ""; }; - 3D8F94E8203D86A8006E7659 /* ConfigurationTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurationTableView.swift; sourceTree = ""; }; + 3D8F94E6203D86A8006E7659 /* FlyoverConfigurationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlyoverConfigurationTableViewCell.swift; sourceTree = ""; }; + 3D8F94E7203D86A8006E7659 /* FlyoverConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlyoverConfiguration.swift; sourceTree = ""; }; + 3D8F94E8203D86A8006E7659 /* FlyoverConfigurationTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlyoverConfigurationTableView.swift; sourceTree = ""; }; 3D8F94EC203D86B2006E7659 /* UIColor+Main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Main.swift"; sourceTree = ""; }; 3D8F94EE203D86BB006E7659 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 3DB39A4C203D9C7E00E00B2D /* FlyoverMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlyoverMapView.swift; sourceTree = ""; }; @@ -211,7 +213,7 @@ children = ( 3D8F94CB203D849D006E7659 /* AppDelegate.swift */, 3D8F94EE203D86BB006E7659 /* ViewController.swift */, - 3D8F94E5203D869A006E7659 /* Configuration */, + 3D8F94E5203D869A006E7659 /* FlyoverConfiguration */, 3D8F94DB203D853F006E7659 /* Supporting Files */, 3D8DB855203DD8E4008A079D /* MetaData */, ); @@ -221,6 +223,7 @@ 3D8F94DB203D853F006E7659 /* Supporting Files */ = { isa = PBXGroup; children = ( + 3D76D7BD2048BC1D003BCD41 /* SplitScreenViewController.swift */, 3D8F94EC203D86B2006E7659 /* UIColor+Main.swift */, 3D8F94D4203D849D006E7659 /* LaunchScreen.storyboard */, 3D8F94D2203D849D006E7659 /* Assets.xcassets */, @@ -237,14 +240,14 @@ name = Frameworks; sourceTree = ""; }; - 3D8F94E5203D869A006E7659 /* Configuration */ = { + 3D8F94E5203D869A006E7659 /* FlyoverConfiguration */ = { isa = PBXGroup; children = ( - 3D8F94E7203D86A8006E7659 /* Configuration.swift */, - 3D8F94E8203D86A8006E7659 /* ConfigurationTableView.swift */, - 3D8F94E6203D86A8006E7659 /* ConfigurationTableViewCell.swift */, + 3D8F94E7203D86A8006E7659 /* FlyoverConfiguration.swift */, + 3D8F94E8203D86A8006E7659 /* FlyoverConfigurationTableView.swift */, + 3D8F94E6203D86A8006E7659 /* FlyoverConfigurationTableViewCell.swift */, ); - path = Configuration; + path = FlyoverConfiguration; sourceTree = ""; }; 3DB39A54203DCADD00E00B2D /* MapView */ = { @@ -354,7 +357,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "Sven Tiigi"; TargetAttributes = { 3D8F94A3203D804F006E7659 = { @@ -492,11 +495,12 @@ buildActionMask = 2147483647; files = ( 3D8F94ED203D86B2006E7659 /* UIColor+Main.swift in Sources */, + 3D76D7BE2048BC1D003BCD41 /* SplitScreenViewController.swift in Sources */, 3D8F94EF203D86BB006E7659 /* ViewController.swift in Sources */, 3D8F94CC203D849D006E7659 /* AppDelegate.swift in Sources */, - 3D8F94EB203D86A8006E7659 /* ConfigurationTableView.swift in Sources */, - 3D8F94EA203D86A8006E7659 /* Configuration.swift in Sources */, - 3D8F94E9203D86A8006E7659 /* ConfigurationTableViewCell.swift in Sources */, + 3D8F94EB203D86A8006E7659 /* FlyoverConfigurationTableView.swift in Sources */, + 3D8F94EA203D86A8006E7659 /* FlyoverConfiguration.swift in Sources */, + 3D8F94E9203D86A8006E7659 /* FlyoverConfigurationTableViewCell.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -541,6 +545,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -548,6 +553,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -601,6 +607,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -608,6 +615,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/FlyoverKit.xcodeproj/xcshareddata/xcschemes/FlyoverKit.xcscheme b/FlyoverKit.xcodeproj/xcshareddata/xcschemes/FlyoverKit.xcscheme index 9e41565..e7a4676 100644 --- a/FlyoverKit.xcodeproj/xcshareddata/xcschemes/FlyoverKit.xcscheme +++ b/FlyoverKit.xcodeproj/xcshareddata/xcschemes/FlyoverKit.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -57,7 +56,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/FlyoverKitExample/AppDelegate.swift b/FlyoverKitExample/AppDelegate.swift index 61045ac..4aff295 100644 --- a/FlyoverKitExample/AppDelegate.swift +++ b/FlyoverKitExample/AppDelegate.swift @@ -20,6 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { navigationController.navigationBar.largeTitleTextAttributes = [ NSAttributedStringKey.foregroundColor: UIColor.main ] + navigationController.view.backgroundColor = .white navigationController.navigationBar.tintColor = .main navigationController.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.main] return navigationController diff --git a/FlyoverKitExample/Configuration/Configuration.swift b/FlyoverKitExample/FlyoverConfiguration/FlyoverConfiguration.swift similarity index 95% rename from FlyoverKitExample/Configuration/Configuration.swift rename to FlyoverKitExample/FlyoverConfiguration/FlyoverConfiguration.swift index 19df9bb..a26d287 100644 --- a/FlyoverKitExample/Configuration/Configuration.swift +++ b/FlyoverKitExample/FlyoverConfiguration/FlyoverConfiguration.swift @@ -11,8 +11,8 @@ import MapKit // MARK: - Configuration -/// The Configuration Enumeration -enum Configuration { +/// The FlyoverConfiguration Enumeration +enum FlyoverConfiguration { /// Flyover start/stop boolean case flyover(Bool) @@ -76,7 +76,7 @@ enum Configuration { // MARK: - RawRepresentable -extension Configuration: RawRepresentable { +extension FlyoverConfiguration: RawRepresentable { /// Associated type RawValue as String typealias RawValue = String diff --git a/FlyoverKitExample/Configuration/ConfigurationTableView.swift b/FlyoverKitExample/FlyoverConfiguration/FlyoverConfigurationTableView.swift similarity index 65% rename from FlyoverKitExample/Configuration/ConfigurationTableView.swift rename to FlyoverKitExample/FlyoverConfiguration/FlyoverConfigurationTableView.swift index 005645e..2ee3f6c 100644 --- a/FlyoverKitExample/Configuration/ConfigurationTableView.swift +++ b/FlyoverKitExample/FlyoverConfiguration/FlyoverConfigurationTableView.swift @@ -1,5 +1,5 @@ // -// ConfigurationTableView.swift +// FlyoverConfigurationTableView.swift // FlyoverKitExample // // Created by Sven Tiigi on 21.02.18. @@ -8,29 +8,29 @@ import UIKit -// MARK: - ConfigurationTableViewDelegate +// MARK: - FlyoverConfigurationTableViewDelegate -/// The ConfigurationTableViewDelegate -protocol ConfigurationTableViewDelegate: class { +/// The FlyoverConfigurationTableViewDelegate +protocol FlyoverConfigurationTableViewDelegate: class { /// On Configuration Change /// /// - Parameter configuration: The updated configuration - func onChange(_ configuration: Configuration) + func onChange(_ configuration: FlyoverConfiguration) } -// MARK: - ConfigurationTableView +// MARK: - FlyoverConfigurationTableView -class ConfigurationTableView: UITableView { +class FlyoverConfigurationTableView: UITableView { // MARK: Properties - /// The ConfigurationDelegate - weak var configurationDelegate: ConfigurationTableViewDelegate? + /// The FlyoverConfigurationTableViewDelegate + weak var configurationDelegate: FlyoverConfigurationTableViewDelegate? /// The cells constructed with default configuration and delegate - lazy private var cells: [ConfigurationTableViewCell] = { + lazy private var cells: [FlyoverConfigurationTableViewCell] = { // Initialize default configurations - let defaultConfigurations: [Configuration] = [ + let defaultConfigurations: [FlyoverConfiguration] = [ .flyover(true), .mapType(.standard), .altitude(600.0), @@ -38,17 +38,13 @@ class ConfigurationTableView: UITableView { .headingStep(20.0), .duration(4.0) ] - return defaultConfigurations.map { ConfigurationTableViewCell($0, self.configurationDelegate) } + return defaultConfigurations.map { FlyoverConfigurationTableViewCell($0, self.configurationDelegate) } }() // MARK: Initializer - /// Default initializer with ConfigurationTableViewDelegate - /// - /// - Parameter configurationDelegate: The delegate - init(configurationDelegate: ConfigurationTableViewDelegate) { - // Set configuration delegate - self.configurationDelegate = configurationDelegate + /// Default initializer + init() { // Super init super.init(frame: .zero, style: .plain) // Set delegate to self @@ -70,7 +66,7 @@ class ConfigurationTableView: UITableView { // MARK: - UITableViewDataSource -extension ConfigurationTableView: UITableViewDataSource { +extension FlyoverConfigurationTableView: UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { // Return 1 section @@ -91,7 +87,7 @@ extension ConfigurationTableView: UITableViewDataSource { // MARK: - UITableViewDelegate -extension ConfigurationTableView: UITableViewDelegate { +extension FlyoverConfigurationTableView: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { // First two rows smaller then the rest diff --git a/FlyoverKitExample/Configuration/ConfigurationTableViewCell.swift b/FlyoverKitExample/FlyoverConfiguration/FlyoverConfigurationTableViewCell.swift similarity index 94% rename from FlyoverKitExample/Configuration/ConfigurationTableViewCell.swift rename to FlyoverKitExample/FlyoverConfiguration/FlyoverConfigurationTableViewCell.swift index a5a5b52..2ca9ad3 100644 --- a/FlyoverKitExample/Configuration/ConfigurationTableViewCell.swift +++ b/FlyoverKitExample/FlyoverConfiguration/FlyoverConfigurationTableViewCell.swift @@ -1,5 +1,5 @@ // -// ConfigurationTableViewCell.swift +// FlyoverConfigurationTableViewCell.swift // FlyoverKitExample // // Created by Sven Tiigi on 21.02.18. @@ -9,17 +9,17 @@ import MapKit import UIKit -// MARK: - ConfigurationTableViewCell +// MARK: - FlyoverConfigurationTableViewCell -class ConfigurationTableViewCell: UITableViewCell { +class FlyoverConfigurationTableViewCell: UITableViewCell { // MARK: Properties /// The Configuration - var configuration: Configuration + var configuration: FlyoverConfiguration - /// The ConfigurationTableViewDelegate - weak var delegate: ConfigurationTableViewDelegate? + /// The FlyoverConfigurationTableViewDelegate + weak var delegate: FlyoverConfigurationTableViewDelegate? /// The title label lazy var titleLabel: UILabel = { @@ -68,7 +68,7 @@ class ConfigurationTableViewCell: UITableViewCell { /// - Parameters: /// - configuration: The Configuration /// - delegate: The Delegate - init(_ configuration: Configuration, _ delegate: ConfigurationTableViewDelegate?) { + init(_ configuration: FlyoverConfiguration, _ delegate: FlyoverConfigurationTableViewDelegate?) { // Set configuration self.configuration = configuration // Set delegate @@ -187,7 +187,7 @@ class ConfigurationTableViewCell: UITableViewCell { // Initialize value of Double slider value type let value = Double(self.slider.value) // Declare updated configuration - let updatedConfiguration: Configuration? + let updatedConfiguration: FlyoverConfiguration? // Switch on configuration switch self.configuration { case .duration: diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/Contents.json b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/Contents.json index 8334752..1d3ecbb 100644 --- a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/Contents.json +++ b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/Contents.json @@ -2,17 +2,17 @@ "images" : [ { "idiom" : "universal", - "filename" : "icons8-github-22.png", + "filename" : "icons8-github-filled-26.png", "scale" : "1x" }, { "idiom" : "universal", - "filename" : "icons8-github-44.png", + "filename" : "icons8-github-filled-52.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "icons8-github-88.png", + "filename" : "icons8-github-filled-78.png", "scale" : "3x" } ], diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-22.png b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-22.png deleted file mode 100644 index 0aeeb61..0000000 Binary files a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-22.png and /dev/null differ diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-44.png b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-44.png deleted file mode 100644 index b5ecf6d..0000000 Binary files a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-44.png and /dev/null differ diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-88.png b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-88.png deleted file mode 100644 index cd7d9eb..0000000 Binary files a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-88.png and /dev/null differ diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-26.png b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-26.png new file mode 100644 index 0000000..57c743d Binary files /dev/null and b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-26.png differ diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-52.png b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-52.png new file mode 100644 index 0000000..38816c5 Binary files /dev/null and b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-52.png differ diff --git a/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-78.png b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-78.png new file mode 100644 index 0000000..1b6741b Binary files /dev/null and b/FlyoverKitExample/Supporting Files/Assets.xcassets/github.imageset/icons8-github-filled-78.png differ diff --git a/FlyoverKitExample/Supporting Files/SplitScreenViewController.swift b/FlyoverKitExample/Supporting Files/SplitScreenViewController.swift new file mode 100644 index 0000000..1a71156 --- /dev/null +++ b/FlyoverKitExample/Supporting Files/SplitScreenViewController.swift @@ -0,0 +1,323 @@ +// +// SplitScreenViewController.swift +// FlyoverKitExample +// +// Created by Sven Tiigi on 01.03.18. +// Copyright © 2018 Sven Tiigi. All rights reserved. +// + +import UIKit + +/// The SplitScreenViewController +open class SplitScreenViewController: UIViewController { + + // MARK: Properties + + /// The TopView + private let topView: UIView + + /// The BottomView + private let bottomView: UIView + + /// The configuration + private let configuration: Configuration + + /// The drag view + private lazy var dragView: UIView = { + return UIView.getUserInteractionEnabledView() + }() + + /// The drag inner view + private lazy var dragInnerView: UIView = { + return UIView.getUserInteractionEnabledView() + }() + + /// The UIPanGestureRecognizer + private lazy var panGestureRecognizer: UIPanGestureRecognizer = { + return UIPanGestureRecognizer(target: self, action: #selector(handleDrag(_:))) + }() + + /// Computed view height + private var viewHeight: CGFloat { + return self.view.frame.size.height + } + + /// Computed view width + private var viewWidth: CGFloat { + return self.view.frame.size.width + } + + // MARK: Initializers + + /// Default initializer with TopView, BottomView and Configuration + /// + /// - Parameters: + /// - topView: The TopView + /// - bottomView: The BottomView + /// - configuration: The SplitScreenViewController.Configuration + public init(topView: UIView, bottomView: UIView, configuration: Configuration = .init()) { + // Set TopView + self.topView = topView + // Set BottomView + self.bottomView = bottomView + // Set Configuration + self.configuration = configuration + // Super init + super.init(nibName: nil, bundle: nil) + // Set Backgroundcolor white + self.view.backgroundColor = .white + // Add drag inner view to drag view + self.dragView.addSubview(self.dragInnerView) + // Add subviews + [self.topView, self.bottomView, self.dragView].forEach(self.view.addSubview) + // Add gesture recognizer on drag view + self.dragView.addGestureRecognizer(self.panGestureRecognizer) + // Set drag view background color + self.dragView.backgroundColor = self.configuration.dragView.backgroundColor + // Set drag inner view background color + self.dragInnerView.backgroundColor = self.configuration.dragInnerView.backgroundColor + // Set drag inner view alpha + self.dragInnerView.alpha = self.configuration.dragInnerView.alpha + // Set drag inner view corner radius + self.dragInnerView.layer.cornerRadius = self.configuration.dragInnerView.cornerRadius + // Clear edges for extended + self.edgesForExtendedLayout = [] + } + + /// Convenience initializer with TopView, BottomView and Configuration Closure + /// + /// - Parameters: + /// - topView: The TopView + /// - bottomView: The BottomView + /// - configuration: The SplitScreenViewController.Configuration Closure + public convenience init(topView: UIView, bottomView: UIView, configuration: (inout Configuration) -> Void) { + // Initialize configuration + var config = Configuration() + // Perform configuration with config + configuration(&config) + // Init with topView, bottomView and config + self.init( + topView: topView, + bottomView: bottomView, + configuration: config + ) + } + + /// Convenience initializer with TopViewController, BottomViewController and Configuration + /// + /// - Parameters: + /// - topViewController: The TopViewController + /// - bottomViewController: The BottomViewController + /// - configuration: The SplitScreenViewController.Configuration + public convenience init(topViewController: UIViewController, bottomViewController: UIViewController, + configuration: Configuration = .init()) { + // Self init with topView, bottomView and configuration + self.init( + topView: topViewController.view, + bottomView: bottomViewController.view, + configuration: configuration + ) + // Add ChildViewControllers + [topViewController, bottomViewController].forEach(self.addChildViewController) + // DidMove to ParentViewController + [topViewController, bottomViewController].forEach { $0.didMove(toParentViewController: self) } + } + + /// Convenience initializer with TopViewController, BottomViewController and Configuration Closure + /// + /// - Parameters: + /// - topViewController: The TopViewController + /// - bottomViewController: The BottomViewController + /// - configuration: The SplitScreenViewController.Configuration Closure + public convenience init(topViewController: UIViewController, bottomViewController: UIViewController, + configuration: (inout Configuration) -> Void) { + // Initialize configuration + var config = Configuration() + // Perform configuration with config + configuration(&config) + // Init with topViewController, bottomViewController and config + self.init( + topViewController: topViewController, + bottomViewController: bottomViewController, + configuration: config + ) + } + + /// NSCoder Initializer (not supported) returns nil + public required init?(coder aDecoder: NSCoder) { + // Return nil + return nil + } + + // MARK: View-Lifecycle + + /// ViewDidLayoutSubView + override open func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + // Check if drag view frame hasn't been set + if self.dragView.frame == CGRect.zero { + // Set drag view Frame + self.dragView.frame.origin.x = 0 + self.dragView.frame.origin.y = self.viewHeight / 2 - self.configuration.dragView.height / 2 + self.dragView.frame.origin.y += self.configuration.dragView.startYPadding + } + // Always Update DragView Width + self.dragView.frame.size.width = self.viewWidth + self.dragView.frame.size.height = self.configuration.dragView.height + // Initialize dragInnerViewHeigh + let dragInnerViewHeight = self.dragView.frame.size.height - self.configuration.dragInnerView.heightPadding * 2 + // Set drag inner view frame + self.dragInnerView.frame = CGRect( + x: self.dragView.frame.size.width / 2 - self.configuration.dragInnerView.width / 2, + y: self.dragView.frame.size.height / 2 - dragInnerViewHeight / 2, + width: self.configuration.dragInnerView.width, + height: dragInnerViewHeight + ) + // Set TopView Frame + self.topView.frame = CGRect( + x: 0, + y: 0, + width: self.viewWidth, + height: self.dragView.frame.origin.y + ) + // Set BottomView Frame + self.bottomView.frame = CGRect( + x: 0, + y: self.dragView.frame.origin.y + self.configuration.dragView.height, + width: self.viewWidth, + height: self.viewHeight - self.dragView.frame.origin.y + ) + } + + // MARK: UIPanGestureRecognizer Handler + + /// Handle UIPanGestureRecognizer drag + /// + /// - Parameter sender: The UIPanGestureRecognizer + @objc private func handleDrag(_ sender: UIPanGestureRecognizer) { + // Initialize gesturerecoggnizer translation for view + let translation = sender.translation(in: self.view) + // Initialize the updated Y origin + let updatedYOrigin = self.dragView.center.y + translation.y + // Check if the new y origin is too small + if updatedYOrigin <= self.configuration.dragThreshold.minY { + // Reached minY threshold + return + } + // Check if the new y origin is too big + if updatedYOrigin >= self.viewHeight - self.configuration.dragThreshold.maxY { + // Reached maxY threshold + return + } + // Update splitViewDrag center + self.dragView.center = CGPoint(x: self.dragView.center.x, y: updatedYOrigin) + // Set view needs layout in order to update the layout + self.view.setNeedsLayout() + // Reset translation + sender.setTranslation(CGPoint.zero, in: self.view) + } + +} + +// MARK: - SplitScreenViewController.Configuration + +public extension SplitScreenViewController { + + /// The SplitScreenViewController Configuration + struct Configuration { + + // MARK: Properties + + // The DragThreshold + public var dragThreshold: DragThreshold + + /// The DragView + public var dragView: DragView + + /// The DragInnerView + public var dragInnerView: DragInnerView + + // MARK: Initializer + + /// Default initializer + public init() { + // Init with default values + self.init( + dragThreshold: ( + minY: 100, + maxY: 100 + ), + dragView: ( + height: 15, + backgroundColor: UIColor(red: 31/255, green: 31/255, blue: 33/255, alpha: 1), + startYPadding: 0 + ), + dragInnerView: ( + width: 80, + heightPadding: 5, + cornerRadius: 5, + backgroundColor: UIColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 0.8), + alpha: 0.8 + ) + ) + } + + /// Initializer with DragThreshold, DragView and DragInnerView configuration + /// + /// - Parameters: + /// - dragThreshold: The DragThreshold configuration + /// - dragView: The DragView configuration + /// - dragInnerView: The DragInnerView configuration + public init(dragThreshold: DragThreshold, dragView: DragView, dragInnerView: DragInnerView) { + self.dragThreshold = dragThreshold + self.dragView = dragView + self.dragInnerView = dragInnerView + } + + } + +} + +public extension SplitScreenViewController.Configuration { + + /// The DragThreshold configuration type + typealias DragThreshold = ( + minY: CGFloat, + maxY: CGFloat + ) + + /// The DragView configuration type + typealias DragView = ( + height: CGFloat, + backgroundColor: UIColor, + startYPadding: CGFloat + ) + + /// The DragInnerView configuration type + typealias DragInnerView = ( + width: CGFloat, + heightPadding: CGFloat, + cornerRadius: CGFloat, + backgroundColor: UIColor, + alpha: CGFloat + ) + +} + +// MARK: - UIView getUserInteractionEnabledView + +extension UIView { + + /// Retrieve an UIView which user interaction is enabled + /// + /// - Returns: The preconfigured view + static func getUserInteractionEnabledView() -> UIView { + // Initialize the UIView + let view = UIView() + // Set user interaction enabled to true + view.isUserInteractionEnabled = true + // Return view + return view + } + +} diff --git a/FlyoverKitExample/ViewController.swift b/FlyoverKitExample/ViewController.swift index 8990bb2..9401048 100644 --- a/FlyoverKitExample/ViewController.swift +++ b/FlyoverKitExample/ViewController.swift @@ -15,25 +15,15 @@ import UIKit // MARK: - ViewController /// The Example View Controller -class ViewController: UIViewController { +class ViewController: SplitScreenViewController { // MARK: Propertirs /// The FlyoverMapView - private lazy var flyoverMapView: FlyoverMapView = { - return FlyoverMapView(configurationTheme: .default) - }() + private var flyoverMapView: FlyoverMapView - private lazy var seperatorView: UIView = { - let view = UIView() - view.backgroundColor = .main - return view - }() - /// The ConfigurationTableView - private lazy var configurationTableView: ConfigurationTableView = { - return ConfigurationTableView(configurationDelegate: self) - }() + private var configurationTableView: FlyoverConfigurationTableView /// The example location // Change the enum case to explore different locations 🤙 @@ -45,6 +35,33 @@ class ViewController: UIViewController { /// Boolean holding Flyover start/stop state var flyoverWasStarted = true + // MARK: Initializer + + /// Default initializer + init() { + // Initialize SplitScreenViewController Configuration + var configuration = Configuration() + // Set main backgroundcolor + configuration.dragView.backgroundColor = .main + // Add y padding + configuration.dragView.startYPadding = 20 + // Set white inner drag view background color + configuration.dragInnerView.backgroundColor = .white + // Initialize FlyoverMapView + self.flyoverMapView = FlyoverMapView(configurationTheme: .default) + // Initialize ConfigurationTableView + self.configurationTableView = FlyoverConfigurationTableView() + // Super init + super.init(topView: self.flyoverMapView, bottomView: self.configurationTableView, configuration: configuration) + // Set ConfigurationDelegate + self.configurationTableView.configurationDelegate = self + } + + /// Initializer with NSCoder always return nil + required init?(coder aDecoder: NSCoder) { + return nil + } + // MARK: ViewLifeCycle /// ViewDidLoad @@ -54,13 +71,6 @@ class ViewController: UIViewController { self.view.backgroundColor = .white // Add Navigation Items self.addNavigationItems() - // Add Subviews - [self.flyoverMapView, - self.seperatorView, - self.configurationTableView - ].forEach(self.view.addSubview) - // Layout SubViews - self.layoutSubViews() } /// viewDidAppear @@ -81,65 +91,23 @@ class ViewController: UIViewController { // Stop self.flyoverMapView.stop() } - - // MARK: Layout - - /// Layout subviews - private func layoutSubViews() { - self.flyoverMapView.snp.makeConstraints { (make) in - make.top.equalTo(self.view.safeAreaLayoutGuide) - make.left.right.equalTo(self.view) - make.height.equalTo(self.view).multipliedBy(0.45) - } - self.seperatorView.snp.makeConstraints { (make) in - make.top.equalTo(self.flyoverMapView.snp.bottom) - make.left.right.equalTo(self.view) - make.height.equalTo(1) - } - self.configurationTableView.snp.makeConstraints { (make) in - make.top.equalTo(self.seperatorView.snp.bottom) - make.left.right.equalTo(self.view) - make.bottom.equalTo(self.view.safeAreaLayoutGuide) - } - } - + // MARK: Custom Functions /// Add navigation items private func addNavigationItems() { self.title = "FlyoverKit" - let fullscreenBarButtonItem = UIBarButtonItem( - title: "Fullscreen", - style: .plain, - target: self, - action: #selector(fullscreenBarButtonItemTouched(_:)) - ) let githubBarButtonItem = UIBarButtonItem( image: #imageLiteral(resourceName: "github"), style: .plain, target: self, action: #selector(githubBarButtonItemTouched(_:)) ) - self.navigationItem.leftBarButtonItem = fullscreenBarButtonItem self.navigationItem.rightBarButtonItem = githubBarButtonItem } - /// Handle double tap - @objc func fullscreenBarButtonItemTouched(_ sender: UIBarButtonItem) { - self.flyoverMapView.snp.removeConstraints() - self.configurationTableView.snp.removeConstraints() - if self.isMapFullscreen { - self.layoutSubViews() - } else { - self.flyoverMapView.snp.makeConstraints({ (make) in - make.edges.equalTo(self.view.safeAreaLayoutGuide) - }) - } - self.isMapFullscreen = !self.isMapFullscreen - } - /// Github BarButtonItem touched handler - @objc func githubBarButtonItemTouched(_ sender: UIBarButtonItem) { + @objc private func githubBarButtonItemTouched(_ sender: UIBarButtonItem) { guard let url = URL(string: "https://github.com/SvenTiigi/FlyoverKit/blob/master/README.md") else { print("Unable to construct Github Repo URL") return @@ -153,12 +121,12 @@ class ViewController: UIViewController { // MARK: - ConfigurationTableViewDelegate -extension ViewController: ConfigurationTableViewDelegate { +extension ViewController: FlyoverConfigurationTableViewDelegate { /// On Configuration Change /// /// - Parameter configuration: The updated configuration - func onChange(_ configuration: Configuration) { + func onChange(_ configuration: FlyoverConfiguration) { // Switch on configuration switch configuration { case .flyover(let started):