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

Mod: Alert UI Change (#84) #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ibcylon
Copy link
Member

@ibcylon ibcylon commented Jun 29, 2024

Motivation ⍰

  • 폴링 피처에서 기능 추가 어려움

Key Changes 🔑

구조 부분

  • Timer를 VC ViewModel이 가지고 있게함
    • timer 객체를 한군데서 관리하는 것이 제어하기 수월함.
    • 모든 셀이 timer를 가지고 있는 것보다 메모리 세이브
  • ReactorKit 처럼 단방향 구현
  • Cell viewModel 제거
  • Cell binding 로직 변경 Action Forwarding 부분과 State Binding 부분으로 구분
  • Cell Activate 시 Hashable Model identifier 사용 (기존 IndexPath)
  • FallingUser - hash ID를 기존 UUID에서 userUUID로 변경함 따라서, Mock Data 넣을 때 안겹치도록 주의!
    • 변경한 이유: map 통해서 state 리스트 변경하는데 UUID로 하면 계속 id가 mutable상태가 되서 바뀜
  • 제거 구현 snapshot에서 제거됨

파일 부분

  • Timer 이름 TFTimer로 변경하여 파일 분리
  • dotPosition 메소드 등 컴포넌트 의존 메소드들 컴포넌트 하위로 옮김

UI 부분

  • dimView, gradientLayer 등 remove하는 방식이 아니라 hidden형식을 변경함
    • 셀이 계속 재활용될 건데 매번 새로 만드는 것 보다 메모리, 퍼포먼스 상 유리함
    • 좋아요 그라디언트 겹쳐서 계속 생기는 문제 수정
  • 카드 셀 페이지 컨트롤러 수정
  • 카드 높이 수정

To Reviewers 🙏🏻

  • (SwiftUI로 치면 Store)Reactor끼리 통신하는 경우도 사용하는 방법인지, 지양하는 방법인지 궁금합니다.
    예를 들어 유저 인터렉션 없이, 내부 state 변경으로 인해서 Cell UI를 띄어야하는 상황이 오면,
    A. 부모 Reactor가 Cell쪽으로 Action을 보내는지
    아니면
    B. 부모 Reactor가 Cell 거치지 않고, 바로 Cell Reactor에게 직접적으로 Action을 보내는지 궁금합니다.
    [src](Simulator Screen Recording - iPhone 15 - 2024-06-29 at 20 37 46)

Linked Issue 🔗

@ibcylon ibcylon added the 🐧 Refactor Code Refactoring label Jun 29, 2024
@ibcylon ibcylon requested review from Minny27 and ChaNoo97 June 29, 2024 11:18
@ibcylon ibcylon self-assigned this Jun 29, 2024
Comment on lines +77 to +92
timerActiveTrigger
.debug("\(indexPath) active")
.drive(cell.activateCardSubject)
.disposed(by: cell.disposeBag)

Driver.just(item)
.drive(cell.rx.user)
.disposed(by: cell.disposeBag)

self?.viewModel.pulse(\.$timeState)
.asDriverOnErrorJustEmpty()
.withLatestFrom(timerActiveTrigger) { ($0, $1) }
.filter { _, isActive in isActive }
.map { timeState, _ in timeState }
.drive(cell.rx.timeState)
.disposed(by: cell.disposeBag)
Copy link
Member Author

Choose a reason for hiding this comment

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

활성화 해야할 id와 tiem의 id를 비교하여 Bool값 만들고 cell에 바인딩하였습니다.

시간을 cell에 바인딩해야하는데 state 필터링을 어디에서 하는게 좋을까요?
A. 지금처럼 VC에서 Cell에 바인딩하는 시점
B. Cell 내부에서 state를 가지고 필터링

animated: true
)
TFLogger.ui.debug("scroll to Item at: \(indexPath)")
case let .scrollAfterDelete(user):
Copy link
Member Author

Choose a reason for hiding this comment

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

@Minny27

  1. ViewModel(Reactor)로부터 삭제 명령이 오면
  2. 먼저 Cell transfrom animation을 수행하고,
  3. cell animation 종료 completion에서 다시 signal 보냄
  4. vm state에서 모델 제거

self.likeImageView.isHidden = isHidden
}

private func addGradientLayer() {
Copy link
Member Author

Choose a reason for hiding this comment

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

gradient 한 번 생성 후 캡처해놨다가 재사용

// MARK: pageControl
func createLayout() -> UICollectionViewLayout {
let sectionLayout: NSCollectionLayoutSection = .horizontalListSection()
sectionLayout.visibleItemsInvalidationHandler = { [weak self] (items, offset, environment) in
Copy link
Member Author

Choose a reason for hiding this comment

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

@Minny27
compositional Layout에서
pageControl 값 변경하려면, sectionLayout의 변경 감지 closure에서 값 계산하여 control에 연결


final class TFCarouselView: TFBaseView {

lazy var carouselView = TFBaseCollectionView(frame: .zero, collectionViewLayout: createLayout())
Copy link
Member Author

Choose a reason for hiding this comment

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

@Minny27
페이지컨트롤과 컬렉션 뷰를 가지고 있는 케로셀 뷰를 컴포넌트로 분리

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐧 Refactor Code Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants