GithubHelp home page GithubHelp logo

takaaptech / materialcardview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cemolcay/materialcardview

0.0 2.0 0.0 616 KB

Create material design cards quick and easy

License: MIT License

Ruby 8.37% Swift 91.63%

materialcardview's Introduction

MaterialCardView

Create material design cards quick and easy

Demo

alt tag

Installation

Manuel

Copy & paste MaterialCardView.swift and CEMKit.swift to your project

Cocoapods

Add to your podfile

	pod 'MaterialCardView', '~> 0.0.2'

Usage

Create a MaterialCardView

	let c = MaterialCardView (
			       x: 10,
			       y: StatusBarHeight + 10,
			       w: ScreenWidth-20)  
	view.addSubview (c)

And start to add MaterialCardCells

  • Header Cell
	func addHeader (title: String)
	func addHeader (view: UIView)
  • Cell
	addCell (text: String, action: (()->Void)? = nil)
	addCell (view: UIView, action: (()->Void)? = nil)
	addCell (cell: MaterialCardCell)
  • FooterCell
	func addFooter (title: String)
	func addFooter (view: UIView)

Material Card will update its frame size when you add or remove MaterialCardCells.
This is why you don't set its height value when initilize it.

MaterialCardAppeareance

	var headerBackgroundColor: UIColor
    var cellBackgroundColor: UIColor
    var borderColor: UIColor
    
    var titleFont: UIFont
    var titleColor: UIColor
    
    var textFont: UIFont
    var textColor: UIColor
    
    var shadowColor: UIColor
    var rippleColor: UIColor
    var rippleDuration: NSTimeInterval

You can change MaterialCardView appeareance by its appeareance property.

The default appeareance is

    func defaultAppeareance () -> MaterialCardAppeareance {
        return MaterialCardAppeareance (
            headerBackgroundColor: UIColor.CardHeaderColor(),
            cellBackgroundColor: UIColor.CardCellColor(),
            borderColor: UIColor.CardBorderColor(),
            titleFont: UIFont.TitleFont(),
            titleColor: UIColor.TitleColor(),
            textFont: UIFont.TextFont(),
            textColor: UIColor.TextColor(),
            shadowColor: UIColor.ShadowColor(),
            rippleColor: UIColor.RippleColor(),
            rippleDuration: rippleDuration)
    }

Which are UIColor and UIFont extensions defined at top of MaterialCardView.swift file.

MaterialAnimationTimingFunction

    enum MaterialAnimationTimingFunction {
        case SwiftEnterInOut
        case SwiftExitInOut
        
        func timingFunction () -> CAMediaTimingFunction {
            switch self {
                
            case .SwiftEnterInOut:
                return CAMediaTimingFunction (controlPoints: 0.4027, 0, 0.1, 1)
                
            case .SwiftExitInOut:
                return CAMediaTimingFunction (controlPoints: 0.4027, 0, 0.2256, 1)
            }
        }
    }

SwiftEnterInOut

(0.4027, 0, 0.1, 1)

SwiftExitInOut

(0.4027, 0, 0.2256, 1)

MaterialRippleLocation

enum MaterialRippleLocation {
    case Center
    case TouchLocation
}

RippleLayer

Adds ripple animation when you add cells with action
	c.addCell("Item 1") { sender in 
		println("item 1 tapped") 
	}

alt tag

Add ripple to material card
     c.addRipple { () -> Void in
       println("all card ripples")
   }

alt tag

materialcardview's People

Contributors

cemolcay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.