mirror of
https://github.com/cranci1/Sora.git
synced 2026-05-19 00:01:48 +00:00
fixed module addition view
This commit is contained in:
parent
b686c452cd
commit
9b610a3b16
1 changed files with 12 additions and 4 deletions
|
|
@ -18,6 +18,13 @@ struct ModuleAdditionSettingsView: View {
|
||||||
@State private var errorMessage: String?
|
@State private var errorMessage: String?
|
||||||
var moduleUrl: String
|
var moduleUrl: String
|
||||||
|
|
||||||
|
private var moduleAlreadyExists: Bool {
|
||||||
|
if let metadata = moduleMetadata {
|
||||||
|
return moduleManager.modules.contains(where: { $0.metadata.sourceName == metadata.sourceName })
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
LinearGradient(
|
LinearGradient(
|
||||||
|
|
@ -194,10 +201,11 @@ struct ModuleAdditionSettingsView: View {
|
||||||
Button(action: addModule) {
|
Button(action: addModule) {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "plus.circle.fill")
|
Image(systemName: "plus.circle.fill")
|
||||||
Text("Add Module")
|
.foregroundColor(colorScheme == .dark ? .black : .white)
|
||||||
|
Text(moduleAlreadyExists ? "Module already added" : "Add Module")
|
||||||
}
|
}
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(Color.accentColor)
|
.foregroundColor(colorScheme == .dark ? .black : .white)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
.padding(.vertical, 14)
|
.padding(.vertical, 14)
|
||||||
.background(
|
.background(
|
||||||
|
|
@ -219,8 +227,8 @@ struct ModuleAdditionSettingsView: View {
|
||||||
)
|
)
|
||||||
.padding(.horizontal, 20)
|
.padding(.horizontal, 20)
|
||||||
}
|
}
|
||||||
.disabled(isLoading || moduleMetadata == nil)
|
.disabled(isLoading || moduleMetadata == nil || moduleAlreadyExists)
|
||||||
.opacity(isLoading ? 0.6 : 1)
|
.opacity(isLoading || moduleAlreadyExists ? 0.6 : 1)
|
||||||
|
|
||||||
Button(action: { presentationMode.wrappedValue.dismiss() }) {
|
Button(action: { presentationMode.wrappedValue.dismiss() }) {
|
||||||
Text("Cancel")
|
Text("Cancel")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue