Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MBL-952] Design System Demo Page (Dark Mode) #1849

Merged
merged 25 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
085d2c6
add new Beta Tools row that navigates to a new SystemDesignViewContro…
scottkicks Aug 28, 2023
a0045e0
package.resolved update
scottkicks Aug 28, 2023
3671a84
add Alerts and Primary buttons
scottkicks Aug 28, 2023
3774097
add controls, inputs, and first couple progress indicators
scottkicks Aug 29, 2023
c467d7e
add shimmer loading, dropdown, and typography
scottkicks Aug 31, 2023
f0327f4
add new color assets and turn off light mode override in info.plist
scottkicks Sep 5, 2023
37e456f
add SystemDesignColors file with color loading helper
scottkicks Sep 5, 2023
7524053
apply adaptive color versions of exisiting component styles
scottkicks Sep 5, 2023
add626a
put light mode override back
scottkicks Sep 5, 2023
fd45111
formatting
scottkicks Sep 5, 2023
e27a358
remove plist key. didn't mean to add that
scottkicks Sep 5, 2023
289ebad
rename: SystemDesign -> Design System
scottkicks Sep 6, 2023
4254207
test goToDesignSystem signal
scottkicks Sep 6, 2023
01d99f0
remove button title feedback
scottkicks Sep 6, 2023
728766b
Build view controller programmatically and remove storyboard
scottkicks Sep 7, 2023
8312415
update current color scheme with actual dark mode colors from design …
scottkicks Sep 7, 2023
a227b23
add Alerts section
scottkicks Sep 8, 2023
87480b2
update BetaToolsViewController snapshot
scottkicks Sep 8, 2023
ab2c9cb
adjust icon sizing
scottkicks Sep 8, 2023
bf56645
update input padding and icons
scottkicks Sep 8, 2023
905722b
Merge branch 'main' into scott/system-design-demo
scottkicks Sep 8, 2023
d13695d
last of the initial pr feedback
scottkicks Sep 8, 2023
defb3ac
Merge branch 'scott/system-design-demo' of https://github.com/kicksta…
scottkicks Sep 8, 2023
da4c5c3
Update MessageBannerViewController.xib
scottkicks Sep 8, 2023
dfaea23
oops missed the footer label
scottkicks Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 207 additions & 0 deletions DemoCTAContainerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import KsApi
import Library
import PassKit
import Prelude
import UIKit

// Just a copy of PledgeViewCTAContainerView to demonstrate Dark Mode differences in SystemSettingsViewController

private enum Layout {
enum Button {
static let minHeight: CGFloat = 48.0
}
}

