Visual_Novel_iOS/crush/Crush/Src/Components/Photo/PhotoBrowser/PhotoBrowserControllerEvent...

99 lines
3.7 KiB
Swift
Raw Normal View History

2025-10-09 10:29:35 +00:00
//
// PhotoBrowserControllerEvent.swift
// Crush
//
// Created by Leon on 2025/9/23.
//
extension PhotoBrowserController{
func reloadStatesByModel(model:PhotoBrowserModel?){
guard let browserModel = model else{return}
if type == .roleMine{
let unlockPrice = browserModel.aiAlbum.unlockPrice
if let lockStatus = browserModel.aiAlbum.lockStatus{
titleLockIcon.isHidden = lockStatus == .unlock
}else{
titleLockIcon.isHidden = true
}
setDefaultEntry.isHidden = false
let isDefault = browserModel.aiAlbum.isDefault.boolValue
setDefaultEntry.setupIsDefault(isDefault)
rolePhotoUnlockEntry.setupCoinUnlock(coin: unlockPrice)
if isDefault{
rolePhotoUnlockEntry.isHidden = true
}else{
rolePhotoUnlockEntry.isHidden = false
}
}else if type == .chatBackgroundSet{
guard let background = browserModel.chatBackground else{return}
if background.isDefault.boolValue{
// more
moreButton?.isHidden = true
}else{
moreButton?.isHidden = false
}
setDefaultEntry.isHidden = background.isSelected.boolValue
setBackgroundDisableButton.isHidden = !background.isSelected.boolValue
}else if type == .roleOthersInAlbum{
guard let album = browserModel.aiAlbum else{return}
getCurrentZoomView(byModel: browserModel)?.scrollView.isScrollEnabled = true
if let lockStatus = album.lockStatus, lockStatus == .locked{
// 🚩
roleOthersContainer?.isHidden = false
bottomCommonOperateContainer?.isHidden = true
likeView?.isHidden = true
titleunlockedIcon.isHidden = true
getCurrentZoomView(byModel: browserModel)?.scrollView.isScrollEnabled = false
let price = browserModel.aiAlbum.unlockPrice
let attributeString = StyleButton.getUnlockAttributeTitleByCoin(coin: price, string: "unlock")
iconUnlockButton?.setAttributedTitle(attributeString, for: .normal)
}else{
// 🚩
roleOthersContainer?.isHidden = true
bottomCommonOperateContainer?.isHidden = false
likeView?.isHidden = false
if album.lockStatus == .unlock{
// 🔓,
titleunlockedIcon.isHidden = false
}else{
//
titleunlockedIcon.isHidden = true
}
likeView?.bind(aiAlbum: album)
}
}
else if type == .roleOthersInIm{
guard let model = browserModel.sessionModel else{
return
}
bottomGradientContainer.isHidden = true
let price = model.baseRemoteInfo?.customAttachment?.unlockPrice ?? 0
if price > 0{
roleOthersContainer?.isHidden = false
let attributeString = StyleButton.getUnlockAttributeTitleByCoin(coin: price, string: "unlock")
iconUnlockButton?.setAttributedTitle(attributeString, for: .normal)
}else{
roleOthersContainer?.isHidden = true
}
}
}
}