Settings: Add AboutView and style buttons
Add a ListRowButtonView which runs a function and include a label. Use this to style magnet choice buttons. Signed-off-by: kingbri <bdashore3@gmail.com>
This commit is contained in:
parent
05d61e440a
commit
6cc9221fe4
6 changed files with 169 additions and 8 deletions
|
|
@ -11,6 +11,9 @@
|
|||
0C0D50E2288DF7700035ECC8 /* TorrentSource+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0D50E0288DF7700035ECC8 /* TorrentSource+CoreDataProperties.swift */; };
|
||||
0C0D50E5288DFE7F0035ECC8 /* SourceModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0D50E4288DFE7F0035ECC8 /* SourceModels.swift */; };
|
||||
0C0D50E7288DFF850035ECC8 /* SourceListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0D50E6288DFF850035ECC8 /* SourceListView.swift */; };
|
||||
0C32FB532890D19D002BD219 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C32FB522890D19D002BD219 /* AboutView.swift */; };
|
||||
0C32FB552890D1BF002BD219 /* UIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C32FB542890D1BF002BD219 /* UIApplication.swift */; };
|
||||
0C32FB572890D1F2002BD219 /* ListRowViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C32FB562890D1F2002BD219 /* ListRowViews.swift */; };
|
||||
0C57D4CC289032ED008534E8 /* SearchResultRDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C57D4CB289032ED008534E8 /* SearchResultRDView.swift */; };
|
||||
0C64A4B4288903680079976D /* Base32 in Frameworks */ = {isa = PBXBuildFile; productRef = 0C64A4B3288903680079976D /* Base32 */; };
|
||||
0C64A4B7288903880079976D /* KeychainSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 0C64A4B6288903880079976D /* KeychainSwift */; };
|
||||
|
|
@ -53,6 +56,9 @@
|
|||
0C0D50E0288DF7700035ECC8 /* TorrentSource+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TorrentSource+CoreDataProperties.swift"; sourceTree = "<group>"; };
|
||||
0C0D50E4288DFE7F0035ECC8 /* SourceModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceModels.swift; sourceTree = "<group>"; };
|
||||
0C0D50E6288DFF850035ECC8 /* SourceListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceListView.swift; sourceTree = "<group>"; };
|
||||
0C32FB522890D19D002BD219 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
|
||||
0C32FB542890D1BF002BD219 /* UIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplication.swift; sourceTree = "<group>"; };
|
||||
0C32FB562890D1F2002BD219 /* ListRowViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRowViews.swift; sourceTree = "<group>"; };
|
||||
0C57D4CB289032ED008534E8 /* SearchResultRDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultRDView.swift; sourceTree = "<group>"; };
|
||||
0CA05456288EE58200850554 /* SettingsSourceUrlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSourceUrlView.swift; sourceTree = "<group>"; };
|
||||
0CA05458288EE9E600850554 /* SourceManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceManager.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -152,6 +158,7 @@
|
|||
children = (
|
||||
0CA148C1288903F000DE2211 /* NavView.swift */,
|
||||
0CFEFCFC288A006200B3F490 /* GroupBoxStyle.swift */,
|
||||
0C32FB562890D1F2002BD219 /* ListRowViews.swift */,
|
||||
);
|
||||
path = CommonViews;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -170,6 +177,7 @@
|
|||
0CA148C9288903F000DE2211 /* Collection.swift */,
|
||||
0CA148CA288903F000DE2211 /* Data.swift */,
|
||||
0CA148CB288903F000DE2211 /* Task.swift */,
|
||||
0C32FB542890D1BF002BD219 /* UIApplication.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -190,6 +198,7 @@
|
|||
0CBC76FC288D914F0054BE44 /* BatchChoiceView.swift */,
|
||||
0CA148BD288903F000DE2211 /* MagnetChoiceView.swift */,
|
||||
0C0D50E6288DFF850035ECC8 /* SourceListView.swift */,
|
||||
0C32FB522890D19D002BD219 /* AboutView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -332,11 +341,13 @@
|
|||
files = (
|
||||
0CE37ABB288E4AE900428C2D /* TorrentSourceUrl+CoreDataProperties.swift in Sources */,
|
||||
0C0D50E5288DFE7F0035ECC8 /* SourceModels.swift in Sources */,
|
||||
0C32FB532890D19D002BD219 /* AboutView.swift in Sources */,
|
||||
0CA148DB288903F000DE2211 /* NavView.swift in Sources */,
|
||||
0CBC7705288DE7F40054BE44 /* PersistenceController.swift in Sources */,
|
||||
0CA0545B288EEA4E00850554 /* SourceListEditorView.swift in Sources */,
|
||||
0CA148E9288903F000DE2211 /* MainView.swift in Sources */,
|
||||
0CBC76FD288D914F0054BE44 /* BatchChoiceView.swift in Sources */,
|
||||
0C32FB552890D1BF002BD219 /* UIApplication.swift in Sources */,
|
||||
0C0D50E7288DFF850035ECC8 /* SourceListView.swift in Sources */,
|
||||
0CA148EC288903F000DE2211 /* ContentView.swift in Sources */,
|
||||
0CA148E1288903F000DE2211 /* Collection.swift in Sources */,
|
||||
|
|
@ -359,6 +370,7 @@
|
|||
0CA148E5288903F000DE2211 /* DebridManager.swift in Sources */,
|
||||
0CBC7702288DE4400054BE44 /* FerriteDB.xcdatamodeld in Sources */,
|
||||
0CA148D9288903F000DE2211 /* CardView.swift in Sources */,
|
||||
0C32FB572890D1F2002BD219 /* ListRowViews.swift in Sources */,
|
||||
0CA148EB288903F000DE2211 /* SearchResultsView.swift in Sources */,
|
||||
0CA148D7288903F000DE2211 /* LoginWebView.swift in Sources */,
|
||||
0C0D50E2288DF7700035ECC8 /* TorrentSource+CoreDataProperties.swift in Sources */,
|
||||
|
|
|
|||
27
Ferrite/Extensions/UIApplication.swift
Normal file
27
Ferrite/Extensions/UIApplication.swift
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// UIApplication.swift
|
||||
// Ferrite
|
||||
//
|
||||
// Created by Brian Dashore on 7/26/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
// Extensions to get the version/build number for AboutView
|
||||
extension UIApplication {
|
||||
var appVersion: String {
|
||||
Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
|
||||
}
|
||||
|
||||
var appBuild: String {
|
||||
Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
|
||||
}
|
||||
|
||||
var buildType: String {
|
||||
#if DEBUG
|
||||
return "Debug"
|
||||
#else
|
||||
return "Release"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
41
Ferrite/Views/AboutView.swift
Normal file
41
Ferrite/Views/AboutView.swift
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// AboutView.swift
|
||||
// Ferrite
|
||||
//
|
||||
// Created by Brian Dashore on 7/26/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct AboutView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
/*
|
||||
Image("AppImage")
|
||||
.resizable()
|
||||
.frame(width: 100, height: 100)
|
||||
.cornerRadius(25)
|
||||
*/
|
||||
|
||||
Text("Ferrite is a free and open source application developed by Brian Dashore under the GNU-GPLv3 license.")
|
||||
.padding()
|
||||
|
||||
List {
|
||||
ListRowTextView(leftText: "Version", rightText: UIApplication.shared.appVersion)
|
||||
ListRowTextView(leftText: "Build number", rightText: UIApplication.shared.appBuild)
|
||||
ListRowTextView(leftText: "Build type", rightText: UIApplication.shared.buildType)
|
||||
ListRowLinkView(text: "GitHub repository", link: "https://github.com/bdashore3/Ferrite")
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
}
|
||||
.navigationTitle("About")
|
||||
}
|
||||
}
|
||||
|
||||
struct AboutView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AboutView()
|
||||
}
|
||||
}
|
||||
75
Ferrite/Views/CommonViews/ListRowViews.swift
Normal file
75
Ferrite/Views/CommonViews/ListRowViews.swift
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
//
|
||||
// ListRowViews.swift
|
||||
// Ferrite
|
||||
//
|
||||
// Created by Brian Dashore on 7/26/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
// These views were imported from Asobi
|
||||
// View alias for a list row with an external link
|
||||
struct ListRowLinkView: View {
|
||||
let text: String
|
||||
let link: String
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Link(text, destination: URL(string: link)!)
|
||||
.foregroundColor(.primary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(systemName: "arrow.up.forward.app.fill")
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ListRowButtonView: View {
|
||||
let text: String
|
||||
let systemImage: String?
|
||||
let action: () -> Void
|
||||
|
||||
init(_ text: String, systemImage: String? = nil, action: @escaping () -> Void) {
|
||||
self.text = text
|
||||
self.systemImage = systemImage
|
||||
self.action = action
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Button(text) {
|
||||
action()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if let imageName = systemImage {
|
||||
Image(systemName: imageName)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ListRowTextView: View {
|
||||
let leftText: String
|
||||
var rightText: String?
|
||||
var rightSymbol: String?
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text(leftText)
|
||||
|
||||
Spacer()
|
||||
|
||||
if let rightText = rightText {
|
||||
Text(rightText)
|
||||
} else {
|
||||
Image(systemName: rightSymbol!)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ struct MagnetChoiceView: View {
|
|||
Form {
|
||||
if realDebridEnabled, debridManager.matchSearchResult(result: scrapingModel.selectedSearchResult) != .none {
|
||||
Section("Real Debrid options") {
|
||||
Button("Play on Outplayer") {
|
||||
ListRowButtonView("Play on Outplayer", systemImage: "arrow.up.forward.app.fill") {
|
||||
guard let downloadUrl = URL(string: "outplayer://\(debridManager.realDebridDownloadUrl)") else {
|
||||
return
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ struct MagnetChoiceView: View {
|
|||
UIApplication.shared.open(downloadUrl)
|
||||
}
|
||||
|
||||
Button("Play on VLC") {
|
||||
ListRowButtonView("Play on VLC", systemImage: "arrow.up.forward.app.fill") {
|
||||
guard let downloadUrl = URL(string: "vlc://\(debridManager.realDebridDownloadUrl)") else {
|
||||
return
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ struct MagnetChoiceView: View {
|
|||
UIApplication.shared.open(downloadUrl)
|
||||
}
|
||||
|
||||
Button("Play on Infuse") {
|
||||
ListRowButtonView("Play on Infuse", systemImage: "arrow.up.forward.app.fill") {
|
||||
guard let downloadUrl = URL(string: "infuse://x-callback-url/play?url=\(debridManager.realDebridDownloadUrl)") else {
|
||||
return
|
||||
}
|
||||
|
|
@ -48,11 +48,11 @@ struct MagnetChoiceView: View {
|
|||
UIApplication.shared.open(downloadUrl)
|
||||
}
|
||||
|
||||
Button("Copy download URL") {
|
||||
ListRowButtonView("Copy download URL", systemImage: "doc.on.doc.fill") {
|
||||
UIPasteboard.general.string = debridManager.realDebridDownloadUrl
|
||||
}
|
||||
|
||||
Button("Share download URL") {
|
||||
ListRowButtonView("Share download URL", systemImage: "square.and.arrow.up.fill") {
|
||||
guard let url = URL(string: debridManager.realDebridDownloadUrl) else {
|
||||
return
|
||||
}
|
||||
|
|
@ -64,18 +64,18 @@ struct MagnetChoiceView: View {
|
|||
}
|
||||
|
||||
Section("Magnet options") {
|
||||
Button("Copy magnet") {
|
||||
ListRowButtonView("Copy magnet", systemImage: "doc.on.doc.fill") {
|
||||
UIPasteboard.general.string = scrapingModel.selectedSearchResult?.magnetLink
|
||||
}
|
||||
|
||||
Button("Share magnet") {
|
||||
ListRowButtonView("Share magnet", systemImage: "square.and.arrow.up.fill") {
|
||||
if let result = scrapingModel.selectedSearchResult, let url = URL(string: result.magnetLink) {
|
||||
activityItem = ActivityItem(items: url)
|
||||
showActivityView.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
Button("Open in WebTor") {
|
||||
ListRowButtonView("Open in WebTor", systemImage: "arrow.up.forward.app.fill") {
|
||||
if let result = scrapingModel.selectedSearchResult,
|
||||
let url = URL(string: "https://webtor.io/#/show?magnet=\(result.magnetLink)")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ struct SettingsView: View {
|
|||
Section("Source management") {
|
||||
NavigationLink("Source lists", destination: SettingsSourceListView())
|
||||
}
|
||||
|
||||
Section {
|
||||
ListRowLinkView(text: "Report issues", link: "https://github.com/bdashore3/Ferrite/issues")
|
||||
|
||||
NavigationLink("About", destination: AboutView())
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $debridManager.showWebView) {
|
||||
LoginWebView(url: URL(string: debridManager.realDebridAuthUrl)!)
|
||||
|
|
|
|||
Loading…
Reference in a new issue