Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct RealtimeTopListCard: View {
}
.padding(.vertical, Constants.step3)
.redacted(reason: viewModel.isFirstLoad ? .placeholder : [])
.onChange(of: selectedItem) { newValue in
.onChange(of: selectedItem) { oldValue, newValue in
viewModel.loadData(for: newValue)
}
}
Expand Down
9 changes: 7 additions & 2 deletions Modules/Sources/JetpackStats/Charts/BarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct BarChartView: View {
.accessibilityElement()
.accessibilityLabel(Strings.Accessibility.chartContainer)
.accessibilityHint(Strings.Accessibility.viewChartData)
.onChange(of: ObjectIdentifier(data)) { _ in
.onChange(of: ObjectIdentifier(data)) {
tappedDataPoint = nil
}
}
Expand Down Expand Up @@ -287,7 +287,12 @@ struct BarChartView: View {
}

private func getSelectedDataPoints(at location: CGPoint, proxy: ChartProxy, geometry: GeometryProxy) -> SelectedDataPoints? {
let origin = geometry[proxy.plotAreaFrame].origin

guard let frame = proxy.plotFrame else {
return nil
}

let origin = geometry[frame].origin
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning was in the same file so I addressed it – plotAreaFrame was renamed to plotFrame and made optional.

let location = CGPoint(
x: location.x - origin.x,
y: location.y - origin.y
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/JetpackStats/Charts/LineChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct LineChartView: View {
.chartXSelection(value: $selectedDate)
.animation(.spring, value: ObjectIdentifier(data))
.onChange(of: selectedDate) {
selectedDataPoints = SelectedDataPoints.compute(for: $0, data: data)
selectedDataPoints = SelectedDataPoints.compute(for: $1, data: data)
}
.dynamicTypeSize(...DynamicTypeSize.xxxLarge)
.accessibilityElement()
Expand Down
4 changes: 2 additions & 2 deletions Modules/Sources/JetpackStats/Screens/AuthorStatsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ struct AuthorStatsView: View {
}
.background(Constants.Colors.background)
.animation(.spring, value: viewModel.data.map(ObjectIdentifier.init))
.onChange(of: dateRange) { newRange in
viewModel.dateRange = newRange
.onChange(of: dateRange) { oldValue, newValue in
viewModel.dateRange = newValue
}
.onAppear {
context.tracker?.send(.authorStatsScreenShown)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Sources/JetpackStats/Screens/StatsMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct StatsMainView: View {
.onAppear {
context.tracker?.send(.statsMainScreenShown)
}
.onChange(of: selectedTab) { newValue in
.onChange(of: selectedTab) { oldValue, newValue in
trackTabChange(from: selectedTab, to: newValue)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct CustomDateRangePicker: View {
private var dateSelectionSection: some View {
HStack(alignment: .bottom, spacing: 0) {
datePickerColumn(label: Strings.DatePicker.from.uppercased(), selection: $startDate, alignment: .leading)
.onChange(of: startDate) { newValue in
.onChange(of: startDate) { oldValue, newValue in
// If start date is after end date, adjust end date to be one day after start
if newValue > endDate {
endDate = calendar.date(byAdding: .day, value: 1, to: newValue) ?? newValue
Expand All @@ -126,7 +126,7 @@ struct CustomDateRangePicker: View {
Spacer(minLength: 32)

datePickerColumn(label: Strings.DatePicker.to.uppercased(), selection: $endDate, alignment: .trailing)
.onChange(of: endDate) { newValue in
.onChange(of: endDate) { oldValue, newValue in
// If end date is before start date, adjust start date to be one day before end
if newValue < startDate {
startDate = calendar.date(byAdding: .day, value: -1, to: newValue) ?? newValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct TopListCardCustomizationView: View {
}
}
}
.onChange(of: selectedItem) { newValue in
.onChange(of: selectedItem) { oldValue, newValue in
if let newValue {
updateConfiguration(with: newValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public struct SupportConversationView: View {
.onAppear {
scrollToBottom(proxy: proxy)
}
.onChange(of: conversation.messages.count) { _, _ in
.onChange(of: conversation.messages.count) {
scrollToBottom(proxy: proxy)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private struct BloganuaryOverlayView: View {
.onAppear {
scrollViewHeight = geo.size.height
}
.onChange(of: viewModel.orientation) { _ in
.onChange(of: viewModel.orientation) {
// since onAppear is only called once, assign the value again every time the orientation changes.
scrollViewHeight = geo.size.height
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct PHPLogsView: View {
.onAppear {
loadLogs(searchCriteria: searchCriteria)
}
.onChange(of: searchCriteria) { value in
loadLogs(searchCriteria: value, reset: true)
.onChange(of: searchCriteria) { oldValue, newValue in
loadLogs(searchCriteria: newValue, reset: true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct WebServerLogsView: View {
.onAppear {
loadLogs(searchCriteria: searchCriteria)
}
.onChange(of: searchCriteria) { value in
loadLogs(searchCriteria: value, reset: true)
.onChange(of: searchCriteria) { oldValue, newValue in
loadLogs(searchCriteria: newValue, reset: true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ struct RelatedPostsSettingsView: View {
}
.toggleStyle(SwitchToggleStyle(tint: Color(UIAppColor.jetpackGreen)))
.onChange(of: settings.relatedPostsEnabled) {
save(field: "show_related_posts", value: $0)
save(field: "show_related_posts", value: $1)
}
.onChange(of: settings.relatedPostsShowHeadline) {
save(field: "show_related_posts_header", value: $0)
save(field: "show_related_posts_header", value: $1)
}
.onChange(of: settings.relatedPostsShowThumbnails) {
save(field: "show_related_posts_thumbnail", value: $0)
save(field: "show_related_posts_thumbnail", value: $1)
}
.navigationTitle(Strings.title)
.navigationBarTitleDisplayMode(.inline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ struct ReaderDetailHeaderView: View {
.onAppear {
onContentSizeChanged?()
}
.onChange(of: proxy.size) { _ in
.onChange(of: proxy.size) {
onContentSizeChanged?()
}
}
Expand Down Expand Up @@ -378,7 +378,7 @@ struct ReaderDetailHeaderView: View {
// The host view does not react properly after the collection view finished its layout.
// This informs any size changes to the host view so that it can readjust correctly.
Color.clear
.onChange(of: geometry.size) { _ in
.onChange(of: geometry.size) {
onContentSizeChanged?()
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct ReaderSubscriptionAddView: View {
.onAppear {
isFocused = true
}
.onChange(of: siteURL) { _ in
.onChange(of: siteURL) {
displayedError = nil
}
.frame(idealWidth: 420)
Expand Down