Skip to content

Commit 5b2ecce

Browse files
author
golson
committed
Simple empty state
1 parent bfd88f7 commit 5b2ecce

File tree

2 files changed

+50
-27
lines changed

2 files changed

+50
-27
lines changed

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -434,33 +434,7 @@ public struct WMFActivityTabView: View {
434434
}
435435

436436
private func customizedEmptyState() -> some View {
437-
VStack {
438-
Spacer()
439-
if let image = UIImage(named: "empty_activity_tab", in: .module, with: nil) {
440-
Image(uiImage: image)
441-
.resizable()
442-
.aspectRatio(contentMode: .fill)
443-
.frame(width: 132, height: 118)
444-
}
445-
WMFHtmlText(html: viewModel.localizedStrings.customizeEmptyState, styles: summaryStyles)
446-
.padding(.top, 12)
447-
.padding(.bottom, 8)
448-
.multilineTextAlignment(.center)
449-
.overlay(
450-
Rectangle()
451-
.fill(Color.clear)
452-
.contentShape(Rectangle())
453-
.onTapGesture {
454-
viewModel.openCustomize()
455-
}
456-
)
457-
Spacer()
458-
}
459-
.padding(.horizontal, 16)
460-
}
461-
462-
private var summaryStyles: HtmlUtils.Styles {
463-
return HtmlUtils.Styles(font: WMFFont.for(.subheadline), boldFont: WMFFont.for(.boldSubheadline), italicsFont: WMFFont.for(.italicSubheadline), boldItalicsFont: WMFFont.for(.boldItalicSubheadline), color: theme.text, linkColor: theme.link, lineSpacing: 3)
437+
WMFSimpleEmptyStateView(imageName: "empty_activity_tab", openCustomize: viewModel.openCustomize, title: viewModel.localizedStrings.customizeEmptyState)
464438
}
465439
}
466440

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import SwiftUI
2+
3+
public struct WMFSimpleEmptyStateView: View {
4+
@ObservedObject var appEnvironment = WMFAppEnvironment.current
5+
var theme: WMFTheme {
6+
return appEnvironment.theme
7+
}
8+
9+
private let imageName: String
10+
private var openCustomize: () -> Void
11+
private let title: String
12+
13+
public init(imageName: String, openCustomize: @escaping () -> Void, title: String) {
14+
self.imageName = imageName
15+
self.openCustomize = openCustomize
16+
self.title = title
17+
}
18+
19+
public var body: some View {
20+
VStack {
21+
Spacer()
22+
if let image = UIImage(named: imageName, in: .module, with: nil) {
23+
Image(uiImage: image)
24+
.resizable()
25+
.aspectRatio(contentMode: .fill)
26+
.frame(width: 132, height: 118)
27+
}
28+
WMFHtmlText(html: title, styles: summaryStyles)
29+
.padding(.top, 12)
30+
.padding(.bottom, 8)
31+
.multilineTextAlignment(.center)
32+
.overlay(
33+
Rectangle()
34+
.fill(Color.clear)
35+
.contentShape(Rectangle())
36+
.onTapGesture {
37+
openCustomize()
38+
}
39+
)
40+
Spacer()
41+
}
42+
.padding(.horizontal, 16)
43+
.background(Color(uiColor: theme.paperBackground))
44+
}
45+
46+
private var summaryStyles: HtmlUtils.Styles {
47+
return HtmlUtils.Styles(font: WMFFont.for(.subheadline), boldFont: WMFFont.for(.boldSubheadline), italicsFont: WMFFont.for(.italicSubheadline), boldItalicsFont: WMFFont.for(.boldItalicSubheadline), color: theme.text, linkColor: theme.link, lineSpacing: 3)
48+
}
49+
}

0 commit comments

Comments
 (0)