final class DemoCTAContainerView: UIView {
// MARK: - Properties

private lazy var applePayButton: PKPaymentButton = { PKPaymentButton() }()

private lazy var ctaStackView: UIStackView = {
UIStackView(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var termsTextView: UITextView = { UITextView(frame: .zero) }()

private lazy var disclaimerStackView: UIStackView = {
UIStackView(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var continueButton: UIButton = {
UIButton(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var submitButton: UIButton = {
UIButton(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var rootStackView: UIStackView = {
UIStackView(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private let viewModel: PledgeViewCTAContainerViewModelType = PledgeViewCTAContainerViewModel()

// MARK: - Lifecycle

override init(frame: CGRect) {
super.init(frame: frame)

self.configureSubviews()
self.setupConstraints()
self.bindViewModel()
}

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Styles

override func bindStyles() {
super.bindStyles()

_ = self
|> \.layoutMargins .~ .init(all: Styles.grid(3))

_ = self.applePayButton
|> applePayButtonStyle

_ = self.ctaStackView
|> ctaStackViewStyle

_ = self.termsTextView
|> termsTextViewStyle

_ = self.disclaimerStackView
|> disclaimerStackViewStyle

_ = self.layer
|> layerStyle

_ = self.continueButton
|> greenButtonStyle
|> UIButton.lens.title(for: .normal) %~ { _ in Strings.Continue() }

_ = self.submitButton
|> greenButtonStyle
|> UIButton.lens.title(for: .normal) %~ { _ in Strings.two_factor_buttons_submit() }

_ = self.rootStackView
|> rootStackViewStyle
}

// MARK: - View Model

override func bindViewModel() {
super.bindViewModel()

self.submitButton.rac.title = self.viewModel.outputs.submitButtonTitle
}

// MARK: Functions

private func configureSubviews() {
_ = (self.rootStackView, self)
|> ksr_addSubviewToParent()
|> ksr_constrainViewToEdgesInParent()

_ = ([self.continueButton, self.submitButton, self.applePayButton], self.ctaStackView)
|> ksr_addArrangedSubviewsToStackView()

_ = ([self.termsTextView], self.disclaimerStackView)
|> ksr_addArrangedSubviewsToStackView()

_ = ([self.ctaStackView, self.disclaimerStackView], self.rootStackView)
|> ksr_addArrangedSubviewsToStackView()
}

private func setupConstraints() {
NSLayoutConstraint.activate([
self.submitButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Layout.Button.minHeight),
self.applePayButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Layout.Button.minHeight)
])
}
}

// MARK: - Styles

private let rootStackViewStyle: StackViewStyle = { stackView in
stackView
|> \.axis .~ NSLayoutConstraint.Axis.vertical
|> \.isLayoutMarginsRelativeArrangement .~ true
|> \.layoutMargins .~ UIEdgeInsets.init(
top: Styles.grid(2),
left: Styles.grid(3),
bottom: Styles.grid(0),
right: Styles.grid(3)
)
|> \.spacing .~ Styles.grid(1)
}

private let ctaStackViewStyle: StackViewStyle = { stackView in
stackView
|> \.axis .~ .horizontal
|> \.distribution .~ .fillEqually
|> \.spacing .~ Styles.grid(2)
|> \.layoutMargins .~ UIEdgeInsets.init(topBottom: Styles.grid(2), leftRight: Styles.grid(0))
|> \.isLayoutMarginsRelativeArrangement .~ true
}

private let disclaimerStackViewStyle: StackViewStyle = { stackView in
stackView
|> \.axis .~ .horizontal
|> \.layoutMargins .~ UIEdgeInsets.init(
top: Styles.grid(0),
left: Styles.grid(5),
bottom: Styles.grid(1),
right: Styles.grid(5)
)
|> \.isLayoutMarginsRelativeArrangement .~ true
}

private let layerStyle: LayerStyle = { layer in
layer
|> checkoutLayerCardRoundedStyle
|> \.backgroundColor .~ adaptiveColor(.white).cgColor
|> \.shadowColor .~ adaptiveColor(.black).cgColor
|> \.shadowOpacity .~ 0.12
|> \.shadowOffset .~ CGSize(width: 0, height: -1.0)
|> \.shadowRadius .~ CGFloat(1.0)
|> \.maskedCorners .~ [
CACornerMask.layerMaxXMinYCorner,
CACornerMask.layerMinXMinYCorner
]
}

private let termsTextViewStyle: TextViewStyle = { (textView: UITextView) -> UITextView in
_ = textView
|> adaptiveTappableLinksViewStyle
|> \.attributedText .~ attributedTermsText()
|> \.accessibilityTraits .~ [.staticText]
|> \.textAlignment .~ .center

return textView
}

private func attributedTermsText() -> NSAttributedString? {
let baseUrl = AppEnvironment.current.apiService.serverConfig.webBaseUrl

guard
let termsOfUseLink = HelpType.terms.url(withBaseUrl: baseUrl)?.absoluteString,
let privacyPolicyLink = HelpType.privacy.url(withBaseUrl: baseUrl)?.absoluteString,
let cookiePolicyLink = HelpType.cookie.url(withBaseUrl: baseUrl)?.absoluteString
else { return nil }

let string = Strings.By_pledging_you_agree_to_Kickstarters_Terms_of_Use_Privacy_Policy_and_Cookie_Policy(
terms_of_use_link: termsOfUseLink,
privacy_policy_link: privacyPolicyLink,
cookie_policy_link: cookiePolicyLink
)

return checkoutAttributedLink(with: string)
}
6 changes: 6 additions & 0 deletions Kickstarter-iOS/Assets.xcassets/colors/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.153",
"green" : "0.122",
"red" : "0.627"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.847",
"green" : "0.875",
"red" : "0.369"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.925",
"green" : "0.949",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.075",
"green" : "0.051",
"red" : "0.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.702",
"green" : "0.800",
"red" : "0.996"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.298",
"green" : "0.200",
"red" : "0.004"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading