Upgrade to Pro — share decks privately, control downloads, hide ads and more …

EightのUI Component化の取り組み

Masashi
March 05, 2019

EightのUI Component化の取り組み

Mobile Engineer Meetup by Sansan
https://sansan.connpass.com/event/121319/

Masashi

March 05, 2019
Tweet

More Decks by Masashi

Other Decks in Design

Transcript

  1.  GPOUDPMPS GPOUTJ[F GPOUXFJHIUΛ௚઀తʹ໋໊ w 1SPT໊લ͔Β4UZMF͕Πϝʔδ͠΍͍͢ w $POTมߋʹऑ͍  GPOUDPMPS

    GPOUTJ[F GPOUXFJHIUΛந৅తʹ໋໊ w 1SPTมߋʹڧ͍ w $POT໊લ͔Β4UZMF͕Πϝʔδ͠ʹ͍͘  GPOUDPMPS GPOUTJ[F GPOUXFJHIUΛจ຺ʹԠ໋໊ͯ͡ w 1SPTͲͷ5FYU4UZMFΛઃఆͨ͠Βྑ͍͔Πϝʔδ͠΍͍͢ w $POTจ຺͝ͱʹ5FYU4UZMFΛఆٛ͢Δඞཁ͕͋Δ
  2.  GPOUDPMPS GPOUTJ[F GPOUXFJHIUΛ௚઀తʹ໋໊ w 1SPT໊લ͔Β4UZMF͕Πϝʔδ͠΍͍͢ w $POTมߋʹऑ͍  GPOUDPMPS

    GPOUTJ[F GPOUXFJHIUΛந৅తʹ໋໊ w 1SPTมߋʹڧ͍ w $POT໊લ͔Β4UZMF͕Πϝʔδ͠ʹ͍͘  GPOUDPMPS GPOUTJ[F GPOUXFJHIUΛจ຺ʹԠ໋໊ͯ͡ w 1SPTͲͷ5FYU4UZMFΛઃఆͨ͠Βྑ͍͔Πϝʔδ͠΍͍͢ w $POTจ຺͝ͱʹ5FYU4UZMFΛఆٛ͢Δඞཁ͕͋Δ
  3. enum TextStyle: String { case Header case Body private typealias

    StyleDefinition = (size: CGFloat, color: UIColor, weight: UIFont.Weight, lineSpacing: CGFloat) private var definition: StyleDefinition { switch self { case .Header: return (size: 19.0, color: EightColor.white, weight: .semibold, lineSpacing: 4.0) case .Body: return (size: 15.0, color: EightColor.veryDarkGray, weight: .regular, lineSpacing: 3.0) } } var size: CGFloat { return definition.size } var weight: UIFont.Weight { return definition.weight } var font: UIFont { return UIFont.systemFont(ofSize: size, weight: weight) } ɾɾɾ }
  4. @IBDesignable final class EightLabel: UILabel { @IBInspectable var style: String

    = "Body" { didSet { setTextFont() } } } private extension EightLabel { var textStyle: TextStyle { guard let textStyle = TextStyle(rawValue: style) else { fatalError("\(style) is undefined TextStyle") } return textStyle } func setTextFont() { font = textStyle.font textColor = textStyle.color } }