-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from vuinguyen/pair-program-with-adam
Bring UI changes to be in line with UIKit Version
- Loading branch information
Showing
7 changed files
with
118 additions
and
43 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
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,34 @@ | ||
// | ||
// CalculatedAmountView.swift | ||
// TipperSwiftUI | ||
// | ||
// Created by Vui Nguyen on 3/17/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CalculatedAmountView: View { | ||
let amountLabel: String | ||
let amount: String | ||
|
||
var body: some View { | ||
HStack(alignment: .center) { | ||
Text(amountLabel) | ||
.primaryStyle() | ||
Spacer(minLength: 100) | ||
Text(amount) | ||
.font(.title2) | ||
.fontWeight(.bold) | ||
// Color in hex #323A56 | ||
.foregroundColor(Color(red: 0.19607843137254902, green: 0.22745098039215686, blue: 0.33725490196078434)) | ||
Spacer() | ||
.frame(width: 20) | ||
} | ||
} | ||
} | ||
|
||
struct CalculatedAmountView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
CalculatedAmountView(amountLabel: "Tip Amount", amount: "$0.00") | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// TipAmountView.swift | ||
// TipperSwiftUI | ||
// | ||
// Created by Vui Nguyen on 3/17/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
// Note: This view is deprecated, but keeping it in this file for | ||
// documentation. This view was used before it was refactored into | ||
// the CalculatedAmountView. | ||
// CalculatedAmountView now displays the tip amount AND the bill total views | ||
struct TipAmountView: View { | ||
@Binding var selectedTipPercentage: TipPercent | ||
@Binding var billAmount: Float | ||
let viewModel: TipperViewModel | ||
|
||
var body: some View { | ||
HStack(alignment: .center) { | ||
Text("Tip Amount") | ||
.primaryStyle() | ||
Spacer(minLength: 100) | ||
Text(viewModel.getTipAmountStringFormatted(tipPercent: selectedTipPercentage, billAmount: billAmount)) | ||
.font(.subheadline) | ||
.fontWeight(.regular) | ||
// Color in hex #323A56 | ||
.foregroundColor(Color(red: 0.19607843137254902, green: 0.22745098039215686, blue: 0.33725490196078434)) | ||
Spacer() | ||
.frame(width: 20) | ||
} | ||
} | ||
} | ||
|
||
// According to a StackOverflow post, we have to set up the binding variables | ||
// into the preview this work for it to work: | ||
// https://stackoverflow.com/a/60105482 | ||
struct TipAmountView_Previews: PreviewProvider { | ||
@State static var selectedTipPercentage = TipPercent.fifteen | ||
@State static var billAmount = Float(10.00) | ||
static var previews: some View { | ||
TipAmountView(selectedTipPercentage: $selectedTipPercentage, billAmount: $billAmount, viewModel: TipperViewModel()) | ||
} | ||
} |
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