mirror of
https://github.com/wallabag/ios-app.git
synced 2026-05-19 15:10:34 +00:00
b59b9e0408
* Bump version * Clean code (#393) * Mac os version (#395) * wip mac os version * Build on macos * WIP Webview * Update app icon Refacto routing * Move folder * Image list * Change badge update * Arrange entry view menu * Add refresh command * Add app Sandbox for macos + first build on macos * Fix #397 * Fix macos build * Try fix app icon * Rework toolbar entry * Fix logo * Add test on serverViewModel * Update refresh button * Clean file + clean Picker * Fix progress view * Fix delete entry on ipad fix #389 * Swiftformat * Add swipe to back fix #356 * enhance bottom button tap fix #400 * Add dismiss action in entry view fix #338 * Add sorting options only on id fix #71 * Add progress
52 lines
1.5 KiB
Swift
52 lines
1.5 KiB
Swift
#if os(iOS)
|
|
import Combine
|
|
import Factory
|
|
import Foundation
|
|
import SharedLib
|
|
import UIKit
|
|
|
|
class PasteBoardViewModel: ObservableObject {
|
|
@Published var showPasteBoardView: Bool = false {
|
|
willSet {
|
|
if newValue {
|
|
if let newPasteBoardUrl = UIPasteboard.general.url {
|
|
WallabagUserDefaults.previousPasteBoardUrl = newPasteBoardUrl.absoluteString
|
|
pasteBoardUrl = newPasteBoardUrl.absoluteString
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Published var pasteBoardUrl: String = ""
|
|
@Injected(\.wallabagSession) var session
|
|
|
|
private var cancellableNotification: AnyCancellable?
|
|
|
|
init() {
|
|
cancellableNotification = NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)
|
|
.map { _ -> Bool in
|
|
guard let pasteBoardUrl = UIPasteboard.general.url,
|
|
pasteBoardUrl.absoluteString != WallabagUserDefaults.previousPasteBoardUrl
|
|
else {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
.assign(to: \.showPasteBoardView, on: self)
|
|
}
|
|
|
|
deinit {
|
|
cancellableNotification?.cancel()
|
|
}
|
|
|
|
func addUrl() {
|
|
session.addEntry(url: pasteBoardUrl) {}
|
|
showPasteBoardView = false
|
|
}
|
|
|
|
func hide() {
|
|
showPasteBoardView = false
|
|
}
|
|
}
|
|
#endif
|