//
//  CLNotificationName.swift

//
//  Created by Leon on 2025/7/12.
//

import Foundation

enum AppNotificationName: String {
    // MARK: Util
    case networkChanged
    case networkRestored  // 新增：网络从无网恢复到有网的通知

    // MARK: Base
    case userInfoUpdated
    case userLogout
    case userLoginSuccess

    case presentSignInVc
    case appLanugageChanged
    case tzImagePickerNoti
    
    // MARK: AI Role
    // AI Role
    case aiRoleCreatedOrDelete
    case aiRoleInfoChanged
    // Album
    case aiRoleAlbumPhotoInfoChanged // AI 相册信息有变更
    case aiRoleAlbumAddOrDelete
    case aiRoleRelationInfoUpdated // 和AI之间的关系有更新
    
    // MARK: Msg
    case unreadCountChanged // ⚠️废弃，通过Combine订阅
    
    // MARK: Pay & Iap & Wallet
    case chargeDonePushTradeId
    case walletInfoUpdated
    
    // MARK: Chat
    case chatNaviMoreRedDotChanged
    case chatPersonaUpdated
    case chatSettingUpdated
    case chatSettingBackgroundChanged
    case chatSettingBackgroundListUpdated // 聊天背景有新生成
    
    // MARK: Heartbeat
    case heartbeatRelationHiddenUpdate
    
    // MARK: VIP
    case vipStateChange
    case buyCreditsOnce
    
    var stringValue: String {
        return rawValue
    }

    var notificationName: NSNotification.Name {
        return NSNotification.Name(stringValue)
    }

    static func post(name: AppNotificationName, object: Any? = nil, userInfo: [String: Any]? = nil) {
        NotificationCenter.default.post(name: name.notificationName, object: object, userInfo: userInfo)
    }
}

extension NotificationCenter {
    static func post(name: AppNotificationName, object: Any? = nil, userInfo: [String: Any]? = nil) {
        NotificationCenter.default.post(name: name.notificationName, object: object, userInfo: userInfo)
    }
}
