2022-02-08 05:36:06 +01:00
|
|
|
//
|
|
|
|
// ReportResultViewModel.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-2-8.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Combine
|
|
|
|
import CoreData
|
|
|
|
import CoreDataStack
|
|
|
|
import Foundation
|
|
|
|
import MastodonSDK
|
|
|
|
import os.log
|
|
|
|
import UIKit
|
2022-05-11 10:09:52 +02:00
|
|
|
import MastodonAsset
|
|
|
|
import MastodonUI
|
2022-05-11 15:10:10 +02:00
|
|
|
import MastodonLocalization
|
2022-02-08 05:36:06 +01:00
|
|
|
|
2022-05-11 10:09:52 +02:00
|
|
|
class ReportResultViewModel: ObservableObject {
|
2022-02-08 05:36:06 +01:00
|
|
|
|
|
|
|
var disposeBag = Set<AnyCancellable>()
|
|
|
|
|
|
|
|
// input
|
|
|
|
let context: AppContext
|
|
|
|
let user: ManagedObjectRecord<MastodonUser>
|
2022-05-11 10:26:57 +02:00
|
|
|
let isReported: Bool
|
2022-02-08 05:36:06 +01:00
|
|
|
|
2022-05-11 10:26:57 +02:00
|
|
|
var headline: String {
|
2022-05-11 15:10:10 +02:00
|
|
|
isReported ? L10n.Scene.Report.reportSentTitle : L10n.Scene.Report.StepFinal.dontWantToSeeThis
|
2022-05-11 10:26:57 +02:00
|
|
|
}
|
2022-05-11 10:09:52 +02:00
|
|
|
@Published var bottomPaddingHeight: CGFloat = .zero
|
|
|
|
@Published var backgroundColor: UIColor = Asset.Scene.Report.background.color
|
|
|
|
|
|
|
|
@Published var isRequestFollow = false
|
|
|
|
@Published var isRequestMute = false
|
|
|
|
@Published var isRequestBlock = false
|
|
|
|
|
2022-02-08 05:36:06 +01:00
|
|
|
// output
|
2022-05-11 10:09:52 +02:00
|
|
|
@Published var avatarURL: URL?
|
|
|
|
@Published var username: String = ""
|
|
|
|
|
|
|
|
let relationshipViewModel = RelationshipViewModel()
|
|
|
|
let muteActionPublisher = PassthroughSubject<Void, Never>()
|
|
|
|
let followActionPublisher = PassthroughSubject<Void, Never>()
|
|
|
|
let blockActionPublisher = PassthroughSubject<Void, Never>()
|
2022-02-08 05:36:06 +01:00
|
|
|
|
|
|
|
init(
|
|
|
|
context: AppContext,
|
2022-05-11 10:26:57 +02:00
|
|
|
user: ManagedObjectRecord<MastodonUser>,
|
|
|
|
isReported: Bool
|
2022-02-08 05:36:06 +01:00
|
|
|
) {
|
|
|
|
self.context = context
|
|
|
|
self.user = user
|
2022-05-11 10:26:57 +02:00
|
|
|
self.isReported = isReported
|
2022-02-08 05:36:06 +01:00
|
|
|
// end init
|
2022-05-11 10:09:52 +02:00
|
|
|
|
|
|
|
Task { @MainActor in
|
|
|
|
guard let user = user.object(in: context.managedObjectContext) else { return }
|
|
|
|
guard let me = context.authenticationService.activeMastodonAuthenticationBox.value?.authenticationRecord.object(in: context.managedObjectContext)?.user else { return }
|
|
|
|
self.relationshipViewModel.user = user
|
|
|
|
self.relationshipViewModel.me = me
|
|
|
|
|
|
|
|
self.avatarURL = user.avatarImageURL()
|
|
|
|
self.username = user.acctWithDomain
|
|
|
|
|
|
|
|
} // end Task
|
2022-02-08 05:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-05-11 10:09:52 +02:00
|
|
|
|
|
|
|
|