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

Functionality Improvements #17

Open
wants to merge 8 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
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0
5 changes: 3 additions & 2 deletions TVOSToast.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Pod::Spec.new do |s|
#

s.name = "TVOSToast"
s.version = "0.9"
s.version = "0.20b"
s.summary = "Toast component for tvOS with built-in siri remote hint support"
s.swift_version = '4.2'

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
Expand Down Expand Up @@ -80,7 +81,7 @@ Toast component for tvOS with built-in siri remote hint support.
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/svtek/TVOSToast.git", :tag => "#{s.version}" }
s.source = { :git => "https://github.com/DoubleNodeOpen/TVOSToast.git", :tag => "#{s.version}" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
44 changes: 31 additions & 13 deletions TVOSToast.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,21 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = MovieLaLa;
TargetAttributes = {
B23D1A6F1C767711009DED9C = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0830;
LastSwiftMigration = 0900;
};
B23D1A801C767711009DED9C = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0830;
LastSwiftMigration = 0900;
TestTargetID = B23D1A6F1C767711009DED9C;
};
B23D1A8B1C767711009DED9C = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0830;
LastSwiftMigration = 0900;
TestTargetID = B23D1A6F1C767711009DED9C;
};
};
Expand Down Expand Up @@ -363,7 +363,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
51D36D729C78F52125F15FF2 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -378,7 +378,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
54CAF4B15DDEA03BFCAFF67C /* [CP] Embed Pods Frameworks */ = {
Expand Down Expand Up @@ -468,7 +468,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
F24C921A0E5DCF5259C2EBCD /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -550,14 +550,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -596,14 +602,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -639,7 +651,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.TVOSToast;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -654,7 +667,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.TVOSToast;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -668,7 +682,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.TVOSToastTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TVOSToast.app/TVOSToast";
};
name = Debug;
Expand All @@ -683,7 +698,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.TVOSToastTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TVOSToast.app/TVOSToast";
};
name = Release;
Expand All @@ -697,7 +713,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.TVOSToastUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = TVOSToast;
USES_XCTRUNNER = YES;
};
Expand All @@ -712,7 +729,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.TVOSToastUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = TVOSToast;
USES_XCTRUNNER = YES;
};
Expand Down
Binary file modified TVOSToast/Resources/tvosToastMenuBlack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastMenuWhite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastPlayPauseBlack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastPlayPauseWhite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastScreenBlack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastScreenWhite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastSiriBlack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastSiriWhite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastVolumeBlack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TVOSToast/Resources/tvosToastVolumeWhite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 25 additions & 4 deletions TVOSToast/TVOSToast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import ManualLayout
public extension UIViewController {

public func presentToast(_ toast: TVOSToast) {
toast.presentOnView(self.view)
if TVOSToast.currentPresentedToast == nil {
toast.presentOnView(self.view)
}
}
}

Expand All @@ -29,8 +31,8 @@ public extension NSAttributedString {

public convenience init(text: String, font: UIFont, color: UIColor) {
let attributes = [
NSFontAttributeName: font,
NSForegroundColorAttributeName: color
NSAttributedString.Key.font: font,
NSAttributedString.Key.foregroundColor: color
]
self.init(string: text, attributes: attributes)
}
Expand Down Expand Up @@ -147,6 +149,7 @@ public struct TVOSToastStyle {
// appearance
public var backgroundColor: UIColor?
public var cornerRadius: CGFloat?
public var blurEffectStyle: UIBlurEffect.Style?
// text style
public var font: UIFont?
public var textColor: UIColor?
Expand All @@ -164,6 +167,9 @@ public struct TVOSToastStyle {
// MARK: - Toast

open class TVOSToast: UIView {
// The refrence to the currently presented toast. This will prevent multiple toasts from being presented ontop of each other.
internal static var currentPresentedToast: TVOSToast?


// MARK: Properties

Expand Down Expand Up @@ -206,20 +212,34 @@ open class TVOSToast: UIView {
// MARK: Present

open func presentOnView(_ view: UIView) {
TVOSToast.currentPresentedToast = self

// get style
let position = style.position ?? .bottom(insets: 20)
let duration = style.duration ?? 3
let backgroundColor = style.backgroundColor ?? UIColor.gray
let cornerRadius = style.cornerRadius ?? 10
let font = style.font ?? UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)
let font = style.font ?? UIFont.preferredFont(forTextStyle: UIFont.TextStyle.headline)
let textColor = style.textColor ?? UIColor.white

// setup style
self.backgroundColor = backgroundColor
self.layer.cornerRadius = cornerRadius
self.alpha = 0
self.clipsToBounds = true
view.addSubview(self)

// Apply Blur Effect if set.
if let blurEffectStyle = style.blurEffectStyle {
let blurEffect = UIBlurEffect(style: blurEffectStyle)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurEffectView.layer.cornerRadius = cornerRadius

self.addSubview(blurEffectView)
self.sendSubviewToBack(blurEffectView)
}

// setup text
if let hintText = hintText {
Expand Down Expand Up @@ -279,6 +299,7 @@ open class TVOSToast: UIView {
},
completion: { finished in
self.removeFromSuperview()
TVOSToast.currentPresentedToast = nil
})
})
}
Expand Down
4 changes: 2 additions & 2 deletions TVOSToast/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ViewController: UIViewController {
view.addGestureRecognizer(tap)
}

open func showToast(tap: UITapGestureRecognizer) {
@objc open func showToast(tap: UITapGestureRecognizer) {
showToastWithAttributedString()
showToastWithHintText()
showToastWithText()
Expand All @@ -28,7 +28,7 @@ class ViewController: UIViewController {
func showToastWithHintText() {
let toast = TVOSToast(frame: CGRect(x: 0, y: 0, width: 800, height: 140))
toast.style.position = TVOSToastPosition.bottom(insets: 20)
toast.hintText = TVOSToastHintText(element: "Press the" + TVOSToastRemoteButtonType.MenuWhite + " button to exit app")
toast.hintText = TVOSToastHintText(element: "Press the" + TVOSToastRemoteButtonType.MenuWhite + " button to exit app")
presentToast(toast)
}

Expand Down