10/05

10/06

hidesBottomBarWhenPushed = true
private var starNumber: Int = 5 {
        didSet { bind() }
    }
    var currentStar: Int = 0 {
        didSet {
            updateStars()
            currentStarSubject.onNext(currentStar)
        }
    }

private func buttonTapped(tag: Int) {
        if tag == currentStar - 1 {
            for index in 0..<starNumber {
                buttons[index].setImage(ImageLiteral.starIcon, for: .normal)
            }
            currentStar = 0
            return
        }
        
        for index in 0...tag {
            buttons[index].setImage(ImageLiteral.fillStarIcon, for: .normal)
        }
        
        for index in tag + 1..<starNumber {
            buttons[index].setImage(ImageLiteral.starIcon, for: .normal)
        }
        
        currentStar = tag + 1
    }

10/07

func handleBookmark(_ store: StoreVO) {
        if store.bookmark && !storeExists(store.id) {
            createBookmark(store)
            
        } else if !store.bookmark && storeExists(store.id) {
            
            if store.rate > 0 || !store.episode.isEmpty {
                updateStoreBookmark(store)
                
            } else {
                deleteStoreBookmark(store)
            }
        }
    }
    
    func  handleLocalStore(_ store: StoreVO) {
        if !storeExists(store.id) && hasRatingOrEpisode(store) {
            // Realm에 존재하지 않으면서, 평점 또는 에피소드 중 하나라도 존재하는 경우
            createBookmark(store)
            
        } else if storeExists(store.id) {
            // Realm에 존재하는 경우
            
            if hasRatingOrEpisode(store) {
                // 평점 또는 에피소드 중 하나라도 존재하는 경우
                
                if shouldUpdateStore(store) {
                    // 변경된 사항이 존재할 경우
                    updateStoreBookmark(store)
                }
                
            } else {
                // Realm에 존재하는데, 평점, 에피소드 모두 값이 없는 경우
                deleteStoreBookmark(store)
            }
        }
    }

10/08