chore: isolate ASDK build

This commit is contained in:
CMK 2021-06-22 13:41:40 +08:00
parent 2c21f00183
commit 0a622f6ca8
29 changed files with 549 additions and 229 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@
<key>CoreDataStack.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>31</integer>
<integer>39</integer>
</dict>
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
<dict>
@ -37,7 +37,7 @@
<key>NotificationService.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>30</integer>
<integer>40</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>

View File

@ -48,8 +48,10 @@ extension SceneCoordinator {
case mastodonResendEmail(viewModel: MastodonResendEmailViewModel)
case mastodonWebView(viewModel:WebViewModel)
#if ASDK
// ASDK
case asyncHome
#endif
// compose
case compose(viewModel: ComposeViewModel)
@ -239,9 +241,11 @@ private extension SceneCoordinator {
let _viewController = WebViewController()
_viewController.viewModel = viewModel
viewController = _viewController
#if ASDK
case .asyncHome:
let _viewController = AsyncHomeTimelineViewController()
viewController = _viewController
#endif
case .compose(let viewModel):
let _viewController = ComposeViewController()
_viewController.viewModel = viewModel

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-19.
//
#if ASDK
import UIKit
import AsyncDisplayKit
import DifferenceKit
@ -79,3 +81,5 @@ extension ASTableNode: ReloadableTableView {
}
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-19.
//
#if ASDK
import UIKit
import AsyncDisplayKit
import DiffableDataSources
@ -109,3 +111,5 @@ open class TableNodeDiffableDataSource<SectionIdentifierType: Hashable, ItemIden
return block
}
}
#endif

View File

