Skip to content

Commit

Permalink
ui: Allow multiple selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Feb 1, 2025
1 parent 6e02e67 commit 33fa93f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<key>All.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>sources.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>2</integer>
</dict>
</dict>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>PhotoBook.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
Expand Down
13 changes: 10 additions & 3 deletions osx/PhotoBook/PhotoBook/SPL/StagedPhotoLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct StagedPhotoLine: View
{
@ObservedObject var model: StagedPhotoLineModel
@Binding var canvasImage: FrontendImage?
@State var selectedIndex: Int = -1
@State var selectedIndices: [Int] = []

var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
Expand All @@ -30,11 +30,18 @@ struct StagedPhotoLine: View
.frame(height: 80)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(selectedIndex == index ? Color.yellow : Color.clear, lineWidth: 3)
.stroke(selectedIndices.contains(index) ? Color.yellow : Color.clear, lineWidth: 3)
)
.onTapGesture {
self.canvasImage = model.list[index]
selectedIndex = index
if selectedIndices.contains(index)
{
selectedIndices.removeAll { $0 == index }
}
else
{
selectedIndices.append(index)
}
}
} else {
Text("Image not found")
Expand Down
13 changes: 10 additions & 3 deletions osx/PhotoBook/PhotoBook/UPL/UnstagedPhotoLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct UnstagedPhotoLine: View
@ObservedObject var model: UnstagedPhotoLineModel
@Binding var canvasImage: FrontendImage?
@Binding var mediaListModel: MediaListModel
@State var selectedIndex: Int = -1
@State var selectedIndices: [Int] = []

var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
Expand All @@ -31,11 +31,18 @@ struct UnstagedPhotoLine: View
.frame(height: 80)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(selectedIndex == index ? Color.yellow : Color.clear, lineWidth: 3)
.stroke(selectedIndices.contains(index) ? Color.yellow : Color.clear, lineWidth: 3)
)
.onTapGesture {
self.canvasImage = model.list[index]
selectedIndex = index
if selectedIndices.contains(index)
{
selectedIndices.removeAll { $0 == index }
}
else
{
selectedIndices.append(index)
}
}
.onDrag {
NSItemProvider(object: UPLIdentifier(row:mediaListModel.selectedIndex(), indices:[UInt(index)]))
Expand Down

0 comments on commit 33fa93f

Please sign in to comment.