mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add VibrantSelectAction and modified import and export OPML to use it
This commit is contained in:
52
iOS/SwiftUI Extensions/SafariView.swift
Normal file
52
iOS/SwiftUI Extensions/SafariView.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SafariView.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 16/6/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import SafariServices
|
||||
|
||||
struct SafariView : UIViewControllerRepresentable {
|
||||
|
||||
let url: URL
|
||||
|
||||
func makeUIViewController(context: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
|
||||
let safari = SFSafariViewController(url: url)
|
||||
safari.delegate = context.coordinator
|
||||
return safari
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SafariView>) {
|
||||
//
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
return Coordinator(self)
|
||||
}
|
||||
|
||||
class Coordinator : NSObject, SFSafariViewControllerDelegate {
|
||||
var parent: SafariView
|
||||
|
||||
init(_ safariView: SafariView) {
|
||||
self.parent = safariView
|
||||
}
|
||||
|
||||
// MARK: SFSafariViewControllerDelegate
|
||||
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
|
||||
|
||||
}
|
||||
|
||||
func safariViewController(_ controller: SFSafariViewController, initialLoadDidRedirectTo URL: URL) {
|
||||
|
||||
}
|
||||
|
||||
func safariViewController(_ controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
iOS/SwiftUI Extensions/VibrantSelectAction.swift
Normal file
36
iOS/SwiftUI Extensions/VibrantSelectAction.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// VibrantSelectAction.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 9/15/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct VibrantSelectAction: ViewModifier {
|
||||
|
||||
let action: () -> Void
|
||||
@State var isTapped = false
|
||||
@GestureState var isLongPressed = false
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.foregroundColor(isLongPressed || isTapped ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary)
|
||||
.listRowBackground(isLongPressed || isTapped ? Color(AppAssets.tableViewCellSelectionColor) : nil)
|
||||
.gesture(
|
||||
LongPressGesture().onEnded( { _ in self.action() })
|
||||
.updating($isLongPressed) { value, state, transcation in state = value }
|
||||
.simultaneously(with:
|
||||
TapGesture().onEnded( {
|
||||
self.isTapped = true
|
||||
self.action()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
||||
self.isTapped = false
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user