Skip to content

Commit

Permalink
Merge branch 'main' into postCampaignFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
ifosli committed Feb 7, 2024
2 parents 330e4c0 + 2096367 commit 4b7902b
Show file tree
Hide file tree
Showing 148 changed files with 101 additions and 70 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ orbs:
aws_cli_setup: &aws_cli_setup
role-arn: $AWS_ROLE_ARN

# Keep xcode version in sync with `.fastlane/Fastfile`
xcode_version: &xcode_version 15.2.0
iphone_name: &iphone_name iPhone SE (3rd generation)

Expand Down
3 changes: 2 additions & 1 deletion .fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ platform :ios do
end

private_lane :xcode_check do
xcodes(version: "14.2", select_for_current_build_only: true)
# Keep xcode version in sync with `.circleci/config.yml`
xcodes(version: "15.2", select_for_current_build_only: true)
end

private_lane :build_the_app do |options|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,18 @@ internal final class FacebookConfirmationViewController: UIViewController,
internal override func bindStyles() {
super.bindStyles()

_ = self
|> baseControllerStyle()

_ = self.disclaimerTextView
|> disclaimerTextViewStyle

_ = self.confirmationLabel |> fbConfirmationMessageLabelStyle
_ = self.createAccountButton |> createNewAccountButtonStyle
_ = self.emailLabel |> fbConfirmEmailLabelStyle
_ = self.loginButton |> loginWithEmailButtonStyle
_ = self.loginLabel |> fbWrongAccountLabelStyle
_ = self.navigationItem.title = Strings.signup_navbar_title()
_ = self.newsletterLabel
|> newsletterLabelStyle
_ = self.newsletterLabel |> newsletterLabelStyle
_ = self.newsletterSwitch |> newsletterSwitchStyle
_ = self.rootStackView |> loginRootStackViewStyle

let isPad = self.traitCollection.userInterfaceIdiom == .pad
applyDisclaimerTextViewStyle(self.disclaimerTextView, useLargerText: isPad)
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)
}

