mirror of
https://github.com/cranci1/Sora.git
synced 2026-01-11 20:10:24 +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?
|
||||
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 {
|
||||
ZStack {
|
||||
LinearGradient(
|
||||
|
|
@ -194,10 +201,11 @@ struct ModuleAdditionSettingsView: View {
|
|||
Button(action: addModule) {
|
||||
HStack {
|
||||
Image(systemName: "plus.circle.fill")
|
||||
Text("Add Module")
|
||||
.foregroundColor(colorScheme == .dark ? .black : .white)
|
||||
Text(moduleAlreadyExists ? "Module already added" : "Add Module")
|
||||
}
|
||||
.font(.headline)
|
||||
.foregroundColor(Color.accentColor)
|
||||
.foregroundColor(colorScheme == .dark ? .black : .white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 14)
|
||||
.background(
|
||||
|
|
@ -219,8 +227,8 @@ struct ModuleAdditionSettingsView: View {
|
|||
)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.disabled(isLoading || moduleMetadata == nil)
|
||||
.opacity(isLoading ? 0.6 : 1)
|
||||
.disabled(isLoading || moduleMetadata == nil || moduleAlreadyExists)
|
||||
.opacity(isLoading || moduleAlreadyExists ? 0.6 : 1)
|
||||
|
||||
Button(action: { presentationMode.wrappedValue.dismiss() }) {
|
||||
Text("Cancel")
|
||||
|
|
|
|||
Loading…
Reference in a new issue