Skip to content

Instantly share code, notes, and snippets.

@foxicode
foxicode / ContactList.swift
Created February 5, 2023 21:26
Contact List
import SnapKit
import UIKit
class ViewControllerLayout: Layout {
lazy var contactList: UITableView = {
let tableView = UITableView()
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.register(ContactCell.self, forCellReuseIdentifier: ContactCell.cellId)
return tableView
@foxicode
foxicode / ContactsAdapter.swift
Created February 5, 2023 21:25
Contacts adapter
import UIKit
class ContactsAdapter: NSObject, UITableViewDelegate, UITableViewDataSource {
var contacts = [Contact]()
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
contacts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@foxicode
foxicode / ContactCell.swift
Created February 5, 2023 21:21
Contact Cell
import SnapKit
import UIKit
class ContactCell: UITableViewCell {
static let cellId = "ContactCell"
private lazy var profilePicture = ProfilePictureView()
@HeaderStyle private var nameLabel
@ParagraphStyle private var emailLabel
@foxicode
foxicode / Contact.swift
Created February 5, 2023 21:17
Contact structure
import Foundation
struct Contact {
var id: Int
var name: String
var email: String
var profilePicture: URL?
}
@foxicode
foxicode / ProfileEdit.swift
Last active February 5, 2023 20:49
Profile edit screen sample
import SnapKit
import UIKit
class ViewControllerLayout: Layout {
lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView()
scrollView.showsHorizontalScrollIndicator = false
scrollView.showsVerticalScrollIndicator = false
scrollView.keyboardDismissMode = .onDrag
@foxicode
foxicode / CardView.swift
Created February 5, 2023 20:10
CardView component
import SnapKit
import UIKit
class CardView: UIView {
init(cornerRadius: CGFloat) {
super.init(frame: .zero)
layer.shadowColor = UIColor.darkGray.cgColor
layer.masksToBounds = false
layer.shadowOffset = CGSize(width: 0, height: 2)
@foxicode
foxicode / UnderlinedTextField.swift
Created February 5, 2023 20:08
Underlined text field component
import SnapKit
import UIKit
class UnderlinedTextField: UIView {
lazy var textField: UITextField = {
let textField = UITextField()
textField.backgroundColor = .clear
textField.borderStyle = .none
return textField
}()
@foxicode
foxicode / HorizontalLineView.swift
Created February 5, 2023 20:02
Horizontal line component
import SnapKit
import UIKit
class HorizontalLineView: UIView {
init(backgroundColor: UIColor, height: CGFloat) {
super.init(frame: .zero)
snp.makeConstraints {
$0.height.equalTo(height)
}
@foxicode
foxicode / ProfilePictureView.swift
Created February 5, 2023 19:49
ProfilePicture component
import Kingfisher
import SnapKit
import UIKit
class ProfilePictureView: UIView {
lazy var shadowView: UIView = {
let view = UIView(backgroundColor: .white, cornerRadius: 64)
view.layer.shadowColor = UIColor.darkGray.cgColor
view.layer.masksToBounds = false
view.layer.shadowOffset = CGSize(width: 0, height: 2)
@foxicode
foxicode / PropertyWrapperStylingSample.swift
Created February 5, 2023 18:57
Propperty wrapper styling usage
import SnapKit
import UIKit
class ViewControllerLayout: Layout {
@HeaderStyle private var headerLabel
@ParagraphStyle private var paragraphLabel
required init() {
super.init()