Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 지도 셀 커스텀 리소스 적용 및 black screen flash 현상 제거 #343

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions iOS/Layover/Layover/Scenes/Map/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ final class MapViewController: BaseViewController {
let maximumZoomScale: CGFloat = 1.0
let inset = (screenSize.width - screenSize.width * groupWidthDimension) / 2
let section: NSCollectionLayoutSection = .makeCarouselSection(groupWidthDimension: groupWidthDimension)
section.orthogonalScrollingBehavior = .groupPagingCentered
section.orthogonalScrollingBehavior = .groupPaging
section.interGroupSpacing = 0
section.contentInsets = NSDirectionalEdgeInsets(top: 0,
leading: inset,
Expand All @@ -173,12 +173,11 @@ final class MapViewController: BaseViewController {
let distanceFromCenter = abs((item.center.x - offset.x) - environment.container.contentSize.width / 2.0)
let scale = max(maximumZoomScale - (distanceFromCenter / containerWidth), minumumZoomScale)
item.transform = CGAffineTransform(scaleX: scale, y: scale)
let cell = self?.carouselCollectionView.cellForItem(at: item.indexPath) as? MapCarouselCollectionViewCell
guard let cell = self?.carouselCollectionView.cellForItem(at: item.indexPath) as? MapCarouselCollectionViewCell else { return }
if scale >= maximumZoomScale * 0.9 {
cell?.play()
self?.selectAnnotation(at: item.indexPath)
} else {
cell?.pause()
cell.pause()
}
}
}
Expand All @@ -197,7 +196,6 @@ final class MapViewController: BaseViewController {
carouselCollectionViewHeight.constant = isSelected ? 151 : 0
UIView.animate(withDuration: 0.3) {
annotationView.transform = isSelected ? CGAffineTransform(scaleX: 1.3, y: 1.3) : .identity
self.view.layoutIfNeeded()
}
}

Expand Down Expand Up @@ -256,15 +254,18 @@ extension MapViewController: MKMapViewDelegate {
if let annotaion = annotation as? LOAnnotation {
// 선택된 pin 정보와 datasource를 비교해 selected item을 찾음
let snapshot = carouselDatasource.snapshot()
guard let selectedItemIdentifiers = carouselDatasource.snapshot().itemIdentifiers.filter({ post in
guard let selectedItemIdentifiers = snapshot.itemIdentifiers.filter({ post in
return post.boardID == annotaion.boardID
}).first else { return }
guard let section = snapshot.sectionIdentifier(containingItem: selectedItemIdentifiers),
let itemIndex = snapshot.indexOfItem(selectedItemIdentifiers),
let sectionIndex = snapshot.indexOfSection(section) else { return }
carouselCollectionView.scrollToItem(at: IndexPath(item: itemIndex, section: sectionIndex),
let indexPath = IndexPath(item: itemIndex, section: sectionIndex)
carouselCollectionView.scrollToItem(at: indexPath,
at: .centeredHorizontally,
animated: false)
guard let cell = carouselCollectionView.cellForItem(at: indexPath) as? MapCarouselCollectionViewCell else { return }
cell.play()
Copy link
Collaborator

@loinsir loinsir Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

재생 시점이 이곳으로 이동했군요. 스크롤 가운데 재생은 더이상 되지 않는건가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가운데 스크롤시 selectAnntation이 호출되면서 재생되도록 했습니다!!

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ final class MapCarouselCollectionViewCell: UICollectionViewCell {
spinner.stopAnimating()
loopingPlayerView.disable()
loopingPlayerView.prepareVideo(with: url,
timeRange: CMTimeRange(start: .zero, duration: CMTime(value: 1800, timescale: 600)))
assetResourceLoaderDelegate: HLSAssetResourceLoaderDelegate(resourceLoader: HLSSliceResourceLoader()),
loopStart: .zero,
duration: 3.0)
loopingPlayerView.player?.isMuted = true
}

Expand Down