mastodon-ios/Mastodon/Scene/Onboarding/Share/OnboardingViewControllerApp...

60 lines
2.3 KiB
Swift
Raw Normal View History

2021-02-25 08:39:48 +01:00
//
// OnboardingViewControllerAppearance.swift
// Mastodon
//
// Created by sxiaojian on 2021/2/25.
//
import UIKit
protocol OnboardingViewControllerAppearance: UIViewController {
static var viewBottomPaddingHeight: CGFloat { get }
2021-02-25 08:39:48 +01:00
func setupOnboardingAppearance()
func setupNavigationBarAppearance()
2021-02-25 08:39:48 +01:00
}
extension OnboardingViewControllerAppearance {
static var actionButtonHeight: CGFloat { return 46 }
2021-02-26 11:27:47 +01:00
static var actionButtonMargin: CGFloat { return 12 }
static var viewBottomPaddingHeight: CGFloat { return 11 }
2021-02-25 08:39:48 +01:00
func setupOnboardingAppearance() {
2021-04-25 09:44:38 +02:00
view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
2021-02-25 08:39:48 +01:00
setupNavigationBarAppearance()
let backItem = UIBarButtonItem()
backItem.title = L10n.Common.Controls.Actions.back
navigationItem.backBarButtonItem = backItem
}
func setupNavigationBarAppearance() {
// use TransparentBackground so view push / dismiss will be more visual nature
// please add opaque background for status bar manually if needs
2021-02-25 08:39:48 +01:00
let barAppearance = UINavigationBarAppearance()
barAppearance.configureWithTransparentBackground()
navigationController?.navigationBar.standardAppearance = barAppearance
navigationController?.navigationBar.compactAppearance = barAppearance
navigationController?.navigationBar.scrollEdgeAppearance = barAppearance
}
func setupNavigationBarBackgroundView() {
let navigationBarBackgroundView: UIView = {
let view = UIView()
2021-04-25 09:44:38 +02:00
view.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
return view
}()
2021-02-25 08:39:48 +01:00
navigationBarBackgroundView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(navigationBarBackgroundView)
NSLayoutConstraint.activate([
navigationBarBackgroundView.topAnchor.constraint(equalTo: view.topAnchor),
navigationBarBackgroundView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
navigationBarBackgroundView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
navigationBarBackgroundView.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor),
])
2021-02-25 08:39:48 +01:00
}
2021-02-25 08:39:48 +01:00
}