@ -11,9 +11,12 @@ import CoreDataStack
import os.log
import UIKit
import AVKit
import AsyncDisplayKit
import Nuke
#if ASDK
import AsyncDisplayKit
#endif
protocol StatusCell: DisposeBagCollectable {
var statusView: StatusView { get }
var pollCountdownSubscription: AnyCancellable? { get set }
@ -24,6 +27,7 @@ enum StatusSection: Equatable, Hashable {
}
extension StatusSection {
#if ASDK
static func tableNodeDiffableDataSource(
tableNode: ASTableNode,
managedObjectContext: NSManagedObjectContext
@ -49,7 +53,7 @@ extension StatusSection {
}
}
}
#endif
static func tableViewDiffableDataSource(
for tableView: UITableView,

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-20.
//
#if ASDK
import Foundation
import ActiveLabel
@ -14,3 +16,5 @@ extension StatusNodeDelegate where Self: StatusProvider {
StatusProviderFacade.responseToStatusActiveLabelAction(provider: self, node: node, didSelectActiveEntityType: type)
}
}
#endif

View File

@ -9,7 +9,10 @@ import UIKit
import Combine
import CoreData
import CoreDataStack
#if ASDK
import AsyncDisplayKit
#endif
protocol StatusProvider: NeedsDependency & DisposeBagCollectable & UIViewController {
// async
@ -23,11 +26,15 @@ protocol StatusProvider: NeedsDependency & DisposeBagCollectable & UIViewControl
func item(for cell: UITableViewCell?, indexPath: IndexPath?) -> Item?
func items(indexPaths: [IndexPath]) -> [Item]
#if ASDK
func status(node: ASCellNode?, indexPath: IndexPath?) -> Status?
#endif
}
#if ASDK
extension StatusProvider {
func status(node: ASCellNode?, indexPath: IndexPath?) -> Status? {
fatalError("Needs implement this")
}
}
#endif

View File

@ -12,7 +12,10 @@ import CoreData
import CoreDataStack
import MastodonSDK
import ActiveLabel
#if ASDK
import AsyncDisplayKit
#endif
enum StatusProviderFacade { }
@ -146,6 +149,7 @@ extension StatusProviderFacade {
}
}
#if ASDK
static func responseToStatusActiveLabelAction(provider: StatusProvider, node: ASCellNode, didSelectActiveEntityType type: ActiveEntityType) {
switch type {
case .hashtag(let text, _):
@ -175,6 +179,7 @@ extension StatusProviderFacade {
guard let status = provider.status(node: node, indexPath: nil) else { return }
coordinateToStatusMentionProfileScene(for: target, provider: provider, status: status, mention: mention)
}
#endif
private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, cell: UITableViewCell, mention: String) {
provider.status(for: cell, indexPath: nil)

View File

@ -5,12 +5,12 @@
// Created by MainasuK Cirno on 2021-6-21.
//
#if ASDK && DEBUG
import os.log
import UIKit
import CoreData
import CoreDataStack
#if DEBUG
import FLEX
extension AsyncHomeTimelineViewController {
@ -25,10 +25,6 @@ extension AsyncHomeTimelineViewController {
guard let self = self else { return }
self.showFLEXAction(action)
}),
UIAction(title: "Toggle Home", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] action in
guard let self = self else { return }
self.context.toggleHomePreference(action)
}),
moveMenu,
dropMenu,
UIAction(title: "Show Welcome", image: UIImage(systemName: "figure.walk"), attributes: []) { [weak self] action in
@ -384,4 +380,5 @@ extension AsyncHomeTimelineViewController {
.store(in: &disposeBag)
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by MainasuK Cirno on 2021-6-21.
//
#if ASDK
import os.log
import UIKit
import Combine
@ -111,3 +113,5 @@ extension AsyncHomeTimelineViewController: StatusProvider {
}
extension AsyncHomeTimelineViewController: UserProvider {}
#endif

View File

@ -5,6 +5,8 @@
// Created by MainasuK Cirno on 2021-6-21.
//
#if ASDK
import os.log
import UIKit
import AVKit
@ -56,16 +58,6 @@ final class AsyncHomeTimelineViewController: ASDKViewController<ASTableNode>, Ne
}()
var tableView: UITableView { node.view }
//let tableView: UITableView = {
// let tableView = ControlContainableTableView()
// tableView.register(StatusTableViewCell.self, forCellReuseIdentifier: String(describing: StatusTableViewCell.self))
// tableView.register(TimelineMiddleLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineMiddleLoaderTableViewCell.self))
// tableView.register(TimelineBottomLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self))
// tableView.rowHeight = UITableView.automaticDimension
// tableView.separatorStyle = .none
// tableView.backgroundColor = .clear
// return tableView
//}()
let publishProgressView: UIProgressView = {
let progressView = UIProgressView(progressViewStyle: .bar)
@ -116,25 +108,10 @@ extension AsyncHomeTimelineViewController {
// long press to trigger debug menu
settingBarButtonItem.menu = debugMenu
PerformanceMonitor.shared().delegate = self
#else
settingBarButtonItem.target = self
settingBarButtonItem.action = #selector(AsyncHomeTimelineViewController.settingBarButtonItemPressed(_:))
#endif
settingBarButtonItem.menu = UIMenu(title: "Toggle Home", image: nil, identifier: nil, options: [], children: [
UIAction(title: "Setting", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] _ in
guard let self = self else { return }
self.settingBarButtonItemPressed(self.settingBarButtonItem)
}),
UIAction(title: "Toggle Home", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] action in
guard let self = self else { return }
self.context.toggleHomePreference(action)
let alertController = UIAlertController(title: "Please Restart App", message: nil, preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(okAction)
self.coordinator.present(scene: .alertController(alertController: alertController), from: nil, transition: .alertController(animated: true, completion: nil))
})
])
navigationItem.rightBarButtonItem = composeBarButtonItem
composeBarButtonItem.target = self
@ -604,3 +581,5 @@ extension AsyncHomeTimelineViewController: ASTableDelegate {
// MARK: - StatusNodeDelegate
extension AsyncHomeTimelineViewController: StatusNodeDelegate { }
#endif

View File

@ -5,6 +5,8 @@
// Created by MainasuK Cirno on 2021-6-21.
//
#if ASDK
import os.log
import UIKit
import CoreData
@ -153,3 +155,5 @@ extension AsyncHomeTimelineViewModel: NSFetchedResultsControllerDelegate {
}
}
#endif

View File

