-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MBL-970] Report Project Info View #1852
Changes from all commits
d3b513e
c46c8d9
a23f0ed
42c426b
36f854d
c2b7914
11e5563
dcfc84e
0d4b397
73cc7a9
63adaba
9596a13
17b3898
be5c703
3a804c6
806c95d
d4a7de4
7daee5a
020ee58
256e33a
07f8d0e
0548b41
bcdf584
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import Combine | |
import KsApi | ||
import Library | ||
import Prelude | ||
import SwiftUI | ||
import UIKit | ||
|
||
public enum ProjectPageViewControllerStyles { | ||
|
@@ -379,6 +380,12 @@ public final class ProjectPageViewController: UIViewController, MessageBannerVie | |
self?.goToDashboard(param: param) | ||
} | ||
|
||
self.viewModel.outputs.goToReportProject | ||
.observeForControllerAction() | ||
.observeValues { [weak self] in | ||
self?.goToReportProject(projectUrl: $0) | ||
} | ||
|
||
self.viewModel.outputs.goToUpdates | ||
.observeForControllerAction() | ||
.observeValues { [weak self] in | ||
|
@@ -650,6 +657,15 @@ public final class ProjectPageViewController: UIViewController, MessageBannerVie | |
} | ||
} | ||
|
||
private func goToReportProject(projectUrl: String) { | ||
if #available(iOS 15, *) { | ||
let reportProjectInfoView = ReportProjectInfoView(projectUrl: projectUrl) | ||
self.viewModel.inputs.showNavigationBar(false) | ||
self.navigationController? | ||
.pushViewController(UIHostingController(rootView: reportProjectInfoView), animated: true) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we'll be releasing this with the iOS 17 upgrade? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No this is blocking our next release and needs to go out in 5.11.0. |
||
} | ||
|
||
private func goToDashboard(param: Param) { | ||
self.view.window?.rootViewController | ||
.flatMap { $0 as? RootTabBarViewController } | ||
|
@@ -813,6 +829,8 @@ extension ProjectPageViewController: UITableViewDelegate { | |
self.viewModel.inputs.tappedComments() | ||
} else if self.dataSource.indexPathIsUpdatesSubpage(indexPath) { | ||
self.viewModel.inputs.tappedUpdates() | ||
} else if self.dataSource.indexPathIsReportProject(indexPath) { | ||
self.viewModel.inputs.tappedReportProject() | ||
} | ||
case ProjectPageViewControllerDataSource.Section.faqsAskAQuestion.rawValue: | ||
self.viewModel.inputs.askAQuestionCellTapped() | ||
|
scottkicks marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import KsApi | ||
import Library | ||
import SwiftUI | ||
|
||
enum ReportProjectHyperLinkType: String, CaseIterable { | ||
case prohibitedItems | ||
case communityGuidelines | ||
|
||
func stringLiteral() -> String { | ||
switch self { | ||
case .prohibitedItems: | ||
return Strings.Prohibited_items() | ||
case .communityGuidelines: | ||
return "community guidelines" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No internationalized text for this from when Android did it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have an internationalized string for this, unfortunately. This is mainly for the hyperlink. I'm not sure how Android handles hyperlinks, but they wouldn't have an internationalized string. I'll request one from the translations team, but those may not be done by code freeze. Seems like something that shouldn't hold up this release. What do you think? |
||
} | ||
} | ||
} | ||
|
||
@available(iOS 15, *) | ||
struct ReportProjectInfoView: View { | ||
let projectUrl: String | ||
|
||
@State private var selection: Set<ReportProjectInfoListItem> = [] | ||
|
||
var body: some View { | ||
ScrollView { | ||
ForEach(listItems) { item in | ||
RowView(item: item, isExpanded: self.selection.contains(item)) | ||
.modifier(ListRowModifier()) | ||
.onTapGesture { | ||
withAnimation { | ||
self.selectDeselect(item) | ||
} | ||
} | ||
.padding(5) | ||
.animation(.linear(duration: 0.3)) | ||
} | ||
} | ||
.navigationTitle(Strings.Report_this_project()) | ||
.navigationBarTitleDisplayMode(.inline) | ||
} | ||
|
||
private func selectDeselect(_ item: ReportProjectInfoListItem) { | ||
if self.selection.contains(item) { | ||
self.selection.remove(item) | ||
} else { | ||
self.selection.insert(item) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Views | ||
|
||
@available(iOS 15, *) | ||
private struct BaseRowView: View { | ||
var item: ReportProjectInfoListItem | ||
var isExpanded: Bool = false | ||
|
||
var body: some View { | ||
HStack { | ||
VStack(spacing: 5) { | ||
Text(item.title) | ||
.font(item.type == .parent ? Font(UIFont.ksr_body()) : Font(UIFont.ksr_callout())) | ||
.bold() | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
|
||
if let hyperLink = hyperLink(in: item.subtitle) { | ||
Text(html: item.subtitle, with: hyperLink.stringLiteral()) | ||
.font(item.type == .parent ? Font(UIFont.ksr_subhead()) : Font(UIFont.ksr_footnote())) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.multilineTextAlignment(.leading) | ||
} else { | ||
Text(item.subtitle) | ||
.font(item.type == .parent ? Font(UIFont.ksr_subhead()) : Font(UIFont.ksr_footnote())) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.multilineTextAlignment(.leading) | ||
} | ||
} | ||
|
||
Spacer() | ||
|
||
Image(isExpanded ? "arrow-down" : "chevron-right") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 15, height: 15) | ||
.foregroundColor(item.type == .parent ? Color(.ksr_create_700) : Color(.ksr_support_400)) | ||
} | ||
} | ||
} | ||
|
||
@available(iOS 15, *) | ||
struct RowView: View { | ||
var item: ReportProjectInfoListItem | ||
let isExpanded: Bool | ||
|
||
private let contentSpacing = 10.0 | ||
private let contentPadding = 12.0 | ||
|
||
var body: some View { | ||
HStack { | ||
VStack(alignment: .leading) { | ||
BaseRowView(item: item, isExpanded: isExpanded) | ||
|
||
if isExpanded { | ||
ForEach(item.subItems ?? []) { item in | ||
VStack(alignment: .leading, spacing: contentSpacing) { | ||
// TODO: Push Submission Form View In MBL-971(https://kickstarter.atlassian.net/browse/MBL-971) | ||
NavigationLink(destination: { Text("submit report view") }, label: { BaseRowView(item: item) }) | ||
.buttonStyle(PlainButtonStyle()) | ||
} | ||
.padding(.vertical, 5) | ||
.padding(.leading, self.contentPadding) | ||
} | ||
} | ||
} | ||
} | ||
.padding(.trailing, 30) | ||
} | ||
} | ||
|
||
// MARK: - Private Methods | ||
|
||
/// Returns a ReportProjectHyperLinkType if the given string contains a type's string literal | ||
private func hyperLink(in string: String) -> ReportProjectHyperLinkType? { | ||
for linkType in ReportProjectHyperLinkType.allCases { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would a |
||
if string.lowercased().contains(linkType.stringLiteral().lowercased()) { | ||
return linkType | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// MARK: - Modifiers | ||
|
||
struct ListRowModifier: ViewModifier { | ||
func body(content: Content) -> some View { | ||
Group { | ||
content | ||
Divider() | ||
}.offset(x: 20) | ||
} | ||
} | ||
|
||
// MARK: - Preview | ||
|
||
@available(iOS 15, *) | ||
struct ReportProjectInfoView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ReportProjectInfoView(projectUrl: "") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be tied to the weird navigation bar behaviour in the review overview video.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look at goToComments and goToUpdates you'll see that we tell the viewmodel to hide the nav bar before pushing those onto the stack. I think this is because the project page is being presented as a sheet. If we don't manually call
self.viewModel.inputs.showNavigationBar(false)
then the project page navbar (has thex
, share, and heart icons) remains on pushed views.I'll work on getting the new view's nav title to be inline at the top, but I think this is how we need to do this for now.