Slide 1

Slide 1 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ ੢ ༔࡞ ωΠςΟϒ੡ΨϯτνϟʔτUIΛ࡞ֶͬͯͿ UICollectionViewLayoutͷҖྗ ੢ ༔࡞

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

ຊ೔࿩͢͜ͱ 3 ͜Εͷ࡞Γํ

Slide 4

Slide 4 text

ຊ೔࿩͢͜ͱ 4 ͜Εͷ࡞Γํ ͷجૅ

Slide 5

Slide 5 text

੢ ༔࡞ @jrsaruo_tech ΞχϝɹອըɹήʔϜɹSwift 1996೥12݄21೔ੜ גࣜձࣾΞϯυύου େࡕग़਎ ੢ ஀ੜ ੢ ੒௕ 5

Slide 6

Slide 6 text

© 2025 ANDPAD All Rights Reserved. Confidential Confidential 現場の効率化から経営改善まで一元管理できる クラウド型建設プロジェクト管理サービス 社 内 社 外 営業 / 監督 / 設計 事務 / 管理職 職人 / 業者 メーカー / 流通 案件管理 資料 工程表 写真 報告 チャット 黒板 図面 受発注 ● ● ● ANDPADとは

Slide 7

Slide 7 text

© 2025 ANDPAD All Rights Reserved. Confidential Confidential 現場の効率化から経営改善まで一元管理できる クラウド型建設プロジェクト管理サービス 社 内 社 外 営業 / 監督 / 設計 事務 / 管理職 職人 / 業者 メーカー / 流通 案件管理 資料 工程表 写真 報告 チャット 黒板 図面 受発注 ● ● ● ANDPADとは

Slide 8

Slide 8 text

- ޻ࣄͷεέδϡʔϧ؅ཧද - ͦͷҰछ͕Ψϯτνϟʔτܗࣜ - ॎ͕࣠࡞ۀ߲໨ɺԣ͕࣠࣌ؒ ༨ஊɿ೔ຊͷݐઃۀքͰ͸ʰόʔνϟʔτ޻ఔදʱ ݐઃۀքͷʰ޻ఔදʱ 現場名 現場住所 月 日 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 曜 火 水 木 金 土 日 月 火 水 木 金 土 日 月 火 水 木 金 土 日 月 火 水 木 金 土 日 月 火 水 木 金 土 日 営業管理業務 ご近隣着工前挨拶 着工前連絡 基礎工事 基礎工事 木工事 土台・建 防蟻工事 断熱工事 足場 足場掛け 屋根工事 外壁工事 水道工事 仮設水道 電気工事 仮設電気 ガス工事 設備工事 塗装・防水 左官工事 株式会社オクト(開発テスト用) サンプル様邸 工事期間 東京都千代 2024/10 8

Slide 9

Slide 9 text

Ͳ͏΍ͬͯ࡞Δʁ 9

Slide 10

Slide 10 text

࡞Γ͍ͨ΋ͷ - ॎ࣠ʹ࡞ۀ߲໨ɺԣ࣠ʹ೔෇ͷνϟʔτ - ࡞ۀ߲໨͸։࢝೔ͱऴྃ೔Λ࣋ͭ - ࡞ۀ߲໨͸։࢝೔ʙऴྃ೔ͷྻʹදࣔ - ֤೔෇ͷॎηύϨʔλ 10

Slide 11

Slide 11 text

࡞Γ͍ͨ΋ͷ - ॎԣແਚʹ׈Β͔ʹεΫϩʔϧͰ͖Δ - ॎ࣠ͷ࡞ۀ߲໨͕Կ݅௥Ճ͞Εͯ΋ಈ͘ - ԣ࣠ͷظ͕ؒͲΕ͚ͩ৳ͼͯ΋ಈ͘ 11

Slide 12

Slide 12 text

࡞Γ͍ͨ΋ͷ - ෳ਺ͷ࡞ۀ߲໨Λ࡞ۀάϧʔϓʹ·ͱΊΔ - ֤άϧʔϓηΫγϣϯΛ։ดͰ͖Δ - Ұ෦ͷϔομʔ͸ϐϯཹΊ͞ΕΔ - ϐϯνδΣενϟͰζʔϜͰ͖Δ 12

Slide 13

Slide 13 text

