//
//  HomeDataSourceModel.swift
//  HackathonWallet
//
//  Created by Nino Zhang on 2022/4/2.
//

import Foundation
import RxDataSources

enum HomeSectionItem {
    case advertising
    case address(ETHAddress)
    case tokenBalance(ETHTokenBalance)
}

extension HomeSectionItem: IdentifiableType, Equatable {
    var identity: String {
        switch self {
        case .advertising:      return "advertising"
        case .address:          return "address"
        case .tokenBalance(let tokenBalance): return "\(tokenBalance.token.hashValue)"
        }
    }
}

enum HomeSectionModel {
    case topContainer(items: [HomeSectionItem])
    case token(items: [HomeSectionItem])
}

extension HomeSectionModel: AnimatableSectionModelType {
    var identity: String {
        switch self {
        case .topContainer: return "topContainer"
        case .token:        return "token"
        }
    }

    var items: [HomeSectionItem] {
        switch self {
        case .topContainer(let items): return items
        case .token(let items):        return items
        }
    }

    init(original: HomeSectionModel, items: [HomeSectionItem]) {
        switch original {
        case .topContainer:
            self = .topContainer(items: items)
        case .token:
            self = .token(items: items)
        }
    }
}
