Created
April 1, 2019 00:12
-
-
Save mavieth/c9305f14a72bcaa55b8d8aeb7ee6c431 to your computer and use it in GitHub Desktop.
Revisions
-
mavieth created this gist
Apr 1, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,110 @@ import UIKit import Material class ViewController: UIViewController { fileprivate var card: PresenterCard! /// Conent area. fileprivate var presenterView: UIImageView! fileprivate var contentView: UILabel! /// Bottom Bar views. fileprivate var bottomBar: Bar! fileprivate var dateFormatter: DateFormatter! fileprivate var dateLabel: UILabel! fileprivate var favoriteButton: IconButton! fileprivate var shareButton: IconButton! /// Toolbar views. fileprivate var toolbar: Toolbar! fileprivate var moreButton: IconButton! open override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = Color.grey.lighten5 preparePresenterView() prepareDateFormatter() prepareDateLabel() prepareFavoriteButton() prepareShareButton() prepareMoreButton() prepareToolbar() prepareContentView() prepareBottomBar() preparePresenterCard() } } extension ViewController { fileprivate func preparePresenterView() { presenterView = UIImageView() presenterView.image = UIImage(named: "pattern")?.resize(toWidth: view.frame.width) presenterView.contentMode = .scaleAspectFill } fileprivate func prepareDateFormatter() { dateFormatter = DateFormatter() dateFormatter.dateStyle = .medium dateFormatter.timeStyle = .none } fileprivate func prepareDateLabel() { dateLabel = UILabel() dateLabel.font = RobotoFont.regular(with: 12) dateLabel.textColor = Color.blueGrey.base dateLabel.textAlignment = .center dateLabel.text = dateFormatter.string(from: Date.distantFuture) } fileprivate func prepareFavoriteButton() { favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.red.base) } fileprivate func prepareShareButton() { shareButton = IconButton(image: Icon.cm.share, tintColor: Color.blueGrey.base) } fileprivate func prepareMoreButton() { moreButton = IconButton(image: Icon.cm.moreHorizontal, tintColor: Color.blueGrey.base) } fileprivate func prepareToolbar() { toolbar = Toolbar(rightViews: [moreButton]) toolbar.title = "Material" toolbar.titleLabel.textAlignment = .left toolbar.detail = "Build Beautiful Software" toolbar.detailLabel.textAlignment = .left toolbar.detailLabel.textColor = Color.blueGrey.base } fileprivate func prepareContentView() { contentView = UILabel() contentView.numberOfLines = 0 contentView.text = "Material is an animation and graphics framework that is used to create beautiful applications." contentView.font = RobotoFont.regular(with: 14) } fileprivate func prepareBottomBar() { bottomBar = Bar(leftViews: [favoriteButton], rightViews: [shareButton], centerViews: [dateLabel]) } fileprivate func preparePresenterCard() { card = PresenterCard() card.toolbar = toolbar card.toolbarEdgeInsetsPreset = .wideRectangle2 card.presenterView = presenterView card.contentView = contentView card.contentViewEdgeInsetsPreset = .square3 card.bottomBar = bottomBar card.bottomBarEdgeInsetsPreset = .wideRectangle2 view.layout(card).horizontally(left: 0, right: 0).center() } }