-
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.
- Loading branch information
grenos
committed
Apr 4, 2020
1 parent
a007ac0
commit f8ea07b
Showing
4 changed files
with
95 additions
and
0 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
Binary file modified
BIN
+1.26 KB
(100%)
...odeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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,87 @@ | ||
// | ||
// GFItemInfoView.swift | ||
// GHFollowers | ||
// | ||
// Created by Vasileios Gkreen on 04/04/2020. | ||
// Copyright © 2020 Vasileios Gkreen. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
enum itemInfoType { | ||
case repos, gists, following, followers | ||
} | ||
|
||
|
||
class GFItemInfoView: UIView { | ||
|
||
let symbolImageView = UIImageView() | ||
let titleLabel = GFTitleLabel(textAlignment: .left, fontSize: 14) | ||
let countLabel = GFTitleLabel(textAlignment: .center, fontSize: 14) | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
configure() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
|
||
|
||
private func configure() { | ||
addSubview(symbolImageView) | ||
addSubview(titleLabel) | ||
addSubview(countLabel) | ||
|
||
// ui setup for symbol | ||
symbolImageView.translatesAutoresizingMaskIntoConstraints = false | ||
symbolImageView.contentMode = .scaleAspectFill | ||
symbolImageView.tintColor = .label | ||
|
||
|
||
NSLayoutConstraint.activate([ | ||
// position symbol at top-left of view | ||
symbolImageView.topAnchor.constraint(equalTo: self.topAnchor), | ||
symbolImageView.leadingAnchor.constraint(equalTo: self.leadingAnchor), | ||
symbolImageView.heightAnchor.constraint(equalToConstant: 20), | ||
symbolImageView.widthAnchor.constraint(equalToConstant: 20), | ||
|
||
// center title label to the center of the symbol | ||
titleLabel.centerYAnchor.constraint(equalTo: symbolImageView.centerYAnchor), | ||
titleLabel.leadingAnchor.constraint(equalTo: symbolImageView.trailingAnchor, constant: 12), | ||
titleLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor), | ||
titleLabel.heightAnchor.constraint(equalToConstant: 18), | ||
|
||
// pin top of counter at bottom of symbol | ||
countLabel.topAnchor.constraint(equalTo: symbolImageView.bottomAnchor, constant: 4), | ||
countLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor), | ||
countLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor), | ||
countLabel.heightAnchor.constraint(equalToConstant: 18) | ||
]) | ||
} | ||
|
||
|
||
func set(itemInfoType: itemInfoType, withCount count: Int ) { | ||
|
||
switch itemInfoType { | ||
case .repos: | ||
symbolImageView.image = UIImage(systemName: SFSymbols.repos) | ||
titleLabel.text = "Public Repos" | ||
case .gists: | ||
symbolImageView.image = UIImage(systemName: SFSymbols.gists) | ||
titleLabel.text = "Public Gists" | ||
case .followers: | ||
symbolImageView.image = UIImage(systemName: SFSymbols.followers) | ||
titleLabel.text = "Followers" | ||
case .following: | ||
symbolImageView.image = UIImage(systemName: SFSymbols.following) | ||
titleLabel.text = "Following" | ||
} | ||
|
||
countLabel.text = String(count) | ||
} | ||
|
||
|
||
} |
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