Skip to content
Open
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
30 changes: 30 additions & 0 deletions Animal-Crossing-Wiki/Projects/App/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyD6Wr2RHm1GyLaQ1kf7bnVHwupp7T3bg2s</string>
<key>GCM_SENDER_ID</key>
<string>863392217119</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>leeari.NookPortalPlus</string>
<key>PROJECT_ID</key>
<string>acnh-wiki-6ab01</string>
<key>STORAGE_BUCKET</key>
<string>acnh-wiki-6ab01.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:863392217119:ios:0e905b7406b4fbe5ebfd2a</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import RxSwift
import CoreData

final class CoreDataDailyTaskStorage: DailyTaskStorage {
final class CoreDataDailyTaskStorage: DailyTaskStorage, ErrorHandling {

private let coreDataStorage: CoreDataStorage

Expand Down Expand Up @@ -73,7 +73,7 @@ final class CoreDataDailyTaskStorage: DailyTaskStorage {
}
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateDailyTask")
}
}
}
Expand All @@ -90,7 +90,7 @@ final class CoreDataDailyTaskStorage: DailyTaskStorage {
}
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "toggleTaskCompleted")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import RxSwift

final class CoreDataItemsStorage: ItemsStorage {
final class CoreDataItemsStorage: ItemsStorage, ErrorHandling {

private let coreDataStorage: CoreDataStorage

Expand Down Expand Up @@ -45,7 +45,7 @@ final class CoreDataItemsStorage: ItemsStorage {
}
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateItem")
}
}
}
Expand All @@ -58,7 +58,7 @@ final class CoreDataItemsStorage: ItemsStorage {
object.addToCritters(NSSet(array: newItems))
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateItems")
}
}
}
Expand All @@ -71,7 +71,7 @@ final class CoreDataItemsStorage: ItemsStorage {
object.removeFromCritters(NSSet(array: items.filter { $0.category == category.rawValue }))
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "resetCategory")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ErrorHandling.swift
// Animal-Crossing-Wiki
//
// Created by Ari on 2025/01/06.
//

import Foundation

protocol ErrorHandling {
func handleError(_ error: Error, operation: String)
}

extension ErrorHandling {
func handleError(_ error: Error, operation: String) {
// 에러 로깅
print("❌ CoreData Error in \(operation): \(error.localizedDescription)")

// 사용자에게 알림 (NotificationCenter 사용)
NotificationCenter.default.post(
name: .coreDataError,
object: nil,
userInfo: [
"operation": operation,
"error": error.localizedDescription
]
)
}
}

extension Notification.Name {
static let coreDataError = Notification.Name("CoreDataError")
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import RxSwift
import CoreData

final class CoreDataUserInfoStorage: UserInfoStorage {
final class CoreDataUserInfoStorage: UserInfoStorage, ErrorHandling {

private let coreDataStorage: CoreDataStorage

Expand All @@ -35,7 +35,7 @@ final class CoreDataUserInfoStorage: UserInfoStorage {
object.islandReputation = Int16(userInfo.islandReputation)
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateUserInfo")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import RxSwift

final class CoreDataVillagersHouseStorage: VillagersHouseStorage {
final class CoreDataVillagersHouseStorage: VillagersHouseStorage, ErrorHandling {

private let coreDataStorage: CoreDataStorage

Expand Down Expand Up @@ -37,7 +37,7 @@ final class CoreDataVillagersHouseStorage: VillagersHouseStorage {
}
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateVillagerHouse")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import RxSwift

final class CoreDataNPCLikeStorage: NPCLikeStorage {
final class CoreDataNPCLikeStorage: NPCLikeStorage, ErrorHandling {

private let coreDataStorage: CoreDataStorage

Expand Down Expand Up @@ -48,7 +48,7 @@ final class CoreDataNPCLikeStorage: NPCLikeStorage {
}
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateNPCLike")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import RxSwift

final class CoreDataVillagersLikeStorage: VillagersLikeStorage {
final class CoreDataVillagersLikeStorage: VillagersLikeStorage, ErrorHandling {

private let coreDataStorage: CoreDataStorage

Expand Down Expand Up @@ -37,7 +37,7 @@ final class CoreDataVillagersLikeStorage: VillagersLikeStorage {
}
context.saveContext()
} catch {
debugPrint(error)
handleError(error, operation: "updateVillagerLike")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ struct Variant: Decodable {
let concepts: [Concept]?
let patternTranslations: Translations?
let soundType: SoundType?

var isCollected: Bool = false

func toKeyword() -> [String] {
return (colors?.map { $0.rawValue } ?? []) + (concepts?.map { $0.rawValue } ?? [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class ItemVariantsView: UIView {
private let disposeBag = DisposeBag()
private var mode: Mode = .color
private let cellImage = BehaviorRelay<UIImage?>(value: nil)
private let checkButtonTapEvent = PublishSubject<Variant>()

private lazy var collectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout()
Expand Down Expand Up @@ -61,14 +62,20 @@ final class ItemVariantsView: UIView {
) { [weak self] _, item, cell in
let name = (self?.mode == .color ? item.variantTranslations?.localizedName() : item.patternTranslations?.localizedName())
?? item.variation?.localized
cell.setUp(imageURL: item.image, name: name)
cell.setUp(imageURL: item.image, name: name, item: item,checkButtonTapObserver: self?.checkButtonTapEvent.asObserver())
}.disposed(by: disposeBag)

collectionView.rx.itemSelected
.subscribe(onNext: { [weak self] indexPath in
let cell = self?.collectionView.cellForItem(at: indexPath) as? VariantCell
self?.cellImage.accept(cell?.imageView.image)
}).disposed(by: disposeBag)

checkButtonTapEvent
.subscribe { item in
print("체크버튼 클릭")
}
.disposed(by: disposeBag)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,60 @@
//

import UIKit
import RxSwift

final class VariantCell: UICollectionViewCell {

private var disposeBag = DisposeBag()

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!

private lazy var checkButton: UIButton = {
let button = UIButton()
let font = UIFont.preferredFont(forTextStyle: .title2)
let config = UIImage.SymbolConfiguration(font: font)
button.setImage(UIImage(systemName: "checkmark.seal", withConfiguration: config), for: .normal)
button.tintColor = .acNavigationBarTint
button.backgroundColor = .acSecondaryBackground
button.layer.cornerRadius = font.pointSize / 2
return button
}()

override func awakeFromNib() {
super.awakeFromNib()
titleLabel.font = .preferredFont(for: .footnote, weight: .bold)
addSubviews(checkButton)
NSLayoutConstraint.activate([
checkButton.topAnchor.constraint(equalTo: imageView.topAnchor),
checkButton.trailingAnchor.constraint(equalTo: imageView.trailingAnchor)
])
}

override func prepareForReuse() {
super.prepareForReuse()
imageView.kf.cancelDownloadTask()
imageView.image = nil
titleLabel.text = nil
disposeBag = DisposeBag()
checkButton.setImage(
UIImage(
systemName: "checkmark.seal",
withConfiguration: UIImage.SymbolConfiguration(font: .preferredFont(forTextStyle: .title2))
),
for: .normal
)
}

func setUp(imageURL: String, name: String?) {
func setUp(imageURL: String, name: String?, item: Variant, checkButtonTapObserver: AnyObserver<Variant>?) {
imageView.setImage(with: imageURL)
titleLabel.text = name

if let checkButtonTapObserver {
checkButton.rx.tap
.map { _ in item }
.bind(to: checkButtonTapObserver)
.disposed(by: disposeBag)
}
}
}
Loading