Skip to content

Instantly share code, notes, and snippets.

View aryasurya21's full-sized avatar
🚀
At School

Arya aryasurya21

🚀
At School
View GitHub Profile
//
// SceneDelegate.swift
// ProductDetailSample
//
// Created by arya.cia on 04/08/22.
//
import UIKit
import ProductDetail
import Shared
//
// ProductDetailPageViewController.swift
// MyAwesomeApp
//
// Created by digital.aurum on 10/06/22.
//
import UIKit
import Shared
//
// SceneDelegate.swift
// MyAwesomeApp
//
// Created by digital.aurum on 10/06/22.
//
import UIKit
import Catalog
import Shared
import UIKit
import Catalog
import Shared
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
import UIKit
import Shared
public class CatalogPageViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
let viewModel: CatalogPageViewModel
extension CatalogPageViewController: UICollectionViewDelegate {
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
switch viewModel.data[indexPath.row] {
case let data as Product:
Router.route(.productDetailPage(productID: data))
default:
fatalError("can't read the data")
}
}
}
//
// Route.swift
// Shared
//
// Created by arya.cia on 04/08/22.
//
import Foundation
public enum Destination {
//
// PracticeViewController.swift
// TPWorkshopUnitTest
//
// Created by digital.aurum on 19/11/21.
//
import UIKit
import Shared
public override func awakeFromNib() {
super.awakeFromNib()
inspirationProductCollectionView.dataSource = self
inspirationProductCollectionView.delegate = self
let bundle = Bundle(identifier: "com.aryasurya.Shared")
//we could also do
//let bundle = Bundle(for: Self.self) since we are accessing the NIB from its own module
inspirationProductCollectionView.register(UINib(
nibName: "InspirationItemCollectionViewCell",
bundle: bundle),
override func viewDidLoad() {
super.viewDidLoad()
title = "Catalog Page"
let bundle = Bundle(identifier: "com.aryasurya.Shared")
collectionView.register(UINib(nibName: "ProductCollectionViewCell", bundle: bundle), forCellWithReuseIdentifier: "ProductCollectionViewCell")
collectionView.register(UINib(nibName: "InspirationCollectionViewCell", bundle: bundle), forCellWithReuseIdentifier: "InspirationCollectionViewCell")
collectionView.dataSource = self
collectionView.delegate = self