@ -6,6 +6,8 @@
//
//
#if ASDK
import os.log
import func QuartzCore.CACurrentMediaTime
import Foundation
@ -128,3 +130,5 @@ extension AsyncHomeTimelineViewModel.LoadLatestState {
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by MainasuK Cirno on 2021-6-21.
//
#if ASDK
import os.log
import Foundation
import GameplayKit
@ -106,3 +108,5 @@ extension AsyncHomeTimelineViewModel.LoadMiddleState {
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by MainasuK Cirno on 2021-6-21.
//
#if ASDK
import os.log
import Foundation
import GameplayKit
@ -111,3 +113,5 @@ extension AsyncHomeTimelineViewModel.LoadOldestState {
}
}
}
#endif

View File

@ -6,6 +6,8 @@
//
//
#if ASDK
import os.log
import func AVFoundation.AVMakeRect
import UIKit
@ -146,3 +148,5 @@ final class AsyncHomeTimelineViewModel: NSObject {
}
extension AsyncHomeTimelineViewModel: SuggestionAccountViewModelDelegate { }
#endif

View File

@ -25,10 +25,6 @@ extension HomeTimelineViewController {
guard let self = self else { return }
self.showFLEXAction(action)
}),
UIAction(title: "Toggle Home", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] action in
guard let self = self else { return }
self.context.toggleHomePreference(action)
}),
moveMenu,
dropMenu,
UIAction(title: "Show Welcome", image: UIImage(systemName: "figure.walk"), attributes: []) { [weak self] action in

View File

@ -15,10 +15,6 @@ import GameplayKit
import MastodonSDK
import AlamofireImage
#if DEBUG
import GDPerformanceView_Swift
#endif
final class HomeTimelineViewController: UIViewController, NeedsDependency, MediaPreviewableViewController {
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
@ -102,22 +98,6 @@ extension HomeTimelineViewController {
#if DEBUG
// long press to trigger debug menu
settingBarButtonItem.menu = debugMenu
PerformanceMonitor.shared().delegate = self
#elseif ASDK
settingBarButtonItem.menu = UIMenu(title: "Toggle Home", image: nil, identifier: nil, options: [], children: [
UIAction(title: "Setting", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] _ in
guard let self = self else { return }
self.settingBarButtonItemPressed(self.settingBarButtonItem)
}),
UIAction(title: "Show Async Home", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off, handler: { [weak self] action in
guard let self = self else { return }
self.context.toggleHomePreference(action)
let alertController = UIAlertController(title: "Please Restart App", message: nil, preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(okAction)
self.coordinator.present(scene: .alertController(alertController: alertController), from: nil, transition: .alertController(animated: true, completion: nil))
})
])
#else
settingBarButtonItem.target = self
settingBarButtonItem.action = #selector(HomeTimelineViewController.settingBarButtonItemPressed(_:))
@ -578,11 +558,3 @@ extension HomeTimelineViewController: StatusTableViewControllerNavigateable {
statusKeyCommandHandler(sender)
}
}
#if DEBUG
extension HomeTimelineViewController: PerformanceMonitorDelegate {
func performanceMonitor(didReport performanceReport: PerformanceReport) {
// print(performanceReport)
}
}
#endif

View File

@ -10,6 +10,10 @@ import UIKit
import Combine
import SafariServices
#if DEBUG
import GDPerformanceView_Swift
#endif
class MainTabBarController: UITabBarController {
var disposeBag = Set<AnyCancellable>()
@ -186,6 +190,14 @@ extension MainTabBarController {
.store(in: &disposeBag)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
#if DEBUG
PerformanceMonitor.shared().start()
#endif
}
}
extension MainTabBarController {
@ -345,3 +357,33 @@ extension MainTabBarController {
}
}
#if ASDK
extension MainTabBarController {
override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
guard let event = event else { return }
switch event.subtype {
case .motionShake:
let alertController = UIAlertController(title: "ASDK Debug Panel", message: nil, preferredStyle: .alert)
let toggleHomeAction = UIAlertAction(title: "Toggle Home", style: .default) { [weak self] _ in
guard let self = self else { return }
MainTabBarController.toggleAsyncHome()
let okAlertController = UIAlertController(title: "Success", message: "Please restart the app", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
okAlertController.addAction(okAction)
self.coordinator.present(scene: .alertController(alertController: okAlertController), from: nil, transition: .alertController(animated: true, completion: nil))
}
alertController.addAction(toggleHomeAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
self.coordinator.present(scene: .alertController(alertController: alertController), from: nil, transition: .alertController(animated: true, completion: nil))
default:
break
}
}
static func toggleAsyncHome() {
UserDefaults.shared.preferAsyncHomeTimeline.toggle()
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-20.
//
#if ASDK
import UIKit
import AsyncDisplayKit
@ -19,3 +21,5 @@ final class ASMetaEditableTextNode: ASEditableTextNode, UITextViewDelegate {
return metaEditableTextNodeDelegate?.metaEditableTextNode(self, shouldInteractWith: URL, in: characterRange, interaction: interaction) ?? false
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-19.
//
#if ASDK
import UIKit
import Combine
import AsyncDisplayKit
@ -235,3 +237,5 @@ extension StatusNode: ASMultiplexImageNodeDataSource {
}
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-19.
//
#if ASDK
import UIKit
import AsyncDisplayKit
@ -35,3 +37,5 @@ final class TimelineBottomLoaderNode: ASCellNode {
}
}
#endif

View File

@ -5,6 +5,8 @@
// Created by Cirno MainasuK on 2021-6-19.
//
#if ASDK
import UIKit
import AsyncDisplayKit
@ -48,3 +50,5 @@ final class TimelineMiddleLoaderNode: ASCellNode {
}
}
#endif

View File

@ -211,9 +211,3 @@ extension AppContext {
}
}
extension AppContext {
@objc func toggleHomePreference(_ action: UIAction) {
UserDefaults.shared.preferAsyncHomeTimeline.toggle()
}
}

View File

@ -9,12 +9,15 @@ import os.log
import UIKit
import UserNotifications
import AppShared
import AsyncDisplayKit
#if DEBUG
import GDPerformanceView_Swift
#endif
#if ASDK
import AsyncDisplayKit
#endif
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
@ -32,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
UNUserNotificationCenter.current().delegate = self
application.registerForRemoteNotifications()
#if DEBUG
#if ASDK && DEBUG
// PerformanceMonitor.shared().start()
// ASDisplayNode.shouldShowRangeDebugOverlay = true
// ASControlNode.enableHitTestDebug = true

View File

@ -1,5 +1,7 @@
// ref: https://github.com/Adlai-Holler/ASDKPlaceholderTest/blob/eea9fa7cff2d16a57efb47d208422ea9b49a630a/ASDKPlaceholderTest/ASDisplayNodeSubclasses.swift
#if ASDK
import Foundation
import AsyncDisplayKit
import UIKit
@ -69,3 +71,5 @@ class ActivityIndicatorNode: ASDisplayNode {
}
}
}
#endif

