RMTabbarController.swift
import UIKit
class RMTabbarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
}
}
SceneDelegate.swift
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
let vc = RMTabbarController()
let window = UIWindow(windowScene: windowScene)
window.rootViewController = vc
window.makeKeyAndVisible()
self.window = window
}
final class RMTabbarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
setUpTabs()
}
private func setUpTabs() {
let charactersVC = RMCharacterViewController()
let locationsVC = RMLocationViewController()
let episodesVC = RMEpisodeViewController()
let settingsVC = RMSettingViewController()
charactersVC.title = "Characters"
locationsVC.title = "Locations"
episodesVC.title = "Episodes"
settingsVC.title = "Settings"
let nav1 = UINavigationController(rootViewController: charactersVC)
let nav2 = UINavigationController(rootViewController: locationsVC)
let nav3 = UINavigationController(rootViewController: episodesVC)
let nav4 = UINavigationController(rootViewController: settingsVC)
setViewControllers(
[nav1, nav2, nav3, nav4],
animated: true
)
}
final class RMTabbarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
setUpTabs()
}
private func setUpTabs() {
let charactersVC = RMCharacterViewController()
let locationsVC = RMLocationViewController()
let episodesVC = RMEpisodeViewController()
let settingsVC = RMSettingViewController()
charactersVC.navigationItem.largeTitleDisplayMode = .automatic
locationsVC.navigationItem.largeTitleDisplayMode = .automatic
episodesVC.navigationItem.largeTitleDisplayMode = .automatic
settingsVC.navigationItem.largeTitleDisplayMode = .automatic
let nav1 = UINavigationController(rootViewController: charactersVC)
let nav2 = UINavigationController(rootViewController: locationsVC)
let nav3 = UINavigationController(rootViewController: episodesVC)
let nav4 = UINavigationController(rootViewController: settingsVC)
nav1.tabBarItem = UITabBarItem(title: "Characters",
image: nil,
tag: 1)
nav2.tabBarItem = UITabBarItem(title: "Locations",
image: nil,
tag: 2)
nav3.tabBarItem = UITabBarItem(title: "Episodes",
image: nil,
tag: 3)
nav4.tabBarItem = UITabBarItem(title: "Settings",
image: nil,
tag: 4)
for nav in [nav1, nav2, nav3, nav4] {
nav.navigationBar.prefersLargeTitles = true
}
setViewControllers(
[nav1, nav2, nav3, nav4],
animated: true
)
RMTabbarController.swift
nav1.tabBarItem = UITabBarItem(title: "Characters",
image: UIImage(systemName: "person"),
tag: 1)
nav2.tabBarItem = UITabBarItem(title: "Locations",
image: UIImage(systemName: "globe"),
tag: 2)
nav3.tabBarItem = UITabBarItem(title: "Episodes",
image: UIImage(systemName: "tv"),
tag: 3)
nav4.tabBarItem = UITabBarItem(title: "Settings",
image: UIImage(systemName: "gear"),
tag: 4)
RMService.swift
/// Primary API service object to get Flick and Morty data
final class RMServive {
/// Shared singlton instance
static let shared = RMServive()
/// Privatized constructer
private init() {}
/// Send Rick and Morty API Call
/// - Parameters:
/// - request: Request Instance
/// - completion: Callback with data or error
public func execute(_ request: RMRequest, completion: @escaping () -> Void) {
}
}
RMEndpoint.swift
import Foundation
/// Represents unique AP
@frozen enum RMEndpoint: String {
/// Endpoint to get character info
case character
/// Endpoint to get location info
case location
/// Endpoint to get episode info
case episode
}
RMRequest.swift
/// Object that reprents a single API call
final class RMRequest {
}