Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Examples/iOS Example/Sources/HeaderFooterSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import UIKit

class HeaderFooterSection: UITableViewHeaderFooterView {

private let numberOflinesCornerRadius = 10

lazy var titleLabel: UILabel = {
let label = UILabel()

label.text = " "
label.isSkeletonable = true
label.linesCornerRadius = 10
label.linesCornerRadius = numberOflinesCornerRadius

return label
}()
Expand Down
17 changes: 12 additions & 5 deletions Examples/iOS Example/Sources/UITextViewByCodeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import UIKit
import SkeletonView

class UITextViewByCodeViewController: UIViewController {

private let numberOflinesCornerRadius = 10
private let topAnchorConstraintConst: CGFloat = 10
private let leftAnchorConstraintConst: CGFloat = 10
private let rightAnchorConstraintConst: CGFloat = -10
private let heightAnchorConstraintConst: CGFloat = 100

lazy var textView: UITextView = {
let tv = UITextView()

tv.text = " "
tv.linesCornerRadius = 10
tv.linesCornerRadius = numberOflinesCornerRadius
tv.isSkeletonable = true
tv.translatesAutoresizingMaskIntoConstraints = false

Expand All @@ -32,10 +39,10 @@ class UITextViewByCodeViewController: UIViewController {
}

func setupElementsConstraints() {
textView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 10).isActive = true
textView.leftAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leftAnchor, constant: 10).isActive = true
textView.rightAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.rightAnchor, constant: -10).isActive = true
textView.heightAnchor.constraint(equalToConstant: 100).isActive = true
textView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: topAnchorConstraintConst).isActive = true
textView.leftAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leftAnchor, constant: leftAnchorConstraintConst).isActive = true
textView.rightAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.rightAnchor, constant: rightAnchorConstraintConst).isActive = true
textView.heightAnchor.constraint(equalToConstant: heightAnchorConstraintConst).isActive = true
}

func showSkeletonForElements() {
Expand Down
45 changes: 32 additions & 13 deletions Examples/iOS Example/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,61 @@ import UIKit
import SkeletonView

class ViewController: UIViewController {

// MARK: - Constants

private let estimatedRowHeight = 120.0
private let estimatedSectionFooterHeight = 20.0
private let estimatedSectionHeaderHeight = 20.0

struct AccessibilityIdentifier {
static let tableViewHeaderIdentifier = "HeaderIdentifier"
static let tableViewFooterIdentifier = "FooterIdentifier"
}

// MARK: - IBOutlet

@IBOutlet weak var tableview: UITableView! {
didSet {
tableview.rowHeight = UITableView.automaticDimension
tableview.sectionHeaderHeight = UITableView.automaticDimension
tableview.sectionFooterHeight = UITableView.automaticDimension
tableview.estimatedRowHeight = 120.0
tableview.estimatedSectionFooterHeight = 20.0
tableview.estimatedSectionHeaderHeight = 20.0
tableview.register(HeaderFooterSection.self, forHeaderFooterViewReuseIdentifier: "HeaderIdentifier")
tableview.register(HeaderFooterSection.self, forHeaderFooterViewReuseIdentifier: "FooterIdentifier")
tableview.estimatedRowHeight = self.estimatedRowHeight
tableview.estimatedSectionFooterHeight = self.estimatedSectionFooterHeight
tableview.estimatedSectionHeaderHeight = estimatedSectionHeaderHeight
tableview.register(HeaderFooterSection.self, forHeaderFooterViewReuseIdentifier: AccessibilityIdentifier.tableViewHeaderIdentifier)
tableview.register(HeaderFooterSection.self, forHeaderFooterViewReuseIdentifier: AccessibilityIdentifier.tableViewFooterIdentifier)
}
}

@IBOutlet weak var avatarImage: UIImageView! {
@IBOutlet private weak var avatarImage: UIImageView! {
didSet {
avatarImage.layer.cornerRadius = avatarImage.frame.width/2
avatarImage.layer.masksToBounds = true
}
}
}

@IBOutlet weak var colorSelectedView: UIView! {
@IBOutlet private weak var colorSelectedView: UIView! {
didSet {
colorSelectedView.layer.cornerRadius = 5
colorSelectedView.layer.masksToBounds = true
colorSelectedView.backgroundColor = SkeletonAppearance.default.tintColor
}
}

@IBOutlet weak var switchAnimated: UISwitch!
@IBOutlet weak var skeletonTypeSelector: UISegmentedControl!
@IBOutlet weak var showOrHideSkeletonButton: UIButton!
@IBOutlet weak var transitionDurationLabel: UILabel!
@IBOutlet weak var transitionDurationStepper: UIStepper!
@IBOutlet private weak var switchAnimated: UISwitch!
@IBOutlet private weak var skeletonTypeSelector: UISegmentedControl!
@IBOutlet private weak var showOrHideSkeletonButton: UIButton!
@IBOutlet private weak var transitionDurationLabel: UILabel!
@IBOutlet private weak var transitionDurationStepper: UIStepper!

var type: SkeletonType {
return skeletonTypeSelector.selectedSegmentIndex == 0 ? .solid : .gradient
}


// MARK: - Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
tableview.isSkeletonable = true
Expand Down Expand Up @@ -155,6 +172,8 @@ class ViewController: UIViewController {
}
}

// MARK: - Extensions

extension ViewController: UIPickerViewDelegate, UIPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
Expand Down