UIScrollViewͰ࡞Δʁ - ύϑΥʔϚϯε໘ͷݒ೦ - Lazy Loading΍Viewͷ࠶ར༻ͷػߏ͕ͳࣗ͘લ࣮૷͕ඞཁ - ϨΠΞ΢τ΍Ξχϝʔγϣϯͷ࣮૷͕େม - ϨΠΞ΢τ੍໿ͷ෇༩ɺߋ৽ɺ… 13

Slide 14

Slide 14 text

UICollectionView - ֤UIཁૉͷLazy Loadingͱ࠶ར༻ - ॊೈͳϨΠΞ΢τ - Ξχϝʔγϣϯ - υϥοά&υϩοϓɺίϯςΩετϝχϡʔɺ… 14 UICollectionViewLayout

Slide 15

Slide 15 text

UICollectionViewLayout - UICollectionViewͷ֤UIཁૉͷϨΠΞ΢τΛ୲͏Ϋϥε - UICollectionViewFlowLayout - UICollectionViewCompositionalLayout - ಠࣗͷαϒΫϥεΛ࣮૷͢Δ͜ͱ΋Մೳ 15

Slide 16

Slide 16 text

ํ਑ 16 Cells Supplementary Views Decoration Views

Slide 17

Slide 17 text

αϯϓϧίʔυ 17 https://github.com/andpad-dev/iOSDC2025GanttChartSample

Slide 18

Slide 18 text

४උ 18 UICollectionViewLayout let collectionView = UICollectionView( frame: .zero, collectionViewLayout: )

Slide 19

Slide 19 text

४උ 19 let layout = CompositionalLayout.list( using: .init(appearance: .insetGrouped) ) let collectionView = UICollectionView( frame: .zero, collectionViewLayout: ) layout lazy var dataSource = UICollectionViewDiffableDataSource< >( collectionView: collectionView ) { [weak self] collectionView, indexPath, itemID in } UICollectionView

Slide 20

Slide 20 text

let layout = CompositionalLayout.list( using: .init(appearance: .insetGrouped) ) ४උ 20 layout let collectionView = UICollectionView( frame: .zero, collectionViewLayout: ) layout

Slide 21

Slide 21 text

