Add VibrantSelectAction and modified import and export OPML to use it

This commit is contained in:
Maurice Parker
2019-09-15 17:14:27 -05:00
parent 38200edb67
commit 984431eb01
4 changed files with 70 additions and 31 deletions

View 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) {
}
}
}

View 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
}
})
)
)
}
}