├── .gitignore ├── FlashLabel.podspec ├── FlashLabel.swift ├── FlashLabel.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── FlashLabel ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── FlashLabelTests ├── FlashLabelTests.swift └── Info.plist ├── LICENSE ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | # CocoaPods 20 | # 21 | # We recommend against adding the Pods directory to your .gitignore. However 22 | # you should judge for yourself, the pros and cons are mentioned at: 23 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 24 | # 25 | # Pods/ 26 | -------------------------------------------------------------------------------- /FlashLabel.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'FlashLabel' 3 | s.version = '0.4.0' 4 | s.license = 'MIT' 5 | s.summary = 'Simple and Lightweight Timer Label for Mac' 6 | s.homepage = 'https://github.com/kaunteya/FlashLabel' 7 | s.authors = { 'Kaunteya Suryawanshi' => 'k.suryawanshi@gmail.com' } 8 | s.source = { :git => 'https://github.com/kaunteya/FlashLabel.git', :tag => s.version } 9 | 10 | s.platform = :osx, '10.10' 11 | s.requires_arc = true 12 | 13 | s.source_files = 'FlashLabel.swift' 14 | end 15 | -------------------------------------------------------------------------------- /FlashLabel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlashLabel.swift 3 | // FlashLabel 4 | // 5 | // Created by Kauntey Suryawanshi on 07/07/15. 6 | // Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Cocoa 11 | 12 | public class FlashLabel: NSTextField { 13 | 14 | private var timer: Timer! 15 | private var timeSummation = CGFloat(0) 16 | let flashInterval = TimeInterval(0.5) 17 | var showTime: CGFloat! 18 | 19 | required public init?(coder: NSCoder) { 20 | super.init(coder: coder) 21 | self.wantsLayer = true 22 | self.layer!.anchorPoint = CGPoint(x: 0.5, y: 0.5) 23 | 24 | self.setVisibility(false, animated: false) 25 | } 26 | 27 | var showAnimation: CABasicAnimation = { 28 | var showAnimation = CABasicAnimation() 29 | showAnimation = CABasicAnimation(keyPath: "opacity") 30 | showAnimation.duration = 2 31 | showAnimation.fromValue = 0 32 | showAnimation.toValue = 1 33 | showAnimation.repeatCount = 0 34 | return showAnimation 35 | }() 36 | 37 | var hideAnimation: CABasicAnimation = { 38 | var showAnimation = CABasicAnimation() 39 | showAnimation = CABasicAnimation(keyPath: "opacity") 40 | showAnimation.duration = 2 41 | showAnimation.fromValue = 1 42 | showAnimation.toValue = 0 43 | showAnimation.repeatCount = 0 44 | return showAnimation 45 | }() 46 | 47 | /** 48 | Shows the FlashLabel for specified time 49 | 50 | - parameter text: Stringvalue of the label 51 | - parameter time: Time to live in seconds 52 | - parameter flash: enabled will flash/blink the label 53 | 54 | */ 55 | public func show(_ text: String, forDuration time: CGFloat, withFlash flash: Bool) { 56 | self.setVisibility(true, animated: false) 57 | self.stringValue = text 58 | self.sizeToFit() 59 | if flash { 60 | timeSummation = 0 61 | showTime = time 62 | timer = Timer.scheduledTimer(timeInterval: flashInterval, target: self, selector: #selector(FlashLabel.flashNotify), userInfo: nil, repeats: true) 63 | } else { 64 | timer = Timer.scheduledTimer(timeInterval: TimeInterval(time), target: self, selector: #selector(FlashLabel.timerNotify), userInfo: nil, repeats: false) 65 | } 66 | } 67 | 68 | func timerNotify() { 69 | self.setVisibility(false, animated: true) 70 | } 71 | 72 | private var visible = false 73 | func flashNotify() { 74 | if timeSummation < showTime { 75 | timeSummation += 0.5 76 | self.setVisibility(visible, animated: false) 77 | visible = !visible 78 | } else { 79 | timer.invalidate() 80 | self.setVisibility(false, animated: false) 81 | } 82 | } 83 | 84 | func setVisibility(_ enabled: Bool, animated: Bool) { 85 | if animated { 86 | if enabled { 87 | self.layer!.add(showAnimation, forKey: nil) 88 | } else { 89 | self.layer!.add(hideAnimation, forKey: nil) 90 | } 91 | } 92 | self.layer!.opacity = enabled ? 1 : 0 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /FlashLabel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E3530A421B4C2D6D0023CE3B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3530A411B4C2D6D0023CE3B /* AppDelegate.swift */; }; 11 | E3530A441B4C2D6D0023CE3B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3530A431B4C2D6D0023CE3B /* ViewController.swift */; }; 12 | E3530A491B4C2D6D0023CE3B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E3530A471B4C2D6D0023CE3B /* Main.storyboard */; }; 13 | E3530A551B4C2D6D0023CE3B /* FlashLabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3530A541B4C2D6D0023CE3B /* FlashLabelTests.swift */; }; 14 | E3D8E7541B4C2F150069B17B /* FlashLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3D8E7531B4C2F150069B17B /* FlashLabel.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | E3530A4F1B4C2D6D0023CE3B /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = E3530A341B4C2D6D0023CE3B /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = E3530A3B1B4C2D6D0023CE3B; 23 | remoteInfo = FlashLabel; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | E3530A3C1B4C2D6D0023CE3B /* FlashLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FlashLabel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | E3530A401B4C2D6D0023CE3B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | E3530A411B4C2D6D0023CE3B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 31 | E3530A431B4C2D6D0023CE3B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 32 | E3530A481B4C2D6D0023CE3B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 33 | E3530A4E1B4C2D6D0023CE3B /* FlashLabelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FlashLabelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | E3530A531B4C2D6D0023CE3B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | E3530A541B4C2D6D0023CE3B /* FlashLabelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlashLabelTests.swift; sourceTree = ""; }; 36 | E3D8E7531B4C2F150069B17B /* FlashLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlashLabel.swift; sourceTree = ""; }; 37 | E3F348F41BC64CAD00FB4317 /* FlashLabel.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FlashLabel.podspec; sourceTree = SOURCE_ROOT; }; 38 | E3F348F61BC64DC300FB4317 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | E3530A391B4C2D6D0023CE3B /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | E3530A4B1B4C2D6D0023CE3B /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | E3530A331B4C2D6D0023CE3B = { 60 | isa = PBXGroup; 61 | children = ( 62 | E3D8E7531B4C2F150069B17B /* FlashLabel.swift */, 63 | E3530A3E1B4C2D6D0023CE3B /* FlashLabel */, 64 | E3530A511B4C2D6D0023CE3B /* FlashLabelTests */, 65 | E3530A3D1B4C2D6D0023CE3B /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | E3530A3D1B4C2D6D0023CE3B /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | E3530A3C1B4C2D6D0023CE3B /* FlashLabel.app */, 73 | E3530A4E1B4C2D6D0023CE3B /* FlashLabelTests.xctest */, 74 | ); 75 | name = Products; 76 | sourceTree = ""; 77 | }; 78 | E3530A3E1B4C2D6D0023CE3B /* FlashLabel */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | E3530A411B4C2D6D0023CE3B /* AppDelegate.swift */, 82 | E3530A431B4C2D6D0023CE3B /* ViewController.swift */, 83 | E3530A471B4C2D6D0023CE3B /* Main.storyboard */, 84 | E3530A3F1B4C2D6D0023CE3B /* Supporting Files */, 85 | ); 86 | path = FlashLabel; 87 | sourceTree = ""; 88 | }; 89 | E3530A3F1B4C2D6D0023CE3B /* Supporting Files */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | E3530A401B4C2D6D0023CE3B /* Info.plist */, 93 | ); 94 | name = "Supporting Files"; 95 | sourceTree = ""; 96 | }; 97 | E3530A511B4C2D6D0023CE3B /* FlashLabelTests */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | E3530A541B4C2D6D0023CE3B /* FlashLabelTests.swift */, 101 | E3530A521B4C2D6D0023CE3B /* Supporting Files */, 102 | ); 103 | path = FlashLabelTests; 104 | sourceTree = ""; 105 | }; 106 | E3530A521B4C2D6D0023CE3B /* Supporting Files */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | E3F348F41BC64CAD00FB4317 /* FlashLabel.podspec */, 110 | E3F348F61BC64DC300FB4317 /* README.md */, 111 | E3530A531B4C2D6D0023CE3B /* Info.plist */, 112 | ); 113 | name = "Supporting Files"; 114 | sourceTree = ""; 115 | }; 116 | /* End PBXGroup section */ 117 | 118 | /* Begin PBXNativeTarget section */ 119 | E3530A3B1B4C2D6D0023CE3B /* FlashLabel */ = { 120 | isa = PBXNativeTarget; 121 | buildConfigurationList = E3530A581B4C2D6D0023CE3B /* Build configuration list for PBXNativeTarget "FlashLabel" */; 122 | buildPhases = ( 123 | E3530A381B4C2D6D0023CE3B /* Sources */, 124 | E3530A391B4C2D6D0023CE3B /* Frameworks */, 125 | E3530A3A1B4C2D6D0023CE3B /* Resources */, 126 | ); 127 | buildRules = ( 128 | ); 129 | dependencies = ( 130 | ); 131 | name = FlashLabel; 132 | productName = FlashLabel; 133 | productReference = E3530A3C1B4C2D6D0023CE3B /* FlashLabel.app */; 134 | productType = "com.apple.product-type.application"; 135 | }; 136 | E3530A4D1B4C2D6D0023CE3B /* FlashLabelTests */ = { 137 | isa = PBXNativeTarget; 138 | buildConfigurationList = E3530A5B1B4C2D6D0023CE3B /* Build configuration list for PBXNativeTarget "FlashLabelTests" */; 139 | buildPhases = ( 140 | E3530A4A1B4C2D6D0023CE3B /* Sources */, 141 | E3530A4B1B4C2D6D0023CE3B /* Frameworks */, 142 | E3530A4C1B4C2D6D0023CE3B /* Resources */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | E3530A501B4C2D6D0023CE3B /* PBXTargetDependency */, 148 | ); 149 | name = FlashLabelTests; 150 | productName = FlashLabelTests; 151 | productReference = E3530A4E1B4C2D6D0023CE3B /* FlashLabelTests.xctest */; 152 | productType = "com.apple.product-type.bundle.unit-test"; 153 | }; 154 | /* End PBXNativeTarget section */ 155 | 156 | /* Begin PBXProject section */ 157 | E3530A341B4C2D6D0023CE3B /* Project object */ = { 158 | isa = PBXProject; 159 | attributes = { 160 | LastSwiftMigration = 0700; 161 | LastSwiftUpdateCheck = 0700; 162 | LastUpgradeCheck = 0800; 163 | ORGANIZATIONNAME = "Kauntey Suryawanshi"; 164 | TargetAttributes = { 165 | E3530A3B1B4C2D6D0023CE3B = { 166 | CreatedOnToolsVersion = 6.3.2; 167 | LastSwiftMigration = 0800; 168 | }; 169 | E3530A4D1B4C2D6D0023CE3B = { 170 | CreatedOnToolsVersion = 6.3.2; 171 | LastSwiftMigration = 0800; 172 | TestTargetID = E3530A3B1B4C2D6D0023CE3B; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = E3530A371B4C2D6D0023CE3B /* Build configuration list for PBXProject "FlashLabel" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = English; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | Base, 183 | ); 184 | mainGroup = E3530A331B4C2D6D0023CE3B; 185 | productRefGroup = E3530A3D1B4C2D6D0023CE3B /* Products */; 186 | projectDirPath = ""; 187 | projectRoot = ""; 188 | targets = ( 189 | E3530A3B1B4C2D6D0023CE3B /* FlashLabel */, 190 | E3530A4D1B4C2D6D0023CE3B /* FlashLabelTests */, 191 | ); 192 | }; 193 | /* End PBXProject section */ 194 | 195 | /* Begin PBXResourcesBuildPhase section */ 196 | E3530A3A1B4C2D6D0023CE3B /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | E3530A491B4C2D6D0023CE3B /* Main.storyboard in Resources */, 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | }; 204 | E3530A4C1B4C2D6D0023CE3B /* Resources */ = { 205 | isa = PBXResourcesBuildPhase; 206 | buildActionMask = 2147483647; 207 | files = ( 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | }; 211 | /* End PBXResourcesBuildPhase section */ 212 | 213 | /* Begin PBXSourcesBuildPhase section */ 214 | E3530A381B4C2D6D0023CE3B /* Sources */ = { 215 | isa = PBXSourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | E3530A441B4C2D6D0023CE3B /* ViewController.swift in Sources */, 219 | E3D8E7541B4C2F150069B17B /* FlashLabel.swift in Sources */, 220 | E3530A421B4C2D6D0023CE3B /* AppDelegate.swift in Sources */, 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | }; 224 | E3530A4A1B4C2D6D0023CE3B /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | E3530A551B4C2D6D0023CE3B /* FlashLabelTests.swift in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXTargetDependency section */ 235 | E3530A501B4C2D6D0023CE3B /* PBXTargetDependency */ = { 236 | isa = PBXTargetDependency; 237 | target = E3530A3B1B4C2D6D0023CE3B /* FlashLabel */; 238 | targetProxy = E3530A4F1B4C2D6D0023CE3B /* PBXContainerItemProxy */; 239 | }; 240 | /* End PBXTargetDependency section */ 241 | 242 | /* Begin PBXVariantGroup section */ 243 | E3530A471B4C2D6D0023CE3B /* Main.storyboard */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | E3530A481B4C2D6D0023CE3B /* Base */, 247 | ); 248 | name = Main.storyboard; 249 | sourceTree = ""; 250 | }; 251 | /* End PBXVariantGroup section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | E3530A561B4C2D6D0023CE3B /* Debug */ = { 255 | isa = XCBuildConfiguration; 256 | buildSettings = { 257 | ALWAYS_SEARCH_USER_PATHS = NO; 258 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 259 | CLANG_CXX_LIBRARY = "libc++"; 260 | CLANG_ENABLE_MODULES = YES; 261 | CLANG_ENABLE_OBJC_ARC = YES; 262 | CLANG_WARN_BOOL_CONVERSION = YES; 263 | CLANG_WARN_CONSTANT_CONVERSION = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_EMPTY_BODY = YES; 266 | CLANG_WARN_ENUM_CONVERSION = YES; 267 | CLANG_WARN_INFINITE_RECURSION = YES; 268 | CLANG_WARN_INT_CONVERSION = YES; 269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 270 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 271 | CLANG_WARN_UNREACHABLE_CODE = YES; 272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 273 | CODE_SIGN_IDENTITY = "-"; 274 | COPY_PHASE_STRIP = NO; 275 | DEBUG_INFORMATION_FORMAT = dwarf; 276 | ENABLE_STRICT_OBJC_MSGSEND = YES; 277 | ENABLE_TESTABILITY = YES; 278 | GCC_C_LANGUAGE_STANDARD = gnu99; 279 | GCC_DYNAMIC_NO_PIC = NO; 280 | GCC_NO_COMMON_BLOCKS = YES; 281 | GCC_OPTIMIZATION_LEVEL = 0; 282 | GCC_PREPROCESSOR_DEFINITIONS = ( 283 | "DEBUG=1", 284 | "$(inherited)", 285 | ); 286 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | MACOSX_DEPLOYMENT_TARGET = 10.10; 294 | MTL_ENABLE_DEBUG_INFO = YES; 295 | ONLY_ACTIVE_ARCH = YES; 296 | SDKROOT = macosx; 297 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 298 | }; 299 | name = Debug; 300 | }; 301 | E3530A571B4C2D6D0023CE3B /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 306 | CLANG_CXX_LIBRARY = "libc++"; 307 | CLANG_ENABLE_MODULES = YES; 308 | CLANG_ENABLE_OBJC_ARC = YES; 309 | CLANG_WARN_BOOL_CONVERSION = YES; 310 | CLANG_WARN_CONSTANT_CONVERSION = YES; 311 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 312 | CLANG_WARN_EMPTY_BODY = YES; 313 | CLANG_WARN_ENUM_CONVERSION = YES; 314 | CLANG_WARN_INFINITE_RECURSION = YES; 315 | CLANG_WARN_INT_CONVERSION = YES; 316 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 317 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 318 | CLANG_WARN_UNREACHABLE_CODE = YES; 319 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 320 | CODE_SIGN_IDENTITY = "-"; 321 | COPY_PHASE_STRIP = NO; 322 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 323 | ENABLE_NS_ASSERTIONS = NO; 324 | ENABLE_STRICT_OBJC_MSGSEND = YES; 325 | GCC_C_LANGUAGE_STANDARD = gnu99; 326 | GCC_NO_COMMON_BLOCKS = YES; 327 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 328 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 329 | GCC_WARN_UNDECLARED_SELECTOR = YES; 330 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 331 | GCC_WARN_UNUSED_FUNCTION = YES; 332 | GCC_WARN_UNUSED_VARIABLE = YES; 333 | MACOSX_DEPLOYMENT_TARGET = 10.10; 334 | MTL_ENABLE_DEBUG_INFO = NO; 335 | SDKROOT = macosx; 336 | }; 337 | name = Release; 338 | }; 339 | E3530A591B4C2D6D0023CE3B /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 343 | COMBINE_HIDPI_IMAGES = YES; 344 | INFOPLIST_FILE = FlashLabel/Info.plist; 345 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 346 | PRODUCT_BUNDLE_IDENTIFIER = "com.kaunteya.$(PRODUCT_NAME:rfc1034identifier)"; 347 | PRODUCT_NAME = "$(TARGET_NAME)"; 348 | SWIFT_VERSION = 3.0; 349 | }; 350 | name = Debug; 351 | }; 352 | E3530A5A1B4C2D6D0023CE3B /* Release */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 356 | COMBINE_HIDPI_IMAGES = YES; 357 | INFOPLIST_FILE = FlashLabel/Info.plist; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 359 | PRODUCT_BUNDLE_IDENTIFIER = "com.kaunteya.$(PRODUCT_NAME:rfc1034identifier)"; 360 | PRODUCT_NAME = "$(TARGET_NAME)"; 361 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 362 | SWIFT_VERSION = 3.0; 363 | }; 364 | name = Release; 365 | }; 366 | E3530A5C1B4C2D6D0023CE3B /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | BUNDLE_LOADER = "$(TEST_HOST)"; 370 | COMBINE_HIDPI_IMAGES = YES; 371 | FRAMEWORK_SEARCH_PATHS = ( 372 | "$(DEVELOPER_FRAMEWORKS_DIR)", 373 | "$(inherited)", 374 | ); 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | INFOPLIST_FILE = FlashLabelTests/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 381 | PRODUCT_BUNDLE_IDENTIFIER = "com.kaunteya.$(PRODUCT_NAME:rfc1034identifier)"; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | SWIFT_VERSION = 3.0; 384 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FlashLabel.app/Contents/MacOS/FlashLabel"; 385 | }; 386 | name = Debug; 387 | }; 388 | E3530A5D1B4C2D6D0023CE3B /* Release */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | BUNDLE_LOADER = "$(TEST_HOST)"; 392 | COMBINE_HIDPI_IMAGES = YES; 393 | FRAMEWORK_SEARCH_PATHS = ( 394 | "$(DEVELOPER_FRAMEWORKS_DIR)", 395 | "$(inherited)", 396 | ); 397 | INFOPLIST_FILE = FlashLabelTests/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = "com.kaunteya.$(PRODUCT_NAME:rfc1034identifier)"; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 402 | SWIFT_VERSION = 3.0; 403 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FlashLabel.app/Contents/MacOS/FlashLabel"; 404 | }; 405 | name = Release; 406 | }; 407 | /* End XCBuildConfiguration section */ 408 | 409 | /* Begin XCConfigurationList section */ 410 | E3530A371B4C2D6D0023CE3B /* Build configuration list for PBXProject "FlashLabel" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | E3530A561B4C2D6D0023CE3B /* Debug */, 414 | E3530A571B4C2D6D0023CE3B /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | E3530A581B4C2D6D0023CE3B /* Build configuration list for PBXNativeTarget "FlashLabel" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | E3530A591B4C2D6D0023CE3B /* Debug */, 423 | E3530A5A1B4C2D6D0023CE3B /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | E3530A5B1B4C2D6D0023CE3B /* Build configuration list for PBXNativeTarget "FlashLabelTests" */ = { 429 | isa = XCConfigurationList; 430 | buildConfigurations = ( 431 | E3530A5C1B4C2D6D0023CE3B /* Debug */, 432 | E3530A5D1B4C2D6D0023CE3B /* Release */, 433 | ); 434 | defaultConfigurationIsVisible = 0; 435 | defaultConfigurationName = Release; 436 | }; 437 | /* End XCConfigurationList section */ 438 | }; 439 | rootObject = E3530A341B4C2D6D0023CE3B /* Project object */; 440 | } 441 | -------------------------------------------------------------------------------- /FlashLabel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FlashLabel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // FlashLabel 4 | // 5 | // Created by Kauntey Suryawanshi on 07/07/15. 6 | // Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /FlashLabel/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | Default 510 | 511 | 512 | 513 | 514 | 515 | 516 | Left to Right 517 | 518 | 519 | 520 | 521 | 522 | 523 | Right to Left 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | Default 535 | 536 | 537 | 538 | 539 | 540 | 541 | Left to Right 542 | 543 | 544 | 545 | 546 | 547 | 548 | Right to Left 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 701 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | -------------------------------------------------------------------------------- /FlashLabel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2015 Kauntey Suryawanshi. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /FlashLabel/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // FlashLabel 4 | // 5 | // Created by Kauntey Suryawanshi on 07/07/15. 6 | // Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | var enableFlash: Bool = false 13 | @IBOutlet weak var flashLabel: FlashLabel! 14 | 15 | @IBAction func enableFlash(_ sender: NSButton) { 16 | enableFlash = sender.state == NSOnState 17 | } 18 | 19 | @IBAction func buttonPressed(_ sender: NSButton) { 20 | flashLabel.show("Please enter a valid password", forDuration: 2, withFlash: self.enableFlash) 21 | } 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /FlashLabelTests/FlashLabelTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlashLabelTests.swift 3 | // FlashLabelTests 4 | // 5 | // Created by Kauntey Suryawanshi on 07/07/15. 6 | // Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class FlashLabelTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FlashLabelTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kaunteya Suryawanshi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FlashLabel 2 | 3 | `FlashLabel` is simple and lightweight Timer based Label for Mac OSX implemented in Swift. 4 | ![](./demo.gif) 5 | 6 | FlashLabel will fadeout the Label after a specific time. 7 | It can be used for 8 | - Alerts 9 | - Notification 10 | - Activity Progress 11 | 12 | The best part about flash label is that it does not demand user interaction unlike alerts and notifications. 13 | 14 | ##Requirements 15 | - Mac OS X 10.10 16 | - Xcode 7 17 | 18 | ##Installation 19 | ####Direct 20 | Drag `FlashLabel.swift` to your project. That is it! 21 | 22 | ####CocoaPods 23 | [CocoaPods](http://cocoapods.org) adds supports for Swift and embedded frameworks. 24 | 25 | To integrate FlashLabel into your Xcode project using CocoaPods, specify it in your `Podfile`: 26 | 27 | ```ruby 28 | use_frameworks! 29 | 30 | pod 'FlashLabel' 31 | ``` 32 | 33 | Then, run the following command: 34 | 35 | ```bash 36 | $ pod install 37 | ``` 38 | 39 | 40 | ##Usage 41 | In Interface builder, drag a `Label` from Object Library and set `Custom Class` to `FlashLabel` 42 | and 43 | ```swift 44 | flashLabel.show("Please enter a valid password", forDuration: 3.1, withFlash: false) 45 | ``` 46 | 47 | ##License 48 | `FlashLabel` is released under the MIT license. See LICENSE for details. 49 | 50 | 51 | 52 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kaunteya/flashlabel/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 53 | 54 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaunteya/FlashLabel/b91eee2681f4605c617f93e91fbf7311193df156/demo.gif --------------------------------------------------------------------------------