diff --git a/iPhone Photos app.xcodeproj/project.pbxproj b/iPhone Photos app.xcodeproj/project.pbxproj index 8e31b4b..b975688 100644 --- a/iPhone Photos app.xcodeproj/project.pbxproj +++ b/iPhone Photos app.xcodeproj/project.pbxproj @@ -9,21 +9,36 @@ /* Begin PBXBuildFile section */ 604A14EB29C041100093E2C0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A14EA29C041100093E2C0 /* AppDelegate.swift */; }; 604A14ED29C041100093E2C0 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A14EC29C041100093E2C0 /* SceneDelegate.swift */; }; - 604A14EF29C041100093E2C0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A14EE29C041100093E2C0 /* ViewController.swift */; }; - 604A14F229C041100093E2C0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 604A14F029C041100093E2C0 /* Main.storyboard */; }; 604A14F429C041120093E2C0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 604A14F329C041120093E2C0 /* Assets.xcassets */; }; 604A14F729C041120093E2C0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 604A14F529C041120093E2C0 /* LaunchScreen.storyboard */; }; + 604A14FF29C04F560093E2C0 /* LibraryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A14FE29C04F560093E2C0 /* LibraryViewController.swift */; }; + 604A150129C04F640093E2C0 /* ForYouViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A150029C04F640093E2C0 /* ForYouViewController.swift */; }; + 604A150329C04F7B0093E2C0 /* AlbumsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A150229C04F7B0093E2C0 /* AlbumsViewController.swift */; }; + 604A150529C04F8A0093E2C0 /* SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A150429C04F8A0093E2C0 /* SearchViewController.swift */; }; + 604A150729C0B7DA0093E2C0 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A150629C0B7DA0093E2C0 /* TabBarController.swift */; }; + 604A150A29C0F2D70093E2C0 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 604A150929C0F2D70093E2C0 /* SnapKit */; }; + 604A150C29C0F4DB0093E2C0 /* AlbumCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A150B29C0F4DB0093E2C0 /* AlbumCollectionViewCell.swift */; }; + 604A151429C100170093E2C0 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A151329C100170093E2C0 /* Models.swift */; }; + 604A151629C19EF40093E2C0 /* AlbumCellHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A151529C19EF40093E2C0 /* AlbumCellHeader.swift */; }; + 604A151829C24E430093E2C0 /* MediaCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 604A151729C24E430093E2C0 /* MediaCollectionViewCell.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 604A14E729C041100093E2C0 /* iPhone Photos app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iPhone Photos app.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 604A14EA29C041100093E2C0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 604A14EC29C041100093E2C0 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 604A14EE29C041100093E2C0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 604A14F129C041100093E2C0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 604A14F329C041120093E2C0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 604A14F629C041120093E2C0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 604A14F829C041120093E2C0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 604A14FE29C04F560093E2C0 /* LibraryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryViewController.swift; sourceTree = ""; }; + 604A150029C04F640093E2C0 /* ForYouViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForYouViewController.swift; sourceTree = ""; }; + 604A150229C04F7B0093E2C0 /* AlbumsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumsViewController.swift; sourceTree = ""; }; + 604A150429C04F8A0093E2C0 /* SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = ""; }; + 604A150629C0B7DA0093E2C0 /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = ""; }; + 604A150B29C0F4DB0093E2C0 /* AlbumCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumCollectionViewCell.swift; sourceTree = ""; }; + 604A151329C100170093E2C0 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; + 604A151529C19EF40093E2C0 /* AlbumCellHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumCellHeader.swift; sourceTree = ""; }; + 604A151729C24E430093E2C0 /* MediaCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaCollectionViewCell.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -31,6 +46,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 604A150A29C0F2D70093E2C0 /* SnapKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -54,17 +70,64 @@ sourceTree = ""; }; 604A14E929C041100093E2C0 /* iPhone Photos app */ = { + isa = PBXGroup; + children = ( + 604A150629C0B7DA0093E2C0 /* TabBarController.swift */, + 604A151329C100170093E2C0 /* Models.swift */, + 604A151229C0F6F40093E2C0 /* SearchVC */, + 604A151029C0F6DC0093E2C0 /* AlbumVC */, + 604A150F29C0F6C80093E2C0 /* ForYouVC */, + 604A150E29C0F6BE0093E2C0 /* LibraryVC */, + 604A150D29C0F5B90093E2C0 /* App */, + ); + path = "iPhone Photos app"; + sourceTree = ""; + }; + 604A150D29C0F5B90093E2C0 /* App */ = { isa = PBXGroup; children = ( 604A14EA29C041100093E2C0 /* AppDelegate.swift */, 604A14EC29C041100093E2C0 /* SceneDelegate.swift */, - 604A14EE29C041100093E2C0 /* ViewController.swift */, - 604A14F029C041100093E2C0 /* Main.storyboard */, 604A14F329C041120093E2C0 /* Assets.xcassets */, 604A14F529C041120093E2C0 /* LaunchScreen.storyboard */, 604A14F829C041120093E2C0 /* Info.plist */, ); - path = "iPhone Photos app"; + path = App; + sourceTree = ""; + }; + 604A150E29C0F6BE0093E2C0 /* LibraryVC */ = { + isa = PBXGroup; + children = ( + 604A14FE29C04F560093E2C0 /* LibraryViewController.swift */, + ); + path = LibraryVC; + sourceTree = ""; + }; + 604A150F29C0F6C80093E2C0 /* ForYouVC */ = { + isa = PBXGroup; + children = ( + 604A150029C04F640093E2C0 /* ForYouViewController.swift */, + ); + path = ForYouVC; + sourceTree = ""; + }; + 604A151029C0F6DC0093E2C0 /* AlbumVC */ = { + isa = PBXGroup; + children = ( + 604A150229C04F7B0093E2C0 /* AlbumsViewController.swift */, + 604A150B29C0F4DB0093E2C0 /* AlbumCollectionViewCell.swift */, + 604A151529C19EF40093E2C0 /* AlbumCellHeader.swift */, + 604A151729C24E430093E2C0 /* MediaCollectionViewCell.swift */, + ); + path = AlbumVC; + sourceTree = ""; + }; + 604A151229C0F6F40093E2C0 /* SearchVC */ = { + isa = PBXGroup; + children = ( + 604A150429C04F8A0093E2C0 /* SearchViewController.swift */, + ); + path = SearchVC; sourceTree = ""; }; /* End PBXGroup section */ @@ -83,6 +146,9 @@ dependencies = ( ); name = "iPhone Photos app"; + packageProductDependencies = ( + 604A150929C0F2D70093E2C0 /* SnapKit */, + ); productName = "iPhone Photos app"; productReference = 604A14E729C041100093E2C0 /* iPhone Photos app.app */; productType = "com.apple.product-type.application"; @@ -111,6 +177,9 @@ Base, ); mainGroup = 604A14DE29C041100093E2C0; + packageReferences = ( + 604A150829C0F2D70093E2C0 /* XCRemoteSwiftPackageReference "SnapKit" */, + ); productRefGroup = 604A14E829C041100093E2C0 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -127,7 +196,6 @@ files = ( 604A14F729C041120093E2C0 /* LaunchScreen.storyboard in Resources */, 604A14F429C041120093E2C0 /* Assets.xcassets in Resources */, - 604A14F229C041100093E2C0 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -138,8 +206,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 604A14EF29C041100093E2C0 /* ViewController.swift in Sources */, + 604A151629C19EF40093E2C0 /* AlbumCellHeader.swift in Sources */, + 604A151429C100170093E2C0 /* Models.swift in Sources */, + 604A150C29C0F4DB0093E2C0 /* AlbumCollectionViewCell.swift in Sources */, + 604A150529C04F8A0093E2C0 /* SearchViewController.swift in Sources */, 604A14EB29C041100093E2C0 /* AppDelegate.swift in Sources */, + 604A150329C04F7B0093E2C0 /* AlbumsViewController.swift in Sources */, + 604A14FF29C04F560093E2C0 /* LibraryViewController.swift in Sources */, + 604A150729C0B7DA0093E2C0 /* TabBarController.swift in Sources */, + 604A150129C04F640093E2C0 /* ForYouViewController.swift in Sources */, + 604A151829C24E430093E2C0 /* MediaCollectionViewCell.swift in Sources */, 604A14ED29C041100093E2C0 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -147,14 +223,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 604A14F029C041100093E2C0 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 604A14F129C041100093E2C0 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; 604A14F529C041120093E2C0 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -289,10 +357,9 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 6YX8RWQNTP; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = "iPhone Photos app/Info.plist"; + INFOPLIST_FILE = "iPhone Photos app/App/Info.plist"; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -317,10 +384,9 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 6YX8RWQNTP; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_FILE = "iPhone Photos app/Info.plist"; + INFOPLIST_FILE = "iPhone Photos app/App/Info.plist"; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -358,6 +424,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 604A150829C0F2D70093E2C0 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit.git"; + requirement = { + branch = develop; + kind = branch; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 604A150929C0F2D70093E2C0 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 604A150829C0F2D70093E2C0 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 604A14DF29C041100093E2C0 /* Project object */; } diff --git a/iPhone Photos app.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iPhone Photos app.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..6790c94 --- /dev/null +++ b/iPhone Photos app.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "branch" : "develop", + "revision" : "58320fe80522414bf3a7e24c88123581dc586752" + } + } + ], + "version" : 2 +} diff --git a/iPhone Photos app.xcodeproj/xcuserdata/adlet-admin.xcuserdatad/xcschemes/xcschememanagement.plist b/iPhone Photos app.xcodeproj/xcuserdata/adlet-admin.xcuserdatad/xcschemes/xcschememanagement.plist index 55f250d..532d329 100644 --- a/iPhone Photos app.xcodeproj/xcuserdata/adlet-admin.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/iPhone Photos app.xcodeproj/xcuserdata/adlet-admin.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,6 +4,27 @@ SchemeUserState + SnapKitPlayground (Playground) 1.xcscheme + + isShown + + orderHint + 2 + + SnapKitPlayground (Playground) 2.xcscheme + + isShown + + orderHint + 3 + + SnapKitPlayground (Playground).xcscheme + + isShown + + orderHint + 1 + iPhone Photos app.xcscheme_^#shared#^_ orderHint diff --git a/iPhone Photos app/AlbumVC/AlbumCellHeader.swift b/iPhone Photos app/AlbumVC/AlbumCellHeader.swift new file mode 100644 index 0000000..27d8657 --- /dev/null +++ b/iPhone Photos app/AlbumVC/AlbumCellHeader.swift @@ -0,0 +1,75 @@ +// +// AlbumCellHeader.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 15.03.2023. +// + +import UIKit +import SnapKit + +class AlbumCellHeader: UICollectionReusableView { + + static let identifier = "AlbumCellHeader" + + lazy var lineView: UIView = { + let view = UIView() + view.backgroundColor = .systemGray5 + return view + }() + + lazy var title: UILabel = { + let label = UILabel() + label.font = UIFont.systemFont(ofSize: 25, weight: .bold) + return label + }() + + lazy var button: UIButton = { + let button = UIButton(type: .system) + button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 17) + button.setTitleColor(.black, for: .normal) + return button + }() + + override init(frame: CGRect) { + super.init(frame: frame) + clipsToBounds = true + setupViews() + setupConstraints() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setupViews() { + addSubview(lineView) + addSubview(title) + addSubview(button) + } + + private func setupConstraints() { + lineView.snp.makeConstraints { + $0.top.equalTo(self) + $0.width.equalTo(self.snp.width) + $0.height.equalTo(1) + } + + title.snp.makeConstraints { + $0.bottom.equalTo(self) + $0.left.equalTo(self) + } + + button.snp.makeConstraints { + $0.bottom.equalTo(self) + $0.right.equalTo(self) + } + } + + override func prepareForReuse() { + super.prepareForReuse() + title.text = nil + button.titleLabel?.text = nil + } + +} diff --git a/iPhone Photos app/AlbumVC/AlbumCollectionViewCell.swift b/iPhone Photos app/AlbumVC/AlbumCollectionViewCell.swift new file mode 100644 index 0000000..00bb351 --- /dev/null +++ b/iPhone Photos app/AlbumVC/AlbumCollectionViewCell.swift @@ -0,0 +1,69 @@ +// +// AlbumCollectionViewCell.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 15.03.2023. +// + +import UIKit + +class AlbumCollectionViewCell: UICollectionViewCell { + + static let identifier = "AlbumCollectionViewCell" + + lazy var image: UIImageView = { + let image = UIImageView() + image.contentMode = .scaleAspectFill + image.clipsToBounds = true + return image + }() + + lazy var title: UILabel = { + let label = UILabel() + return label + }() + + lazy var quantity: UILabel = { + let label = UILabel() + return label + }() + + private let stack: UIStackView = { + let stack = UIStackView() + stack.axis = .vertical + stack.distribution = .fill + return stack + }() + + override init(frame: CGRect) { + super.init(frame: frame) + clipsToBounds = true + setupViews() + setupConstraints() + } + + private func setupViews() { + contentView.addSubview(stack) + stack.addArrangedSubview(image) + stack.addArrangedSubview(title) + stack.addArrangedSubview(quantity) + } + + private func setupConstraints() { + stack.snp.makeConstraints { + $0.left.top.right.bottom.equalTo(contentView) + $0.width.equalTo(170) + $0.height.equalTo(200) + } + } + + override func prepareForReuse() { + self.image.image = nil + self.title.text = nil + self.quantity.text = nil + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/iPhone Photos app/AlbumVC/AlbumsViewController.swift b/iPhone Photos app/AlbumVC/AlbumsViewController.swift new file mode 100644 index 0000000..c497adf --- /dev/null +++ b/iPhone Photos app/AlbumVC/AlbumsViewController.swift @@ -0,0 +1,278 @@ +// +// AlbumsViewController.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 14.03.2023. +// + +import UIKit + +class AlbumsViewController: UIViewController { + + private let settingsDelegate = MediaCollectionViewCell() + + private lazy var collectionView: UICollectionView = { + let layout = createLayout() + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.register(AlbumCollectionViewCell.self, forCellWithReuseIdentifier: AlbumCollectionViewCell.identifier) + collectionView.register(AlbumCellHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: AlbumCellHeader.identifier) + collectionView.register(MediaCollectionViewCell.self, forCellWithReuseIdentifier: MediaCollectionViewCell.identifier) + collectionView.delegate = self + collectionView.dataSource = self + return collectionView + }() + + override func viewDidLoad() { + super.viewDidLoad() + setupController() + setupViews() + setupConstraints() + } + + private func setupController() { + view.backgroundColor = .white + title = "Albums" + navigationController?.navigationBar.prefersLargeTitles = true + navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(libraryNCleftButtonTapped)) + navigationItem.leftBarButtonItem?.tintColor = .black + } + + private func setupViews() { + view.addSubview(collectionView) + } + + private func setupConstraints() { + collectionView.snp.makeConstraints { + $0.left.top.right.bottom.equalToSuperview() + } + } + + @objc func libraryNCleftButtonTapped() { } + + private func createLayout() -> UICollectionViewCompositionalLayout { + return UICollectionViewCompositionalLayout { sectionIndex, _ in + + switch sectionIndex { + case 0: + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .fractionalHeight(1) + ) + let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize) + layoutItem.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let groupSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.47), + heightDimension: .fractionalHeight(0.5) + ) + let layoutGroup = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitem: layoutItem, count: 2) + layoutGroup.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let layoutSection = NSCollectionLayoutSection(group: layoutGroup) + layoutSection.orthogonalScrollingBehavior = .continuous + + let layoutSectionHeaderSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.93), + heightDimension: .estimated(50) + ) + let layoutSectionHeader = NSCollectionLayoutBoundarySupplementaryItem( + layoutSize: layoutSectionHeaderSize, + elementKind: UICollectionView.elementKindSectionHeader, + alignment: .top + ) + layoutSection.boundarySupplementaryItems = [layoutSectionHeader] + return layoutSection + case 1: + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .fractionalHeight(1) + ) + let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize) + layoutItem.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let groupSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .fractionalHeight(0.3) + ) + let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: layoutItem, count: 2) + layoutGroup.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let layoutSection = NSCollectionLayoutSection(group: layoutGroup) + layoutSection.orthogonalScrollingBehavior = .continuous + + let layoutSectionHeaderSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.93), + heightDimension: .estimated(50) + ) + let layoutSectionHeader = NSCollectionLayoutBoundarySupplementaryItem( + layoutSize: layoutSectionHeaderSize, + elementKind: UICollectionView.elementKindSectionHeader, + alignment: .top + ) + layoutSection.boundarySupplementaryItems = [layoutSectionHeader] + return layoutSection + case 2: + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .fractionalHeight(1) + ) + let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize) + layoutItem.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let groupSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .absolute(44) + ) + let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [layoutItem]) +// layoutGroup.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let layoutSection = NSCollectionLayoutSection(group: layoutGroup) +// layoutSection.orthogonalScrollingBehavior = .continuous + layoutSection.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10) + + let layoutSectionHeaderSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.93), + heightDimension: .estimated(50) + ) + let layoutSectionHeader = NSCollectionLayoutBoundarySupplementaryItem( + layoutSize: layoutSectionHeaderSize, + elementKind: UICollectionView.elementKindSectionHeader, + alignment: .top + ) + layoutSection.boundarySupplementaryItems = [layoutSectionHeader] + return layoutSection + case 3: + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .fractionalHeight(1) + ) + let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize) + layoutItem.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let groupSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .absolute(44) + ) + let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [layoutItem]) + let layoutSection = NSCollectionLayoutSection(group: layoutGroup) + layoutSection.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10) + + let layoutSectionHeaderSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.93), + heightDimension: .estimated(50) + ) + let layoutSectionHeader = NSCollectionLayoutBoundarySupplementaryItem( + layoutSize: layoutSectionHeaderSize, + elementKind: UICollectionView.elementKindSectionHeader, + alignment: .top + ) + layoutSection.boundarySupplementaryItems = [layoutSectionHeader] + return layoutSection + default: + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .fractionalHeight(1) + ) + let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize) + layoutItem.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let groupSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.47), + heightDimension: .fractionalHeight(0.5) + ) + let layoutGroup = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitem: layoutItem, count: 2) + layoutGroup.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) + let layoutSection = NSCollectionLayoutSection(group: layoutGroup) + layoutSection.orthogonalScrollingBehavior = .continuous + + let layoutSectionHeaderSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.93), + heightDimension: .estimated(50) + ) + let layoutSectionHeader = NSCollectionLayoutBoundarySupplementaryItem( + layoutSize: layoutSectionHeaderSize, + elementKind: UICollectionView.elementKindSectionHeader, + alignment: .top + ) + layoutSection.boundarySupplementaryItems = [layoutSectionHeader] + return layoutSection + } + } + } +} + +extension AlbumsViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + func numberOfSections(in collectionView: UICollectionView) -> Int { + AlbumModel.modelsArray.count + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + AlbumModel.modelsArray[section].count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + + switch indexPath.section { + case 0: + let item = collectionView.dequeueReusableCell(withReuseIdentifier: AlbumCollectionViewCell.identifier, for: indexPath) as? AlbumCollectionViewCell + item?.image.image = UIImage(named: AlbumModel.modelsArray[indexPath.section][indexPath.row].image) + item?.title.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].title + item?.quantity.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].quantity + return item ?? UICollectionViewCell() + case 1: + let item = collectionView.dequeueReusableCell(withReuseIdentifier: AlbumCollectionViewCell.identifier, for: indexPath) as? AlbumCollectionViewCell + item?.image.image = UIImage(named: AlbumModel.modelsArray[indexPath.section][indexPath.row].image) + item?.title.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].title + item?.quantity.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].quantity + return item ?? UICollectionViewCell() + case 2: + let item = collectionView.dequeueReusableCell(withReuseIdentifier: MediaCollectionViewCell.identifier, for: indexPath) as? MediaCollectionViewCell + item?.image.image = UIImage(systemName: AlbumModel.modelsArray[indexPath.section][indexPath.row].image) + item?.title.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].title + item?.quantity.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].quantity + item?.accessory.image = UIImage(systemName: "checkmark") + return item ?? UICollectionViewCell() + case 3: + let item = collectionView.dequeueReusableCell(withReuseIdentifier: MediaCollectionViewCell.identifier, for: indexPath) as? MediaCollectionViewCell + item?.image.image = UIImage(systemName: AlbumModel.modelsArray[indexPath.section][indexPath.row].image) + item?.title.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].title + item?.quantity.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].quantity + item?.accessory.image = UIImage(systemName: "checkmark") + return item ?? UICollectionViewCell() + default: + let item = collectionView.dequeueReusableCell(withReuseIdentifier: AlbumCollectionViewCell.identifier, for: indexPath) as? AlbumCollectionViewCell + item?.image.image = UIImage(named: AlbumModel.modelsArray[indexPath.section][indexPath.row].image) + item?.title.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].title + item?.quantity.text = AlbumModel.modelsArray[indexPath.section][indexPath.row].quantity + return item ?? UICollectionViewCell() + } + } + + func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + + switch indexPath.section { + case 0: + let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: AlbumCellHeader.identifier, for: indexPath) as! AlbumCellHeader + header.title.text = "My Albums" + header.button.setTitle("See All", for: .normal) + return header + case 1: + let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: AlbumCellHeader.identifier, for: indexPath) as! AlbumCellHeader + header.title.text = "People and places" + return header + case 2: + let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: AlbumCellHeader.identifier, for: indexPath) as! AlbumCellHeader + header.title.text = "Media Types" + return header + case 3: + let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: AlbumCellHeader.identifier, for: indexPath) as! AlbumCellHeader + header.title.text = "Other" + header.button.setTitle("", for: .normal) + return header + default: + let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: AlbumCellHeader.identifier, for: indexPath) as! AlbumCellHeader + header.title.text = "Other" + return header + } + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: 170, height: 200) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 15) + } +} diff --git a/iPhone Photos app/AlbumVC/MediaCollectionViewCell.swift b/iPhone Photos app/AlbumVC/MediaCollectionViewCell.swift new file mode 100644 index 0000000..d3ffc5d --- /dev/null +++ b/iPhone Photos app/AlbumVC/MediaCollectionViewCell.swift @@ -0,0 +1,89 @@ +// +// MediaCollectionViewCell.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 16.03.2023. +// + +import UIKit + +class MediaCollectionViewCell: UICollectionViewCell { + + static let identifier = "MediaCollectionViewCell" + + lazy var image: UIImageView = { + let image = UIImageView() + image.contentMode = .scaleAspectFit + image.clipsToBounds = true + return image + }() + + lazy var title: UILabel = { + let label = UILabel() + return label + }() + + lazy var quantity: UILabel = { + let label = UILabel() + return label + }() + + lazy var accessory: UIImageView = { + let image = UIImageView() + image.contentMode = .scaleAspectFit + image.clipsToBounds = true + return image + }() + + private let stack: UIStackView = { + let stack = UIStackView() + stack.axis = .horizontal + return stack + }() + + override init(frame: CGRect) { + super.init(frame: frame) + setupViews() + setupConstraints() + } + + private func setupViews() { + contentView.addSubview(image) + contentView.addSubview(title) + contentView.addSubview(quantity) + contentView.addSubview(accessory) + } + + private func setupConstraints() { + image.snp.makeConstraints { + $0.centerY.equalTo(contentView) + $0.leading.equalTo(contentView) + } + + title.snp.makeConstraints { + $0.centerY.equalTo(contentView) + $0.leading.equalTo(image.snp.trailing).offset(10) + } + + accessory.snp.makeConstraints { + $0.centerY.equalTo(contentView) + $0.trailing.equalTo(contentView) + } + + quantity.snp.makeConstraints { + $0.centerY.equalTo(contentView) + $0.trailing.equalTo(accessory.snp.leading).offset(-10) + } + } + + override func prepareForReuse() { + self.image.image = nil + self.title.text = nil + self.quantity.text = nil + self.accessory.image = nil + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/iPhone Photos app/AppDelegate.swift b/iPhone Photos app/App/AppDelegate.swift similarity index 100% rename from iPhone Photos app/AppDelegate.swift rename to iPhone Photos app/App/AppDelegate.swift diff --git a/iPhone Photos app/Assets.xcassets/AccentColor.colorset/Contents.json b/iPhone Photos app/App/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from iPhone Photos app/Assets.xcassets/AccentColor.colorset/Contents.json rename to iPhone Photos app/App/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/iPhone Photos app/Assets.xcassets/AppIcon.appiconset/Contents.json b/iPhone Photos app/App/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from iPhone Photos app/Assets.xcassets/AppIcon.appiconset/Contents.json rename to iPhone Photos app/App/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/iPhone Photos app/Assets.xcassets/Contents.json b/iPhone Photos app/App/Assets.xcassets/Contents.json similarity index 100% rename from iPhone Photos app/Assets.xcassets/Contents.json rename to iPhone Photos app/App/Assets.xcassets/Contents.json diff --git a/iPhone Photos app/App/Assets.xcassets/thanos.imageset/Contents.json b/iPhone Photos app/App/Assets.xcassets/thanos.imageset/Contents.json new file mode 100644 index 0000000..72aee9c --- /dev/null +++ b/iPhone Photos app/App/Assets.xcassets/thanos.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "thanos.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iPhone Photos app/App/Assets.xcassets/thanos.imageset/thanos.jpg b/iPhone Photos app/App/Assets.xcassets/thanos.imageset/thanos.jpg new file mode 100644 index 0000000..1c9547d Binary files /dev/null and b/iPhone Photos app/App/Assets.xcassets/thanos.imageset/thanos.jpg differ diff --git a/iPhone Photos app/App/Base.lproj/LaunchScreen.storyboard b/iPhone Photos app/App/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..d54fe6d --- /dev/null +++ b/iPhone Photos app/App/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iPhone Photos app/Info.plist b/iPhone Photos app/App/Info.plist similarity index 90% rename from iPhone Photos app/Info.plist rename to iPhone Photos app/App/Info.plist index dd3c9af..0eb786d 100644 --- a/iPhone Photos app/Info.plist +++ b/iPhone Photos app/App/Info.plist @@ -15,8 +15,6 @@ Default Configuration UISceneDelegateClassName $(PRODUCT_MODULE_NAME).SceneDelegate - UISceneStoryboardFile - Main diff --git a/iPhone Photos app/App/SceneDelegate.swift b/iPhone Photos app/App/SceneDelegate.swift new file mode 100644 index 0000000..58e170e --- /dev/null +++ b/iPhone Photos app/App/SceneDelegate.swift @@ -0,0 +1,22 @@ +// +// SceneDelegate.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 14.03.2023. +// + +import UIKit + +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 window = UIWindow(windowScene: windowScene) + window.rootViewController = TabBarController() + window.makeKeyAndVisible() + self.window = window + } +} + diff --git a/iPhone Photos app/Base.lproj/LaunchScreen.storyboard b/iPhone Photos app/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index 865e932..0000000 --- a/iPhone Photos app/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iPhone Photos app/Base.lproj/Main.storyboard b/iPhone Photos app/Base.lproj/Main.storyboard deleted file mode 100644 index 25a7638..0000000 --- a/iPhone Photos app/Base.lproj/Main.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iPhone Photos app/ForYouVC/ForYouViewController.swift b/iPhone Photos app/ForYouVC/ForYouViewController.swift new file mode 100644 index 0000000..be8f823 --- /dev/null +++ b/iPhone Photos app/ForYouVC/ForYouViewController.swift @@ -0,0 +1,22 @@ +// +// ForYouViewController.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 14.03.2023. +// + +import UIKit + +class ForYouViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .white + title = "For You" + navigationController?.navigationBar.prefersLargeTitles = true + navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(libraryNCleftButtonTapped)) + navigationItem.leftBarButtonItem?.tintColor = .black + } + + @objc func libraryNCleftButtonTapped() { } +} diff --git a/iPhone Photos app/LibraryVC/LibraryViewController.swift b/iPhone Photos app/LibraryVC/LibraryViewController.swift new file mode 100644 index 0000000..b7aebef --- /dev/null +++ b/iPhone Photos app/LibraryVC/LibraryViewController.swift @@ -0,0 +1,63 @@ +// +// LibraryViewController.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 14.03.2023. +// + +import UIKit +import SnapKit + +class LibraryViewController: UIViewController { + + private lazy var collectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell") + collectionView.delegate = self + collectionView.dataSource = self + return collectionView + }() + + override func viewDidLoad() { + super.viewDidLoad() + setupController() + setupViews() + setupConstraints() + } + + private func setupController() { + view.backgroundColor = .white + title = "Library" + navigationController?.navigationBar.prefersLargeTitles = true + navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(libraryNCleftButtonTapped)) + navigationItem.leftBarButtonItem?.tintColor = .black + } + + private func setupViews() { + view.addSubview(collectionView) + } + + private func setupConstraints() { + collectionView.snp.makeConstraints { + $0.left.top.right.bottom.equalToSuperview() + } + } + + @objc func libraryNCleftButtonTapped() { } +} + +extension LibraryViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 10 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let item = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) + return item + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: view.frame.width/2, height: view.frame.height/2) + } +} diff --git a/iPhone Photos app/Models.swift b/iPhone Photos app/Models.swift new file mode 100644 index 0000000..1203c74 --- /dev/null +++ b/iPhone Photos app/Models.swift @@ -0,0 +1,51 @@ +// +// Model.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 15.03.2023. +// + +import UIKit + +struct AlbumModel { + var image: String + var title: String + var quantity: String +} + +extension AlbumModel { + static let modelsArray = [ + [AlbumModel(image: "thanos", title: "Недавние", quantity: "100"), + AlbumModel(image: "thanos", title: "Whatsapp", quantity: "50"), + AlbumModel(image: "thanos", title: "Избранное", quantity: "30"), + AlbumModel(image: "thanos", title: "Media", quantity: "30"), + AlbumModel(image: "thanos", title: "Telegram", quantity: "30"), + AlbumModel(image: "thanos", title: "Chrome", quantity: "30"), + AlbumModel(image: "thanos", title: "Firefox", quantity: "30"), + AlbumModel(image: "thanos", title: "Family", quantity: "30")], + [AlbumModel(image: "thanos", title: "Недавние", quantity: "100"), + AlbumModel(image: "thanos", title: "Whatsapp", quantity: "50"), + AlbumModel(image: "thanos", title: "Избранное", quantity: "30"), + AlbumModel(image: "thanos", title: "Media", quantity: "30"), + AlbumModel(image: "thanos", title: "Telegram", quantity: "30"), + AlbumModel(image: "thanos", title: "Chrome", quantity: "30"), + AlbumModel(image: "thanos", title: "Firefox", quantity: "30"), + AlbumModel(image: "thanos", title: "Family", quantity: "30")], + [AlbumModel(image: "house", title: "Недавние", quantity: "100"), + AlbumModel(image: "house", title: "Whatsapp", quantity: "50"), + AlbumModel(image: "house", title: "Избранное", quantity: "30"), + AlbumModel(image: "house", title: "Media", quantity: "30"), + AlbumModel(image: "house", title: "Telegram", quantity: "30"), + AlbumModel(image: "house", title: "Chrome", quantity: "30"), + AlbumModel(image: "house", title: "Firefox", quantity: "30"), + AlbumModel(image: "house", title: "Family", quantity: "30")], + [AlbumModel(image: "house", title: "Недавние", quantity: "100"), + AlbumModel(image: "house", title: "Whatsapp", quantity: "50"), + AlbumModel(image: "house", title: "Избранное", quantity: "30"), + AlbumModel(image: "house", title: "Media", quantity: "30"), + AlbumModel(image: "house", title: "Telegram", quantity: "30"), + AlbumModel(image: "house", title: "Chrome", quantity: "30"), + AlbumModel(image: "house", title: "Firefox", quantity: "30"), + AlbumModel(image: "house", title: "Family", quantity: "30")] + ] +} diff --git a/iPhone Photos app/SceneDelegate.swift b/iPhone Photos app/SceneDelegate.swift deleted file mode 100644 index f53b5da..0000000 --- a/iPhone Photos app/SceneDelegate.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// SceneDelegate.swift -// iPhone Photos app -// -// Created by Adlet Zhantassov on 14.03.2023. -// - -import UIKit - -class SceneDelegate: UIResponder, UIWindowSceneDelegate { - - var window: UIWindow? - - - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. - // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. - // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). - guard let _ = (scene as? UIWindowScene) else { return } - } - - func sceneDidDisconnect(_ scene: UIScene) { - // Called as the scene is being released by the system. - // This occurs shortly after the scene enters the background, or when its session is discarded. - // Release any resources associated with this scene that can be re-created the next time the scene connects. - // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). - } - - func sceneDidBecomeActive(_ scene: UIScene) { - // Called when the scene has moved from an inactive state to an active state. - // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. - } - - func sceneWillResignActive(_ scene: UIScene) { - // Called when the scene will move from an active state to an inactive state. - // This may occur due to temporary interruptions (ex. an incoming phone call). - } - - func sceneWillEnterForeground(_ scene: UIScene) { - // Called as the scene transitions from the background to the foreground. - // Use this method to undo the changes made on entering the background. - } - - func sceneDidEnterBackground(_ scene: UIScene) { - // Called as the scene transitions from the foreground to the background. - // Use this method to save data, release shared resources, and store enough scene-specific state information - // to restore the scene back to its current state. - } - - -} - diff --git a/iPhone Photos app/SearchVC/SearchViewController.swift b/iPhone Photos app/SearchVC/SearchViewController.swift new file mode 100644 index 0000000..16efa18 --- /dev/null +++ b/iPhone Photos app/SearchVC/SearchViewController.swift @@ -0,0 +1,22 @@ +// +// SearchViewController.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 14.03.2023. +// + +import UIKit + +class SearchViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .white + title = "Search" + navigationController?.navigationBar.prefersLargeTitles = true + navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(libraryNCleftButtonTapped)) + navigationItem.leftBarButtonItem?.tintColor = .black + } + + @objc func libraryNCleftButtonTapped() { } +} diff --git a/iPhone Photos app/TabBarController.swift b/iPhone Photos app/TabBarController.swift new file mode 100644 index 0000000..77bc32b --- /dev/null +++ b/iPhone Photos app/TabBarController.swift @@ -0,0 +1,49 @@ +// +// TabBarController.swift +// iPhone Photos app +// +// Created by Adlet Zhantassov on 14.03.2023. +// + +import UIKit + +class TabBarController: UITabBarController { + + override func viewDidLoad() { + super.viewDidLoad() + + setupTabBarController() + setupTabBarViewControllers() + } + + func setupTabBarController() { + tabBar.tintColor = .black + tabBar.backgroundColor = .systemGray5 + } + + func setupTabBarViewControllers() { + let libraryVC = LibraryViewController() + let libraryIcon = UITabBarItem(title: "Library", image: UIImage(systemName: "photo.artframe"), selectedImage: UIImage(systemName: "photo.artframe")) + libraryVC.tabBarItem = libraryIcon + + let foryouVC = ForYouViewController() + let foryouIcon = UITabBarItem(title: "For You", image: UIImage(systemName: "lock.doc"), selectedImage: UIImage(systemName: "lock.doc.fill")) + foryouVC.tabBarItem = foryouIcon + + let albumVC = AlbumsViewController() + let albumIcon = UITabBarItem(title: "Album", image: UIImage(systemName: "creditcard"), selectedImage: UIImage(systemName: "creditcard.fill")) + albumVC.tabBarItem = albumIcon + + let searchVC = SearchViewController() + let searchIcon = UITabBarItem(title: "Search", image: UIImage(systemName: "magnifyingglass"), selectedImage: UIImage(systemName: "magnifyingglass")) + searchVC.tabBarItem = searchIcon + + let libraryNC = UINavigationController(rootViewController: libraryVC) + let foryouNC = UINavigationController(rootViewController: foryouVC) + let albumNC = UINavigationController(rootViewController: albumVC) + let searchNC = UINavigationController(rootViewController: searchVC) + + let controllers = [libraryNC,foryouNC,albumNC,searchNC] + self.setViewControllers(controllers, animated: true) + } +} diff --git a/iPhone Photos app/ViewController.swift b/iPhone Photos app/ViewController.swift deleted file mode 100644 index 9b88bd6..0000000 --- a/iPhone Photos app/ViewController.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ViewController.swift -// iPhone Photos app -// -// Created by Adlet Zhantassov on 14.03.2023. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - -} -