Repositorios

App FrontBack (Fork)

Listado ficticio de NFT y transacciones en UIKit

Reemplazo de librerías AlamoFire por URLSession, añadidos tests con URLProtocol, reemplazo de UIViewCell por vistas en SwiftUI

Sustituida librería AlamoFire y AlamoFireImage por URLSession
Añadidos URLSessionMock para test unitarios de Network en HomeViewModel y Wallet ViewModel
final class HomeServiceTests: XCTestCase {
    var network: Network!
    var sut: HomeService!
    
    
    override func setUpWithError() throws {
        network = Network(urlProtocol: URLSessionMock.self)
        sut = HomeService(network: network)
        
    }

    override func tearDownWithError() throws {
        network = nil
        sut = nil
    }
    
    func testGetHome_ShouldBe() {
        let expectation = XCTestExpectation(description: "carga en callback HomeService.getHome")
        sut.getHome { result, failure in
            isFailure(failure)
            let result = try! XCTUnwrap(result)
            let list = try! XCTUnwrap(result.nftList)
          
            XCTAssertEqual(list.count, 3)
            expectation.fulfill()
        }
        wait(for: [expectation],timeout: 5)
    }
}
Sustituidas ViewCell por celdas en SwiftUI con UIHostingConfiguration
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        switch WalletNameCell(rawValue: indexPath.row) {
            
        case.quotationEth:
            let cell = tableView.dequeueReusableCell(withIdentifier: QuotationEthTableViewCell.identifier, for: indexPath) as? QuotationEthTableViewCell
            cell?.contentConfiguration = UIHostingConfiguration {
                QuotationEthCell(quotationEthereum: viewModel.quotationEthereum)
            }
            return cell ?? UITableViewCell()
            
        case.transactionList:
            let cell = tableView.dequeueReusableCell(withIdentifier: LatestTransactionsTableViewCell.identifier, for: indexPath) as? LatestTransactionsTableViewCell
            cell?.contentConfiguration = UIHostingConfiguration {
                LatestTransactionsViewCell(cell: viewModel.latestTransactionsCell)
            }
            return cell ?? UITableViewCell()
            
        default:
            return UITableViewCell()
        }
    }
Sustituido ProfileVC por ProfileView con UIHostingController y patrón Delegate
 override func viewDidLoad() {
        super.viewDidLoad()
        let profileView = ProfileView(delegate: self)
        let hostingController = UIHostingController(rootView: profileView)
        addChild(hostingController)
        view.addSubview(hostingController.view)
        hostingController.view.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
                    hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
                    hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
                    hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
                    hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
                ])
        
        hostingController.didMove(toParent: self)
    }

AppFrontBack
Lucasnp