mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-24 09:10:59 +00:00
Remove macOS vestiges
This commit is contained in:
parent
0b0548c1de
commit
8ad4c6294c
9 changed files with 13 additions and 80 deletions
|
@ -86,19 +86,17 @@ extension AddIdentityViewModel {
|
|||
static let development = RootViewModel.development.addIdentityViewModel()
|
||||
}
|
||||
|
||||
extension MainNavigationViewModel {
|
||||
static let development = RootViewModel.development.mainNavigationViewModel!
|
||||
extension TabNavigationViewModel {
|
||||
static let development = RootViewModel.development.tabNavigationViewModel!
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
extension SecondaryNavigationViewModel {
|
||||
static let development = MainNavigationViewModel.development.secondaryNavigationViewModel()
|
||||
static let development = TabNavigationViewModel.development.secondaryNavigationViewModel()
|
||||
}
|
||||
|
||||
extension IdentitiesViewModel {
|
||||
static let development = IdentitiesViewModel(identityService: .development)
|
||||
}
|
||||
#endif
|
||||
|
||||
extension PreferencesViewModel {
|
||||
static let development = PreferencesViewModel(identityService: .development)
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
#elseif canImport(AppKit)
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
extension TimelinesEndpoint: Stubbing {
|
||||
func data(url: URL) -> Data? {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
#elseif canImport(AppKit)
|
||||
import AppKit
|
||||
#endif
|
||||
import Kingfisher
|
||||
|
||||
extension NSMutableAttributedString {
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
typealias AppDelegateType = NSApplicationDelegate
|
||||
typealias ApplicationType = NSApplication
|
||||
#else
|
||||
import UIKit
|
||||
typealias AppDelegateType = UIApplicationDelegate
|
||||
typealias ApplicationType = UIApplication
|
||||
#endif
|
||||
|
||||
import Combine
|
||||
|
||||
class AppDelegate: NSObject {
|
||||
@Published private var application: ApplicationType?
|
||||
@Published private var application: UIApplication?
|
||||
private let remoteNotificationDeviceTokens = PassthroughSubject<Data, Error>()
|
||||
}
|
||||
|
||||
|
@ -30,12 +21,7 @@ extension AppDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
extension AppDelegate: AppDelegateType {
|
||||
#if os(macOS)
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
application = notification.object as? ApplicationType
|
||||
}
|
||||
#else
|
||||
extension AppDelegate: UIApplicationDelegate {
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
|
||||
|
@ -43,15 +29,13 @@ extension AppDelegate: AppDelegateType {
|
|||
|
||||
return true
|
||||
}
|
||||
#endif
|
||||
|
||||
func application(_ application: ApplicationType,
|
||||
func application(_ application: UIApplication,
|
||||
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
||||
// this doesn't get called on macOS, need to figure out why
|
||||
remoteNotificationDeviceTokens.send(deviceToken)
|
||||
}
|
||||
|
||||
func application(_ application: ApplicationType,
|
||||
func application(_ application: UIApplication,
|
||||
didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
||||
remoteNotificationDeviceTokens.send(completion: .failure(error))
|
||||
}
|
||||
|
|
|
@ -5,11 +5,7 @@ import SwiftUI
|
|||
@main
|
||||
struct MetatextApp: App {
|
||||
// swiftlint:disable weak_delegate
|
||||
#if os(macOS)
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
#else
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
#endif
|
||||
// swiftlint:enable weak_delegate
|
||||
|
||||
private let allIdentitiesService: AllIdentitiesService = {
|
||||
|
|
|
@ -14,7 +14,7 @@ class RootViewModelTests: XCTestCase {
|
|||
identityDatabase: .fresh(),
|
||||
environment: .development),
|
||||
userNotificationService: UserNotificationService())
|
||||
let recorder = sut.$mainNavigationViewModel.record()
|
||||
let recorder = sut.$tabNavigationViewModel.record()
|
||||
|
||||
XCTAssertNil(try wait(for: recorder.next(), timeout: 1))
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import Foundation
|
|||
import Combine
|
||||
|
||||
class RootViewModel: ObservableObject {
|
||||
@Published private(set) var mainNavigationViewModel: MainNavigationViewModel?
|
||||
@Published private(set) var tabNavigationViewModel: TabNavigationViewModel?
|
||||
@Published private var mostRecentlyUsedIdentityID: UUID?
|
||||
|
||||
// swiftlint:disable weak_delegate
|
||||
|
@ -38,7 +38,7 @@ class RootViewModel: ObservableObject {
|
|||
extension RootViewModel {
|
||||
func newIdentitySelected(id: UUID?) {
|
||||
guard let id = id else {
|
||||
mainNavigationViewModel = nil
|
||||
tabNavigationViewModel = nil
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ extension RootViewModel {
|
|||
.sink { _ in } receiveValue: { _ in }
|
||||
.store(in: &cancellables)
|
||||
|
||||
mainNavigationViewModel = MainNavigationViewModel(identityService: identityService)
|
||||
tabNavigationViewModel = TabNavigationViewModel(identityService: identityService)
|
||||
}
|
||||
|
||||
func deleteIdentity(_ identity: Identity) {
|
||||
|
|
|
@ -8,15 +8,10 @@ struct AddIdentityView: View {
|
|||
|
||||
var body: some View {
|
||||
Form {
|
||||
#if os(macOS)
|
||||
Spacer()
|
||||
urlTextField
|
||||
#else
|
||||
urlTextField
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.keyboardType(.URL)
|
||||
#endif
|
||||
Group {
|
||||
if viewModel.loading {
|
||||
ProgressView()
|
||||
|
@ -28,11 +23,7 @@ struct AddIdentityView: View {
|
|||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
Button("add-identity.browse-anonymously", action: viewModel.browseAnonymouslyTapped)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
#if os(macOS)
|
||||
Spacer()
|
||||
#endif
|
||||
}
|
||||
.paddingIfMac()
|
||||
.alertItem($viewModel.alertItem)
|
||||
.onReceive(viewModel.addedIdentityID) { id in
|
||||
withAnimation {
|
||||
|
@ -48,16 +39,6 @@ extension AddIdentityView {
|
|||
}
|
||||
}
|
||||
|
||||
private extension View {
|
||||
func paddingIfMac() -> some View {
|
||||
#if os(macOS)
|
||||
return padding()
|
||||
#else
|
||||
return self
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct AddAccountView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
|
|
|
@ -2,18 +2,12 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
#if os(macOS)
|
||||
typealias MainNavigationViewModel = SidebarNavigationViewModel
|
||||
#else
|
||||
typealias MainNavigationViewModel = TabNavigationViewModel
|
||||
#endif
|
||||
|
||||
struct RootView: View {
|
||||
@StateObject var viewModel: RootViewModel
|
||||
|
||||
var body: some View {
|
||||
if let mainNavigationViewModel = viewModel.mainNavigationViewModel {
|
||||
Self.mainNavigation(mainNavigationViewModel: mainNavigationViewModel)
|
||||
if let tabNavigationViewModel = viewModel.tabNavigationViewModel {
|
||||
TabNavigationView(viewModel: tabNavigationViewModel)
|
||||
.id(UUID())
|
||||
.environmentObject(viewModel)
|
||||
.transition(.opacity)
|
||||
|
@ -25,18 +19,6 @@ struct RootView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private extension RootView {
|
||||
@ViewBuilder
|
||||
private static func mainNavigation(mainNavigationViewModel: MainNavigationViewModel) -> some View {
|
||||
#if os(macOS)
|
||||
SidebarNavigationView(viewModel: mainNavigationViewModel)
|
||||
.frame(minWidth: 900, maxWidth: .infinity, minHeight: 500, maxHeight: .infinity)
|
||||
#else
|
||||
TabNavigationView(viewModel: mainNavigationViewModel)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
|
|
Loading…
Reference in a new issue