View File

@ -8,7 +8,7 @@ target 'Mastodon' do
# UI
pod 'UITextField+Shake', '~> 1.2'
pod 'Texture', '~> 3.0.0'
pod 'Texture', '~> 3.0.0', :configurations => ['ASDK - Debug', 'ASDK - Release']
# misc
pod 'SwiftGen', '~> 6.4.0'
@ -16,8 +16,8 @@ target 'Mastodon' do
pod 'Kanna', '~> 5.2.2'
# DEBUG
pod 'FLEX', '~> 4.4.0', :configurations => ['Debug']
pod 'GDPerformanceView-Swift', '~> 2.1.1', :configurations => ['Debug']
pod 'FLEX', '~> 4.4.0', :configurations => ['Debug', 'ASDK - Debug']
pod 'GDPerformanceView-Swift', '~> 2.1.1', :configurations => ['Debug', 'ASDK - Debug']
target 'MastodonTests' do
inherit! :search_paths

View File

@ -82,6 +82,6 @@ SPEC CHECKSUMS:
Texture: 2f109e937850d94d1d07232041c9c7313ccddb81
"UITextField+Shake": 298ac5a0f239d731bdab999b19b628c956ca0ac3
PODFILE CHECKSUM: ffa234348a25b078905180858ee4119fec0712d1
PODFILE CHECKSUM: a0d0a385a2888802244e7841940a7d5a55315e1f
COCOAPODS: 1.10.1