-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b09d4ee
commit d3e880e
Showing
11 changed files
with
182 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Overseer"] | ||
path = Overseer | ||
url = https://github.com/Kosoku/Overseer.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// | ||
// UIControl+Extensions.swift | ||
// Romita | ||
// | ||
// Created by William Towe on 10/19/23. | ||
// Copyright © 2023 Kosoku Interactive, LLC. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import Foundation | ||
#if os(iOS) || os(tvOS) | ||
import UIKit | ||
|
||
private final class UIControlBlockWrapper: NSObject { | ||
// MARK: - Public Properties | ||
let block: UIControl.Block | ||
weak var control: UIControl? | ||
let controlEvents: UIControl.Event | ||
|
||
// MARK: - Private Functions | ||
@objc | ||
private func controlAction(sender: UIControl) { | ||
self.block(sender, self.controlEvents) | ||
} | ||
|
||
// MARK: - Initializers | ||
init(block: @escaping UIControl.Block, control: UIControl, controlEvents: UIControl.Event) { | ||
self.block = block | ||
self.control = control | ||
self.controlEvents = controlEvents | ||
|
||
super.init() | ||
|
||
control.addTarget(self, action: #selector(controlAction(sender:)), for: self.controlEvents) | ||
} | ||
|
||
deinit { | ||
self.control?.removeTarget(self, action: #selector(controlAction(sender:)), for: self.controlEvents) | ||
} | ||
} | ||
|
||
extension UIControl.Event: Hashable { | ||
// MARK: - Hashable | ||
public func hash(into hasher: inout Hasher) { | ||
hasher.combine(self.rawValue) | ||
} | ||
} | ||
|
||
public extension UIControl { | ||
// MARK: - Public Types | ||
/** | ||
Block to invoke when control events are triggered. | ||
*/ | ||
typealias Block = (UIControl, UIControl.Event) -> Void | ||
|
||
// MARK: - Private Properties | ||
private var controlEventsToControlBlockWrappers: [UIControl.Event: Set<UIControlBlockWrapper>] { | ||
get { | ||
(objc_getAssociatedObject(self, #function) as? [UIControl.Event: Set<UIControlBlockWrapper>]).valueOrEmpty | ||
} | ||
set { | ||
objc_setAssociatedObject(self, #function, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
} | ||
} | ||
|
||
// MARK: - Public Functions | ||
/** | ||
Returns whether the control has blocks associated with it for the provided `controlEvents`. | ||
|
||
- Parameter controlEvents: The control events to check for associated blocks | ||
- Returns: `true` if there are associated blocks, otherwise `false` | ||
*/ | ||
func hasBlocks(forControlEvents controlEvents: UIControl.Event) -> Bool { | ||
self.controlEventsToControlBlockWrappers[controlEvents].isNotNil | ||
} | ||
|
||
/** | ||
Add a `block` to be invoked when the provided `controlEvents` are triggered. | ||
|
||
- Parameter controlEvents: The control events that should invoke `block` | ||
- Parameter block: The block to invoke when `controlEvents` are triggered | ||
*/ | ||
func addBlock(forControlEvents controlEvents: UIControl.Event = .touchUpInside, block: @escaping Block) { | ||
self.addControlBlockWrapper(.init(block: block, control: self, controlEvents: controlEvents)) | ||
} | ||
|
||
/** | ||
Remove all blocks for the provided `controlEvents`. | ||
|
||
- Parameter controlEvents: The control events for which all blocks should be removed | ||
*/ | ||
func removeBlocks(forControlEvents controlEvents: UIControl.Event) { | ||
var wrappers = self.controlEventsToControlBlockWrappers | ||
|
||
wrappers[controlEvents] = nil | ||
|
||
self.controlEventsToControlBlockWrappers = wrappers | ||
} | ||
|
||
// MARK: - Private Functions | ||
private func addControlBlockWrapper(_ wrapper: UIControlBlockWrapper) { | ||
var dict = self.controlEventsToControlBlockWrappers | ||
var wrappers = dict[wrapper.controlEvents].valueOrEmpty | ||
|
||
wrappers.insert(wrapper) | ||
dict[wrapper.controlEvents] = wrappers | ||
|
||
self.controlEventsToControlBlockWrappers = dict | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app | ||
# apple_id("[[APPLE_ID]]") # Your Apple Developer Portal username | ||
|
||
|
||
# For more information about the Appfile, see: | ||
# https://docs.fastlane.tools/advanced/#appfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file contains the fastlane.tools configuration | ||
# You can find the documentation at https://docs.fastlane.tools | ||
# | ||
# For a list of all available actions, check out | ||
# | ||
# https://docs.fastlane.tools/actions | ||
# | ||
# For a list of all available plugins, check out | ||
# | ||
# https://docs.fastlane.tools/plugins/available-plugins | ||
# | ||
|
||
# Uncomment the line if you want fastlane to automatically update itself | ||
# update_fastlane | ||
|
||
$module_scheme_name = "Romita" | ||
|
||
ENV["SCHEME_NAME"] = $module_scheme_name | ||
ENV["MODULE_NAME"] = $module_scheme_name | ||
ENV["INFO_PLIST_PATH"] = "Romita/Info.plist" | ||
ENV["PODSPEC_PATH"] = "Romita.podspec" | ||
ENV["XCODEPROJ_PATH"] = "Romita.xcodeproj" | ||
|
||
import("../Overseer/fastlane/Fastfile") | ||
|
||
default_platform(:ios) |
This file was deleted.
Oops, something went wrong.