UICollectionViewLayoutͷαϒΫϥεΛ࣮૷ 21 final class GanttChartViewLayout: UICollectionViewLayout { // Not implemented }

Slide 22

Slide 22 text

UICollectionViewLayoutͷαϒΫϥεΛ࣮૷ 22 final class GanttChartViewLayout: UICollectionViewLayout { // Not implemented } let layout = GanttChartViewLayout() let collectionView = UICollectionView( frame: .zero, collectionViewLayout: layout )

Slide 23

Slide 23 text

UICollectionViewLayoutͷαϒΫϥεΛ࣮૷ 23 final class GanttChartViewLayout: { // Not implemented } let layout = GanttChartViewLayout() let collectionView = UICollectionView( frame: .zero, collectionViewLayout: layout )

Slide 24

Slide 24 text

- layoutAttributesForElements(in:) - දࣔ͢΂͖ཁૉͷϨΠΞ΢τଐੑΛฦ͢ - collectionViewContentSize - UICollectionViewͷcontentSize ࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ 24 Ҏ্ ʢޠฐʣ

Slide 25

Slide 25 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 25 class GanttChartViewLayout: UICollectionViewLayout { override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { } }

Slide 26

Slide 26 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 26 class GanttChartViewLayout: UICollectionViewLayout { override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { } } let dummy = UICollectionViewLayoutAttributes( forCellWith: IndexPath(item: 0, section: 0) ) dummy.frame = .init(x: 20, y: 40, ) return [dummy]

Slide 27

Slide 27 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 27 class GanttChartViewLayout: UICollectionViewLayout { override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { } } let dummy = UICollectionViewLayoutAttributes( forCellWith: IndexPath(item: 0, section: 0) ) dummy.frame = .init(x: 20, y: 40, ) return [dummy]

Slide 28

Slide 28 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 28 class GanttChartViewLayout: UICollectionViewLayout { override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { } } let dummy = UICollectionViewLayoutAttributes( forCellWith: IndexPath(item: 0, section: 0) ) dummy.frame = .init(x: 20, y: 40, ) return [dummy]

Slide 29

Slide 29 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 29 class GanttChartViewLayout: UICollectionViewLayout { override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { } } let dummy = UICollectionViewLayoutAttributes( forCellWith: IndexPath(item: 0, section: 0) ) dummy.frame = .init(x: 20, y: 40, ) return [dummy]

Slide 30

Slide 30 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 30 class GanttChartViewLayout: UICollectionViewLayout { override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { } } let dummy = UICollectionViewLayoutAttributes( forCellWith: IndexPath(item: 0, section: 0) ) dummy.frame = .init(x: 20, y: 40, ) return [dummy]

Slide 31

Slide 31 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) 31 override func layoutAttributesForElements( ) -> { var attributes: [UICollectionViewLayoutAttributes] = [] for section in { for item in { let indexPath = IndexPath(item: item, section: section) let dummy = UICollectionViewLayoutAttributes( forCellWith: indexPath ) dummy.frame = .init( ) attributes.append(dummy) } } return attributes }

Slide 32

Slide 32 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - layoutAttributesForElements(in:) override func layoutAttributesForElements( ) -> { var attributes: [UICollectionViewLayoutAttributes] = [] for section in { for item in { let indexPath = IndexPath( ) let dummy = UICollectionViewLayoutAttributes( forCellWith: indexPath ) dummy.frame = .init( ) attributes.append(dummy) } } return attributes } 32

Slide 33

Slide 33 text

࠷௿ݶ࣮૷͕ඞཁͳ΋ͷ - collectionViewContentSize 33 final class GanttChartViewLayout: { override var collectionViewContentSize: CGSize { CGSize(width: 1500, height: 1000) } }

Slide 34

Slide 34 text

໰୊఺ - layoutAttributesForElements(in:)͸සൟʹݺ͹ΕΔ - εΫϩʔϧதʹ౎౓ϨΠΞ΢τଐੑΛ͢΂ͯܭࢉͯ͠͠·͏ - εΫϩʔϧύϑΥʔϚϯεʹӨڹ - ϨΠΞ΢τଐੑͷ४උ͸͋Β͔͡Ί΍͓͖ͬͯ࢖͍ճ͍ͨ͠ 34

Slide 35

Slide 35 text

prepare() - ϨΠΞ΢τͷߋ৽લ͚ͩݺ͹ΕΔ - ཧ૝ͷྲྀΕɿ 1. prepare()ͰϨΠΞ΢τଐੑΛܭࢉͯ͠Ωϟογϡ 2. layoutAttributesForElements(in:)Ͱ Ωϟογϡ͔Βඞཁͳ෼͚ͩऔΓग़ͯ͠ฦ͢ 35

Slide 36

Slide 36 text

prepare() - ϨΠΞ΢τଐੑͷΩϟογϡ 36 struct LayoutAttributes { typealias Dictionary = [ IndexPath: UICollectionViewLayoutAttributes ] var items = Dictionary() // Ωϟογϡ func forVisibleElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes] { // rectͱॏͳΔ෼͚ͩऔΓग़ͯ͠ฦ͢ let attributesForVisibleItems = items.values .filter { $0.frame.intersects(rect) } return attributesForVisibleItems } }

Slide 37

Slide 37 text

final class GanttChartViewLayout: UICollectionViewLayout { private var layoutAttributes = LayoutAttributes() override func layoutAttributesForElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes]? { layoutAttributes.forVisibleElements(in: rect) } } prepare() 37 override func prepare() { }

Slide 38

Slide 38 text

override func prepare() { } prepare() 38 var attributes: [UICollectionViewLayoutAttributes] = [] for section in { for item in { let indexPath = IndexPath(item: item, section: section) let dummy = UICollectionViewLayoutAttributes( forCellWith: indexPath ) dummy.frame = .init( ) layoutAttributes.items[indexPath] = dummy } } return attributes

Slide 39

Slide 39 text

೔෇ηϧΛ௥Ճ 39

Slide 40

Slide 40 text

ϨΠΞ΢τܭࢉ 40

Slide 41

Slide 41 text

LayoutReferences - ϨΠΞ΢τͷج४஋ 41 struct LayoutReferences { struct DateReference { var cellFrame: CGRect } var dates: [Date: DateReference] = [:] }

Slide 42

Slide 42 text

LayoutReferences - ϨΠΞ΢τͷج४஋ 42 struct LayoutReferences { struct DateReference { var cellFrame: CGRect } var dates: [Date: DateReference] = [:] }

Slide 43

Slide 43 text

LayoutReferences - ϨΠΞ΢τͷج४஋ 43 struct LayoutReferences { struct DateReference { var cellFrame: CGRect } var dates: [Date: DateReference] = [:] } struct WorkItemReference { var cellMinY: CGFloat } var workItems: [WorkItem.ID: WorkItemReference] = [:] var contentSize: CGSize = .zero

Slide 44

Slide 44 text

೔෇ηϧͷϑϨʔϜΛܭࢉ 44 extension GanttChartViewLayout.LayoutReferences { var dateCellSize: CGSize { } private mutating func prepareDateArea( with itemIDs: [GanttChartView.ItemID] ) { var previousDate: Date? for case .date(let date) in itemIDs { let minX: CGFloat = if let previousDate { dates[previousDate]!.cellFrame.maxX } else { 0.0 } let frame = CGRect( origin: .init(x: minX, y: 0), size: dateCellSize ) dates[date] = .init(cellFrame: frame) previousDate = date } } }

Slide 45

Slide 45 text

extension GanttChartViewLayout.LayoutReferences { mutating func prepare( with itemIDs: [GanttChartView.ItemID] ) { } } ࡞ۀ߲໨ηϧͷY࠲ඪΛܭࢉ 45 for case .workItem(let workItemID) in itemIDs { workItems[workItemID] = .init(cellMinY: bottomY) bottomY += workItemCellHeight + verticalSpacing } // ͜ͷ஋Λ౎౓ߋ৽͠ͳ͕Β֤ཁૉͷY࠲ඪΛܭࢉ var bottomY = dateCellSize.height let verticalSpacing = 4.0

Slide 46

Slide 46 text

extension GanttChartViewLayout.LayoutReferences { mutating func prepare( with itemIDs: [GanttChartView.ItemID] ) { } } contentSizeΛܭࢉ 46 contentSize = CGSize( width: dates[lastDate]!.cellFrame.maxX, height: bottomY ) for case .workItem(let workItemID) in itemIDs { workItems[workItemID] = .init(cellMinY: bottomY) bottomY += workItemCellHeight + verticalSpacing }

Slide 47

Slide 47 text

࡞ۀ߲໨ηϧͷϑϨʔϜΛܭࢉ 47 let schedule = workItem.schedule let minX = dates[schedule.lowerBound]!.cellFrame.minX let maxX = dates[schedule.upperBound]!.cellFrame.maxX let workItemCellFrame = CGRect( x: minX, y: workItems[workItem.id]!.cellMinY, width: maxX - minX, height: workItemCellHeight )

Slide 48

Slide 48 text

࡞ۀ߲໨ηϧͷϑϨʔϜΛܭࢉ 48 let schedule = workItem.schedule let minX = dates[schedule.lowerBound]!.cellFrame.minX let maxX = dates[schedule.upperBound]!.cellFrame.maxX let workItemCellFrame = CGRect( x: minX, y: workItems[workItem.id]!.cellMinY, width: maxX - minX, height: workItemCellHeight )

Slide 49

Slide 49 text

ϑϨʔϜΛ൓ө 49

Slide 50

Slide 50 text

ํ਑ʢ࠶ܝʣ 50 Cells Supplementary Views Decoration Views

Slide 51

Slide 51 text

Supplementary Views - UICollectionReusableViewΫϥεΛܧঝͨ͠ิॿతͳView - UITableViewͷηΫγϣϯϔομʔ/ϑολʔͳͲʹ૬౰ - ηϧͱಉ༷Lazy Loadingɾ࠶ར༻͞ΕΔ - didSelectItemAtͷΑ͏ͳΠϕϯτݕ஌ͷ࢓૊Έ͸ͳ͍ 51

Slide 52

Slide 52 text

Supplementary Views - ElementKind - Supplementary Views΍Decoration Views͸ಉ͡IndexPathʹରͯ͠ ෳ਺छྨඥ͚ͮΒΕΔ - ͦΕΒΛ۠ผ͢ΔͨΊʹ࢖ΘΕΔͷ͕elementKindͱ͍͏จࣈྻ - จࣈྻͰ͸ѻ͍ͮΒ͍ͨΊElementKindܕΛఆٛ 52 struct ElementKind: { let rawValue: String }

Slide 53

Slide 53 text

Supplementary Views - ϨΠΞ΢τଐੑͷΩϟογϡ 53 struct LayoutAttributes { var items = Dictionary() var supplementaryViews = [ElementKind: Dictionary]() func forVisibleElements( in rect: CGRect ) -> [UICollectionViewLayoutAttributes] { let attributesForVisibleItems = items.values .filter { $0.frame.intersects(rect) } let attributesForVisibleSupplementaryViews = supplementaryViews.values .flatMap(\.values) .filter { $0.frame.intersects(rect) } return attributesForVisibleItems + attributesForVisibleSupplementaryViews } }

Slide 54

Slide 54 text

Supplementary Views - ϨΠΞ΢τଐੑͷΩϟογϡ 54 let elementKind = ElementKind.workItemGroupHeader let header = UICollectionViewLayoutAttributes( forSupplementaryViewOfKind: elementKind.rawValue, with: indexPath ) header.frame = layoutAttributes.supplementaryViews[elementKind, default: [:]] [indexPath] = header

Slide 55

Slide 55 text

Supplementary Views 55

Slide 56

Slide 56 text

ํ਑ʢ࠶ܝʣ 56 Cells Supplementary Views Decoration Views

Slide 57

Slide 57 text

Decoration Views - UICollectionReusableViewΛܧঝͨ͠૷০ઐ༻ͷView - ηϧͱಉ༷Lazy Loadingɾ࠶ར༻͞ΕΔ - didSelectItemAtͷΑ͏ͳΠϕϯτݕ஌ͷ࢓૊Έ͸ͳ͍ - ಺༰ΛindexPathʹԠͯ͡มߋ͢Δͱ͍ͬͨ͜ͱ͕Ͱ͖ͳ͍ 57

Slide 58

Slide 58 text

Decoration Views 58 class GanttChartViewLayout: { override init() { super.init() register( GanttChartSeparator.self, forDecorationViewOfKind: ) } }

Slide 59

Slide 59 text

ϔομʔͷϐϯཹΊ 59

Slide 60

Slide 60 text

ϔομʔͷϐϯཹΊ 60 εΫϩʔϧ εΫϩʔϧ෼ ໭͢

Slide 61

Slide 61 text

ϔομʔͷϐϯཹΊ 61 final class GanttChartViewLayout: UICollectionViewLayout { override func shouldInvalidateLayout( forBoundsChange newBounds: CGRect ) -> Bool { // εΫϩʔϧҐஔ͕มΘΔͨͼʹϨΠΞ΢τΛ࠶ܭࢉͤ͞Δ true } }

Slide 62

Slide 62 text

ϔομʔͷϐϯཹΊ 62

Slide 63

Slide 63 text

ηΫγϣϯͷ։ด 63 let layout = collectionView.collectionViewLayout as! GanttChartViewLayout UIView.animate(withDuration: 0.3) { // ηΫγϣϯͷ։ดঢ়ଶΛ੾Γସ͑Δ layout.toggleWorkItemGroupSectionExpansion( for: groupID ) layout.invalidateLayout() }

Slide 64

Slide 64 text

ग़དྷ্͕ͬͨ΋ͷ 64

Slide 65

Slide 65 text

͞ΒʹͳΜ΍͔Μ΍͢Δͱ ͜͏ͳΔ

Slide 66

Slide 66 text

ͳΜͰ΋Ͱ͖Δ΍Μ 66 ͳΜͰ΋Ͱ͖·͢

Slide 67

Slide 67 text

ͳΜͰ΋Ͱ͖Δ΍Μ 67

Slide 68

Slide 68 text

·ͱΊ - UICollectionViewͰࣗ༝౓ͷߴ͍ϋΠύϑΥʔϚϯεͳUIΛ࡞ΕΔ - UICollectionViewLayoutͰॊೈͳϨΠΞ΢τ͕Մೳ 68 https://github.com/andpad-dev/iOSDC2025GanttChartSample

Slide 69

Slide 69 text

https://engineer.andpad.co.jp/ ΤϯδχΞ࠾༻ 幸せを築く人を、幸せに。 住まいをつくる。ビルや施設をつくる。街をつくる。 生活を豊かにする建築・建設業は、幸せづくりと例えられます。 私たちは、その幸せづくりをする人たちをテクノロジーの力で 後押ししていきたい。心からそう考えてます。 我々はこれからもお客様の声をサービスに反映して、 建設業界及び建設業従事者様の業務効率化、 DX化を支援してまいります。 Mission We are Hiring !!

Slide 70

Slide 70 text

͋Γ͕ͱ͏͍͟͝·ͨ͠ @jrsaruo_tech Follow me! 𝕏