Ferrite: Format

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2023-04-08 23:47:34 -04:00
parent eacccf36ff
commit 9427ca271b
14 changed files with 62 additions and 64 deletions

View file

@ -1 +1 @@
5.7
5.8

View file

@ -7,8 +7,8 @@
import SwiftUI
extension Color {
public init(hex: String) {
public extension Color {
init(hex: String) {
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int: UInt64 = 0
Scanner(string: hex).scanHexInt64(&int)
@ -28,7 +28,7 @@ extension Color {
.sRGB,
red: Double(r) / 255,
green: Double(g) / 255,
blue: Double(b) / 255,
blue: Double(b) / 255,
opacity: Double(a) / 255
)
}

View file

@ -10,6 +10,6 @@ import UIKit
extension UIApplication {
// From https://stackoverflow.com/questions/69650504/how-to-get-rid-of-message-windows-was-deprecated-in-ios-15-0-use-uiwindowsc
var currentUIWindow: UIWindow? {
return UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }
UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }
}
}

View file

@ -725,7 +725,8 @@ class ScrapingViewModel: ObservableObject {
// A capture group must be used in the provided regex
if let regexString,
let parsedValue {
let parsedValue
{
return runRegex(parsedValue: parsedValue, regexString: regexString)
} else {
return parsedValue
@ -922,7 +923,8 @@ class ScrapingViewModel: ObservableObject {
}
if let parsedValue,
let regexString {
let regexString
{
return runRegex(parsedValue: parsedValue, regexString: regexString)
} else {
return parsedValue

View file

@ -16,16 +16,16 @@ struct NavView<Content: View>: View {
var body: some View {
// Uncomment once NavigationStack issues are fixed
/*
if #available(iOS 16, *) {
NavigationStack {
content
}
} else {
*/
NavigationView {
content
}
.navigationViewStyle(.stack)
//}
if #available(iOS 16, *) {
NavigationStack {
content
}
} else {
*/
NavigationView {
content
}
.navigationViewStyle(.stack)
// }
}
}

View file

@ -58,7 +58,7 @@ struct PluginCatalogButtonView<PJ: PluginJson>: View {
)
.padding(.horizontal, 7)
.padding(.vertical, 5)
.background(Color.init(uiColor: .tertiarySystemBackground))
.background(Color(uiColor: .tertiarySystemBackground))
.clipShape(RoundedRectangle(cornerRadius: 10))
}
.buttonStyle(.borderless)

View file

@ -38,8 +38,7 @@ struct PluginAggregateView<P: Plugin, PJ: PluginJson>: View {
installedPlugins: installedPlugins,
searchText: searchText
)
if !filteredUpdatedPlugins.isEmpty
{
if !filteredUpdatedPlugins.isEmpty {
Section(header: InlineHeader("Updates")) {
ForEach(filteredUpdatedPlugins, id: \.self) { (updatedPlugin: PJ) in
PluginCatalogButtonView(availablePlugin: updatedPlugin, needsUpdate: true)
@ -59,14 +58,12 @@ struct PluginAggregateView<P: Plugin, PJ: PluginJson>: View {
}
}
let filteredAvailablePlugins = pluginManager.fetchFilteredPlugins(
forType: PJ.self,
installedPlugins: installedPlugins,
searchText: searchText
)
if !filteredAvailablePlugins.isEmpty
{
if !filteredAvailablePlugins.isEmpty {
Section(header: InlineHeader("Catalog")) {
ForEach(filteredAvailablePlugins, id: \.self) { availablePlugin in
PluginCatalogButtonView(availablePlugin: availablePlugin, needsUpdate: false)

View file

@ -133,7 +133,7 @@ struct SearchResultButtonView: View {
} message: {
Text(
"RealDebrid is currently caching this file. Would you like to delete it? \n\n" +
"Progress can be checked on the RealDebrid website."
"Progress can be checked on the RealDebrid website."
)
}
.onReceive(NotificationCenter.default.publisher(for: .didDeleteBookmark)) { notification in

View file

@ -17,7 +17,7 @@ struct ContentView: View {
@AppStorage("Behavior.AutocorrectSearch") var autocorrectSearch: Bool = false
@State private var isSearching = false
@State private var dismissAction: () -> () = {}
@State private var dismissAction: () -> Void = {}
var body: some View {
NavView {
@ -47,7 +47,7 @@ struct ContentView: View {
sources: sources,
debridManager: debridManager
)
logManager.hideIndeterminateToast()
scrapingModel.runningSearchTask = nil
}

View file

@ -71,6 +71,7 @@ struct MainView: View {
Application.shared.osVersion.toString() >= Application.shared.minVersion
{
// MARK: If scope bar duplication happens, this may be the problem
// Sleep for 2 seconds to allow for view layout and app init
try? await Task.sleep(seconds: 2)

View file

@ -9,32 +9,30 @@ import SwiftUI
public extension View {
// A dismissAction must be added in the parent view struct due to lifecycle issues
func expandedSearchable<Content: View>(
text: Binding<String>,
isSearching: Binding<Bool>? = nil,
prompt: String? = nil,
dismiss: Binding<(() -> ())>? = nil,
scopeBarContent: @escaping () -> Content = {
EmptyView()
},
onSubmit: (() -> ())? = nil,
onCancel: (() -> ())? = nil
) -> some View {
self
.overlay(
SearchBar(
searchText: text,
isSearching: isSearching ?? Binding(get: { true }, set: { _, _ in }),
prompt: prompt ?? "Search",
dismiss: dismiss ?? Binding(get: { {} }, set: { _, _ in }),
scopeBarContent: scopeBarContent,
onSubmit: onSubmit,
onCancel: onCancel
)
.frame(width: 0, height: 0)
func expandedSearchable(text: Binding<String>,
isSearching: Binding<Bool>? = nil,
prompt: String? = nil,
dismiss: Binding<() -> Void>? = nil,
scopeBarContent: @escaping () -> some View = {
EmptyView()
},
onSubmit: (() -> Void)? = nil,
onCancel: (() -> Void)? = nil) -> some View
{
overlay(
SearchBar(
searchText: text,
isSearching: isSearching ?? Binding(get: { true }, set: { _, _ in }),
prompt: prompt ?? "Search",
dismiss: dismiss ?? Binding(get: { {} }, set: { _, _ in }),
scopeBarContent: scopeBarContent,
onSubmit: onSubmit,
onCancel: onCancel
)
.environment(\.esIsSearching, isSearching?.wrappedValue ?? false)
.environment(\.esDismissSearch, ESDismissSearchAction(action: dismiss?.wrappedValue ?? { }))
.frame(width: 0, height: 0)
)
.environment(\.esIsSearching, isSearching?.wrappedValue ?? false)
.environment(\.esDismissSearch, ESDismissSearchAction(action: dismiss?.wrappedValue ?? {}))
}
func esAutocapitalization(_ autocapitalizationType: UITextAutocapitalizationType) -> some View {
@ -47,9 +45,9 @@ struct ESIsSearching: EnvironmentKey {
}
struct ESDismissSearchAction: EnvironmentKey {
static var defaultValue: ESDismissSearchAction = ESDismissSearchAction(action: {})
static var defaultValue: ESDismissSearchAction = .init(action: {})
let action: () -> ()
let action: () -> Void
func callAsFunction() {
action()
@ -78,7 +76,7 @@ extension EnvironmentValues {
}
struct SearchBar<ScopeContent: View>: UIViewControllerRepresentable {
var searchController: UISearchController = UISearchController(searchResultsController: nil)
var searchController: UISearchController = .init(searchResultsController: nil)
@Environment(\.autocorrectionDisabled) var autocorrectionDisabled
@Environment(\.esAutocapitalizationType) var autocapitalization
@ -87,10 +85,10 @@ struct SearchBar<ScopeContent: View>: UIViewControllerRepresentable {
@Binding var searchText: String
@Binding var isSearching: Bool
var prompt: String
@Binding var dismiss: (() -> ())
@Binding var dismiss: () -> Void
let scopeBarContent: () -> ScopeContent
let onSubmit: (() -> ())?
let onCancel: (() -> ())?
let onSubmit: (() -> Void)?
let onCancel: (() -> Void)?
class Coordinator: NSObject, UISearchBarDelegate, UISearchResultsUpdating {
let parent: SearchBar
@ -123,7 +121,7 @@ struct SearchBar<ScopeContent: View>: UIViewControllerRepresentable {
}
func makeCoordinator() -> Coordinator {
return Coordinator(self)
Coordinator(self)
}
func makeUIViewController(context: Context) -> NavSearchBarWrapper {
@ -186,7 +184,7 @@ struct SearchBar<ScopeContent: View>: UIViewControllerRepresentable {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewWillAppear(_ animated: Bool) {
setup()
}

View file

@ -13,6 +13,6 @@ struct ShareSheet: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIActivityViewController {
UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
}

View file

@ -51,7 +51,7 @@ struct SettingsView: View {
}
Section(header: InlineHeader("Playback services")) {
NavigationLink{
NavigationLink {
SettingsKodiView(kodiServers: kodiServers)
} label: {
HStack {

View file

@ -39,7 +39,7 @@ struct BatchChoiceView: View {
if file.fileName.lowercased().contains(searchText.lowercased()) || searchText.isEmpty {
Button(file.fileName) {
debridManager.selectedAllDebridFile = file
queueCommonDownload(fileName: file.fileName)
}
}
@ -49,7 +49,7 @@ struct BatchChoiceView: View {
if file.name.lowercased().contains(searchText.lowercased()) || searchText.isEmpty {
Button(file.name) {
debridManager.selectedPremiumizeFile = file
queueCommonDownload(fileName: file.name)
}
}