-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
244 additions
and
65 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
26 changes: 0 additions & 26 deletions
26
AtomeMerchantDemo/AtomeMerchantDemo/Base.lproj/Main.storyboard
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
AtomeMerchantDemo/AtomeMerchantDemo/Home/HomeContentArchView.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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// HomeContentArchView.swift | ||
// AtomeMerchantDemo | ||
// | ||
// Created by boye on 2021/11/9. | ||
// Copyright © 2021 boye. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class HomeContentArchView: UIView { | ||
static let contentHeight: CGFloat = 600 | ||
|
||
private let archCoverView = UIImageView() | ||
private let centerView = UIView() | ||
private let centerViewHeight: CGFloat = 180 | ||
private let centerViewWidth: CGFloat = UIScreen.main.bounds.width - 30 | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
archCoverView.backgroundColor = UIColor.white | ||
archCoverView.layer.cornerRadius = 5 | ||
addSubview(archCoverView) | ||
archCoverView.snp.makeConstraints { (make) in | ||
make.leading.trailing.bottom.equalToSuperview() | ||
make.width.equalToSuperview() | ||
make.top.equalToSuperview().offset(73) | ||
make.height.equalTo(HomeContentArchView.contentHeight) | ||
} | ||
|
||
addSubview(centerView) | ||
centerView.layer.cornerRadius = 10 | ||
centerView.backgroundColor = UIColor.white | ||
|
||
let path = UIBezierPath() | ||
let shadowGap: CGFloat = 10 | ||
path.move(to: CGPoint(x: -3, y: 0)) | ||
path.addLine(to: CGPoint(x: -3, y: centerViewHeight - shadowGap)) | ||
path.addLine(to: CGPoint(x: 0, y: centerViewHeight - shadowGap)) | ||
path.addLine(to: CGPoint(x: -3, y: 0)) | ||
path.move(to: CGPoint(x: centerViewWidth, y: 0)) | ||
path.addLine(to: CGPoint(x: centerViewWidth, y: centerViewHeight - shadowGap)) | ||
path.addLine(to: CGPoint(x: centerViewWidth + 3, y: centerViewHeight - shadowGap)) | ||
path.addLine(to: CGPoint(x: centerViewWidth + 3, y: 0)) | ||
path.close() | ||
centerView.layer.shadowPath = path.cgPath | ||
centerView.layer.shadowColor = UIColor(red: 9.0 / 255.0, green: 152.0 / 255.0, blue: 255.0 / 255.0, alpha: 0.8).cgColor | ||
centerView.layer.shadowOpacity = 0.8 | ||
centerView.layer.shadowRadius = 10 | ||
centerView.layer.shadowOffset = CGSize(width: 3, height: 0) | ||
|
||
centerView.snp.makeConstraints { (make) in | ||
make.leading.equalTo(15) | ||
make.trailing.equalTo(-15) | ||
make.top.equalToSuperview() | ||
make.height.equalTo(centerViewHeight) | ||
} | ||
} | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
func addViews(_ contentView: UIView) { | ||
// just layout | ||
addSubview(contentView) | ||
contentView.snp.makeConstraints { (make) in | ||
make.leading.trailing.equalTo(centerView) | ||
make.top.equalTo(centerView) | ||
make.bottom.equalTo(archCoverView) | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
AtomeMerchantDemo/AtomeMerchantDemo/Home/HomeContentView.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// HomeContentView.swift | ||
// AtomeMerchantDemo | ||
// | ||
// Created by boye on 2021/11/9. | ||
// Copyright © 2021 boye. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class HomeContentView: UIView { | ||
var getStartCallback: (()->Void)? | ||
|
||
private let descLabel = UILabel() | ||
private let gettingStartButton = GradientButton(title: "Get start") | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setupUI() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupUI() { | ||
descLabel.textAlignment = .center | ||
descLabel.font = UIFont.boldSystemFont(ofSize: 15) | ||
descLabel.textColor = UIColor.darkGray | ||
descLabel.text = "Click the button below to start" | ||
addSubview(descLabel) | ||
descLabel.snp.makeConstraints { make in | ||
make.top.equalToSuperview().offset(50) | ||
make.leading.equalToSuperview().offset(15) | ||
make.trailing.equalToSuperview().offset(-15) | ||
} | ||
|
||
addSubview(gettingStartButton) | ||
gettingStartButton.layer.cornerRadius = GradientButton.buttonSize.height / 2 | ||
gettingStartButton.snp.makeConstraints { make in | ||
make.centerX.equalToSuperview() | ||
make.top.equalTo(descLabel.snp.bottom).offset(30) | ||
make.size.equalTo(GradientButton.buttonSize) | ||
} | ||
|
||
gettingStartButton.addTarget(self, action: #selector(getStartAction), for: .touchUpInside) | ||
} | ||
|
||
@objc private func getStartAction() { | ||
getStartCallback?() | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
AtomeMerchantDemo/AtomeMerchantDemo/Home/HomeViewController.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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// HomeViewController.swift | ||
// AtomeMerchantDemo | ||
// | ||
// Created by boye on 2021/11/8. | ||
// Copyright © 2021 boye. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import SnapKit | ||
|
||
class HomeViewController: UIViewController { | ||
private let backgroundImageView = UIImageView() | ||
private let bottomCoverView = UIView() | ||
private let logoImageView = UIImageView() | ||
private let scrollView = UIScrollView() | ||
private let contentView = UIView() | ||
private let coverView = HomeContentArchView() | ||
private let homeContentView = HomeContentView() | ||
|
||
override func viewWillAppear(_ animated: Bool) { | ||
super.viewWillAppear(animated) | ||
navigationController?.navigationBar.setBackgroundImage(UIImage.init(), for: .default) | ||
navigationController?.navigationBar.shadowImage = UIImage.init() | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupUI() | ||
setupAction() | ||
} | ||
|
||
private func setupUI() { | ||
backgroundImageView.backgroundColor = UIColor.canary | ||
view.addSubview(backgroundImageView) | ||
backgroundImageView.snp.makeConstraints { (make) in | ||
make.edges.equalToSuperview() | ||
} | ||
|
||
view.addSubview(bottomCoverView) | ||
bottomCoverView.backgroundColor = UIColor.white | ||
bottomCoverView.snp.makeConstraints { (make) in | ||
make.trailing.leading.bottom.equalToSuperview() | ||
make.height.equalTo(UIScreen.main.bounds.height / 2) | ||
} | ||
|
||
logoImageView.image = UIImage(named: "logoDark") | ||
view.addSubview(logoImageView) | ||
logoImageView.snp.makeConstraints { (make) in | ||
make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(38) | ||
make.leading.equalToSuperview().offset(15) | ||
make.width.equalTo(110) | ||
make.height.equalTo(21) | ||
} | ||
|
||
view.addSubview(scrollView) | ||
scrollView.showsVerticalScrollIndicator = false | ||
scrollView.showsHorizontalScrollIndicator = false | ||
scrollView.snp.makeConstraints { (make) in | ||
make.leading.trailing.bottom.equalToSuperview() | ||
make.top.equalTo(logoImageView.snp.bottom).offset(30) | ||
} | ||
|
||
scrollView.addSubview(contentView) | ||
contentView.snp.makeConstraints { (make) in | ||
make.leading.trailing.top.bottom.equalToSuperview() | ||
make.width.equalToSuperview() | ||
} | ||
|
||
contentView.addSubview(coverView) | ||
coverView.snp.makeConstraints { (make) in | ||
make.top.leading.trailing.bottom.equalToSuperview() | ||
make.width.equalToSuperview() | ||
make.height.equalTo(HomeContentArchView.contentHeight) | ||
} | ||
|
||
coverView.addViews(homeContentView) | ||
} | ||
|
||
private func setupAction() { | ||
homeContentView.getStartCallback = { [weak self] in | ||
guard let self = self else { return } | ||
let vc = ViewController() | ||
self.navigationController?.pushViewController(vc, animated: true) | ||
} | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
AtomeMerchantDemo/AtomeMerchantDemo/HomeViewController.swift
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
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
Oops, something went wrong.