Skip to content

Commit 1c1a919

Browse files
author
golson
committed
Merge branch 'liquid-glass' into T416194
2 parents 7ffd09a + 9097211 commit 1c1a919

File tree

182 files changed

+3877
-3936
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+3877
-3936
lines changed

ContinueReadingWidget/WMFTodayContinueReadingWidgetViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class WMFTodayContinueReadingWidgetViewController: ExtensionViewController, NCWi
4343
emptyDescriptionLabel.text = WMFLocalizedString("continue-reading-empty-description", value:"Explore Wikipedia for more articles to read", comment: "Explore Wikipedia for more articles to read")
4444

4545
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.handleTapGestureRecognizer(_:))))
46+
47+
registerForTraitChanges([UITraitPreferredContentSizeCategory.self, UITraitHorizontalSizeClass.self, UITraitVerticalSizeClass.self]) { [weak self] (viewController: Self, previousTraitCollection: UITraitCollection) in
48+
guard let self else { return }
49+
self.updatePreferredContentSize()
50+
}
4651
}
4752

4853
@objc func handleTapGestureRecognizer(_ recognizer: UITapGestureRecognizer) {
@@ -162,11 +167,6 @@ class WMFTodayContinueReadingWidgetViewController: ExtensionViewController, NCWi
162167
preferredContentSize = fitSize
163168
}
164169

165-
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
166-
super.traitCollectionDidChange(previousTraitCollection)
167-
updatePreferredContentSize()
168-
}
169-
170170
@IBAction func continueReading(_ sender: AnyObject) {
171171
openApp(with: articleURL)
172172
}

WMF Framework/ActionButton.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class ActionButton: SetupButton {
1010
deprecatedSelf.deprecatedContentEdgeInsets = UIEdgeInsets(top: layoutMargins.top + 1, left: layoutMargins.left + 7, bottom: layoutMargins.bottom + 1, right: layoutMargins.right + 7)
1111
titleLabel?.numberOfLines = 0
1212
updateFonts(with: traitCollection)
13+
14+
registerForTraitChanges([UITraitPreferredContentSizeCategory.self, UITraitHorizontalSizeClass.self, UITraitVerticalSizeClass.self]) { [weak self] (viewController: Self, previousTraitCollection: UITraitCollection) in
15+
guard let self else { return }
16+
self.maybeUpdateFonts(with: self.traitCollection)
17+
}
1318
}
1419

1520
// MARK: - Dynamic Type
1621
// Only applies new fonts if the content size category changes
1722

