diff --git a/.DS_Store b/.DS_Store index 9189fc5..dcbfa2d 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Rick-and-Morty/Rick And Morty.xcodeproj/project.pbxproj b/Rick-and-Morty/Rick And Morty.xcodeproj/project.pbxproj index f0b45a2..f657038 100644 --- a/Rick-and-Morty/Rick And Morty.xcodeproj/project.pbxproj +++ b/Rick-and-Morty/Rick And Morty.xcodeproj/project.pbxproj @@ -8,9 +8,8 @@ /* Begin PBXBuildFile section */ 1711B39C26B16D6200BE935B /* CharactersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1711B39B26B16D6200BE935B /* CharactersView.swift */; }; + 1711B39E26B1898100BE935B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1711B39D26B1898100BE935B /* ContentView.swift */; }; 17CAB4FA26A824470048F2F1 /* CharacterCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CAB4F926A824470048F2F1 /* CharacterCell.swift */; }; - 17F1E38226A18A54009C1CDB /* CharacterCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17F1E38126A18A54009C1CDB /* CharacterCollectionViewController.swift */; }; - 17F1E38426A18EA8009C1CDB /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17F1E38326A18EA8009C1CDB /* TabBarController.swift */; }; 17F1E38626A1AF6A009C1CDB /* Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17F1E38526A1AF6A009C1CDB /* Character.swift */; }; 17F1E38A26A1D877009C1CDB /* CharacterCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17F1E38926A1D877009C1CDB /* CharacterCollectionViewCell.swift */; }; 17F1E38D26A1DCF0009C1CDB /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17F1E38C26A1DCF0009C1CDB /* Data.swift */; }; @@ -35,9 +34,8 @@ /* Begin PBXFileReference section */ 1711B39B26B16D6200BE935B /* CharactersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharactersView.swift; sourceTree = ""; }; + 1711B39D26B1898100BE935B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 17CAB4F926A824470048F2F1 /* CharacterCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCell.swift; sourceTree = ""; }; - 17F1E38126A18A54009C1CDB /* CharacterCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCollectionViewController.swift; sourceTree = ""; }; - 17F1E38326A18EA8009C1CDB /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = ""; }; 17F1E38526A1AF6A009C1CDB /* Character.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Character.swift; sourceTree = ""; }; 17F1E38926A1D877009C1CDB /* CharacterCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterCollectionViewCell.swift; sourceTree = ""; }; 17F1E38C26A1DCF0009C1CDB /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; @@ -83,21 +81,13 @@ path = Models; sourceTree = ""; }; - 17F1E38B26A1DCA0009C1CDB /* ViewControllers */ = { - isa = PBXGroup; - children = ( - 17F1E38326A18EA8009C1CDB /* TabBarController.swift */, - 17F1E38126A18A54009C1CDB /* CharacterCollectionViewController.swift */, - ); - path = ViewControllers; - sourceTree = ""; - }; 17F1E38E26A5724A009C1CDB /* Views */ = { isa = PBXGroup; children = ( 17F1E38926A1D877009C1CDB /* CharacterCollectionViewCell.swift */, 17CAB4F926A824470048F2F1 /* CharacterCell.swift */, 1711B39B26B16D6200BE935B /* CharactersView.swift */, + 1711B39D26B1898100BE935B /* ContentView.swift */, ); path = Views; sourceTree = ""; @@ -124,7 +114,6 @@ isa = PBXGroup; children = ( 17F1E38E26A5724A009C1CDB /* Views */, - 17F1E38B26A1DCA0009C1CDB /* ViewControllers */, 17F1E38026A184F3009C1CDB /* Models */, B811686C1CFF1C9900301A0A /* AppDelegate.swift */, B81168721CFF1C9900301A0A /* Main.storyboard */, @@ -250,10 +239,9 @@ buildActionMask = 2147483647; files = ( 17F1E38D26A1DCF0009C1CDB /* Data.swift in Sources */, + 1711B39E26B1898100BE935B /* ContentView.swift in Sources */, B811686D1CFF1C9900301A0A /* AppDelegate.swift in Sources */, - 17F1E38226A18A54009C1CDB /* CharacterCollectionViewController.swift in Sources */, 17CAB4FA26A824470048F2F1 /* CharacterCell.swift in Sources */, - 17F1E38426A18EA8009C1CDB /* TabBarController.swift in Sources */, B81168931CFF234900301A0A /* Rick.swift in Sources */, 1711B39C26B16D6200BE935B /* CharactersView.swift in Sources */, 17F1E38626A1AF6A009C1CDB /* Character.swift in Sources */, @@ -348,7 +336,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -398,7 +386,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; @@ -414,7 +402,7 @@ CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Rick And Morty/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.novoda.Rick-And-Morty"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -432,7 +420,7 @@ CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Rick And Morty/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.novoda.Rick-And-Morty"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Rick-and-Morty/Rick And Morty/AppDelegate.swift b/Rick-and-Morty/Rick And Morty/AppDelegate.swift index 31619e2..4bc13f8 100644 --- a/Rick-and-Morty/Rick And Morty/AppDelegate.swift +++ b/Rick-and-Morty/Rick And Morty/AppDelegate.swift @@ -1,10 +1,11 @@ import UIKit +import SwiftUI -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - return true +@main +struct RickAndMorty: App { + var body: some Scene { + WindowGroup { + ContentView() + } } } diff --git a/Rick-and-Morty/Rick And Morty/ViewControllers/CharacterCollectionViewController.swift b/Rick-and-Morty/Rick And Morty/ViewControllers/CharacterCollectionViewController.swift deleted file mode 100644 index 828f265..0000000 --- a/Rick-and-Morty/Rick And Morty/ViewControllers/CharacterCollectionViewController.swift +++ /dev/null @@ -1,44 +0,0 @@ -import UIKit - -class CharacterCollectionViewController: UICollectionViewController { - public var charactersTitle: String? - public var characters: [Character] = [] - - override func viewDidLoad() { - self.navigationItem.title = charactersTitle - - // not to sure what this does, but makes things work - collectionView.register(CharacterCollectionViewCell.self, forCellWithReuseIdentifier: CharacterCollectionViewCell.reuseIdentifier) - - if let flowLayout = collectionViewLayout as? UICollectionViewFlowLayout { - flowLayout.itemSize = CGSize(width: collectionView.frame.width, height: 120) - } - } - - override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return characters.count - } - - override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CharacterCollectionViewCell.reuseIdentifier, for:indexPath) - guard let characterCell = cell as? CharacterCollectionViewCell else { - return cell - } - - let character = characters[indexPath.row] - let imagePosition = getImagePosition(character: character) - - characterCell.embed(in: self, withCharacter: character, imagePosition: imagePosition) - - return characterCell - } - - private func getImagePosition(character: Character) -> CharacterImagePosition { - if character is Morty { - return .left - } - else { - return .right - } - } -} diff --git a/Rick-and-Morty/Rick And Morty/ViewControllers/TabBarController.swift b/Rick-and-Morty/Rick And Morty/ViewControllers/TabBarController.swift deleted file mode 100644 index 4dbc3ea..0000000 --- a/Rick-and-Morty/Rick And Morty/ViewControllers/TabBarController.swift +++ /dev/null @@ -1,16 +0,0 @@ -import UIKit -import SwiftUI - -class TabBarController: UITabBarController, UITabBarControllerDelegate { - - override func viewDidLoad() { - - let rickViewController = UIHostingController(rootView: CharactersView(characters: ricks, title: "Ricks")) - rickViewController.tabBarItem = UITabBarItem(title: "Ricks", image: UIImage(named: "rick-icon"), tag: 1) - - let mortyViewController = UIHostingController(rootView: CharactersView(characters: morties, title: "Morties")) - mortyViewController.tabBarItem = UITabBarItem(title: "Morties", image: UIImage(named: "morty-icon"), tag: 2) - - self.setViewControllers([rickViewController, mortyViewController], animated: false) - } -} diff --git a/Rick-and-Morty/Rick And Morty/Views/ContentView.swift b/Rick-and-Morty/Rick And Morty/Views/ContentView.swift new file mode 100644 index 0000000..3501bbe --- /dev/null +++ b/Rick-and-Morty/Rick And Morty/Views/ContentView.swift @@ -0,0 +1,31 @@ +// +// ContentView.swift +// Rick And Morty +// +// Created by Scottie Gray on 2021-07-28. +// Copyright © 2021 Novoda. All rights reserved. +// + +import SwiftUI + +struct ContentView: View { + + var body: some View { + TabView { + CharactersView(characters: ricks, title: "Ricks") + .tabItem { + Label("Ricks", image: "rick-icon") + } + CharactersView(characters: morties, title: "Morties") + .tabItem { + Label("Morties", image: "morty-icon") + } + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +}