little adjustement to the module add view

This commit is contained in:
cranci1 2025-02-02 09:30:24 +01:00
parent ae692907bd
commit 182244b708
2 changed files with 114 additions and 87 deletions

View file

@ -18,99 +18,124 @@ struct ModuleAdditionSettingsView: View {
var moduleUrl: String
var body: some View {
ScrollView {
VStack {
if let metadata = moduleMetadata {
VStack(spacing: 25) {
VStack(spacing: 15) {
KFImage(URL(string: metadata.iconUrl))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 120, height: 120)
.clipShape(Circle())
.shadow(radius: 5)
.transition(.scale)
VStack {
ScrollView {
VStack {
if let metadata = moduleMetadata {
VStack(spacing: 25) {
VStack(spacing: 15) {
KFImage(URL(string: metadata.iconUrl))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 120, height: 120)
.clipShape(Circle())
.shadow(radius: 5)
.transition(.scale)
Text(metadata.sourceName)
.font(.system(size: 28, weight: .bold))
.multilineTextAlignment(.center)
}
.padding(.top)
Text(metadata.sourceName)
.font(.system(size: 28, weight: .bold))
Divider()
HStack(spacing: 15) {
KFImage(URL(string: metadata.author.icon))
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 60, height: 60)
.clipShape(Circle())
.shadow(radius: 3)
VStack(alignment: .leading, spacing: 4) {
Text(metadata.author.name)
.font(.headline)
Text("Author")
.font(.subheadline)
.foregroundColor(.secondary)
}
Spacer()
}
.padding(.horizontal)
Divider()
VStack(alignment: .leading, spacing: 12) {
InfoRow(title: "Version", value: metadata.version)
InfoRow(title: "Language", value: metadata.language)
InfoRow(title: "Quality", value: metadata.quality)
InfoRow(title: "Stream Typed", value: metadata.streamType)
InfoRow(title: "Base URL", value: metadata.baseUrl)
.onLongPressGesture {
UIPasteboard.general.string = metadata.baseUrl
DropManager.shared.showDrop(title: "Copied to Clipboard", subtitle: "", duration: 1.0, icon: UIImage(systemName: "doc.on.clipboard.fill"))
}
InfoRow(title: "Script URL", value: metadata.scriptUrl)
.onLongPressGesture {
UIPasteboard.general.string = metadata.scriptUrl
DropManager.shared.showDrop(title: "Copied to Clipboard", subtitle: "", duration: 1.0, icon: UIImage(systemName: "doc.on.clipboard.fill"))
}
}
.padding(.horizontal)
}
Divider()
} else if isLoading {
VStack(spacing: 20) {
ProgressView()
.scaleEffect(1.5)
Text("Loading module information...")
.foregroundColor(.secondary)
}
.frame(maxHeight: .infinity)
.padding(.top, 100)
} else if let errorMessage = errorMessage {
VStack(spacing: 20) {
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 50))
.foregroundColor(.red)
Text(errorMessage)
.foregroundColor(.red)
.multilineTextAlignment(.center)
}
.padding(.top)
Divider()
HStack(spacing: 15) {
KFImage(URL(string: metadata.author.icon))
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 60, height: 60)
.clipShape(Circle())
.shadow(radius: 3)
VStack(alignment: .leading, spacing: 4) {
Text(metadata.author.name)
.font(.headline)
Text("Author")
.font(.subheadline)
.foregroundColor(.secondary)
}
Spacer()
}
.padding(.horizontal)
Divider()
VStack(alignment: .leading, spacing: 12) {
InfoRow(title: "Version", value: metadata.version)
InfoRow(title: "Language", value: metadata.language)
InfoRow(title: "Base URL", value: metadata.baseUrl)
InfoRow(title: "Script URL", value: metadata.scriptUrl)
}
.padding(.horizontal)
.frame(maxHeight: .infinity)
.padding(.top, 100)
}
Divider()
Button(action: addModule) {
HStack {
Image(systemName: "plus.circle.fill")
Text("Add Module")
}
.font(.headline)
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.padding()
.background(
RoundedRectangle(cornerRadius: 15)
.fill(Color.accentColor)
)
.padding(.horizontal)
}
.disabled(isLoading)
.opacity(isLoading ? 0.6 : 1)
} else if isLoading {
VStack(spacing: 20) {
ProgressView()
.scaleEffect(1.5)
Text("Loading module information...")
.foregroundColor(.secondary)
}
.frame(maxHeight: .infinity)
.padding(.top, 100)
} else if let errorMessage = errorMessage {
VStack(spacing: 20) {
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 50))
.foregroundColor(.red)
Text(errorMessage)
.foregroundColor(.red)
.multilineTextAlignment(.center)
}
.frame(maxHeight: .infinity)
.padding(.top, 100)
}
}
Spacer()
VStack {
Button(action: addModule) {
HStack {
Image(systemName: "plus.circle.fill")
Text("Add Module")
}
.font(.headline)
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.padding()
.background(
RoundedRectangle(cornerRadius: 15)
.fill(Color.accentColor)
)
.padding(.horizontal)
}
.disabled(isLoading)
.opacity(isLoading ? 0.6 : 1)
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}) {
Text("Cancel")
.foregroundColor(.accentColor)
.padding(.top, 10)
}
}
.padding(.bottom, 20)
}
.navigationTitle("Add Module")
.onAppear(perform: fetchModuleMetadata)

View file

@ -14,6 +14,8 @@ struct ModuleMetadata: Codable, Hashable {
let version: String
let language: String
let baseUrl: String
let streamType: String
let quality: String
let searchBaseUrl: String
let scriptUrl: String
let asyncJS: Bool?