Skip to content

Commit

Permalink
create tabbar, and add some view on HomeViewController, create custom…
Browse files Browse the repository at this point in the history
… UITableViewCell and tweaked it a little)
  • Loading branch information
Ernazar02A committed Oct 2, 2023
1 parent 09eb062 commit c7d9731
Show file tree
Hide file tree
Showing 16 changed files with 369 additions and 55 deletions.
116 changes: 95 additions & 21 deletions Twitgram.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,31 @@
/* Begin PBXBuildFile section */
52A7DA112ACAED4600F258CE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA102ACAED4600F258CE /* AppDelegate.swift */; };
52A7DA132ACAED4600F258CE /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA122ACAED4600F258CE /* SceneDelegate.swift */; };
52A7DA152ACAED4600F258CE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA142ACAED4600F258CE /* ViewController.swift */; };
52A7DA182ACAED4600F258CE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52A7DA162ACAED4600F258CE /* Main.storyboard */; };
52A7DA152ACAED4600F258CE /* MainTabbarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA142ACAED4600F258CE /* MainTabbarViewController.swift */; };
52A7DA1A2ACAED4800F258CE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 52A7DA192ACAED4800F258CE /* Assets.xcassets */; };
52A7DA1D2ACAED4800F258CE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52A7DA1B2ACAED4800F258CE /* LaunchScreen.storyboard */; };
52A7DA292ACAEF4700F258CE /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA282ACAEF4700F258CE /* HomeViewController.swift */; };
52A7DA2B2ACAEF5100F258CE /* SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA2A2ACAEF5100F258CE /* SearchViewController.swift */; };
52A7DA2D2ACAEF6C00F258CE /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA2C2ACAEF6C00F258CE /* NotificationsViewController.swift */; };
52A7DA2F2ACAEF9B00F258CE /* DirectMessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA2E2ACAEF9B00F258CE /* DirectMessagesViewController.swift */; };
52A7DA332ACAF49700F258CE /* TweetTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA322ACAF49700F258CE /* TweetTableViewCell.swift */; };
52A7DA372ACAF50A00F258CE /* extention + UITableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A7DA362ACAF50A00F258CE /* extention + UITableViewCell.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
52A7DA0D2ACAED4600F258CE /* Twitgram.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Twitgram.app; sourceTree = BUILT_PRODUCTS_DIR; };
52A7DA102ACAED4600F258CE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
52A7DA122ACAED4600F258CE /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
52A7DA142ACAED4600F258CE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
52A7DA172ACAED4600F258CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
52A7DA142ACAED4600F258CE /* MainTabbarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabbarViewController.swift; sourceTree = "<group>"; };
52A7DA192ACAED4800F258CE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
52A7DA1C2ACAED4800F258CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
52A7DA1E2ACAED4800F258CE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
52A7DA282ACAEF4700F258CE /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = "<group>"; };
52A7DA2A2ACAEF5100F258CE /* SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = "<group>"; };
52A7DA2C2ACAEF6C00F258CE /* NotificationsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsViewController.swift; sourceTree = "<group>"; };
52A7DA2E2ACAEF9B00F258CE /* DirectMessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectMessagesViewController.swift; sourceTree = "<group>"; };
52A7DA322ACAF49700F258CE /* TweetTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TweetTableViewCell.swift; sourceTree = "<group>"; };
52A7DA362ACAF50A00F258CE /* extention + UITableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "extention + UITableViewCell.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -54,17 +64,86 @@
sourceTree = "<group>";
};
52A7DA0F2ACAED4600F258CE /* Twitgram */ = {
isa = PBXGroup;
children = (
52A7DA342ACAF4CE00F258CE /* Extentions */,
52A7DA242ACAED7C00F258CE /* App */,
52A7DA262ACAEF0100F258CE /* Controllers */,
52A7DA302ACAF45400F258CE /* Component */,
52A7DA252ACAED8400F258CE /* Resourse */,
);
path = Twitgram;
sourceTree = "<group>";
};
52A7DA242ACAED7C00F258CE /* App */ = {
isa = PBXGroup;
children = (
52A7DA102ACAED4600F258CE /* AppDelegate.swift */,
52A7DA122ACAED4600F258CE /* SceneDelegate.swift */,
52A7DA142ACAED4600F258CE /* ViewController.swift */,
52A7DA162ACAED4600F258CE /* Main.storyboard */,
);
path = App;
sourceTree = "<group>";
};
52A7DA252ACAED8400F258CE /* Resourse */ = {
isa = PBXGroup;
children = (
52A7DA192ACAED4800F258CE /* Assets.xcassets */,
52A7DA1B2ACAED4800F258CE /* LaunchScreen.storyboard */,
52A7DA1E2ACAED4800F258CE /* Info.plist */,
);
path = Twitgram;
path = Resourse;
sourceTree = "<group>";
};
52A7DA262ACAEF0100F258CE /* Controllers */ = {
isa = PBXGroup;
children = (
52A7DA272ACAEF2100F258CE /* Core */,
);
path = Controllers;
sourceTree = "<group>";
};
52A7DA272ACAEF2100F258CE /* Core */ = {
isa = PBXGroup;
children = (
52A7DA142ACAED4600F258CE /* MainTabbarViewController.swift */,
52A7DA282ACAEF4700F258CE /* HomeViewController.swift */,
52A7DA2A2ACAEF5100F258CE /* SearchViewController.swift */,
52A7DA2C2ACAEF6C00F258CE /* NotificationsViewController.swift */,
52A7DA2E2ACAEF9B00F258CE /* DirectMessagesViewController.swift */,
);
path = Core;
sourceTree = "<group>";
};
52A7DA302ACAF45400F258CE /* Component */ = {
isa = PBXGroup;
children = (
52A7DA312ACAF47300F258CE /* Cells */,
);
path = Component;
sourceTree = "<group>";
};
52A7DA312ACAF47300F258CE /* Cells */ = {
isa = PBXGroup;
children = (
52A7DA322ACAF49700F258CE /* TweetTableViewCell.swift */,
);
path = Cells;
sourceTree = "<group>";
};
52A7DA342ACAF4CE00F258CE /* Extentions */ = {
isa = PBXGroup;
children = (
52A7DA352ACAF4E400F258CE /* UITableViewCell */,
);
path = Extentions;
sourceTree = "<group>";
};
52A7DA352ACAF4E400F258CE /* UITableViewCell */ = {
isa = PBXGroup;
children = (
52A7DA362ACAF50A00F258CE /* extention + UITableViewCell.swift */,
);
path = UITableViewCell;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -127,7 +206,6 @@
files = (
52A7DA1D2ACAED4800F258CE /* LaunchScreen.storyboard in Resources */,
52A7DA1A2ACAED4800F258CE /* Assets.xcassets in Resources */,
52A7DA182ACAED4600F258CE /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -138,23 +216,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
52A7DA152ACAED4600F258CE /* ViewController.swift in Sources */,
52A7DA2B2ACAEF5100F258CE /* SearchViewController.swift in Sources */,
52A7DA152ACAED4600F258CE /* MainTabbarViewController.swift in Sources */,
52A7DA2D2ACAEF6C00F258CE /* NotificationsViewController.swift in Sources */,
52A7DA372ACAF50A00F258CE /* extention + UITableViewCell.swift in Sources */,
52A7DA112ACAED4600F258CE /* AppDelegate.swift in Sources */,
52A7DA132ACAED4600F258CE /* SceneDelegate.swift in Sources */,
52A7DA292ACAEF4700F258CE /* HomeViewController.swift in Sources */,
52A7DA2F2ACAEF9B00F258CE /* DirectMessagesViewController.swift in Sources */,
52A7DA332ACAF49700F258CE /* TweetTableViewCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
52A7DA162ACAED4600F258CE /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
52A7DA172ACAED4600F258CE /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
52A7DA1B2ACAED4800F258CE /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down Expand Up @@ -289,10 +365,9 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = F7W7R66652;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Twitgram/Info.plist;
INFOPLIST_FILE = Twitgram/Resourse/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 = (
Expand All @@ -317,10 +392,9 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = F7W7R66652;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Twitgram/Info.plist;
INFOPLIST_FILE = Twitgram/Resourse/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 = (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {


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 }
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = MainTabbarViewController()
window?.makeKeyAndVisible()
}

func sceneDidDisconnect(_ scene: UIScene) {
Expand Down
24 changes: 0 additions & 24 deletions Twitgram/Base.lproj/Main.storyboard

This file was deleted.

85 changes: 85 additions & 0 deletions Twitgram/Component/Cells/TweetTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// TweetTableViewCell.swift
// Twitgram
//
// Created by Ernazar on 2/10/23.
//

import UIKit

class TweetTableViewCell: UITableViewCell {

private lazy var avatarImageView: UIImageView = {
let view = UIImageView()
view.contentMode = .scaleAspectFill
view.layer.cornerRadius = 25
view.clipsToBounds = true
view.backgroundColor = .red
view.image = UIImage(systemName: "person")
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
private lazy var displayNameLabel: UILabel = {
let view = UILabel()
view.text = "Ernazar"
view.font = .systemFont(ofSize: 18, weight: .bold)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
private lazy var userNameLabel: UILabel = {
let view = UILabel()
view.text = "@Aibekov"
view.textColor = .secondaryLabel
view.font = .systemFont(ofSize: 16, weight: .regular)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
private lazy var tweetTextContentLabel: UILabel = {
let view = UILabel()
view.text = "This is my Mockup tweet. it is going to take multiple lines. I believe some more text is enough but let add some more anyway.."
view.numberOfLines = 0
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}

private func setup() {
setupView()
setupConstraints()
}

private func setupView() {
contentView.addSubview(avatarImageView)
contentView.addSubview(displayNameLabel)
contentView.addSubview(userNameLabel)
contentView.addSubview(tweetTextContentLabel)
}

private func setupConstraints() {
NSLayoutConstraint.activate([
avatarImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
avatarImageView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 14),
avatarImageView.heightAnchor.constraint(equalToConstant: 50),
avatarImageView.widthAnchor.constraint(equalToConstant: 50),

displayNameLabel.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: 20),
displayNameLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),

userNameLabel.leadingAnchor.constraint(equalTo: displayNameLabel.trailingAnchor, constant: 10),
userNameLabel.centerYAnchor.constraint(equalTo: displayNameLabel.centerYAnchor),

tweetTextContentLabel.leadingAnchor.constraint(equalTo: displayNameLabel.leadingAnchor),
tweetTextContentLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15),
tweetTextContentLabel.topAnchor.constraint(equalTo: displayNameLabel.bottomAnchor, constant: 10),
tweetTextContentLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -15),
])
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
//
// ViewController.swift
// DirectMessagesViewController.swift
// Twitgram
//
// Created by Ernazar on 2/10/23.
//

import UIKit

class ViewController: UIViewController {
class DirectMessagesViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
}


}

55 changes: 55 additions & 0 deletions Twitgram/Controllers/Core/HomeViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// HomeViewController.swift
// Twitgram
//
// Created by Ernazar on 2/10/23.
//

import UIKit

class HomeViewController: UIViewController {

private lazy var timelineTableView: UITableView = {
let view = UITableView()
view.register(TweetTableViewCell.self, forCellReuseIdentifier: TweetTableViewCell.identifier)
view.dataSource = self
view.delegate = self
return view
}()

override func viewDidLoad() {
super.viewDidLoad()

setup()
}

private func setup() {
setupView()
}

private func setupView() {
view.addSubview(timelineTableView)
timelineTableView.frame = view.frame
}

}

//MARK: - UITableViewDataSource
extension HomeViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
10
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: TweetTableViewCell.identifier, for: indexPath) as? TweetTableViewCell else {
return UITableViewCell()
}

return cell
}
}

//MARK: - UITableViewDelegate
extension HomeViewController: UITableViewDelegate {
//
}
Loading

0 comments on commit c7d9731

Please sign in to comment.