diff --git a/Localizable.xcstrings b/Localizable.xcstrings index d3105d3a..3583174f 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -1,6 +1,9 @@ { "sourceLanguage" : "en", "strings" : { + "-" : { + "comment" : "Less daylight middle of sentence" + }, "—" : { "localizations" : { "it" : { @@ -284,6 +287,9 @@ } } }, + "+" : { + "comment" : "More daylight middle of sentence" + }, "a specific time" : { "localizations" : { "it" : { diff --git a/Solstice/Extensions/Solar++.swift b/Solstice/Extensions/Solar++.swift index 39f960a6..081d8623 100644 --- a/Solstice/Extensions/Solar++.swift +++ b/Solstice/Extensions/Solar++.swift @@ -51,6 +51,16 @@ extension Solar { return Solar(for: yesterdayDate, coordinate: coordinate)! } + var compactDifferenceString: LocalizedStringKey { + let comparator = date.isToday ? yesterday : Solar(coordinate: self.coordinate)! + let difference = daylightDuration - comparator.daylightDuration + let differenceString = Duration.seconds(abs(difference)).formatted(.units(maximumUnitCount: 2)) + + let moreOrLess = difference >= 0 ? NSLocalizedString("+", comment: "More daylight middle of sentence") : NSLocalizedString("-", comment: "Less daylight middle of sentence") + + return LocalizedStringKey("\(moreOrLess)\(differenceString)") + } + var differenceString: LocalizedStringKey { let formatter = DateFormatter() formatter.doesRelativeDateFormatting = true diff --git a/Widget/Overview Widget/OverviewWidgetView.swift b/Widget/Overview Widget/OverviewWidgetView.swift index 3542a7f9..1238b1b6 100644 --- a/Widget/Overview Widget/OverviewWidgetView.swift +++ b/Widget/Overview Widget/OverviewWidgetView.swift @@ -71,26 +71,26 @@ struct OverviewWidgetView: View { ZStack(alignment: .bottomLeading) { #if !os(watchOS) GeometryReader { geom in - if family != .systemSmall { - DaylightChart(solar: solar, - timeZone: location.timeZone, - eventTypes: [.sunrise, .sunset], - includesSummaryTitle: false, - hideXAxis: true, - markSize: 5) - .padding(.horizontal, -20) - .frame(maxHeight: 200) - - if family == .systemMedium { - VStack { - Spacer() - Rectangle() - .fill(.clear) - .background(.background) - .frame(width: geom.size.width, height: min(geom.size.height / 1.25, 100)) - .padding(.leading, geom.size.width * -0.5) - .blur(radius: 20) - } + DaylightChart( + solar: solar, + timeZone: location.timeZone, + eventTypes: [.sunrise, .sunset], + includesSummaryTitle: false, + hideXAxis: true, + markSize: family == .systemSmall ? 3 : 5 + ) + .padding(.horizontal, -20) + .frame(maxHeight: 200) + + if family == .systemMedium || family == .systemSmall { + VStack { + Spacer() + Rectangle() + .fill(.clear) + .background(.background) + .frame(width: geom.size.width, height: min(geom.size.height / 1.25, 100)) + .padding(.leading, geom.size.width * -0.5) + .blur(radius: 20) } } } @@ -123,32 +123,27 @@ struct OverviewWidgetView: View { Group { if let begins = relevantSolar?.safeSunrise.withTimeZoneAdjustment(for: location.timeZone), let ends = relevantSolar?.safeSunset.withTimeZoneAdjustment(for: location.timeZone) { - if family == .systemSmall { - Text(begins...ends) + if let differenceString = relevantSolar?.compactDifferenceString { + Text(differenceString) + .lineLimit(4) + .font(.footnote) .foregroundStyle(.secondary) - } else { - if let differenceString = relevantSolar?.differenceString { - Text(differenceString) - .lineLimit(4) - .font(.footnote) - .foregroundStyle(.secondary) - .fixedSize(horizontal: false, vertical: true) + .fixedSize(horizontal: false, vertical: true) + } + + HStack { + Label { + Text(begins, style: .time) + } icon: { + Image(systemName: "sunrise.fill") } - HStack { - Label { - Text(begins, style: .time) - } icon: { - Image(systemName: "sunrise.fill") - } - - Spacer() - - Label { - Text(ends, style: .time) - } icon: { - Image(systemName: "sunset.fill") - } + Spacer() + + Label { + Text(ends, style: .time) + } icon: { + Image(systemName: "sunset.fill") } } }