feat: add dislike report path

This commit is contained in:
CMK 2022-05-11 16:26:57 +08:00
parent 7f1b3188de
commit 16dc0adccd
3 changed files with 49 additions and 14 deletions

View File

@ -91,8 +91,16 @@ extension ReportViewController: ReportReasonViewControllerDelegate {
guard let reason = viewController.viewModel.selectReason else { return }
switch reason {
case .dislike:
// TODO:
break
let reportResultViewModel = ReportResultViewModel(
context: context,
user: viewModel.user,
isReported: false
)
coordinator.present(
scene: .reportResult(viewModel: reportResultViewModel),
from: self,
transition: .show
)
case .violateRule:
coordinator.present(
scene: .reportServerRules(viewModel: viewModel.reportServerRulesViewModel),
@ -113,7 +121,16 @@ extension ReportViewController: ReportReasonViewControllerDelegate {
extension ReportViewController: ReportServerRulesViewControllerDelegate {
func reportServerRulesViewController(_ viewController: ReportServerRulesViewController, nextButtonPressed button: UIButton) {
if viewController.viewModel.isDislike {
// TODO:
let reportResultViewModel = ReportResultViewModel(
context: context,
user: viewModel.user,
isReported: false
)
coordinator.present(
scene: .reportResult(viewModel: reportResultViewModel),
from: self,
transition: .show
)
} else if viewController.viewModel.selectRule != nil {
coordinator.present(
scene: .reportStatus(viewModel: viewModel.reportStatusViewModel),
@ -163,7 +180,8 @@ extension ReportViewController: ReportSupplementaryViewControllerDelegate {
let reportResultViewModel = ReportResultViewModel(
context: context,
user: viewModel.user
user: viewModel.user,
isReported: true
)
coordinator.present(

View File

@ -50,10 +50,16 @@ struct ReportResultView: View {
Text(viewModel.headline)
.foregroundColor(Color(Asset.Colors.Label.primary.color))
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 28, weight: .bold)) as CTFont))
avatarView
Text(verbatim: "While we review this, you can take action against @\(viewModel.username)")
.foregroundColor(Color(Asset.Colors.Label.secondary.color))
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont))
if viewModel.isReported {
avatarView
Text(verbatim: "While we review this, you can take action against @\(viewModel.username)")
.foregroundColor(Color(Asset.Colors.Label.secondary.color))
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont))
} else {
Text(verbatim: "When you see something you dont like on Mastodon, you can remove the person from your experience.")
.foregroundColor(Color(Asset.Colors.Label.secondary.color))
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont))
}
}
Spacer()
}
@ -151,7 +157,7 @@ struct ReportActionButton: View {
#if DEBUG
struct ReportResultView_Previews: PreviewProvider {
static var viewModel: ReportResultViewModel {
static func viewModel(isReported: Bool) -> ReportResultViewModel {
let context = AppContext.shared
let request = MastodonUser.sortedFetchRequest
request.fetchLimit = 1
@ -184,18 +190,24 @@ struct ReportResultView_Previews: PreviewProvider {
return ReportResultViewModel(
context: context,
user: .init(objectID: user.objectID)
user: .init(objectID: user.objectID),
isReported: isReported
)
}
static var previews: some View {
Group {
NavigationView {
ReportResultView(viewModel: viewModel)
ReportResultView(viewModel: viewModel(isReported: true))
.navigationBarTitle(Text(""))
.navigationBarTitleDisplayMode(.inline)
}
NavigationView {
ReportResultView(viewModel: viewModel)
ReportResultView(viewModel: viewModel(isReported: false))
.navigationBarTitle(Text(""))
.navigationBarTitleDisplayMode(.inline)
}
NavigationView {
ReportResultView(viewModel: viewModel(isReported: true))
.navigationBarTitle(Text(""))
.navigationBarTitleDisplayMode(.inline)
}

View File

@ -22,8 +22,11 @@ class ReportResultViewModel: ObservableObject {
// input
let context: AppContext
let user: ManagedObjectRecord<MastodonUser>
let isReported: Bool
@Published var headline = "Thanks for reporting, well look into this."
var headline: String {
isReported ? "Thanks for reporting, well look into this." : "Dont want to see this?"
}
@Published var bottomPaddingHeight: CGFloat = .zero
@Published var backgroundColor: UIColor = Asset.Scene.Report.background.color
@ -42,10 +45,12 @@ class ReportResultViewModel: ObservableObject {
init(
context: AppContext,
user: ManagedObjectRecord<MastodonUser>
user: ManagedObjectRecord<MastodonUser>,
isReported: Bool
) {
self.context = context
self.user = user
self.isReported = isReported
// end init
Task { @MainActor in