Skip to content

Commit

Permalink
Publish source 2024-10-22
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 22, 2024
1 parent 31aac23 commit 694c152
Show file tree
Hide file tree
Showing 69 changed files with 406 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildLogic {
version(
yyyy = 2024,
version = 71,
patch = 1,
patch = 2,
build = 1
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct CardContentBitcoinPrice: View {
font: .body3Bold,
textColor: Color.bitcoinPrimary
))
.fixedSize(horizontal: true, vertical: false)

Spacer()

Expand All @@ -32,15 +31,13 @@ struct CardContentBitcoinPrice: View {
font: .body4Regular,
textColor: Color.clear
))
.fixedSize(horizontal: true, vertical: false)
.loadingBackground()
} else {
ModeledText(model: .standard(
viewModel.lastUpdated,
font: .body4Regular,
textColor: Color.foreground30
))
.fixedSize(horizontal: true, vertical: false)
}
}.animation(.spring, value: viewModel)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public struct CardView: View {
private var mainContent: some View {
if viewModel.content is CardModelCardContentBitcoinPrice {
CardContentViewBitcoinPriceCard(viewModel: viewModel)
.frame(minWidth: 0)
} else {
CardContentView(
viewModel: viewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ public struct MoneyHomeButtonsView: View {
switch viewModel {
case let buttonsModel as MoneyHomeButtonsModelMoneyMovementButtonsModel:
let buttonCount = buttonsModel.buttons.count
let spacing: Double = buttonCount > 3 ? 20 : 40

HStack(spacing: spacing) {
let spacing: Double = buttonCount > 3 ? 16 : 32

// Adaptive layout that wraps the buttons to a second row on smaller screens
// 60 is a bit of a magic number here, but it's the best default for our supported devices
let columns = [
GridItem(.adaptive(minimum: 60), spacing: spacing)
]

LazyVGrid(columns: columns, alignment: .center, spacing: spacing) {
ForEach(buttonsModel.buttons, id: \.self) { model in
IconButtonView(model: model)
}
}
.frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 16)
.padding(.bottom, 40)
.padding(.horizontal, 20)
.padding(.horizontal, spacing)

case let model as MoneyHomeButtonsModelSingleButtonModel:
ButtonView(model: model.button)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public struct MoneyHomeView: View {
.padding(.top, 40)

// Balance Hero
MoneyHomeButtonsView(viewModel: viewModel.buttonsModel)
.animation(.none, value: viewModel)
MoneyHomeButtonsView(viewModel: viewModel.buttonsModel)
.frame(minWidth: 0)
.animation(.none, value: viewModel)

// No UI between the action buttons and the tx list so show a divider
if viewModel.cardsModel.cards.isEmpty, viewModel.transactionsModel != nil {
Expand All @@ -83,11 +84,12 @@ public struct MoneyHomeView: View {

// Cards
if viewModel.cardsModel.cards.count > 0, moneyHomeCardsHeight != 0 {
MoneyHomeCardsView(
viewModel: viewModel.cardsModel,
height: $moneyHomeCardsHeight
)
.animation(.none, value: viewModel)
MoneyHomeCardsView(
viewModel: viewModel.cardsModel,
height: $moneyHomeCardsHeight
)
.frame(minWidth: 0)
.animation(.none, value: viewModel)
}

// Transactions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ final class MoneyHomeSnapshotTests: XCTestCase {

func test_money_home() {
let view = MoneyHomeView(viewModel: .snapshotTestFull())
assertBitkeySnapshots(view: view)
assertBitkeySnapshotsAllDevices(view: view)
}

func test_money_home_with_sell_button() {
let view = MoneyHomeView(viewModel: .snapshotTestFull(showSellButton: true))
assertBitkeySnapshots(view: view)
assertBitkeySnapshotsAllDevices(view: view)
}

func test_money_home_with_status_banner() {
Expand Down
41 changes: 41 additions & 0 deletions app/ios/Wallet/Tests/SnapshotTests/SnapshotTestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,47 @@ extension XCTestCase {
XCTAssertNil(iPhone15ProMax)
}

func assertBitkeySnapshotsAllDevices(
view: some View,
screenModel: ScreenModel? = nil,
usesVisualEffect: Bool = false,
fileName: String = #function,
precision: Float = 0.9992,
perceptualPrecision: Float = 0.98
) {
let viewController: UIViewController = if let screenModel {
SwiftUIWrapperViewController(view, screenModel: screenModel)
} else {
UIHostingController(rootView: view)
}

let deviceConfigs = [
ViewImageConfig.iPhone8, .iPhone8Plus, .iPhoneSe, .iPhoneX, .iPhoneXr, .iPhoneXsMax,
.iPhone12, .iPhone12Pro, .iPhone12ProMax,
.iPhone13, .iPhone13Mini, .iPhone13Pro, .iPhone13ProMax,
.iPhone14(.portrait), .iPhone14Plus(.portrait), .iPhone14Pro(.portrait), .iPhone14ProMax(.portrait),
.iPhone15(.portrait), .iPhone15Plus(.portrait), .iPhone15Pro(.portrait), .iPhone15ProMax(.portrait)
]

for config in deviceConfigs {
let snapshot = verifySnapshot(
of: viewController,
as: .image(
drawHierarchyInKeyWindow: usesVisualEffect,
precision: precision,
perceptualPrecision: perceptualPrecision,
size: config.size,
traits: config.traits
),
named: config.description!,
record: isRecording,
testName: fileName
)

XCTAssertNil(snapshot)
}
}

func assertBitkeySnapshot(
image: UIImage,
fileName: String = #function,
Expand Down
174 changes: 174 additions & 0 deletions app/ios/Wallet/Tests/SnapshotTests/UITraitCollection+Devices.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import SnapshotTesting
import UIKit

extension UITraitCollection {

internal static func iPhone14(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone14Plus(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone14Pro(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone14ProMax(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone15(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone15Plus(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone15Pro(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}

internal static func iPhone15ProMax(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
let base: [UITraitCollection] = [
UITraitCollection(forceTouchCapability: .unavailable),
UITraitCollection(layoutDirection: .leftToRight),
UITraitCollection(preferredContentSizeCategory: .medium),
UITraitCollection(userInterfaceIdiom: .phone)
]
return switch orientation {
case .landscape:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .regular),
UITraitCollection(verticalSizeClass: .compact)
])
case .portrait:
UITraitCollection(traitsFrom: base + [
UITraitCollection(horizontalSizeClass: .compact),
UITraitCollection(verticalSizeClass: .regular)
])
}
}
}

Loading

0 comments on commit 694c152

Please sign in to comment.