18-
override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
19-
super.traitCollectionDidChange(previousTraitCollection)
20-
maybeUpdateFonts(with: traitCollection)
21-
}
22-
2323
var contentSizeCategory: UIContentSizeCategory?
2424
fileprivate func maybeUpdateFonts(with traitCollection: UITraitCollection) {
2525
guard contentSizeCategory == nil || contentSizeCategory != traitCollection.preferredContentSizeCategory else {

WMF Framework/ExtensionViewController.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ import UIKit
33
open class ExtensionViewController: UIViewController, Themeable {
44
public final var theme: Theme = Theme.widgetLight
55

6+
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
7+
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
8+
setupTraitChangeObservation()
9+
}
10+
11+
public required init?(coder: NSCoder) {
12+
super.init(coder: coder)
13+
setupTraitChangeObservation()
14+
}
15+
16+
private func setupTraitChangeObservation() {
17+
registerForTraitChanges([UITraitPreferredContentSizeCategory.self, UITraitHorizontalSizeClass.self, UITraitVerticalSizeClass.self]) { [weak self] (viewController: Self, previousTraitCollection: UITraitCollection) in
18+
guard let self else { return }
19+
self.updateThemeFromTraitCollection()
20+
}
21+
}
22+
623
open func apply(theme: Theme) {
724
self.theme = theme
825
}
@@ -26,11 +43,6 @@ open class ExtensionViewController: UIViewController, Themeable {
2643
apply(theme: compatibleTheme)
2744
}
2845

29-
override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
30-
super.traitCollectionDidChange(previousTraitCollection)
31-
updateThemeFromTraitCollection()
32-
}
33-
3446
public func openAppInActivity(with activityType: WMFUserActivityType) {
3547
self.extensionContext?.open(NSUserActivity.wmf_baseURLForActivity(of: activityType))
3648
}

WMFComponents/Sources/WMFComponents/Assets.xcassets/watchlist/user-contributions.imageset/Contents.json renamed to WMFComponents/Sources/WMFComponents/Assets.xcassets/watchlist/user-contribution.imageset/Contents.json

File renamed without changes.

WMFComponents/Sources/WMFComponents/Assets.xcassets/watchlist/user-contributions.imageset/user-contributions.pdf renamed to WMFComponents/Sources/WMFComponents/Assets.xcassets/watchlist/user-contribution.imageset/user-contributions.pdf

File renamed without changes.

WMFComponents/Sources/WMFComponents/Components/Activity Tab/WMFActivityTabCustomizeView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct WMFActivityTabCustomizeView: View {
2222
isOn: $viewModel.isTimeSpentReadingOn
2323
)
2424
.listRowBackground(Color(theme.paperBackground).edgesIgnoringSafeArea([.all]))
25-
.onChange(of: viewModel.isTimeSpentReadingOn) { newValue in
25+
.onChange(of: viewModel.isTimeSpentReadingOn) { _, newValue in
2626
guard newValue == true else { return }
2727
guard viewModel.isLoggedIn else {
2828
viewModel.isTimeSpentReadingOn = false
@@ -36,7 +36,7 @@ public struct WMFActivityTabCustomizeView: View {
3636
isOn: $viewModel.isReadingInsightsOn
3737
)
3838
.listRowBackground(Color(theme.paperBackground).edgesIgnoringSafeArea([.all]))
39-
.onChange(of: viewModel.isReadingInsightsOn) { newValue in
39+
.onChange(of: viewModel.isReadingInsightsOn) { _, newValue in
4040
guard newValue == true else { return }
4141
guard viewModel.isLoggedIn else {
4242
viewModel.isReadingInsightsOn = false
@@ -50,7 +50,7 @@ public struct WMFActivityTabCustomizeView: View {
5050
isOn: $viewModel.isEditingInsightsOn
5151
)
5252
.listRowBackground(Color(theme.paperBackground).edgesIgnoringSafeArea([.all]))
53-
.onChange(of: viewModel.isEditingInsightsOn) { newValue in
53+
.onChange(of: viewModel.isEditingInsightsOn) { _, newValue in
5454
guard newValue == true else { return }
5555
guard viewModel.isLoggedIn else {
5656
viewModel.isEditingInsightsOn = false
@@ -64,7 +64,7 @@ public struct WMFActivityTabCustomizeView: View {
6464
isOn: $viewModel.isTimelineOfBehaviorOn
6565
)
6666
.listRowBackground(Color(theme.paperBackground).edgesIgnoringSafeArea([.all]))
67-
.onChange(of: viewModel.isTimelineOfBehaviorOn) { newValue in
67+
.onChange(of: viewModel.isTimelineOfBehaviorOn) { _, newValue in
6868
guard newValue == true else { return }
6969
guard viewModel.isLoggedIn else {
7070
viewModel.isTimelineOfBehaviorOn = false

WMFComponents/Sources/WMFComponents/Components/Activity Tab/WMFActivityTabView.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public struct WMFActivityTabView: View {
5151
.accessibilityElement()
5252
.accessibilityLabel(viewModel.articlesReadViewModel.usernamesReading)
5353
.accessibilityHint(viewModel.localizedStrings.onWikipediaiOS)
54-
54+
5555
VStack(alignment: .center, spacing: 8) {
5656
hoursMinutesRead
5757
.accessibilityLabel(viewModel.hoursMinutesRead)
@@ -64,17 +64,17 @@ public struct WMFActivityTabView: View {
6464
.accessibilityElement()
6565
.accessibilityLabel("\(viewModel.hoursMinutesRead), \(viewModel.localizedStrings.timeSpentReading)")
6666
}
67-
68-
67+
68+
6969
if viewModel.customizeViewModel.isReadingInsightsOn {
7070
articlesReadModule(proxy: proxy)
7171
savedArticlesModule
72-
72+
7373
if viewModel.shouldShowExploreCTA {
7474
exploreCTA
7575
.padding(.vertical, 12)
7676
}
77-
77+
7878
if !viewModel.articlesReadViewModel.topCategories.isEmpty {
7979
topCategoriesModule(categories: viewModel.articlesReadViewModel.topCategories)
8080
}
@@ -96,25 +96,25 @@ public struct WMFActivityTabView: View {
9696
}
9797
.listRowSeparator(.hidden)
9898
}
99-
99+
100100
if viewModel.customizeViewModel.isEditingInsightsOn && viewModel.shouldShowYourImpactHeader {
101-
101+
102102
Section(header: YourImpactHeaderView(viewModel: viewModel)) {
103-
103+
104104
VStack(spacing: 16) {
105-
105+
106106
if let mostViewedArticlesViewModel = viewModel.mostViewedArticlesViewModel {
107107
TopViewedEditsView(viewModel: viewModel, mostViewedViewModel: mostViewedArticlesViewModel)
108108
}
109-
109+
110110
if let contributionsViewModel = viewModel.contributionsViewModel {
111111
ContributionsView(viewModel: contributionsViewModel)
112112
}
113-
113+
114114
if viewModel.allTimeImpactViewModel != nil || viewModel.recentActivityViewModel != nil || viewModel.articleViewsViewModel != nil {
115115
CombinedImpactView(allTimeImpactViewModel: viewModel.allTimeImpactViewModel, recentActivityViewModel: viewModel.recentActivityViewModel, articleViewsViewModel: viewModel.articleViewsViewModel)
116116
}
117-
117+
118118
if let globalEditCount = viewModel.globalEditCount, globalEditCount > 0 {
119119
totalEditsView(amount: animatedGlobalEditCount)
120120
.onAppear {
@@ -128,7 +128,7 @@ public struct WMFActivityTabView: View {
128128
animatedGlobalEditCount = globalEditCount
129129
}
130130
}
131-
.onChange(of: globalEditCount) { newValue in
131+
.onChange(of: globalEditCount) { _, newValue in
132132
withAnimation(.easeOut(duration: 0.6)) {
133133
animatedGlobalEditCount = newValue
134134
}
@@ -151,7 +151,7 @@ public struct WMFActivityTabView: View {
151151
}
152152
.listRowSeparator(.hidden)
153153
}
154-
154+
155155
if viewModel.customizeViewModel.isTimelineOfBehaviorOn {
156156
timelineSectionsList()
157157
.id("timelineSection")
@@ -162,7 +162,7 @@ public struct WMFActivityTabView: View {
162162
.listStyle(.grouped)
163163
.listCustomSectionSpacing(0)
164164
}
165-
165+
166166
private var exploreCTA: some View {
167167
VStack(alignment: .center, spacing: 12) {
168168
Text(viewModel.localizedStrings.lookingForSomethingNew)
@@ -187,7 +187,7 @@ public struct WMFActivityTabView: View {
187187
.listRowInsets(EdgeInsets())
188188
}
189189
.listRowSeparator(.hidden)
190-
190+
191191
HStack {
192192
Spacer()
193193
WMFEmptyView(
@@ -216,7 +216,7 @@ public struct WMFActivityTabView: View {
216216
.background(Color(uiColor: theme.paperBackground).edgesIgnoringSafeArea(.all))
217217
}
218218
}
219-
219+
220220
private func totalEditsView(amount: Int) -> some View {
221221

222222
let cardView = WMFActivityTabInfoCardView(
@@ -234,14 +234,14 @@ public struct WMFActivityTabView: View {
234234
}
235235
}
236236
)
237-
237+
238238
let formattedAmount = amountAccessibilityLabel(for: amount)
239239
let accessibilityLabel: String = [viewModel.localizedStrings.totalEditsAcrossProjects, formattedAmount].joined(separator: ",")
240-
240+
241241
return cardView.accessibilityElement(children: .ignore)
242242
.accessibilityLabel(accessibilityLabel)
243243
.accessibilityAddTraits(.isButton)
244-
244+
245245
}
246246

247247
private func timelineSectionsList() -> some View {
@@ -354,10 +354,10 @@ public struct WMFActivityTabView: View {
354354
}
355355
}
356356
)
357-
357+
358358
let formattedAmount = amountAccessibilityLabel(for: viewModel.articlesReadViewModel.totalArticlesRead)
359359
let accessibilityLabel: String = [viewModel.localizedStrings.totalArticlesRead, viewModel.articlesReadViewModel.dateTimeLastRead, formattedAmount].joined(separator: ",")
360-
360+
361361
return cardView
362362
.accessibilityElement(children: .ignore)
363363
.accessibilityLabel(accessibilityLabel)
@@ -389,10 +389,10 @@ public struct WMFActivityTabView: View {
389389
}
390390
}
391391
)
392-
392+
393393
let formattedAmount = amountAccessibilityLabel(for: viewModel.articlesSavedViewModel.articlesSavedAmount)
394394
let accessibilityLabel: String = [viewModel.localizedStrings.articlesSavedTitle, viewModel.articlesSavedViewModel.dateTimeLastSaved, formattedAmount].joined(separator: ",")
395-
395+
396396
return cardView
397397
.accessibilityElement(children: .ignore)
398398
.accessibilityLabel(accessibilityLabel)
@@ -443,14 +443,14 @@ public struct WMFActivityTabView: View {
443443
let maxReads = weeklyReads.max() ?? 1
444444
let chartHeight: CGFloat = 45
445445
let minBarHeight: CGFloat = 4
446-
446+
447447
return VStack {
448448
Spacer(minLength: 0)
449449
HStack(alignment: .bottom, spacing: 6) {
450450
ForEach(weeklyReads.indices, id: \.self) { index in
451451
let percentage = maxReads > 0 ? CGFloat(weeklyReads[index]) / CGFloat(maxReads) : 0
452452
let barHeight = weeklyReads[index] > 0 ? chartHeight * percentage : minBarHeight
453-
453+
454454
RoundedRectangle(cornerRadius: 1.5)
455455
.fill(weeklyReads[index] > 0
456456
? Color(uiColor: theme.accent)
@@ -467,7 +467,7 @@ public struct WMFActivityTabView: View {
467467
}
468468

469469
private func topCategoriesModule(categories: [String]) -> some View {
470-
470+
471471
let cardView = WMFActivityTabInfoCardView(
472472
icon: WMFSFSymbolIcon.for(symbol: .rectangle3, font: WMFFont.boldCaption1),
473473
title: viewModel.localizedStrings.topCategories,
@@ -497,23 +497,23 @@ public struct WMFActivityTabView: View {
497497
}
498498
}
499499
)
500-
500+
501501
let accessibilityLabel = viewModel.localizedStrings.topCategories
502502
let accessibilityValue = viewModel.articlesReadViewModel.topCategories.joined(separator: ", ")
503-
503+
504504
return cardView
505505
.accessibilityElement()
506506
.accessibilityLabel(accessibilityLabel)
507507
.accessibilityValue(accessibilityValue)
508508
}
509-
509+
510510
private func amountAccessibilityLabel(for amount: Int) -> String {
511511
let numberFormatter = NumberFormatter()
512512
numberFormatter.numberStyle = .decimal
513-
513+
514514
return numberFormatter.string(from: NSNumber(value: amount)) ?? "\(amount)"
515515
}
516-
516+
517517
private func customizedEmptyState() -> some View {
518518
WMFSimpleEmptyStateView(imageName: "empty_activity_tab", openCustomize: viewModel.openCustomize, title: viewModel.localizedStrings.customizeEmptyState)
519519
.frame(maxWidth: .infinity)

0 commit comments

Comments
 (0)