Skip to content

evgenyneu/Dodo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔨🔨🔨 This is work in progress 🔨🔨🔨

A notification bar for iOS written in Swift

This is a UI widget for showing notification messages in iOS apps.

  • It has built-in style presets for common types of messages: success, info, warning and error.
  • The bar can have buttons with custom tap handlers.
  • Bar styles can be customized.
  • Includes customizable animations for showing and hiding the bar.

Dodo, from  Alice's Adventures in Wonderland

At last the Dodo said, `EVERYBODY has won, and all must have prizes.'

From Alice's Adventures in Wonderland.

Usage

Show and hide notification bar

view.dodo.success("Everybody has won and all must have prizes.")
view.dodo.info("Extinction is the rule. Survival is the exception.")
view.dodo.warning("This world is but a canvas to our imagination.")
view.dodo.error("The perception of beauty is a moral test.")

view.dodo.hide()

Note: if there is an existing notification bar in a UIView it will be replaced by the new one.

Dodo success presets

Dodo info presets

Dodo warning presets

Dodo error presets

Styling

view.dodo.style.label.color = UIColor.whiteColor()
view.dodo.style.label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
view.dodo.style.bar.backgroundColor = DodoColor.fromHexString("#00000090")
view.dodo.style.bar.cornerRadius = 0
view.dodo.style.bar.marginToSuperview = CGSize(width: 0, height: 0)

Add buttons or icons

view.dodo.style.leftButton.image = UIImage(named: "CloseIcon")
view.dodo.style.leftButton.tintColor = DodoColor.fromHexString("#FFFFFF90")
view.dodo.style.leftButton.onTap = { /* Button tapped */ }

Dodo bar with left buttons

Dodo bar with right and left buttons

Customize animation

// Use existing animations
view.dodo.style.bar.animationShow = DodoAnimations.fadeIn
view.dodo.style.bar.animationHide = DodoAnimations.fadeOut
// Turn off animation
view.dodo.style.bar.animationShow = DodoAnimations.noAnimation
view.dodo.style.bar.animationHide = DodoAnimations.noAnimation
// Privide custom animation

view.dodo.style.bar.animationShow = { view, locationTop, completed in
  view.transform = CGAffineTransformMakeTranslation(0, locationTop ? -100 : 100)

  UIView.animateWithDuration(0.5,
    delay: 0,
    usingSpringWithDamping: 1,
    initialSpringVelocity: 1,
    options: nil,
    animations: {
      view.transform = CGAffineTransformIdentity
    },
    completion: { finished in
      completed()
    }
  )
}

About

A message bar for iOS written in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages