-
Notifications
You must be signed in to change notification settings - Fork 368
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
Whistles #9
Merged
Merged
Whistles #9
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ddea14a
Adds some code for the first status bar button
RamonGilabert 97ddd78
Adds the new file with some initializer for the message
RamonGilabert 9832bfe
Adds some of the core methods
RamonGilabert 57139f0
Adds the main first configurationm
RamonGilabert 4566a3b
Adds the first main configuration for the Whsitle
RamonGilabert 642b501
Adds some security when no navigation bar
RamonGilabert e64d02c
Doing some more work
RamonGilabert 2b40ba3
Adds some more changes to actually display it
RamonGilabert 705bc78
Adds the basic configuration for the status bar snapshot
RamonGilabert 365b01f
Deletes the snapshot of the status bar, crazy difficult
RamonGilabert 5135e6e
Playing with Windows
RamonGilabert bbbded7
Adds a window instead of a view, now this makes it work
RamonGilabert 94496ff
Adds support to the project for landscape
RamonGilabert 857699e
Adds support for landscape now for real
RamonGilabert cd95fb1
Deletes some innecessary code
RamonGilabert 4827c46
Adds forEach everywhere
RamonGilabert 560330a
Not hidding the status bar no more
RamonGilabert 538566e
Moves the code of the status bar away
RamonGilabert 437a8f8
Moves the status bar down or up even with rotation
RamonGilabert 2b1606c
Fixes a bit the issue with it
RamonGilabert 66ce239
Make it resign key window
RamonGilabert b00fa5c
Fixes the rotation problem
RamonGilabert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
+1.83 KB
(110%)
...isperDemo.xcworkspace/xcuserdata/RamonGilabert.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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 |
---|---|---|
|
@@ -55,6 +55,14 @@ class ViewController: UIViewController { | |
return button | ||
}() | ||
|
||
lazy var statusBarButton: UIButton = { [unowned self] in | ||
let button = UIButton() | ||
button.addTarget(self, action: "statusBarButtonDidPress:", forControlEvents: .TouchUpInside) | ||
button.setTitle("Status bar", forState: .Normal) | ||
|
||
return button | ||
}() | ||
|
||
lazy var containerView: UIView = { | ||
let view = UIView() | ||
view.backgroundColor = UIColor.grayColor() | ||
|
@@ -68,9 +76,10 @@ class ViewController: UIViewController { | |
view.backgroundColor = UIColor.whiteColor() | ||
|
||
view.addSubview(scrollView) | ||
for subview in [icon, titleLabel, presentButton, showButton, presentPermanentButton, notificationButton] { scrollView.addSubview(subview) } | ||
for subview in [icon, titleLabel, presentButton, showButton, | ||
presentPermanentButton, notificationButton, statusBarButton] { scrollView.addSubview(subview) } | ||
|
||
for button in [presentButton, showButton, presentPermanentButton, notificationButton] { | ||
for button in [presentButton, showButton, presentPermanentButton, notificationButton, statusBarButton] { | ||
button.setTitleColor(UIColor.grayColor(), forState: .Normal) | ||
button.layer.borderColor = UIColor.grayColor().CGColor | ||
button.layer.borderWidth = 1.5 | ||
|
@@ -120,11 +129,20 @@ class ViewController: UIViewController { | |
} | ||
|
||
func presentNotificationDidPress(button: UIButton) { | ||
let announcement = Announcement(title: "Ramon Gilabert", subtitle: "Vadym Markov just commented your post", image: UIImage(named: "avatar")) | ||
let announcement = Announcement(title: "Ramon Gilabert", | ||
|
||
subtitle: "Vadym Markov just commented your post", image: UIImage(named: "avatar")) | ||
|
||
Shout(announcement, to: self) | ||
} | ||
|
||
func statusBarButtonDidPress(button: UIButton) { | ||
let murmur = Murmur(title: "This is a small whistle", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🐈 |
||
backgroundColor: UIColor(red: 0.975, green: 0.975, blue: 0.975, alpha: 1)) | ||
|
||
Whistle(murmur) | ||
} | ||
|
||
// MARK - Configuration | ||
|
||
func setupFrames() { | ||
|
@@ -136,6 +154,7 @@ class ViewController: UIViewController { | |
showButton.frame = CGRect(x: 50, y: presentButton.frame.maxY + 15, width: totalSize.width - 100, height: 50) | ||
presentPermanentButton.frame = CGRect(x: 50, y: showButton.frame.maxY + 15, width: totalSize.width - 100, height: 50) | ||
notificationButton.frame = CGRect(x: 50, y: presentPermanentButton.frame.maxY + 15, width: totalSize.width - 100, height: 50) | ||
statusBarButton.frame = CGRect(x: 50, y: notificationButton.frame.maxY + 15, width: totalSize.width - 100, height: 50) | ||
} | ||
} | ||
|
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,100 @@ | ||
import UIKit | ||
|
||
let whistleFactory = WhistleFactory() | ||
|
||
public func Whistle(murmur: Murmur) { | ||
whistleFactory.whistler(murmur) | ||
} | ||
|
||
public class WhistleFactory: UIView { | ||
|
||
public lazy var whistleWindow: UIWindow = { | ||
let window = UIWindow() | ||
return window | ||
}() | ||
|
||
public lazy var titleLabel: UILabel = { | ||
let label = UILabel() | ||
label.textAlignment = .Center | ||
|
||
return label | ||
}() | ||
|
||
public var duration: NSTimeInterval = 2 | ||
public var viewController: UIViewController? | ||
public var hideTimer = NSTimer() | ||
|
||
// MARK: - Initializers | ||
|
||
public override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
setupWindow() | ||
clipsToBounds = true | ||
[titleLabel].forEach { addSubview($0) } | ||
} | ||
|
||
public required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Configuration | ||
|
||
public func whistler(murmur: Murmur) { | ||
titleLabel.text = murmur.title | ||
titleLabel.font = murmur.font | ||
titleLabel.textColor = murmur.titleColor | ||
backgroundColor = murmur.backgroundColor | ||
whistleWindow.backgroundColor = murmur.backgroundColor | ||
|
||
setupFrames() | ||
present() | ||
} | ||
|
||
// MARK: - Setup | ||
|
||
public func setupWindow() { | ||
whistleWindow.addSubview(self) | ||
whistleWindow.windowLevel = UIWindowLevelAlert | ||
whistleWindow.clipsToBounds = true | ||
} | ||
|
||
public func setupFrames() { | ||
titleLabel.sizeToFit() | ||
|
||
whistleWindow.frame = CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, | ||
height: UIApplication.sharedApplication().statusBarFrame.height) | ||
frame = whistleWindow.bounds | ||
titleLabel.frame = bounds | ||
} | ||
|
||
// MARK: - Movement methods | ||
|
||
public func present() { | ||
hideTimer.invalidate() | ||
|
||
let initialOrigin = whistleWindow.frame.origin.y | ||
whistleWindow.frame.origin.y = initialOrigin - UIApplication.sharedApplication().statusBarFrame.height | ||
whistleWindow.makeKeyAndVisible() | ||
UIView.animateWithDuration(0.2, animations: { | ||
self.whistleWindow.frame.origin.y = initialOrigin | ||
}) | ||
|
||
hideTimer = NSTimer.scheduledTimerWithTimeInterval(1.5, target: self, selector: "timerDidFire", userInfo: nil, repeats: false) | ||
} | ||
|
||
public func hide() { | ||
let finalOrigin = frame.origin.y - UIApplication.sharedApplication().statusBarFrame.height | ||
UIView.animateWithDuration(0.2, animations: { | ||
self.whistleWindow.frame.origin.y = finalOrigin | ||
}, completion: { _ in | ||
self.window?.makeKeyAndVisible() | ||
}) | ||
} | ||
|
||
// MARK: - Timer methods | ||
|
||
public func timerDidFire() { | ||
hide() | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