Skip to content

Commit 9b2a932

Browse files
authored
Add a tip (#24769)
1 parent 7ed437d commit 9b2a932

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

Modules/Sources/JetpackStats/Strings.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ enum Strings {
9999
static let samePeriodLastYear = AppLocalizedString("jetpackStats.datePicker.lastYear", value: "Last Year", comment: "Compare with same period last year option")
100100
}
101101

102+
enum DateRangeTips {
103+
static let title = AppLocalizedString("jetpackStats.dateRangeTip.title", value: "Navigate Through Time", comment: "Title for stats date range control tip")
104+
static let message = AppLocalizedString("jetpackStats.dateRangeTip.message", value: "View recent days, weeks, months, years, or select custom date ranges.", comment: "Message explaining how to use the date range control")
105+
}
106+
102107
enum Chart {
103108
static let showData = AppLocalizedString("jetpackStats.chart.showData", value: "Show Data", comment: "Show chart data menu item")
104109
static let lineChart = AppLocalizedString("jetpackStats.chart.lineChart", value: "Lines", comment: "Line chart type")

Modules/Sources/JetpackStats/Views/LegacyFloatingDateControl.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftUI
2+
import TipKit
23

34
/// A pre-Liquid Glass version.
45
struct LegacyFloatingDateControl: View {
@@ -56,6 +57,7 @@ struct LegacyFloatingDateControl: View {
5657
.tint(Color.primary)
5758
.menuOrder(.fixed)
5859
.buttonStyle(.plain)
60+
.modifier(DateRangeTipModifier())
5961
}
6062

6163
private var dateRangeButtonContent: some View {
@@ -138,8 +140,38 @@ private struct FloatingStyle: ViewModifier {
138140
}
139141
}
140142

143+
@available(iOS 17, *)
144+
private struct StatsDateRangeTip: Tip {
145+
var title: Text {
146+
Text(Strings.DateRangeTips.title)
147+
}
148+
149+
var message: Text? {
150+
Text(Strings.DateRangeTips.message)
151+
}
152+
153+
var image: Image? {
154+
Image(systemName: "calendar")
155+
}
156+
157+
var options: [any TipOption] {
158+
[Tips.MaxDisplayCount(1)]
159+
}
160+
}
161+
141162
private extension View {
142163
func floatingStyle(cornerRadius: CGFloat = 40) -> some View {
143164
modifier(FloatingStyle(cornerRadius: cornerRadius))
144165
}
145166
}
167+
168+
private struct DateRangeTipModifier: ViewModifier {
169+
func body(content: Content) -> some View {
170+
if #available(iOS 17, *) {
171+
content
172+
.popoverTip(StatsDateRangeTip(), arrowEdge: .bottom)
173+
} else {
174+
content
175+
}
176+
}
177+
}

WordPress/Classes/ViewRelated/Tips/AppTips.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ enum AppTips {
8383
MaxDisplayCount(1)
8484
}
8585
}
86+
87+
@available(iOS 17, *)
88+
struct StatsDateRangeTip: Tip {
89+
let id = "stats_date_range_tip"
90+
91+
var title: Text {
92+
Text(NSLocalizedString("tips.statsDateRange.title", value: "Navigate Through Time", comment: "Title for stats date range control tip"))
93+
}
94+
95+
var message: Text? {
96+
Text(NSLocalizedString("tips.statsDateRange.message", value: "Use the calendar to select days, weeks, months, years, or choose custom date ranges to view your stats.", comment: "Message explaining how to use the date range control"))
97+
}
98+
99+
var image: Image? {
100+
Image(systemName: "calendar")
101+
}
102+
103+
var options: [any TipOption] {
104+
MaxDisplayCount(1)
105+
}
106+
}
86107
}
87108

88109
extension UIViewController {

0 commit comments

Comments
 (0)