diff --git a/osx/PhotoBook/PhotoBook/Pages/TableContentView.swift b/osx/PhotoBook/PhotoBook/Pages/TableContentView.swift index 551d8871..fef75e91 100644 --- a/osx/PhotoBook/PhotoBook/Pages/TableContentView.swift +++ b/osx/PhotoBook/PhotoBook/Pages/TableContentView.swift @@ -266,7 +266,7 @@ struct TableContentView: View, PhotobookUIListener { VStack { ScrollView(.horizontal, showsIndicators: false) { HStack { - StagedPhotoLine(model: splModel, canvasImage: $canvasModel.mainImage) + StagedPhotoLine(model: splModel, canvasImage: $canvasModel.mainImage, unstagedPhotoLineModel: $uplModel) } .frame(width:geometry.size.width, height: 80) .border(Color.BorderColor, width: 1) @@ -311,7 +311,7 @@ struct TableContentView: View, PhotobookUIListener { } } - UnstagedPhotoLine(model: uplModel, canvasImage: $canvasModel.mainImage, mediaListModel: $mediaListModel) + UnstagedPhotoLine(model: uplModel, canvasImage: $canvasModel.mainImage, mediaListModel: $mediaListModel, stagedPhotoLineModel: $splModel) } .frame(height: geometry.size.height * 0.3) diff --git a/osx/PhotoBook/PhotoBook/SPL/StagedPhotoLine.swift b/osx/PhotoBook/PhotoBook/SPL/StagedPhotoLine.swift index 7227b80f..9eb2932f 100644 --- a/osx/PhotoBook/PhotoBook/SPL/StagedPhotoLine.swift +++ b/osx/PhotoBook/PhotoBook/SPL/StagedPhotoLine.swift @@ -10,13 +10,14 @@ import SwiftUI class StagedPhotoLineModel: ObservableObject { @Published public var list: [FrontendImage] = [] + @State var selectedIndices: [Int] = [] } struct StagedPhotoLine: View { @ObservedObject var model: StagedPhotoLineModel @Binding var canvasImage: FrontendImage? - @State var selectedIndices: [Int] = [] + @Binding var unstagedPhotoLineModel: UnstagedPhotoLineModel var body: some View { ScrollView(.horizontal, showsIndicators: false) { @@ -30,17 +31,18 @@ struct StagedPhotoLine: View .frame(height: 80) .overlay( RoundedRectangle(cornerRadius: 10) - .stroke(selectedIndices.contains(index) ? Color.yellow : Color.clear, lineWidth: 3) + .stroke(model.selectedIndices.contains(index) ? Color.yellow : Color.clear, lineWidth: 3) ) .onTapGesture { self.canvasImage = model.list[index] - if selectedIndices.contains(index) + unstagedPhotoLineModel.list.removeAll() + if model.selectedIndices.contains(index) { - selectedIndices.removeAll { $0 == index } + model.selectedIndices.removeAll { $0 == index } } else { - selectedIndices.append(index) + model.selectedIndices.append(index) } } } else { diff --git a/osx/PhotoBook/PhotoBook/UPL/UnstagedPhotoLine.swift b/osx/PhotoBook/PhotoBook/UPL/UnstagedPhotoLine.swift index 10912d1e..fd814fa5 100644 --- a/osx/PhotoBook/PhotoBook/UPL/UnstagedPhotoLine.swift +++ b/osx/PhotoBook/PhotoBook/UPL/UnstagedPhotoLine.swift @@ -10,6 +10,7 @@ import SwiftUI class UnstagedPhotoLineModel: ObservableObject { @Published public var list: [FrontendImage] = [] + @State var selectedIndices: [Int] = [] } struct UnstagedPhotoLine: View @@ -17,7 +18,8 @@ struct UnstagedPhotoLine: View @ObservedObject var model: UnstagedPhotoLineModel @Binding var canvasImage: FrontendImage? @Binding var mediaListModel: MediaListModel - @State var selectedIndices: [Int] = [] + @Binding var stagedPhotoLineModel: StagedPhotoLineModel + var body: some View { ScrollView(.horizontal, showsIndicators: false) { @@ -31,17 +33,18 @@ struct UnstagedPhotoLine: View .frame(height: 80) .overlay( RoundedRectangle(cornerRadius: 10) - .stroke(selectedIndices.contains(index) ? Color.yellow : Color.clear, lineWidth: 3) + .stroke(model.selectedIndices.contains(index) ? Color.yellow : Color.clear, lineWidth: 3) ) .onTapGesture { self.canvasImage = model.list[index] - if selectedIndices.contains(index) + stagedPhotoLineModel.list.removeAll() + if model.selectedIndices.contains(index) { - selectedIndices.removeAll { $0 == index } + model.selectedIndices.removeAll { $0 == index } } else { - selectedIndices.append(index) + model.selectedIndices.append(index) } } .onDrag {