-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MBL-1457] Create empty state view for PPO (#2092)
* Create PPO empty state view Fix accessibility * Add snapshot test * Wire up button
- Loading branch information
Showing
6 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Kickstarter-iOS/Features/PledgedProjectsOverview/PPOEmptyStateView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import SwiftUI | ||
|
||
struct PPOEmptyStateView: View { | ||
weak var tabBarController: RootTabBarViewController? | ||
|
||
private enum Constants { | ||
public static let largePadding = 24.0 | ||
public static let horizontalPadding = 16.0 | ||
public static let verticalButtonPadding = 13.0 | ||
public static let buttonRadius = 12.0 | ||
} | ||
|
||
// TODO: Translate these strings (MBL-1558) | ||
var body: some View { | ||
VStack(alignment: .center) { | ||
Text("You're all caught up!") | ||
.font(Font(UIFont.ksr_title2().bolded)) | ||
.padding(EdgeInsets( | ||
top: 0, | ||
leading: Constants.horizontalPadding, | ||
bottom: Constants.largePadding, | ||
trailing: Constants.horizontalPadding | ||
)) | ||
.multilineTextAlignment(.center) | ||
.accessibilityAddTraits(.isHeader) | ||
|
||
VStack(spacing: Constants.largePadding) { | ||
Text("When projects you've backed need your attention, you'll see them here.") | ||
.font(Font(UIFont.ksr_body())) | ||
.multilineTextAlignment(.center) | ||
|
||
Button { | ||
self.tabBarController?.switchToProfile() | ||
} label: { | ||
Text("See all backed projects") | ||
.frame(maxWidth: .infinity) | ||
} | ||
.padding(EdgeInsets( | ||
top: Constants.verticalButtonPadding, | ||
leading: Constants.horizontalPadding, | ||
bottom: Constants.verticalButtonPadding, | ||
trailing: Constants.horizontalPadding | ||
)) | ||
.foregroundColor(.white) | ||
.background( | ||
Color(UIColor.ksr_create_700), | ||
in: RoundedRectangle(cornerRadius: Constants.buttonRadius) | ||
) | ||
.font(Font(UIFont.ksr_body())) | ||
} | ||
.padding(EdgeInsets( | ||
top: 0, | ||
leading: Constants.largePadding, | ||
bottom: 0, | ||
trailing: Constants.largePadding | ||
)) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
PPOEmptyStateView() | ||
} |
12 changes: 12 additions & 0 deletions
12
Kickstarter-iOS/Features/PledgedProjectsOverview/PPOEmptyStateViewTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@testable import Kickstarter_Framework | ||
import SnapshotTesting | ||
import SwiftUI | ||
import XCTest | ||
|
||
final class PPOEmptyStateViewTests: TestCase { | ||
func testEmptyStateView() { | ||
let view = PPOEmptyStateView().frame(width: 320, height: 500) | ||
// TODO: Record multiple snapshots once translations are available (MBL-1558) | ||
assertSnapshot(matching: view, as: .image, named: "lang_en") | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
Kickstarter-iOS/Features/PledgedProjectsOverview/PPOView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+40.1 KB
...ctsOverview/__Snapshots__/PPOEmptyStateViewTests/testEmptyStateView.lang_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters