-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create tabbar, and add some view on HomeViewController, create custom…
… UITableViewCell and tweaked it a little)
- Loading branch information
1 parent
09eb062
commit c7d9731
Showing
16 changed files
with
369 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
Twitgram/ViewController.swift → ...s/Core/DirectMessagesViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
// | ||
} |
Oops, something went wrong.