-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Show the waiting image in the UPL.
- Loading branch information
Showing
5 changed files
with
169 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// MediaList.swift | ||
// PhotoBook | ||
// | ||
// Created by Cosmin Mihai on 21.01.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class MediaListModel: ObservableObject | ||
{ | ||
@Published public var list: [MediaItem] = [] | ||
@Published public var selectedItem: MediaItem? = nil | ||
|
||
@State var photobook: Photobook | ||
|
||
init(photobook: Photobook) | ||
{ | ||
_photobook = State(initialValue: photobook) | ||
} | ||
|
||
public func removeSelected() | ||
{ | ||
if let index = list.firstIndex(where: {$0.path == selectedItem?.path}) | ||
{ | ||
list.remove(at: index) | ||
self.photobook.removeImportFolder(selectedItem?.path) | ||
} | ||
} | ||
} | ||
|
||
struct MediaList: View | ||
{ | ||
@State private var frameSize:CGSize | ||
@ObservedObject var model: MediaListModel | ||
|
||
private var tabViewRatio = 0.5 | ||
|
||
init(frameSize: CGSize, model: MediaListModel) | ||
{ | ||
self.frameSize = frameSize | ||
self.model = model | ||
} | ||
|
||
var body: some View { | ||
VStack | ||
{ | ||
List(model.list, id: \.self, selection: $model.selectedItem) { item in | ||
HStack | ||
{ | ||
Text("\(item.displayName)") | ||
.listRowBackground(Color.PrimaryColor) | ||
.font(.title) | ||
} | ||
.frame(height: 36) | ||
} | ||
.frame(width: frameSize.width * tabViewRatio) | ||
.scrollIndicators(.hidden) | ||
} | ||
.frame(alignment:.leading) | ||
.tag(0) | ||
.scrollIndicators(.hidden) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// UnstagedPhotoLine.swift | ||
// PhotoBook | ||
// | ||
// Created by Cosmin Mihai on 21.01.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class UnstagedPhotoLineModel: ObservableObject | ||
{ | ||
@Published public var list: [FrontendImage] = [] | ||
} | ||
|
||
struct UnstagedPhotoLine: View | ||
{ | ||
@ObservedObject var model: UnstagedPhotoLineModel | ||
|
||
init(model: UnstagedPhotoLineModel) | ||
{ | ||
self.model = model | ||
} | ||
|
||
var body: some View { | ||
ScrollView(.horizontal, showsIndicators: false) { | ||
HStack { | ||
ForEach(self.model.list, id: \.self) { item in | ||
if let fileName = item.resources().small | ||
{ | ||
if let nsImage = NSImage(contentsOfFile: fileName) { | ||
Image(nsImage: nsImage) | ||
.frame(width: 80, height: 80) | ||
} else { | ||
Text("Image not found") | ||
} | ||
} | ||
} | ||
} | ||
.padding(.horizontal) | ||
} | ||
} | ||
|
||
func getImagePath(fileName: String) -> String? { | ||
let fileManager = FileManager.default | ||
do { | ||
let documentsURL = try fileManager.url(for: .documentDirectory, | ||
in: .userDomainMask, | ||
appropriateFor: nil, | ||
create: false) | ||
return documentsURL.appendingPathComponent(fileName).path | ||
} catch { | ||
print("Error getting documents directory: \(error)") | ||
return nil | ||
} | ||
} | ||
} |