Skip to content

Commit 406fb90

Browse files
committed
Re-integrate customize changes
1 parent 7ed8c6a commit 406fb90

File tree

1 file changed

+112
-89
lines changed

1 file changed

+112
-89
lines changed

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

Lines changed: 112 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -21,114 +21,134 @@ public struct WMFActivityTabView: View {
2121
public var body: some View {
2222
ScrollViewReader { proxy in
2323
if viewModel.authenticationState == .loggedIn {
24-
loggedInList(proxy: proxy)
24+
if !viewModel.customizeViewModel.isTimelineOfBehaviorOn, !viewModel.customizeViewModel.isTimeSpentReadingOn, !viewModel.customizeViewModel.isEditingInsightsOn, !viewModel.customizeViewModel.isReadingInsightsOn {
25+
customizedEmptyState()
26+
} else {
27+
loggedInList(proxy: proxy)
28+
}
2529
} else {
26-
loggedOutList(proxy: proxy)
30+
if !viewModel.customizeViewModel.isTimelineOfBehaviorOn {
31+
customizedEmptyState()
32+
} else {
33+
loggedOutList(proxy: proxy)
34+
}
2735
}
2836
}
2937
}
3038

3139
private func loggedInList(proxy: ScrollViewProxy) -> some View {
3240
List {
33-
Section {
34-
VStack(spacing: 16) {
35-
headerView
36-
.accessibilityElement()
37-
.accessibilityLabel(viewModel.articlesReadViewModel.usernamesReading)
38-
.accessibilityHint(viewModel.localizedStrings.onWikipediaiOS)
39-
40-
VStack(alignment: .center, spacing: 8) {
41-
hoursMinutesRead
42-
.accessibilityLabel(viewModel.hoursMinutesRead)
43-
Text(viewModel.localizedStrings.timeSpentReading)
44-
.font(Font(WMFFont.for(.semiboldHeadline)))
45-
.foregroundColor(Color(uiColor: theme.text))
46-
.accessibilityHidden(true)
47-
}
48-
.frame(maxWidth: .infinity)
49-
.accessibilityElement()
50-
.accessibilityLabel("\(viewModel.hoursMinutesRead), \(viewModel.localizedStrings.timeSpentReading)")
41+
if viewModel.customizeViewModel.isTimeSpentReadingOn || viewModel.customizeViewModel.isReadingInsightsOn {
42+
Section {
43+
VStack(spacing: 16) {
44+
45+
if viewModel.customizeViewModel.isTimeSpentReadingOn {
46+
headerView
47+
.accessibilityElement()
48+
.accessibilityLabel(viewModel.articlesReadViewModel.usernamesReading)
49+
.accessibilityHint(viewModel.localizedStrings.onWikipediaiOS)
50+
51+
VStack(alignment: .center, spacing: 8) {
52+
hoursMinutesRead
53+
.accessibilityLabel(viewModel.hoursMinutesRead)
54+
Text(viewModel.localizedStrings.timeSpentReading)
55+
.font(Font(WMFFont.for(.semiboldHeadline)))
56+
.foregroundColor(Color(uiColor: theme.text))
57+
.accessibilityHidden(true)
58+
}
59+
.frame(maxWidth: .infinity)
60+
.accessibilityElement()
61+
.accessibilityLabel("\(viewModel.hoursMinutesRead), \(viewModel.localizedStrings.timeSpentReading)")
62+
}
63+
5164

52-
articlesReadModule(proxy: proxy)
53-
savedArticlesModule
65+
if viewModel.customizeViewModel.isReadingInsightsOn {
66+
articlesReadModule(proxy: proxy)
67+
savedArticlesModule
5468

55-
if !viewModel.articlesReadViewModel.topCategories.isEmpty {
56-
topCategoriesModule(categories: viewModel.articlesReadViewModel.topCategories)
57-
.accessibilityElement()
58-
.accessibilityLabel(viewModel.localizedStrings.topCategories)
59-
.accessibilityValue(viewModel.articlesReadViewModel.topCategories.joined(separator: ", "))
69+
if !viewModel.articlesReadViewModel.topCategories.isEmpty {
70+
topCategoriesModule(categories: viewModel.articlesReadViewModel.topCategories)
71+
.accessibilityElement()
72+
.accessibilityLabel(viewModel.localizedStrings.topCategories)
73+
.accessibilityValue(viewModel.articlesReadViewModel.topCategories.joined(separator: ", "))
74+
}
75+
}
6076
}
61-
}
62-
.padding(.horizontal, 16)
63-
.padding(.bottom, 16)
64-
.listRowInsets(EdgeInsets())
65-
.background(
66-
LinearGradient(
67-
stops: [
68-
Gradient.Stop(color: Color(uiColor: theme.paperBackground), location: 0),
69-
Gradient.Stop(color: Color(uiColor: theme.softEditorBlue), location: 1)
70-
],
71-
startPoint: .top,
72-
endPoint: .bottom
77+
.padding(.horizontal, 16)
78+
.padding(.bottom, 16)
79+
.listRowInsets(EdgeInsets())
80+
.background(
81+
LinearGradient(
82+
stops: [
83+
Gradient.Stop(color: Color(uiColor: theme.paperBackground), location: 0),
84+
Gradient.Stop(color: Color(uiColor: theme.softEditorBlue), location: 1)
85+
],
86+
startPoint: .top,
87+
endPoint: .bottom
88+
)
7389
)
74-
)
90+
}
91+
.listRowSeparator(.hidden)
7592
}
76-
.listRowSeparator(.hidden)
7793

78-
Section(header: YourImpactHeaderView(title: viewModel.localizedStrings.yourImpact)) {
79-
VStack(spacing: 16) {
80-
81-
// TODO: Uncomment here for user impact data with stub UI
82-
// if let mostViewedArticlesViewModel = viewModel.mostViewedArticlesViewModel {
83-
// MostViewedArticlesView(viewModel: mostViewedArticlesViewModel)
84-
// }
85-
//
86-
// if let contributionsViewModel = viewModel.contributionsViewModel {
87-
// ContributionsView(viewModel: contributionsViewModel)
88-
// }
89-
//
90-
// if viewModel.allTimeImpactViewModel != nil || viewModel.recentActivityViewModel != nil || viewModel.articleViewsViewModel != nil {
91-
// CombinedImpactView(allTimeImpactViewModel: viewModel.allTimeImpactViewModel, recentActivityViewModel: viewModel.recentActivityViewModel, articleViewsViewModel: viewModel.articleViewsViewModel)
92-
// }
93-
94-
if let globalEditCount = viewModel.globalEditCount, globalEditCount > 0 {
95-
totalEditsView(amount: animatedGlobalEditCount)
96-
.onAppear {
97-
if !hasShownGlobalEditsCard {
98-
hasShownGlobalEditsCard = true
99-
animatedGlobalEditCount = 0
100-
withAnimation(.easeOut(duration: 0.6)) {
94+
if viewModel.customizeViewModel.isEditingInsightsOn {
95+
Section(header: YourImpactHeaderView(title: viewModel.localizedStrings.yourImpact)) {
96+
VStack(spacing: 16) {
97+
98+
// TODO: Uncomment here for user impact data with stub UI
99+
// if let mostViewedArticlesViewModel = viewModel.mostViewedArticlesViewModel {
100+
// MostViewedArticlesView(viewModel: mostViewedArticlesViewModel)
101+
// }
102+
//
103+
// if let contributionsViewModel = viewModel.contributionsViewModel {
104+
// ContributionsView(viewModel: contributionsViewModel)
105+
// }
106+
//
107+
// if viewModel.allTimeImpactViewModel != nil || viewModel.recentActivityViewModel != nil || viewModel.articleViewsViewModel != nil {
108+
// CombinedImpactView(allTimeImpactViewModel: viewModel.allTimeImpactViewModel, recentActivityViewModel: viewModel.recentActivityViewModel, articleViewsViewModel: viewModel.articleViewsViewModel)
109+
// }
110+
111+
if let globalEditCount = viewModel.globalEditCount, globalEditCount > 0 {
112+
totalEditsView(amount: animatedGlobalEditCount)
113+
.onAppear {
114+
if !hasShownGlobalEditsCard {
115+
hasShownGlobalEditsCard = true
116+
animatedGlobalEditCount = 0
117+
withAnimation(.easeOut(duration: 0.6)) {
118+
animatedGlobalEditCount = globalEditCount
119+
}
120+
} else {
101121
animatedGlobalEditCount = globalEditCount
102122
}
103-
} else {
104-
animatedGlobalEditCount = globalEditCount
105123
}
106-
}
107-
.onChange(of: globalEditCount) { newValue in
108-
withAnimation(.easeOut(duration: 0.6)) {
109-
animatedGlobalEditCount = newValue
124+
.onChange(of: globalEditCount) { newValue in
125+
withAnimation(.easeOut(duration: 0.6)) {
126+
animatedGlobalEditCount = newValue
127+
}
110128
}
111-
}
129+
}
112130
}
113-
}
114-
.padding(.horizontal, 16)
115-
.padding(.bottom, 16)
116-
.listRowInsets(EdgeInsets())
117-
.background(
118-
LinearGradient(
119-
stops: [
120-
Gradient.Stop(color: Color(uiColor: theme.paperBackground), location: 0),
121-
Gradient.Stop(color: Color(uiColor: theme.softEditorBlue), location: 1)
122-
],
123-
startPoint: .top,
124-
endPoint: .bottom
131+
.padding(.horizontal, 16)
132+
.padding(.bottom, 16)
133+
.listRowInsets(EdgeInsets())
134+
.background(
135+
LinearGradient(
136+
stops: [
137+
Gradient.Stop(color: Color(uiColor: theme.paperBackground), location: 0),
138+
Gradient.Stop(color: Color(uiColor: theme.softEditorBlue), location: 1)
139+
],
140+
startPoint: .top,
141+
endPoint: .bottom
142+
)
125143
)
126-
)
144+
}
145+
.listRowSeparator(.hidden)
146+
}
147+
148+
if viewModel.customizeViewModel.isTimelineOfBehaviorOn {
149+
timelineSectionsList()
150+
.id("timelineSection")
127151
}
128-
.listRowSeparator(.hidden)
129-
130-
timelineSectionsList()
131-
.id("timelineSection")
132152
}
133153
.background(Color(uiColor: theme.paperBackground).edgesIgnoringSafeArea(.all))
134154
.scrollContentBackground(.hidden)
@@ -181,7 +201,6 @@ public struct WMFActivityTabView: View {
181201
}
182202
}
183203
)
184-
// .padding(.top, 20)
185204
}
186205

187206
private func timelineSectionsList() -> some View {
@@ -447,6 +466,10 @@ public struct WMFActivityTabView: View {
447466

448467
return numberFormatter.string(from: NSNumber(value: amount)) ?? "\(amount)"
449468
}
469+
470+
private func customizedEmptyState() -> some View {
471+
WMFSimpleEmptyStateView(imageName: "empty_activity_tab", openCustomize: viewModel.openCustomize, title: viewModel.localizedStrings.customizeEmptyState)
472+
}
450473
}
451474

452475
struct TimelineSectionView: View {

0 commit comments

Comments
 (0)