Skip to content

๐ŸŒณ Library created to create GitHub contributions ๐ŸŒฒ

License

Notifications You must be signed in to change notification settings

jjunhaa0211/PerfectContributionsView

Repository files navigation

logoimage

CI Status Carthage Compatible SwiftPM Version License Platform

Table of contents

Screenshots

iPhone

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-11-23 แ„‹แ…ฉแ„’แ…ฎ 1 33 30-2

Installation

CocoaPods:

  • For iOS9+: ๐ŸŒˆ
use_frameworks!
target '<Your Target Name>' do
    pod 'PContributionsView'
end

Carthage:

  • For iOS9+: ๐ŸŒˆ
github "jjunhaa0211/PContributionsView"

SPM:

  • For iOS13+: โšก๏ธ
https://github.com/jjunhaa0211/PerfectContributionsView

Setup

Use Interface Builder

1ใ€ Drag an UIView object to ViewController Scene
2ใ€ Change the Custom Class to PContributionsView

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-11-23 แ„‹แ…ฉแ„’แ…ฎ 1 40 08

Or swift

var activityView: PContributionsView!
// In Class
let dataSquare = [ ]

var contributionView = PContributionsView()

// In loadView or viewDidLoad
contributionView.contrilbutionsData = dataSquare
view.addSubview(contributionView)

Example

To run the example project, clone the repo, and run arch -x86_64 pod install from the Example directory first.

Make Contributions Cell

var activityView: PContributionsView!
// In Class
    let dataActivity = [
        [-1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 3],
        [-1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 1, 4, 2, 1, 2, 1, 3],
        [-1, 1, 1, 1, 2, 3, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 4],
        [-1, 3, 4, 2, 1, 3, 1, 4, 1, 2, 1, 3, 1, 1, 2, 2, 1, 2, 2, 4],
        [1, 2, 4, 3, 2, 3, 2, 3, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2],
        [2, 3, 3, 3, 1, 3, 2, 3, 4, 1, 3, 3, 3, 2, 1, 1, 1, 3, 3],
        [3, 1, 2, 2, 1, 3, 3, 2, 1, 1, 4, 2, 1, 1, 4, 4, 1, 2, 3]
    ]


    var contributionView = PContributionsView()

// In loadView or viewDidLoad
// Interface Builder
        activityView.contrilbutionsData = dataActivity

Change Cell Color

var activityView: PContributionsView!
// In loadView or viewDidLoad
      activityView.userCustomColor(ColorMap("#F4F4F4", "#72FFFF", "#00D7FF", "#0096FF", "#5800FF"))

defult Color is githubContributionsColor ๐ŸŸฉ

CellCornerRadius

var activityView: PContributionsView!
// In Class
    let dataSquare = [
        [-1, 0, -1, 0, -1],
        [0, -1, 0, -1, 0],
        [-1, 0, -1, 0, -1],
        [0, -1, 0, -1, 0],
        [-1, 0, -1, 0, -1],
        [0 ,-1 ,0, -1, 0]
    ]

// In loadView or viewDidLoad
      activityView.cellCornerRadius(10)

defult shape is square

Color Level

// In Class
    let dataSquare = [
        [1, 2, -1, 4, -1],
        [1, -1, 2, 1, 0],
        [4, 2, -1, 0, -1],
        [0, 4, 0, 2, 1],
        [1, 0, -1, 0, -1],
        [4 ,-1 ,0, -1, 1]
    ]
-1 NULL
0 very light
1 little light
2 neutral
3 bit darker
4 very dark

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-11-23 แ„‹แ…ฉแ„’แ…ฎ 2 10 12

ContributionsCell Spacing

var activityView: PContributionsView!
// In loadView or viewDidLoad
      activityView.spacing = 5

defult Spacing is "2"

Change Shape

activityView.shapeType = .hexagon // .rectangle // .triangle // .pentagon

listBackgroud

var activityView: PContributionsView!
// In Class

    let dataActivity = [
        [-1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 3],
        [-1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 1, 4, 2, 1, 2, 1, 3],
        [-1, 1, 1, 1, 2, 3, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 4],
        [-1, 3, 4, 2, 1, 3, 1, 4, 1, 2, 1, 3, 1, 1, 2, 2, 1, 2, 2, 4],
        [1, 2, 4, 3, 2, 3, 2, 3, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2],
        [2, 3, 3, 3, 1, 3, 2, 3, 4, 1, 3, 3, 3, 2, 1, 1, 1, 3, 3],
        [3, 1, 2, 2, 1, 3, 3, 2, 1, 1, 4, 2, 1, 1, 4, 4, 1, 2, 3]
    ]
    
    let dataSquare = [
        [-1, 0, -1, 0, -1],
        [0, -1, 0, -1, 0],
        [-1, 0, -1, 0, -1],
        [0, -1, 0, -1, 0],
        [-1, 0, -1, 0, -1],
        [0 ,-1 ,0, -1, 0]
    ]

// In loadView or viewDidLoad
      activityView.listBackground(.red)
      dataActivity.listBackground(.green)

What is the difference between listBackground and classic BackGround?

  • listBackground is based on the created view, so if there are multiple views in one view, you can change the color of only the one you want.
  • Existing background won't be a single selection

ColorMap

(PerfectContributionsView Color supported)

//In loadView or viewDidLoad

    let colorMap = VioletColorMap()
    let c1 = colorMap.getColor(0)
    let c2 = colorMap.getColor(1)
    let c3 = colorMap.getColor(2)
    let c4 = colorMap.getColor(3)
        
    activityView.userCustomColor(ColorMap(c1, c2, c3, c4, c4))
// Colors currently supported
    let defaultColorMap = DefaultColorMap() // github green color ๐ŸŸฉ
    let violetColorMap = VioletColorMap() // Violet Related colors ๐ŸŸช
    let shootingStarColorMap = ShootingStarColorMap() // shootiongStar color ๐ŸŸฆ

Author

  • ๐Ÿˆโ€โฌ› Github = jjunhaa0211
  • โœ‰๏ธ Gmail = goodjunha@gmail.com
  • ๐ŸŒŸ Dm = jn_xhx

Realization

  • ๐Ÿ‡บ๐Ÿ‡ธ The library still has many bugs. I will correct it little by little. If you find any bugs, please contact me. Advice is always welcome ๐Ÿ˜†
  • ๐Ÿ‡ฐ๐Ÿ‡ท ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—๋Š” ์—ฌ์ „ํžˆ ๋งŽ์€ ๋ฒ„๊ทธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์กฐ๊ธˆ์”ฉ ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ฒ„๊ทธ๋ฅผ ๋ฐœ๊ฒฌํ•˜๋ฉด ์ €์—๊ฒŒ ์—ฐ๋ฝํ•˜์‹ญ์‹œ์˜ค. ์กฐ์–ธ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค ๐Ÿฅน

License

PContributionsView is available under the MIT license. See the LICENSE file for more info.

About

๐ŸŒณ Library created to create GitHub contributions ๐ŸŒฒ

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published