Created the FeedViewModel view model in the Feed framework and integrated it to the FeedViewController view controller.
This commit is contained in:
parent
24600daefa
commit
22a48e1888
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// AppDelegate.swift
|
// AppDelegate.swift
|
||||||
// AppStoreReviews
|
// ReviewsFeed
|
||||||
//
|
//
|
||||||
// Created by Dmitrii Ivanov on 21/07/2020.
|
// Created by Dmitrii Ivanov on 21/07/2020.
|
||||||
// Copyright © 2020 ING. All rights reserved.
|
// Copyright © 2020 ING. All rights reserved.
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// FeedViewModel.swift
|
||||||
|
// ReviewsFeed
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 18/03/2024.
|
||||||
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension FeedViewController {
|
||||||
|
final class ViewModel: ObservableObject {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// AppDelegate.swift
|
// AppDelegate.swift
|
||||||
// AppStoreReviews
|
// ReviewsFeed
|
||||||
//
|
//
|
||||||
// Created by Dmitrii Ivanov on 21/07/2020.
|
// Created by Dmitrii Ivanov on 21/07/2020.
|
||||||
// Copyright © 2020 ING. All rights reserved.
|
// Copyright © 2020 ING. All rights reserved.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// AppDelegate.swift
|
// AppDelegate.swift
|
||||||
// AppStoreReviews
|
// ReviewsFeed
|
||||||
//
|
//
|
||||||
// Created by Dmitrii Ivanov on 21/07/2020.
|
// Created by Dmitrii Ivanov on 21/07/2020.
|
||||||
// Copyright © 2020 ING. All rights reserved.
|
// Copyright © 2020 ING. All rights reserved.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// AppDelegate.swift
|
// AppDelegate.swift
|
||||||
// AppStoreReviews
|
// ReviewsFeed
|
||||||
//
|
//
|
||||||
// Created by Dmitrii Ivanov on 21/07/2020.
|
// Created by Dmitrii Ivanov on 21/07/2020.
|
||||||
// Copyright © 2020 ING. All rights reserved.
|
// Copyright © 2020 ING. All rights reserved.
|
||||||
@ -10,6 +10,10 @@ import UIKit
|
|||||||
|
|
||||||
public class FeedViewController: UITableViewController {
|
public class FeedViewController: UITableViewController {
|
||||||
|
|
||||||
|
// MARK: Constants
|
||||||
|
private let viewModel: ViewModel = .init()
|
||||||
|
|
||||||
|
// MARK: Initialisers
|
||||||
public init() {
|
public init() {
|
||||||
super.init(style: .plain)
|
super.init(style: .plain)
|
||||||
}
|
}
|
||||||
@ -18,28 +22,37 @@ public class FeedViewController: UITableViewController {
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: UIViewController
|
||||||
public override func viewDidLoad() {
|
public override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
tableView.register(ReviewCell.self, forCellReuseIdentifier: "cellId")
|
tableView.register(ReviewCell.self, forCellReuseIdentifier: "cellId")
|
||||||
tableView.rowHeight = 160
|
tableView.rowHeight = 160
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: UITableViewDataSource
|
||||||
public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
public override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
return 100
|
return 100
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
let c = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath) as! ReviewCell
|
let c = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath) as! ReviewCell
|
||||||
c.update(item: randomReview())
|
c.update(item: randomReview())
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: UITableViewDelegate
|
||||||
public override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
public override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
let vc = DetailsViewController(review: randomReview())
|
let vc = DetailsViewController(review: randomReview())
|
||||||
navigationController!.pushViewController(vc, animated: true)
|
navigationController!.pushViewController(vc, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
private extension FeedViewController {
|
||||||
|
|
||||||
|
// MARK: Functions
|
||||||
func randomReview() -> Review {
|
func randomReview() -> Review {
|
||||||
let author = ["Dan Auerbach", "Bo Diddley", "Otis Rush", "Jimi Hendrix", "Albert King", "Buddy Guy", "Muddy Waters", "Eric Clapton"].randomElement()!
|
let author = ["Dan Auerbach", "Bo Diddley", "Otis Rush", "Jimi Hendrix", "Albert King", "Buddy Guy", "Muddy Waters", "Eric Clapton"].randomElement()!
|
||||||
let version = ["3.11", "3.12"].randomElement()!
|
let version = ["3.11", "3.12"].randomElement()!
|
||||||
@ -54,5 +67,5 @@ public class FeedViewController: UITableViewController {
|
|||||||
id: id,
|
id: id,
|
||||||
content: content)
|
content: content)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
02620B8C2BA89C9A00DE7137 /* FeedViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */; };
|
||||||
02DC7F9F2BA51793000EEEBE /* ReviewsFeed.h in Headers */ = {isa = PBXBuildFile; fileRef = 02DC7F912BA51793000EEEBE /* ReviewsFeed.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
02DC7F9F2BA51793000EEEBE /* ReviewsFeed.h in Headers */ = {isa = PBXBuildFile; fileRef = 02DC7F912BA51793000EEEBE /* ReviewsFeed.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
02DC7FA22BA51793000EEEBE /* ReviewsFeed.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */; };
|
02DC7FA22BA51793000EEEBE /* ReviewsFeed.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */; };
|
||||||
02DC7FA32BA51793000EEEBE /* ReviewsFeed.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
02DC7FA32BA51793000EEEBE /* ReviewsFeed.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
@ -46,6 +47,7 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewModel.swift; sourceTree = "<group>"; };
|
||||||
02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReviewsFeed.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
02DC7F8F2BA51793000EEEBE /* ReviewsFeed.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReviewsFeed.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
02DC7F912BA51793000EEEBE /* ReviewsFeed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReviewsFeed.h; sourceTree = "<group>"; };
|
02DC7F912BA51793000EEEBE /* ReviewsFeed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReviewsFeed.h; sourceTree = "<group>"; };
|
||||||
02DC7FB12BA52084000EEEBE /* Libraries */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Libraries; sourceTree = "<group>"; };
|
02DC7FB12BA52084000EEEBE /* Libraries */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Libraries; sourceTree = "<group>"; };
|
||||||
@ -102,6 +104,7 @@
|
|||||||
02620B872BA89C0700DE7137 /* View Models */ = {
|
02620B872BA89C0700DE7137 /* View Models */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
02620B8B2BA89C9A00DE7137 /* FeedViewModel.swift */,
|
||||||
);
|
);
|
||||||
path = "View Models";
|
path = "View Models";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -362,6 +365,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
02620B8C2BA89C9A00DE7137 /* FeedViewModel.swift in Sources */,
|
||||||
02DC7FAC2BA51B4C000EEEBE /* DetailsViewController.swift in Sources */,
|
02DC7FAC2BA51B4C000EEEBE /* DetailsViewController.swift in Sources */,
|
||||||
02DC7FAF2BA51B4C000EEEBE /* Review.swift in Sources */,
|
02DC7FAF2BA51B4C000EEEBE /* Review.swift in Sources */,
|
||||||
02DC7FAE2BA51B4C000EEEBE /* FeedViewController.swift in Sources */,
|
02DC7FAE2BA51B4C000EEEBE /* FeedViewController.swift in Sources */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user