override func bindViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal final class FacebookConfirmationViewControllerTests: TestCase {

func testView() {
let devices = [Device.phone4_7inch, Device.phone5_8inch, Device.pad]
combos(Language.allLanguages, devices).forEach { language, device in
orthogonalCombos(Language.allLanguages, devices).forEach { language, device in
withEnvironment(language: language) {
let controller = FacebookConfirmationViewController
.configuredWith(facebookUserEmail: "hello@kickstarter.com", facebookAccessToken: "")
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public final class FacebookResetPasswordViewController: UIViewController {

_ = self.rootStackView
|> baseStackViewStyle
|> loginRootStackViewStyle
let isPad = self.traitCollection.userInterfaceIdiom == .pad
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)

_ = self.emailLabel
|> textFieldLabelStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal final class FacebookResetPasswordViewControllerTests: TestCase {

func testFacebookResetPasswordViewController() {
let devices = [Device.phone4_7inch, Device.pad]
combos(Language.allLanguages, devices).forEach { language, device in
orthogonalCombos(Language.allLanguages, devices).forEach { language, device in
withEnvironment(language: language) {
let controller = FacebookResetPasswordViewController.instantiate()
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ internal final class LoginViewController: UIViewController {

_ = self.formBackgroundView |> cardStyle()

_ = self.rootStackView |> loginRootStackViewStyle
let isPad = self.traitCollection.userInterfaceIdiom == .pad
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)
}

override func bindViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ internal final class LoginViewControllerTests: TestCase {
}

func testView() {
combos(Language.allLanguages, [Device.phone4_7inch, Device.phone5_8inch, Device.pad]).forEach {
orthogonalCombos(Language.allLanguages, [Device.pad, Device.phone4_7inch, Device.phone5_8inch]).forEach {
language, device in
withEnvironment(language: language) {
let controller = Storyboard.Login.instantiate(LoginViewController.self)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)

self.scheduler.run()

assertSnapshot(matching: parent.view, as: .image, named: "lang_\(language)_device_\(device)")
assertSnapshot(
matching: parent.view,
as: .image,
named: "lang_\(language)_device_\(device)"
)
}
}
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
public override func bindStyles() {
super.bindStyles()

let isPad = self.traitCollection.userInterfaceIdiom == .pad

_ = self.backgroundImageView
|> backgroundImageViewStyle

Expand All @@ -131,8 +133,8 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC

_ = self.getNotifiedLabel
|> baseLabelStyle
|> UILabel.lens.font %~~ { _, label in
label.traitCollection.isRegularRegular ? UIFont.ksr_subhead() : UIFont.ksr_caption2()
|> UILabel.lens.font %~~ { _, _ in
isPad ? UIFont.ksr_subhead() : UIFont.ksr_caption2()
}
|> UILabel.lens.text %~ { _ in Strings.Get_notified_when_your_friends_back_and_launch_projects() }

Expand All @@ -144,9 +146,9 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC

_ = self.loginContextStackView
|> UIStackView.lens.spacing .~ Styles.gridHalf(1)
|> UIStackView.lens.layoutMargins %~~ { _, stack in
stack.traitCollection.isRegularRegular
? .init(topBottom: Styles.grid(10), leftRight: 0)
|> UIStackView.lens.layoutMargins %~~ { _, _ in
isPad
? .init(topBottom: Styles.grid(2), leftRight: 0)
: .init(top: Styles.grid(10), left: 0, bottom: Styles.grid(5), right: 0)
}
|> UIStackView.lens.isLayoutMarginsRelativeArrangement .~ true
Expand All @@ -156,8 +158,8 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC

_ = self.rootStackView
|> baseStackViewStyle
|> loginRootStackViewStyle
|> UIStackView.lens.spacing .~ Styles.grid(5)
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)

_ = self.separatorView
|> separatorViewStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal final class LoginToutViewControllerTests: TestCase {
let devices = [Device.phone4_7inch, Device.phone5_8inch, Device.pad]
let intents = [LoginIntent.generic, .starProject, .messageCreator, .backProject]

combos(Language.allLanguages, devices, intents).forEach { language, device, intent in
orthogonalCombos(Language.allLanguages, devices, intents).forEach { language, device, intent in
withEnvironment(language: language) {
let controller = LoginToutViewController.configuredWith(loginIntent: intent)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ internal final class ResetPasswordViewController: UIViewController {
_ = self.emailTextField |> emailFieldStyle
_ = self.emailTextFieldBackgroundView |> cardStyle()
_ = self.resetPasswordButton |> resetPasswordButtonStyle
_ = self.rootStackView |> loginRootStackViewStyle

let isPad = self.traitCollection.userInterfaceIdiom == .pad
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)
}

override func bindViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal final class ResetPasswordViewControllerTests: TestCase {
}

func testView() {
combos(Language.allLanguages, [Device.phone4_7inch, Device.phone5_8inch, Device.pad]).forEach {
orthogonalCombos(Language.allLanguages, [Device.pad, Device.phone4_7inch, Device.phone5_8inch]).forEach {
language, device in
withEnvironment(language: language) {
let controller = ResetPasswordViewController.configuredWith(email: "americasnexttopmodulus@gmail.com")
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ public final class SetYourPasswordViewController: UIViewController {
_ = self.contextLabel
|> contextLabelStyle

let isPad = self.traitCollection.userInterfaceIdiom == .pad

_ = self.rootStackView
|> baseStackViewStyle
|> loginRootStackViewStyle
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)

_ = self.newPasswordLabel
|> textFieldLabelStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class SetYourPasswordViewControllerTests: TestCase {
let userEnvelope = UserEnvelope(me: userTemplate)
let service = MockService(fetchGraphUserResult: .success(userEnvelope))

combos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach {
orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach {
language, device in
withEnvironment(apiService: service, apiDelayInterval: .seconds(0), language: language) {
let controller = SetYourPasswordViewController.instantiate()
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
10 changes: 4 additions & 6 deletions Kickstarter-iOS/Features/Signup/SignupViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ internal final class SignupViewController: UIViewController, MFMailComposeViewCo
_ = self
|> signupControllerStyle

_ = self.disclaimerTextView
|> disclaimerTextViewStyle

_ = self.nameTextField
|> UITextField.lens.returnKeyType .~ .next
|> UITextField.lens.placeholder %~ { _ in Strings.Name() }
Expand All @@ -103,11 +100,12 @@ internal final class SignupViewController: UIViewController, MFMailComposeViewCo
|> newPasswordFieldAutoFillStyle
|> UITextField.lens.returnKeyType .~ .go

_ = self.rootStackView
|> loginRootStackViewStyle

_ = self.signupButton
|> signupButtonStyle

let isPad = self.traitCollection.userInterfaceIdiom == .pad
applyDisclaimerTextViewStyle(self.disclaimerTextView, useLargerText: isPad)
applyLoginRootStackViewStyle(self.rootStackView, useLargerMargins: isPad)
}

internal override func bindViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal final class SignupViewControllerTests: TestCase {
}

func testView() {
let devices = [Device.phone4_7inch, Device.phone5_8inch, Device.pad]
combos(Language.allLanguages, devices).forEach { language, device in
let devices = [Device.phone4_7inch, Device.pad, Device.phone5_8inch]
orthogonalCombos(Language.allLanguages, devices).forEach { language, device in
withEnvironment(language: language) {
let controller = SignupViewController.instantiate()
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ internal final class TwoFactorViewController: UIViewController {
internal override func bindStyles() {
super.bindStyles()

let isPad = self.traitCollection.isRegularRegular

_ = self
|> twoFactorControllerStyle
|> UIViewController.lens.view.layoutMargins %~~ { _, view in
view.traitCollection.isRegularRegular ? .init(all: Styles.grid(20)) : .init(all: Styles.grid(3))
|> UIViewController.lens.view.layoutMargins %~~ { _, _ in
isPad ? .init(all: Styles.grid(20)) : .init(all: Styles.grid(3))
}

_ = self.codeTextField
|> tfaCodeFieldAutoFillStyle

_ = self.formBackgroundView
|> cardStyle()
|> UIView.lens.layoutMargins %~~ { _, view in
view.traitCollection.isRegularRegular ? .init(all: Styles.grid(10)) : .init(all: Styles.grid(3))
|> UIView.lens.layoutMargins %~~ { _, _ in
isPad ? .init(all: Styles.grid(10)) : .init(all: Styles.grid(3))
}

_ = self.formStackView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal final class TwoFactorViewControllerTests: TestCase {
}

func testView() {
combos(Language.allLanguages, [Device.phone4_7inch, Device.phone5_8inch, Device.pad]).forEach {
orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.phone5_8inch, Device.pad]).forEach {
language, device in
withEnvironment(language: language) {
let controller = Storyboard.Login.instantiate(TwoFactorViewController.self)
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
36 changes: 36 additions & 0 deletions Kickstarter-iOS/TestHelpers/Combos.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Combine two arrays by creating an array consisting of each pairwise combo.
// Result consists of `A.count * B.count` pairs.
internal func combos<A, B>(_ xs: [A], _ ys: [B]) -> [(A, B)] {
return xs.flatMap { x in
ys.map { y in
Expand All @@ -6,6 +8,8 @@ internal func combos<A, B>(_ xs: [A], _ ys: [B]) -> [(A, B)] {
}
}

// Combine three arrays by creating an array consisting of all possible tuples.
// Result consists of `A.count * B.count * C.count` tuples.
internal func combos<A, B, C>(_ xs: [A], _ ys: [B], _ zs: [C]) -> [(A, B, C)] {
return xs.flatMap { x in
ys.flatMap { y in
Expand All @@ -15,3 +19,35 @@ internal func combos<A, B, C>(_ xs: [A], _ ys: [B], _ zs: [C]) -> [(A, B, C)] {
}
}
}

// Combine two arrays by creating an array where each element is represented at least once.
// Result consists of `max(A.count, B.count)` pairs.
internal func orthogonalCombos<A, B>(_ xs: [A], _ ys: [B]) -> [(A, B)] {
if xs.count >= ys.count {
return xs.enumerated().map { index, x in
(x, ys[index % ys.count])
}
} else {
return ys.enumerated().map { index, y in
(xs[index % xs.count], y)
}
}
}

// Combine three arrays by creating an array where each element is represented at least once.
// Result consists of `max(A.count, B.count, C.count)` tuples.
internal func orthogonalCombos<A, B, C>(_ xs: [A], _ ys: [B], _ zs: [C]) -> [(A, B, C)] {
if xs.count >= ys.count, xs.count >= zs.count {
return xs.enumerated().map { index, x in
(x, ys[index % ys.count], zs[index % zs.count])
}
} else if ys.count >= xs.count, ys.count >= zs.count {
return ys.enumerated().map { index, y in
(xs[index % xs.count], y, zs[index % zs.count])
}
} else {
return zs.enumerated().map { index, z in
(xs[index % xs.count], ys[index % ys.count], z)
}
}
}

0 comments on commit 4b7902b

Please sign in to comment.