mirror of
https://github.com/SwiftKickMobile/SwiftMessages.git
synced 2026-04-07 19:17:33 +00:00
Check readme rendering
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
Copyright (c) 2016 SwiftKick Mobile LLC
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,4 +1,66 @@
|
||||
# SwiftMessages
|
||||
A designer-friendly iOS message bar written in Swift.
|
||||
|
||||
Under construction.
|
||||
SwiftMessages is a library for displaying temporary status messages on iOS.
|
||||
|
||||
In addition to providing numerous layouts, themes and configuration options, SwiftMessages allows complete control over the design of your message:
|
||||
|
||||
* Copy one of the included nib files into your project and modify it.
|
||||
* Subclass `MessageView` to add elements, etc.
|
||||
* Or just supply an arbitrary view.
|
||||
|
||||
Try exploring [the demo app](./Demo/Demo.xcworkspace) to get a feel for the extensive configurability of SwiftMessages.
|
||||
|
||||
## Installation
|
||||
|
||||
### CocoaPods
|
||||
|
||||
Add the following line to your Podfile:
|
||||
|
||||
````
|
||||
pod 'SwiftMessages'
|
||||
````
|
||||
|
||||
### Carthage
|
||||
|
||||
Todo
|
||||
|
||||
## Usage
|
||||
|
||||
````swift
|
||||
// A type-safe factory method for one of the
|
||||
// provided nib-based layouts. The main bundle is always
|
||||
// searched first, so you can easily copy the nib file
|
||||
// into your project and modify it.
|
||||
let view = MessageView.viewFromNib(layout: .MessageView)
|
||||
|
||||
// One of several convenience methods for theming
|
||||
// message elements.
|
||||
view.configureWarningTheme()
|
||||
|
||||
|
||||
view.configureContent(title: "Warning", body: "Consider yourself warned.", iconText: "🤔")
|
||||
SwiftMessages.show(view: view)
|
||||
````
|
||||
|
||||
````swift
|
||||
SwiftMessages.show {
|
||||
let view = MessageView.viewFromNib(layout: .MessageView)
|
||||
...
|
||||
return view
|
||||
}
|
||||
````
|
||||
|
||||
````swift
|
||||
var config = SwiftMessages.Config()
|
||||
|
||||
config.presentationStyle = .Bottom // Slide up from the bottom
|
||||
config.presentationContext = .Window(windowLevel: UIWindowLevelNormal) // Display over key window
|
||||
config.duration = .Forever // Disable auto-hiding
|
||||
config.dimMode = .Automatic(interactive: true) // Dim the background (like a popover view)
|
||||
config.interactiveHide = false // Disable the interactive hide gesture
|
||||
config.preferredStatusBarStyle = .LightContent // Specify a matching status bar style
|
||||
|
||||
SwiftMessages.show(config: config) { ... }
|
||||
````
|
||||
|
||||
## License
|
||||
@@ -1,11 +1,11 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'SwiftMessages'
|
||||
spec.version = '0.0.1'
|
||||
spec.version = '1.0.0'
|
||||
spec.license = { :type => 'MIT' }
|
||||
spec.homepage = 'https://github.com/SwiftKickMobile/swift-messages-ios'
|
||||
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }
|
||||
spec.summary = 'A designer-friendly iOS message bar written in Swift.'
|
||||
spec.source = {:git => 'https://github.com/SwiftKickMobile/swift-messages-ios.git', :tag => 'v0.0.1'}
|
||||
spec.summary = 'A very flexible message bar for iOS written in Swift.'
|
||||
spec.source = {:git => 'https://github.com/SwiftKickMobile/swift-messages-ios.git', :tag => 'v1.0.0'}
|
||||
spec.platform = :ios, '8.0'
|
||||
spec.ios.deployment_target = '8.0'
|
||||
spec.source_files = 'SwiftMessages/**/*.swift'
|
||||
|
||||
@@ -168,7 +168,7 @@ class Presenter: NSObject, UIGestureRecognizerDelegate {
|
||||
switch config.dimMode {
|
||||
case .None:
|
||||
break
|
||||
case .Automatic(let interactive):
|
||||
case .Default(let interactive):
|
||||
if interactive { setupInteractive() }
|
||||
case .Color(_, let interactive):
|
||||
if interactive { setupInteractive() }
|
||||
@@ -208,9 +208,9 @@ class Presenter: NSObject, UIGestureRecognizerDelegate {
|
||||
switch config.dimMode {
|
||||
case .None:
|
||||
break
|
||||
case .Automatic(let interactive):
|
||||
case .Default:
|
||||
dim(UIColor(white: 0, alpha: 0.3))
|
||||
case .Color(let color, let interactive):
|
||||
case .Color(let color, _):
|
||||
dim(color)
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ class Presenter: NSObject, UIGestureRecognizerDelegate {
|
||||
switch config.dimMode {
|
||||
case .None:
|
||||
break
|
||||
case .Automatic:
|
||||
case .Default:
|
||||
undim()
|
||||
case .Color:
|
||||
undim()
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SwiftMessages: PresenterDelegate {
|
||||
|
||||
public enum DimMode {
|
||||
case None
|
||||
case Automatic(interactive: Bool)
|
||||
case Default(interactive: Bool)
|
||||
case Color(color: UIColor, interactive: Bool)
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ public class SwiftMessages: PresenterDelegate {
|
||||
|
||||
public init() {}
|
||||
|
||||
public var presentationStyle = PresentationStyle.Top
|
||||
|
||||
public var presentationContext = PresentationContext.Automatic
|
||||
|
||||
public var duration = Duration.Automatic
|
||||
|
||||
public var presentationStyle = PresentationStyle.Top
|
||||
|
||||
public var dimMode = DimMode.None
|
||||
|
||||
public var presentationContext = PresentationContext.Automatic
|
||||
|
||||
public var interactiveHide = true
|
||||
|
||||
/**
|
||||
@@ -274,7 +274,7 @@ extension SwiftMessages {
|
||||
return view
|
||||
}
|
||||
|
||||
public class func viewFromNib<T: UIView>(named name: String, bundle: NSBundle, filesOwner: AnyObject = NSNull.init()) throws -> T {
|
||||
public class func viewFromNib<T: UIView>(named name: String, bundle: NSBundle, filesOwner: AnyObject = NSNull.init()) throws -> T {
|
||||
let view: T = try internalViewFromNib(named: name, bundle: bundle, filesOwner: filesOwner)
|
||||
return view
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user