-
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.
- Loading branch information
Showing
8 changed files
with
132 additions
and
15 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,45 @@ | ||
// | ||
// LutGrid.swift | ||
// PhotoBook | ||
// | ||
// Created by Cosmin Mihai on 25.01.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LutGrid: View | ||
{ | ||
@State private var frameSize:CGSize | ||
@ObservedObject var model: LutGridModel | ||
|
||
private var tabViewRatio = 0.5 | ||
|
||
init(frameSize: CGSize, model: LutGridModel) | ||
{ | ||
self.frameSize = frameSize | ||
self.model = model | ||
} | ||
|
||
var body: some View { | ||
ScrollView { | ||
LazyVGrid(columns: model.columns, spacing: 10) { | ||
ForEach(self.model.images, id: \.self) { item in | ||
if let fileName = item.path | ||
{ | ||
if let nsImage = NSImage(contentsOfFile: fileName) { | ||
Image(nsImage: nsImage) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(height: 80) | ||
} else { | ||
Text("Image not found") | ||
} | ||
} | ||
} | ||
} | ||
.frame(width: frameSize.width * tabViewRatio) | ||
} | ||
.frame(alignment:.leading) | ||
.tag(2) | ||
} | ||
} |
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,26 @@ | ||
// | ||
// LutGridModel.swift | ||
// PhotoBook | ||
// | ||
// Created by Cosmin Mihai on 25.01.2025. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class LutGridModel: ObservableObject | ||
{ | ||
@State var photobook: Photobook | ||
@Published public var images:[LutItem] = [] | ||
|
||
// TODO: Do a flexible calculation here | ||
@Published public var columns = [ | ||
GridItem(.flexible()), | ||
GridItem(.flexible()), | ||
GridItem(.flexible()) | ||
] | ||
|
||
init(photobook: Photobook) | ||
{ | ||
_photobook = State(initialValue: photobook) | ||
} | ||
} |
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,25 @@ | ||
// | ||
// LutItem.h | ||
// PhotoBook | ||
// | ||
// Created by Cosmin Mihai on 25.01.2025. | ||
// | ||
|
||
#ifndef LutItem_h | ||
#define LutItem_h | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#if __cplusplus | ||
#include <pb/entities/LutIconInfo.h> | ||
#endif | ||
|
||
@interface LutItem : NSObject | ||
@property (nonatomic, strong) NSString* path; | ||
@property (nonatomic, strong) NSString* name; | ||
#if __cplusplus | ||
- (id)initWithCpp:(PB::LutIconInfo)lutIconInfo; | ||
#endif | ||
@end | ||
|
||
#endif /* LutItem_h */ |
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,17 @@ | ||
// | ||
// LutItem.mm | ||
// PhotoBook | ||
// | ||
// Created by Cosmin Mihai on 25.01.2025. | ||
// | ||
|
||
#include "LutItem.h" | ||
|
||
@implementation LutItem | ||
- (id)initWithCpp:(PB::LutIconInfo)lutIconInfo; | ||
{ | ||
self.name = [NSString stringWithUTF8String:lutIconInfo.name.c_str()]; | ||
self.path = [NSString stringWithUTF8String:lutIconInfo.path.c_str()]; | ||
return self; | ||
} | ||
@end |
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