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