Implemented a basic navigation bar for the FeedViewController view controller in the Feed framework.
This commit is contained in:
parent
05b5b8dc50
commit
0512f2fa42
@ -33,12 +33,9 @@ public class FeedViewController: UITableViewController {
|
|||||||
// MARK: UIViewController
|
// MARK: UIViewController
|
||||||
public override func viewDidLoad() {
|
public override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
tableView.register(
|
|
||||||
UITableViewCell.self,
|
|
||||||
forCellReuseIdentifier: .Cell.feedItem
|
|
||||||
)
|
|
||||||
|
|
||||||
|
setNavigationBar()
|
||||||
|
registerTableCells()
|
||||||
bindViewModel()
|
bindViewModel()
|
||||||
|
|
||||||
viewModel.fetch()
|
viewModel.fetch()
|
||||||
@ -113,6 +110,17 @@ private extension FeedViewController {
|
|||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func registerTableCells() {
|
||||||
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: .Cell.feedItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setNavigationBar() {
|
||||||
|
navigationController?.navigationBar.prefersLargeTitles = true
|
||||||
|
navigationController?.navigationBar.isTranslucent = true
|
||||||
|
|
||||||
|
navigationItem.title = "Latest reviews"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
@ -150,6 +158,15 @@ private extension String {
|
|||||||
import ReviewsFoundationKit
|
import ReviewsFoundationKit
|
||||||
import ReviewsiTunesKit
|
import ReviewsiTunesKit
|
||||||
|
|
||||||
|
@available(iOS 17.0, *)
|
||||||
|
#Preview("Feed View Controller loading reviews") {
|
||||||
|
MockURLProtocol.response = .init(statusCode: 200)
|
||||||
|
|
||||||
|
return UINavigationController(
|
||||||
|
rootViewController: FeedViewController(configuration: .init(session: .mock))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@available(iOS 17.0, *)
|
@available(iOS 17.0, *)
|
||||||
#Preview("Feed View Controller with few reviews") {
|
#Preview("Feed View Controller with few reviews") {
|
||||||
MockURLProtocol.response = .init(
|
MockURLProtocol.response = .init(
|
||||||
@ -182,10 +199,30 @@ import ReviewsiTunesKit
|
|||||||
version: "v1.0.0",
|
version: "v1.0.0",
|
||||||
updated: .init()
|
updated: .init()
|
||||||
),
|
),
|
||||||
|
.init(
|
||||||
|
id: 4,
|
||||||
|
author: "Some author name #4 here",
|
||||||
|
title: "Some review title #4 goes here...",
|
||||||
|
content: "Some long, explanatory review comment #4 goes here...",
|
||||||
|
rating: 4,
|
||||||
|
version: "v1.0.0",
|
||||||
|
updated: .init()
|
||||||
|
),
|
||||||
|
.init(
|
||||||
|
id: 5,
|
||||||
|
author: "Some author name #5 here",
|
||||||
|
title: "Some review title #5 goes here...",
|
||||||
|
content: "Some long, explanatory review comment #5 goes here...",
|
||||||
|
rating: 2,
|
||||||
|
version: "v1.0.0",
|
||||||
|
updated: .init()
|
||||||
|
),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
return FeedViewController(configuration: .init(session: .mock))
|
return UINavigationController(
|
||||||
|
rootViewController: FeedViewController(configuration: .init(session: .mock))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 17.0, *)
|
@available(iOS 17.0, *)
|
||||||
@ -195,6 +232,13 @@ import ReviewsiTunesKit
|
|||||||
object: Feed(entries: [])
|
object: Feed(entries: [])
|
||||||
)
|
)
|
||||||
|
|
||||||
return FeedViewController(configuration: .init(session: .mock))
|
return UINavigationController(
|
||||||
|
rootViewController: FeedViewController(configuration: .init(session: .mock))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 17.0, *)
|
||||||
|
#Preview("Feed View Controller with live reviews") {
|
||||||
|
UINavigationController(rootViewController: FeedViewController())
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user