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

Diversity is Good

nakajijapan
October 23, 2015
250

Diversity is Good

Shibuya Swift #01

nakajijapan

October 23, 2015
Tweet

Transcript

  1. Diversity is Good
    Shibuya.swift #1
    @nakajijapan
    Introducing to PhotoSlider for swift

    View Slide

  2. About Me

    View Slide

  3. @nakajijapan
    Software Engineer
    GMO PEPABO inc.
    iOS / Web / OS X

    View Slide

  4. View Slide

  5. GitHub

    View Slide

  6. Talk about

    View Slide

  7. PhotoSlider

    View Slide

  8. Talk about
    • ެ։
    • ͳͥ࡞੒ͨ͠ͷ͔
    • ӡ༻ϑΣʔζ
    • εϫΠϓͰ࡟আͰ͖ΔΑ͏ʹͳΔ·Ͱ
    • Ճ଎౓ͷௐ੔
    • ΋ͬͱؾ࣋ͪྑ͘
    • ެ։͔ͯ͠Βͷ൓Ԡ

    View Slide

  9. Why?

    View Slide

  10. PhotoSlider
    • ༷ʑͳձࣾͰར༻͞Ε͍ͯΔը૾ʹϑΥʔΧεͨ͠ɺݟΔઐ༻ͷը໘
    • ͚ͦͬͳ͍
    • ଞͱมΘΒͳ͍
    • ΋ͬͱྑ͍ײ͡ʹ͍ͨ͠

    View Slide

  11. PhotoSlider
    • OSSʹࣅͨΑ͏ͳ΋ͷ͸ͳ͍΋ͷ͔

    View Slide

  12. PhotoSlider
    193

    View Slide

  13. PhotoSlider
    30

    View Slide

  14. PhotoSlider
    • OSSʹࣅͨΑ͏ͳ΋ͷ͸ͳ͍΋ͷ͔
    • IDMPhotoBrowser
    • Facebook, TwitterͷΠϯλϥΫγϣϯΛऔΓೖΕͯྑͦ͞͏
    • MWPhotoBrowserͷ೿ੜܥ
    • εϫΠϓͰ࡟আ͢ΔඍົͳΞχϝʔγϣϯ͕ؾʹ৯Θͳ͍
    • ϝϯς͞Ε͍ͯͳ͍…
    • ྑ͍ײ͡ͷ΋ͷ͕ͳ͍

    View Slide

  15. SwiftͰʂ

    View Slide

  16. Release as OSS

    View Slide

  17. Maintenance
    • ΠϯλϥΫγϣϯͷվળ
    • CollectionView໰୊
    • εΫϩʔϧͷ଎౓Ͱը໘Λ࡟আ͍ͨ͠
    • PhotoSliderʹը໘ભҠ࣌ͷΞχϝʔγϣϯ(Transition)
    • ؆୯ͳUI Testingಋೖ
    • ϦϦʔε࣌ͷόʔδϣχϯά

    View Slide

  18. CollectionView
    ಋೖࣦഊ

    View Slide

  19. *NBHF
    CollectionViewಋೖࣦഊ
    • ࣮૷͸؆୯ʹͰ͖ͨ
    • εΫϩʔϧ࣌ʹࢦͱϏϡʔʹ͕ࠩग़͖ͯͨ
    *NBHF

    View Slide

  20. CollectionViewಋೖࣦഊ

    View Slide

  21. CollectionViewಋೖࣦഊ
    • ScrollViewͰ࡞Γ௚͠
    • ͨͩ͜Ε͚ͩͩͱCollectionViewͱಉ͡ݱ৅ʹͳΔ
    *NBHF *NBHF *NBHF *NBHF
    *NBHF

    View Slide

  22. *NBHF
    CollectionViewಋೖࣦഊ
    • ScrollViewΛ޿͛Δ
    • ҧ࿨ײͳ͍εΫϩʔϧ͕࣮ݱͰ͖Δ
    *NBHF *NBHF *NBHF
    *NBHF
    ScrollView
    ্Լʹ΋εϫΠϓͰ͖Δ͔ͷΑ͏ʹ͢Δ

    View Slide

  23. CollectionViewಋೖࣦഊ
    • ΋͔ͨ͠͠ΒUIPangestureRecognizerར༻͢Ε͹UIScrollView޿͛ͳ͘
    ͯ΋࣮ݱͰ͖͔ͨ΋͠Εͳ͍ɻɻɻ

    View Slide

  24. ScrollViewʹมߋ

    View Slide

  25. εΫϩʔϧͷ
    Ճ଎౓ͰClose

    View Slide

  26. εΫϩʔϧͷ଎౓Ͱ࡟আ
    • ΑΓ௚ײతͳΠϯλϥΫγϣϯ͕͍ͨ͠
    • UIScrollView͕ϓϩύςΟͱͯ͠UIPanGestureRecognizerΛ͍࣋ͬͯΔ
    scrollView.panGestureRecognizer.velocityInView(scrollView)
    GVODWFMPDJUZ*O7JFX @WJFX6*7JFX
    $(1PJOU
    6*1BO(FTUVSF3FDPHOJ[FS

    View Slide

  27. εΫϩʔϧͷ଎౓Ͱ࡟আ
    • ΑΓ௚ײతͳΠϯλϥΫγϣϯ͕͍ͨ͠
    • UIScrollView͕ϓϩύςΟͱͯ͠UIPanGestureRecognizerΛ͍࣋ͬͯΔ
    let velocity = scrollView.panGestureRecognizer.velocityInView(scrollView)
    GVODWFMPDJUZ*O7JFX @WJFX6*7JFX
    $(1PJOU
    6*1BO(FTUVSF3FDPHOJ[FS

    View Slide

  28. εΫϩʔϧͷ଎౓Ͱ࡟আ
    public func scrollViewDidEndDragging(scrollView: UIScrollView,
    willDecelerate decelerate: Bool) {
    if self.scrollMode == .Vertical {
    let velocity = scrollView.panGestureRecognizer
    .velocityInView(scrollView)
    if velocity.y < -500 {
    self.scrollView.frame = scrollView.frame
    self.closePhotoSlider(true)
    } else if velocity.y > 500 {
    self.scrollView.frame = scrollView.frame
    self.closePhotoSlider(false)
    }
    }
    }

    View Slide

  29. ViewController
    Transitions

    View Slide

  30. ViewController Transitions
    7JFX$POUSPMMFS
    "OJNBUPS6*7JFX$POUSPMMFS"OJNBUFE5SBOTJUJPOJOH
    7JFX$POUSPMMFS

    View Slide

  31. ViewController Transitions
    7JFX$POUSPMMFS
    "OJNBUPS6*7JFX$POUSPMMFS"OJNBUFE5SBOTJUJPOJOH
    7JFX$POUSPMMFS
    public protocol UIViewControllerAnimatedTransitioning : NSObjectProtocol {
    public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?)
    ->
    NSTimeInterval
    public func animateTransition(transitionContext: UIViewControllerContextTransitioning)
    optional public func animationEnded(transitionCompleted: Bool)
    }

    View Slide

  32. ViewController Transitions
    "OJNBUPS6*7JFX$POUSPMMFS"OJNBUFE5SBOTJUJPOJOH
    public class ZoomingAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
    var present = true
    public var sourceTransition: ZoomingAnimationControllerTransitioning?
    public var destinationTransition: ZoomingAnimationControllerTransitioning?
    public init(present: Bool) {
    super.init()
    self.present = present
    }
    public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
    return 0.2
    }
    public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
    if self.present {
    self.animatePresenting(transitionContext)
    } else {
    self.animateDismiss(transitionContext)
    }
    }
    }

    View Slide

  33. ViewController Transitions
    4PVSDF7JFX$POUSPMMFS
    // Using transition
    let photoSlider = PhotoSlider.ViewController(imageURLs: self.imageURLs)
    photoSlider.delegate = self
    photoSlider.currentPage = indexPath.row
    photoSlider.transitioningDelegate = self
    self.presentViewController(photoSlider, animated: true) { () -> Void in
    // Something
    }

    View Slide

  34. ViewController Transitions
    4PVSDF7JFX$POUSPMMFS
    // MARK: UIViewControllerTransitioningDelegate
    func animationControllerForDismissedController(dismissed: UIViewController) ->
    UIViewControllerAnimatedTransitioning? {
    let animationController = PhotoSlider.ZoomingAnimationController(present: false)
    animationController.sourceTransition = dismissed as? ZoomingAnimationControllerTransitioning
    animationController.destinationTransition = self
    return animationController
    }
    func animationControllerForPresentedController(presented: UIViewController, presentingController
    presenting: UIViewController, sourceController source: UIViewController) ->
    UIViewControllerAnimatedTransitioning? {
    let animationController = PhotoSlider.ZoomingAnimationController(present: true)
    animationController.sourceTransition = source as? ZoomingAnimationControllerTransitioning
    animationController.destinationTransition = presented as? ZoomingAnimationControllerTransitioning
    return animationController
    }

    View Slide

  35. RMPZoomTransitionAnimator

    View Slide

  36. ViewController Transitions
    • @_mpon͞Μ͔Β঺հ͞Εͯ࡞Γͨ͘ͳͬͨ
    • Ͳͬ΀Γࢀߟʹ͍͖ͤͯͨͩ͞·ͨ͠

    View Slide

  37. Versioning

    View Slide

  38. Versioning
    • Versioning͢Δͱ͖ͷ࡞ۀ
    • xxx.podspecͷόʔδϣϯมߋ
    • git tag x.x.x
    • ҙ֎ͱͩΔ͍ͷͰbumpͷpodspec൛࡞ͬͨ(RubyͰ)
    • ࣮͸ɻɻɻ

    View Slide

  39. @azu͞Μ͕npmͰग़͍ͯͨ͠

    View Slide

  40. Versioning
    • Versioning͢Δͱ͖ͷ࡞ۀ
    • xxx.podspecͷόʔδϣϯมߋ
    • git tag x.x.x
    • ҙ֎ͱͩΔ͍ͷͰbumpͷpodspec൛࡞ͬͨ(RubyͰ)
    • RubyͰ͋ͬͯ΋͍͍΍Μ

    View Slide

  41. Subsequently

    View Slide

  42. Subsequently
    • ެ։͔ͯ͠ΒΆͪΆͪStar͕૿͑࢝Ίͨ
    • ཁ๬͕དྷΔΑ͏ʹͳͬͨ
    • ਺ϲ݄ͯ͠pull request͕དྷΔΑ͏ʹͳͬͨ
    • ஍ಓʹमਖ਼΍Βճ౴΍Β
    • ࢖ͬͯ͘Ε͍ͯΔͱ͍͏ϞνϕʔγϣϯͰܧଓத

    View Slide

  43. Subsequently
    • Test
    • UI Testingͷ͓͔͛ͰUI ܥͷϓϥάΠϯͰ΋ςετ͕Ͱ͖Δʂ
    • Travis CIͰ͚͜Δͷ͕Α͘Θ͔ͬͯͳ͍

    View Slide

  44. Conclusion

    View Slide

  45. Diversity is Good

    View Slide

  46. Enjoy OSS

    View Slide

  47. We are hiring!!!
    http://pepabo.com/recruit/career/#jobs
    ⚠ ⚠

    View Slide

  48. Thanks.

    View Slide