[UPDATE] AppPillButton dimensions and expiration text

This commit is contained in:
Fabian Thies
2023-01-31 22:37:37 +01:00
committed by Joe Mattiello
parent d3e04c1db7
commit f3e58e1485
3 changed files with 21 additions and 15 deletions

View File

@@ -22,25 +22,18 @@ struct DateFormatterHelper {
let startDate = Date() let startDate = Date()
let interval = date.timeIntervalSince(startDate) let interval = date.timeIntervalSince(startDate)
guard interval > 0 else { guard interval > 0 else {
return "" return "EXPIRED"
} }
if interval < (1 * 60 * 60) { if interval < (24 * 60 * 60) {
self.appExpirationDateFormatter.unitsStyle = .positional self.appExpirationDateFormatter.unitsStyle = .positional
self.appExpirationDateFormatter.allowedUnits = [.minute, .second] self.appExpirationDateFormatter.allowedUnits = [.minute, .second]
} } else {
else if interval < (2 * 24 * 60 * 60)
{
self.appExpirationDateFormatter.unitsStyle = .positional
self.appExpirationDateFormatter.allowedUnits = [.hour, .minute, .second]
}
else
{
self.appExpirationDateFormatter.unitsStyle = .full self.appExpirationDateFormatter.unitsStyle = .full
self.appExpirationDateFormatter.allowedUnits = [.day] self.appExpirationDateFormatter.allowedUnits = [.day]
}
// let numberOfDays = endDate.numberOfCalendarDays(since: startDate) return self.appExpirationDateFormatter.string(from: startDate, to: date) ?? ""
// text = String(format: NSLocalizedString("%@ DAYS", comment: ""), NSNumber(value: numberOfDays))
} }
return self.appExpirationDateFormatter.string(from: startDate, to: date) ?? "" return self.appExpirationDateFormatter.string(from: startDate, to: date) ?? ""

View File

@@ -51,10 +51,10 @@ struct AppPillButton: View {
} }
var body: some View { var body: some View {
SwiftUI.Button(action: handleButton, label: { SwiftUI.Button(action: handleButton) {
Text(buttonText.uppercased()) Text(buttonText.uppercased())
.bold() .bold()
}) }
.buttonStyle(PillButtonStyle(tintColor: storeApp?.tintColor ?? .black, progress: progress)) .buttonStyle(PillButtonStyle(tintColor: storeApp?.tintColor ?? .black, progress: progress))
} }

View File

@@ -25,7 +25,7 @@ struct PillButtonStyle: ButtonStyle {
} }
.frame(minWidth: 40) .frame(minWidth: 40)
.padding(.horizontal, 16) .padding(.horizontal, 16)
.padding(.vertical, 8) .padding(.vertical, 6)
.background(background) .background(background)
.foregroundColor(self.progress == nil ? .white : Color(tintColor)) .foregroundColor(self.progress == nil ? .white : Color(tintColor))
.clipShape(Capsule()) .clipShape(Capsule())
@@ -44,3 +44,16 @@ struct PillButtonStyle: ButtonStyle {
} }
} }
} }
struct PillButtonStyle_Previews: PreviewProvider {
static var previews: some View {
SwiftUI.Button {
} label: {
Text("Label").bold()
}
.buttonStyle(PillButtonStyle(tintColor: Asset.accentColor.color))
}
}