Skip to content

Commit

Permalink
[MBL-1458 pt 2] Add address summary for PPO (#2121)
Browse files Browse the repository at this point in the history
* Add address summary for PPO

* Inject column size for calculation from outside

* More cleanup of constants and unneeded calls to lineLimit(nil)

* Update address summary with shared styles
  • Loading branch information
stevestreza-ksr authored Aug 21, 2024
1 parent 38a8907 commit 0ff8bfe
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Foundation
import SwiftUI

struct PPOAddressSummary: View {
let address: String
let leadingColumnWidth: CGFloat

var body: some View {
HStack(alignment: .firstTextBaseline) {
// TODO: Localize
Text("Shipping address")
.font(Font(PPOCardStyles.title.font))
.foregroundStyle(Color(PPOCardStyles.title.color))
.frame(width: self.leadingColumnWidth, alignment: Constants.textAlignment)

Text(self.address)
.font(Font(PPOCardStyles.body.font))
.foregroundStyle(Color(PPOCardStyles.body.color))
.frame(maxWidth: Constants.maxWidth, alignment: Constants.textAlignment)
}
.frame(maxWidth: Constants.maxWidth)
}

private enum Constants {
static let textAlignment = Alignment.leadingLastTextBaseline
static let maxWidth = CGFloat.infinity
}
}

#Preview {
VStack(spacing: 28) {
GeometryReader(content: { geometry in
PPOAddressSummary(
address: """
Firsty Lasty
123 First Street, Apt #5678
Los Angeles, CA 90025-1234
United States
""",
leadingColumnWidth: geometry.size.width / 4
)
})
}
.padding(28)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ enum PPOCardStyles {
color: UIColor.ksr_support_400
)

static let body = (
font: UIFont.ksr_caption1(),
color: UIColor.ksr_black
)

static let timeImage = ImageResource.iconLimitedTime
static let alertImage = ImageResource.iconNotice
}
4 changes: 4 additions & 0 deletions Kickstarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@
A7F441E91D005A9400FE6FC5 /* TwoFactorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F441AC1D005A9400FE6FC5 /* TwoFactorViewModel.swift */; };
A7F6F0C11DC7EBF7002C118C /* DateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F6F0C01DC7EBF7002C118C /* DateProtocol.swift */; };
A7FC8C061C8F1DEA00C3B49B /* CircleAvatarImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FC8C051C8F1DEA00C3B49B /* CircleAvatarImageView.swift */; };
AA6E9E8A2C63EE78001543FC /* PPOAddressSummary.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA6E9E892C63EE78001543FC /* PPOAddressSummary.swift */; };
AA6E9E842C62B9DC001543FC /* PPOProjectDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA592782C5C708000482087 /* PPOProjectDetails.swift */; };
AA6E9E852C62B9DC001543FC /* PPOAlertFlag.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAD2BEE82C59B981003D8B95 /* PPOAlertFlag.swift */; };
AA6E9E882C63EAE9001543FC /* PPOProjectCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA6E9E862C63E7C3001543FC /* PPOProjectCreator.swift */; };
Expand Down Expand Up @@ -2765,6 +2766,7 @@
A7F761741C85FA40005405ED /* ActivitiesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivitiesViewController.swift; sourceTree = "<group>"; };
A7F761761C85FACB005405ED /* LoginToutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = LoginToutViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
A7FC8C051C8F1DEA00C3B49B /* CircleAvatarImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircleAvatarImageView.swift; sourceTree = "<group>"; };
AA6E9E892C63EE78001543FC /* PPOAddressSummary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PPOAddressSummary.swift; sourceTree = "<group>"; };
AA6E9E862C63E7C3001543FC /* PPOProjectCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PPOProjectCreator.swift; sourceTree = "<group>"; };
AAA592782C5C708000482087 /* PPOProjectDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PPOProjectDetails.swift; sourceTree = "<group>"; };
AAD2BEE82C59B981003D8B95 /* PPOAlertFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PPOAlertFlag.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6689,6 +6691,7 @@
AAD2BEE72C59B964003D8B95 /* CardView */ = {
isa = PBXGroup;
children = (
AA6E9E892C63EE78001543FC /* PPOAddressSummary.swift */,
AAE7C9A12C75142A00800E03 /* PPOCardStyles.swift */,
AAD2BEE82C59B981003D8B95 /* PPOAlertFlag.swift */,
AAA592782C5C708000482087 /* PPOProjectDetails.swift */,
Expand Down Expand Up @@ -8479,6 +8482,7 @@
06EB4E3127B5D32000D8BFCC /* PinchToZoom.swift in Sources */,
60C996E42ABCA5E5006BE4F4 /* ReportProjectLabelView.swift in Sources */,
60C996E42ABCA5E5006BE4F4 /* ReportProjectLabelView.swift in Sources */,
AA6E9E8A2C63EE78001543FC /* PPOAddressSummary.swift in Sources */,
A75CBDE81C8A26F800758C55 /* AppDelegateViewModel.swift in Sources */,
A72C3AA71D00F7A30075227E /* SortPagerViewController.swift in Sources */,
D764370A224040D100DAFC9E /* SharedFunctions.swift in Sources */,
Expand Down

0 comments on commit 0ff8bfe

Please # to comment.