forked from zelo72/mastodon-ios
feat: add dislike report path
This commit is contained in:
parent
7f1b3188de
commit
16dc0adccd
|
@ -91,8 +91,16 @@ extension ReportViewController: ReportReasonViewControllerDelegate {
|
||||||
guard let reason = viewController.viewModel.selectReason else { return }
|
guard let reason = viewController.viewModel.selectReason else { return }
|
||||||
switch reason {
|
switch reason {
|
||||||
case .dislike:
|
case .dislike:
|
||||||
// TODO:
|
let reportResultViewModel = ReportResultViewModel(
|
||||||
break
|
context: context,
|
||||||
|
user: viewModel.user,
|
||||||
|
isReported: false
|
||||||
|
)
|
||||||
|
coordinator.present(
|
||||||
|
scene: .reportResult(viewModel: reportResultViewModel),
|
||||||
|
from: self,
|
||||||
|
transition: .show
|
||||||
|
)
|
||||||
case .violateRule:
|
case .violateRule:
|
||||||
coordinator.present(
|
coordinator.present(
|
||||||
scene: .reportServerRules(viewModel: viewModel.reportServerRulesViewModel),
|
scene: .reportServerRules(viewModel: viewModel.reportServerRulesViewModel),
|
||||||
|
@ -113,7 +121,16 @@ extension ReportViewController: ReportReasonViewControllerDelegate {
|
||||||
extension ReportViewController: ReportServerRulesViewControllerDelegate {
|
extension ReportViewController: ReportServerRulesViewControllerDelegate {
|
||||||
func reportServerRulesViewController(_ viewController: ReportServerRulesViewController, nextButtonPressed button: UIButton) {
|
func reportServerRulesViewController(_ viewController: ReportServerRulesViewController, nextButtonPressed button: UIButton) {
|
||||||
if viewController.viewModel.isDislike {
|
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 {
|
} else if viewController.viewModel.selectRule != nil {
|
||||||
coordinator.present(
|
coordinator.present(
|
||||||
scene: .reportStatus(viewModel: viewModel.reportStatusViewModel),
|
scene: .reportStatus(viewModel: viewModel.reportStatusViewModel),
|
||||||
|
@ -163,7 +180,8 @@ extension ReportViewController: ReportSupplementaryViewControllerDelegate {
|
||||||
|
|
||||||
let reportResultViewModel = ReportResultViewModel(
|
let reportResultViewModel = ReportResultViewModel(
|
||||||
context: context,
|
context: context,
|
||||||
user: viewModel.user
|
user: viewModel.user,
|
||||||
|
isReported: true
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator.present(
|
coordinator.present(
|
||||||
|
|
|
@ -50,10 +50,16 @@ struct ReportResultView: View {
|
||||||
Text(viewModel.headline)
|
Text(viewModel.headline)
|
||||||
.foregroundColor(Color(Asset.Colors.Label.primary.color))
|
.foregroundColor(Color(Asset.Colors.Label.primary.color))
|
||||||
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 28, weight: .bold)) as CTFont))
|
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 28, weight: .bold)) as CTFont))
|
||||||
avatarView
|
if viewModel.isReported {
|
||||||
Text(verbatim: "While we review this, you can take action against @\(viewModel.username)")
|
avatarView
|
||||||
.foregroundColor(Color(Asset.Colors.Label.secondary.color))
|
Text(verbatim: "While we review this, you can take action against @\(viewModel.username)")
|
||||||
.font(Font(UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) as CTFont))
|
.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 don’t 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()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
@ -151,7 +157,7 @@ struct ReportActionButton: View {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
struct ReportResultView_Previews: PreviewProvider {
|
struct ReportResultView_Previews: PreviewProvider {
|
||||||
|
|
||||||
static var viewModel: ReportResultViewModel {
|
static func viewModel(isReported: Bool) -> ReportResultViewModel {
|
||||||
let context = AppContext.shared
|
let context = AppContext.shared
|
||||||
let request = MastodonUser.sortedFetchRequest
|
let request = MastodonUser.sortedFetchRequest
|
||||||
request.fetchLimit = 1
|
request.fetchLimit = 1
|
||||||
|
@ -184,18 +190,24 @@ struct ReportResultView_Previews: PreviewProvider {
|
||||||
|
|
||||||
return ReportResultViewModel(
|
return ReportResultViewModel(
|
||||||
context: context,
|
context: context,
|
||||||
user: .init(objectID: user.objectID)
|
user: .init(objectID: user.objectID),
|
||||||
|
isReported: isReported
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
ReportResultView(viewModel: viewModel)
|
ReportResultView(viewModel: viewModel(isReported: true))
|
||||||
.navigationBarTitle(Text(""))
|
.navigationBarTitle(Text(""))
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
}
|
}
|
||||||
NavigationView {
|
NavigationView {
|
||||||
ReportResultView(viewModel: viewModel)
|
ReportResultView(viewModel: viewModel(isReported: false))
|
||||||
|
.navigationBarTitle(Text(""))
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
}
|
||||||
|
NavigationView {
|
||||||
|
ReportResultView(viewModel: viewModel(isReported: true))
|
||||||
.navigationBarTitle(Text(""))
|
.navigationBarTitle(Text(""))
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,11 @@ class ReportResultViewModel: ObservableObject {
|
||||||
// input
|
// input
|
||||||
let context: AppContext
|
let context: AppContext
|
||||||
let user: ManagedObjectRecord<MastodonUser>
|
let user: ManagedObjectRecord<MastodonUser>
|
||||||
|
let isReported: Bool
|
||||||
|
|
||||||
@Published var headline = "Thanks for reporting, we’ll look into this."
|
var headline: String {
|
||||||
|
isReported ? "Thanks for reporting, we’ll look into this." : "Don’t want to see this?"
|
||||||
|
}
|
||||||
@Published var bottomPaddingHeight: CGFloat = .zero
|
@Published var bottomPaddingHeight: CGFloat = .zero
|
||||||
@Published var backgroundColor: UIColor = Asset.Scene.Report.background.color
|
@Published var backgroundColor: UIColor = Asset.Scene.Report.background.color
|
||||||
|
|
||||||
|
@ -42,10 +45,12 @@ class ReportResultViewModel: ObservableObject {
|
||||||
|
|
||||||
init(
|
init(
|
||||||
context: AppContext,
|
context: AppContext,
|
||||||
user: ManagedObjectRecord<MastodonUser>
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
|
isReported: Bool
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.user = user
|
self.user = user
|
||||||
|
self.isReported = isReported
|
||||||
// end init
|
// end init
|
||||||
|
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
|
|
Loading…
Reference in New Issue