mirror of https://github.com/oxen-io/session-ios
Sketch out the onboarding splash view.
parent
9fb08c1171
commit
54c8c1f352
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "Screen Shot 2019-02-12 at 2.22.35 PM.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public class OnboardingBaseViewController: OWSViewController {
|
||||||
|
// Unlike a delegate, we can and should retain a strong reference to the OnboardingController.
|
||||||
|
let onboardingController: OnboardingController
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public init(onboardingController: OnboardingController) {
|
||||||
|
self.onboardingController = onboardingController
|
||||||
|
|
||||||
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, unavailable, message: "use other init() instead.")
|
||||||
|
required public init?(coder aDecoder: NSCoder) {
|
||||||
|
notImplemented()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: -
|
||||||
|
|
||||||
|
func titleLabel(text: String) -> UILabel {
|
||||||
|
let titleLabel = UILabel()
|
||||||
|
titleLabel.text = text
|
||||||
|
titleLabel.textColor = Theme.primaryColor
|
||||||
|
titleLabel.font = UIFont.ows_dynamicTypeTitle2.ows_mediumWeight()
|
||||||
|
titleLabel.numberOfLines = 0
|
||||||
|
titleLabel.lineBreakMode = .byWordWrapping
|
||||||
|
titleLabel.textAlignment = .center
|
||||||
|
return titleLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
func explanationLabel(explanationText: String, linkText: String, selector: Selector) -> UILabel {
|
||||||
|
let explanationText = NSAttributedString(string: explanationText)
|
||||||
|
.rtlSafeAppend(NSAttributedString(string: " "))
|
||||||
|
.rtlSafeAppend(linkText,
|
||||||
|
attributes: [
|
||||||
|
NSAttributedStringKey.foregroundColor: UIColor.ows_materialBlue
|
||||||
|
])
|
||||||
|
let explanationLabel = UILabel()
|
||||||
|
explanationLabel.textColor = Theme.secondaryColor
|
||||||
|
explanationLabel.font = UIFont.ows_dynamicTypeCaption1
|
||||||
|
explanationLabel.attributedText = explanationText
|
||||||
|
explanationLabel.numberOfLines = 0
|
||||||
|
explanationLabel.textAlignment = .center
|
||||||
|
explanationLabel.lineBreakMode = .byWordWrapping
|
||||||
|
explanationLabel.isUserInteractionEnabled = true
|
||||||
|
explanationLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: selector))
|
||||||
|
return explanationLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
func button(title: String, selector: Selector) -> UIView {
|
||||||
|
// TODO: Make sure this all fits if dynamic font sizes are maxed out.
|
||||||
|
let buttonHeight: CGFloat = 48
|
||||||
|
let button = OWSFlatButton.button(title: title,
|
||||||
|
font: OWSFlatButton.fontForHeight(buttonHeight),
|
||||||
|
titleColor: .white,
|
||||||
|
backgroundColor: .ows_materialBlue,
|
||||||
|
target: self,
|
||||||
|
selector: selector)
|
||||||
|
button.autoSetDimension(.height, toSize: buttonHeight)
|
||||||
|
return button
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Orientation
|
||||||
|
|
||||||
|
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||||
|
return .portrait
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public class OnboardingSplashViewController: OnboardingBaseViewController {
|
||||||
|
|
||||||
|
override public func loadView() {
|
||||||
|
super.loadView()
|
||||||
|
|
||||||
|
view.backgroundColor = Theme.backgroundColor
|
||||||
|
view.layoutMargins = .zero
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// navigationItem.title = NSLocalizedString("SETTINGS_BACKUP", comment: "Label for the backup view in app settings.")
|
||||||
|
|
||||||
|
let heroImage = UIImage(named: "onboarding_splash_hero")
|
||||||
|
let heroImageView = UIImageView(image: heroImage)
|
||||||
|
heroImageView.contentMode = .scaleAspectFit
|
||||||
|
heroImageView.layer.minificationFilter = kCAFilterTrilinear
|
||||||
|
heroImageView.layer.magnificationFilter = kCAFilterTrilinear
|
||||||
|
heroImageView.setCompressionResistanceLow()
|
||||||
|
heroImageView.setContentHuggingVerticalLow()
|
||||||
|
|
||||||
|
let titleLabel = self.titleLabel(text: NSLocalizedString("ONBOARDING_SPLASH_TITLE", comment: "Title of the 'onboarding splash' view."))
|
||||||
|
view.addSubview(titleLabel)
|
||||||
|
titleLabel.autoPinWidthToSuperviewMargins()
|
||||||
|
titleLabel.autoPinEdge(toSuperviewMargin: .top)
|
||||||
|
|
||||||
|
// TODO: Finalize copy.
|
||||||
|
let explanationLabel = self.explanationLabel(explanationText: NSLocalizedString("ONBOARDING_SPLASH_EXPLANATION",
|
||||||
|
comment: "Explanation in the 'onboarding splash' view."),
|
||||||
|
linkText: NSLocalizedString("ONBOARDING_SPLASH_TERM_AND_PRIVACY_POLICY",
|
||||||
|
comment: "Link to the 'terms and privacy policy' in the 'onboarding splash' view."),
|
||||||
|
selector: #selector(explanationLabelTapped))
|
||||||
|
|
||||||
|
// TODO: Make sure this all fits if dynamic font sizes are maxed out.
|
||||||
|
let continueButton = self.button(title: NSLocalizedString("BUTTON_CONTINUE",
|
||||||
|
comment: "Label for 'continue' button."),
|
||||||
|
selector: #selector(continuePressed))
|
||||||
|
view.addSubview(continueButton)
|
||||||
|
|
||||||
|
let stackView = UIStackView(arrangedSubviews: [
|
||||||
|
heroImageView,
|
||||||
|
UIView.spacer(withHeight: 22),
|
||||||
|
titleLabel,
|
||||||
|
UIView.spacer(withHeight: 56),
|
||||||
|
explanationLabel,
|
||||||
|
UIView.spacer(withHeight: 40),
|
||||||
|
continueButton
|
||||||
|
])
|
||||||
|
stackView.axis = .vertical
|
||||||
|
stackView.alignment = .fill
|
||||||
|
stackView.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32)
|
||||||
|
stackView.isLayoutMarginsRelativeArrangement = true
|
||||||
|
view.addSubview(stackView)
|
||||||
|
stackView.autoPinWidthToSuperviewMargins()
|
||||||
|
stackView.autoPin(toTopLayoutGuideOf: self, withInset: 0)
|
||||||
|
stackView.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func viewWillAppear(_ animated: Bool) {
|
||||||
|
super.viewWillAppear(animated)
|
||||||
|
|
||||||
|
self.navigationController?.isNavigationBarHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
|
self.navigationController?.isNavigationBarHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Events
|
||||||
|
|
||||||
|
@objc func explanationLabelTapped(sender: UIGestureRecognizer) {
|
||||||
|
guard sender.state == .recognized else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func continuePressed() {
|
||||||
|
Logger.info("")
|
||||||
|
|
||||||
|
onboardingController.onboardingSplashDidComplete(viewController: self)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue