-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MBL-1458 pt 2] Add address summary for PPO (#2121)
* 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
1 parent
38a8907
commit 0ff8bfe
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
Kickstarter-iOS/Features/PledgedProjectsOverview/CardView/PPOAddressSummary.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters