Skip to content

Commit

Permalink
ui: Exclusive UPL/SPL selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Feb 1, 2025
1 parent 33fa93f commit 424c77d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions osx/PhotoBook/PhotoBook/Pages/TableContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions osx/PhotoBook/PhotoBook/SPL/StagedPhotoLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
13 changes: 8 additions & 5 deletions osx/PhotoBook/PhotoBook/UPL/UnstagedPhotoLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ import SwiftUI
class UnstagedPhotoLineModel: ObservableObject
{
@Published public var list: [FrontendImage] = []
@State var selectedIndices: [Int] = []
}

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) {
Expand All @@ -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 {
Expand Down

0 comments on commit 424c77d

Please sign in to comment.