You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.6 KiB
50 lines
1.6 KiB
//
|
|
// Created by Marco Schmickler on 26.01.22.
|
|
// Copyright (c) 2022 Marco Schmickler. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
struct SearchItemView: View {
|
|
@ObservedObject
|
|
var item: MediaItem
|
|
|
|
var completionHandler: (() -> Void)?
|
|
|
|
var body: some View {
|
|
VStack {
|
|
FlexibleView(
|
|
data: DatabaseManager.sharedInstance.allTags[""]!,
|
|
spacing: 15,
|
|
alignment: .leading
|
|
) { tag in
|
|
Button(action: {
|
|
if item.tags.contains(tag) {
|
|
item.tags.removeAll(where: { toRemove in toRemove == tag })
|
|
} else {
|
|
item.tags.append(tag)
|
|
}
|
|
item.objectWillChange.send()
|
|
print(tag)
|
|
}, label: {
|
|
Text(verbatim: tag)
|
|
.padding(8)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.fill(item.tags.contains(tag) ?
|
|
Color.yellow.opacity(0.4) :
|
|
Color.gray.opacity(0.2)
|
|
)
|
|
)
|
|
})
|
|
.buttonStyle(BorderlessButtonStyle())
|
|
}
|
|
Button(action: {
|
|
self.completionHandler?()
|
|
}, label: {
|
|
Text("ok")
|
|
})
|
|
}
|
|
}
|
|
}
|