2022-02-08 05:36:06 +01:00
|
|
|
//
|
|
|
|
// ReportSupplementaryViewModel.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-2-7.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import Combine
|
|
|
|
import CoreDataStack
|
|
|
|
import MastodonSDK
|
|
|
|
|
|
|
|
class ReportSupplementaryViewModel {
|
|
|
|
|
2022-05-10 12:34:39 +02:00
|
|
|
weak var delegate: ReportSupplementaryViewControllerDelegate?
|
|
|
|
|
2022-02-08 05:36:06 +01:00
|
|
|
// Input
|
|
|
|
var context: AppContext
|
|
|
|
let user: ManagedObjectRecord<MastodonUser>
|
|
|
|
let commentContext = ReportItem.CommentContext()
|
|
|
|
|
2022-05-10 12:34:39 +02:00
|
|
|
@Published var isSkip = false
|
|
|
|
@Published var isBusy = false
|
|
|
|
|
2022-02-08 05:36:06 +01:00
|
|
|
// output
|
|
|
|
var diffableDataSource: UITableViewDiffableDataSource<ReportSection, ReportItem>?
|
|
|
|
@Published var isNextButtonEnabled = false
|
|
|
|
|
|
|
|
init(
|
|
|
|
context: AppContext,
|
2022-05-10 12:34:39 +02:00
|
|
|
user: ManagedObjectRecord<MastodonUser>
|
2022-02-08 05:36:06 +01:00
|
|
|
) {
|
|
|
|
self.context = context
|
|
|
|
self.user = user
|
|
|
|
// end init
|
|
|
|
|
2022-05-10 12:53:02 +02:00
|
|
|
Publishers.CombineLatest(
|
|
|
|
commentContext.$comment,
|
|
|
|
$isBusy
|
|
|
|
)
|
|
|
|
.map { comment, isBusy -> Bool in
|
|
|
|
guard !isBusy else { return false }
|
|
|
|
return !comment.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
|
|
}
|
|
|
|
.assign(to: &$isNextButtonEnabled)
|
2022-02-08 05:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|