Code Monkey home page Code Monkey logo

graghview's People

Contributors

shoheiyokoyama avatar

Watchers

 avatar  avatar

graghview's Issues

Labelのfont sizeを自動調整

labelの大きさに合わせてフォントサイズを自動調整したいです。

またその逆の、テキストの領域を求めてからlabelのサイズを決める方法も知りたいです。

Dateパラメータ

度々Dateっていう名前を見るんだけど、これはx軸のこと?

GraghViewCell

まず、UITableViewCell, UICollectionViewCellのサブクラス以外でcellという名前をつけるのは良くないかな。

仕様

コードの構文は全体的に良さげ。かけるようになってきたね。
あとは仕様とか軽くまとめてもらうと、設計とかの指摘はできそう。

ライブラリ

類似ライブラリとかは確認したほうがいいかな。
どんな実装になってるかとか、この機能を実現するためにどんな設計をしてるかとかわかるし。
GrapghだったらChartsとか有名かも

Stract名

// GraghViewCellのレイアウトを決定するためのデータ
    struct GraghViewCellLayoutOptions {
        // MARK: Shared
        
        // cellAreaHeight / frame.height
        var barAreaHeightRate: CGFloat = 0.8
        // maxGraghValueRate / maxBarAreaHeight
        var maxGraghValueRate: CGFloat = 0.8
        // cell width
        var cellAreaWidth: CGFloat = 50
        // if over label is hidden
        var valueLabelIsHidden: Bool = false
        
        // MARK: Only Bar
        
        // bar.width / rect.width
        var barWidthRate: CGFloat = 0.5
        // Bar Color
        var barColor = UIColor.init(red: 1.0, green: 0.7, blue: 0.7, alpha: 1.0)
        // Label backgroundColor
        var labelBackgroundColor = UIColor.init(white: 0.95, alpha: 1.0)
        // Gragh backgroundColor
        var GraghBackgroundColor = UIColor.init(white: 0.9, alpha: 1.0)
        
        // MARK: Only Round
        
        // round size / cellAreaWidth
        var roundSizeRate: CGFloat = 0.1
        // round color
        var roundColor = UIColor.init(red: 0.7, green: 0.7, blue: 1.0, alpha: 1.0)
        // if round is hidden
        var onlyPathLine: Bool = false
        
        // MARK: Only Jaggy
        
        // jaggy color
        var jaggyColor = UIColor.init(red: 1.0, green: 1.0, blue: 0.6, alpha: 1.0)
        
        
    }
    
    // GraghViewCellsに付加するViewsのレイアウトを決定するためのデータ
    struct GraghLayoutOptions {
        // MARK: Comparison Value
        
        var comparisonLabelBackgroundColor = UIColor.lightGray.withAlphaComponent(0.7)
        var comparisonLineColor = UIColor.red
        var comparisonLineWidth: CGFloat = 1
        
        // MARK: Round Path
        
        var roundPathWidth: CGFloat = 2
        
        // MARK: Average Value
        var avarageLabelBackgroundColor = UIColor.init(red: 0.8, green: 0.7, blue: 1, alpha: 0.7)
        var averageLineColor = UIColor.init(red: 0.7, green: 0.6, blue: 0.9, alpha: 1)
        var averageLineWidth: CGFloat = 1
        
        
    }

これらの構造体はGraghViewの中に定義されてるから、少し抽象的な命名でいい気がする。
CellLayoutOptionsLayoutOptionsでいい気がするな.cellって名前も...だけどそれは別issueで

sample

class Parent {
    var child = Child()
    
    func registerClosure() {
        child.callback = { number in
            print("Number \(number)")
        }
    }
}

class Child {
    var callback: ((Int) -> ())?
    
    var frame: CGRect = .zero
    
    func call() {
        callback?(3)
    }
}

let p = Parent()
p.registerClosure()
p.child.call()

変数?定数

// GraghViewCellsに付加するViewsのレイアウトを決定するためのデータ
    struct GraghLayoutOptions {
        // MARK: Comparison Value
        
        var comparisonLabelBackgroundColor = UIColor.lightGray.withAlphaComponent(0.7)
        var comparisonLineColor = UIColor.red
        var comparisonLineWidth: CGFloat = 1
        
        // MARK: Round Path
        
        var roundPathWidth: CGFloat = 2
        
        // MARK: Average Value
        var avarageLabelBackgroundColor = UIColor.init(red: 0.8, green: 0.7, blue: 1, alpha: 0.7)
        var averageLineColor = UIColor.init(red: 0.7, green: 0.6, blue: 0.9, alpha: 1)
        var averageLineWidth: CGFloat = 1
        
        
    }

質問だけどここら辺は変数で可読性とかまとまりを持たせるために、stractでまとめてる感じ?

親子関係

いまの #22 だとcallbackパターンで、親のプロパティにアクセスしているけどちょっと微妙だから設計考えよう

親子関係の考え方

  1. 子への通知はchild.param = ..が一番簡潔。これを基本とする
  2. 親が持つ状態を使って子を扱う時は、
  • 初期化時に渡せるpramは渡す
  • 親のpramが更新されたタイミングで子のpramを更新するdidSetとかを使う。
  • 関数と一緒に渡す

これを意識して設計を考えようか
#22 がマージされた後で

関数ジャンプ

// MARK: Only Bar

これ
//MARK: -
じゃないとジャンプできなくない?

enumのcase

enum GraghViewContetOffset {
    case atMinimumDate, atMaximizeDate
}

でいい気がする

enum GraghViewContetOffset {
    case minimumDate, maximizeDate
}

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.