Skip to content

Commit

Permalink
Fix: Responsive components
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed Oct 29, 2023
1 parent 393e0aa commit 45e95a7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
3 changes: 3 additions & 0 deletions PhotosProcessor/Views/Features/CompressImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import SwiftUI

struct CompressImageView: View {
@StateObject var processImage = ProcessImage.shared

@State private var isStatusPopoverShown = false
@State var showingLogSheetID = ""

Expand Down Expand Up @@ -104,6 +106,7 @@ struct CompressImageView: View {
} label: {
Label("Start Compressing", systemImage: "play")
}
.disabled(!processImage.inited)
}
ToolbarItem {
Button {
Expand Down
47 changes: 27 additions & 20 deletions PhotosProcessor/Views/Features/ModifyMetadataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ let supportArea: [String] = [


struct ModifyMetadataView: View {
@StateObject var processImage = ProcessImage.shared

enum ModifyType: String {
case copy = "Copy"
Expand Down Expand Up @@ -169,11 +170,11 @@ struct ModifyMetadataView: View {
Label("Image Metadata", systemImage: "info.circle")
}
.help("Image Metadata")
.disabled(processImage.inited == false || processImage.imageMetadata == nil)
.disabled(!processImage.inited)
}
ToolbarItem {
Button {
if (processImage.inited == false || processImage.imageMetadata == nil) {
if (!processImage.inited) {
return
}
let _ = processImage.imageMetadata!.syncImageDate(path: processImage.imageMetadata!.url!.path)
Expand All @@ -182,12 +183,12 @@ struct ModifyMetadataView: View {
Label("Sync DateTimeOriginal to CreateDate", systemImage: "arrow.clockwise")
}
.help("Sync DateTimeOriginal to CreateDate")
.disabled(processImage.inited == false || processImage.imageMetadata == nil)
.disabled(!processImage.inited)
}
// Start Modify
ToolbarItem {
Button {
if (processImage.inited == false || processImage.imageMetadata == nil) {
if (!processImage.inited) {
return
}
// set blur radius to 10 gradually
Expand Down Expand Up @@ -237,17 +238,21 @@ struct ModifyMetadataView: View {
}
}
} label: {
Label("Modify", systemImage: "hammer")
Label("Modify", systemImage: "play")
}
.help("Modify")
.disabled(processImage.inited == false || processImage.imageMetadata == nil)
.disabled(!processImage.inited)
}
}
}
}

var leftColumn: some View {
ImageUniversalView()
ImageUniversalView(
dropAction: { url in
updateProcessMetadataValue()
}
)
.blur(radius: CGFloat(imageViewBlurRadius))
}

Expand Down Expand Up @@ -276,7 +281,7 @@ struct ModifyMetadataView: View {
.onChange(of: copyFromKey) { _ in
updateProcessMetadataValue()
}

.disabled(!processImage.inited)
.help("Copy from")
Text("Select a metadata key to copy from.")
.font(.caption)
Expand All @@ -289,6 +294,7 @@ struct ModifyMetadataView: View {
Text("Input").tag("Input")
}
.pickerStyle(SegmentedPickerStyle())
.disabled(!processImage.inited)
// .frame(width: 300, height: 30)
.onChange(of: processMetadataKeyInputType) { newValue in
if newValue == "Input" {
Expand All @@ -303,7 +309,7 @@ struct ModifyMetadataView: View {
.foregroundColor(.secondary)
if processMetadataKeyInputType == "Input" {
TextField("Process metadata key", text: $processMetadataKey)

.disabled(!processImage.inited)
.help("Process metadata key")
// .onChange(of: processMetadataKey) { _ in
// updateProcessMetadataValue()
Expand All @@ -319,7 +325,7 @@ struct ModifyMetadataView: View {
}
.pickerStyle(MenuPickerStyle())
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Process metadata key")
.onChange(of: processMetadataKey) { _ in
updateProcessMetadataValue()
Expand All @@ -337,7 +343,7 @@ struct ModifyMetadataView: View {
Text("Input").tag("Input")
}
.pickerStyle(SegmentedPickerStyle())
// .frame(width: 300, height: 30)
.disabled(!processImage.inited)
.onChange(of: processMetadataKeyInputType) { newValue in
if newValue == "Input" {
processMetadataKey = ""
Expand All @@ -353,7 +359,7 @@ struct ModifyMetadataView: View {
if processMetadataKeyInputType == "Input" {
TextField("New metadata key", text: $processMetadataKey)
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("New metadata key")
// .onChange(of: processMetadataKey) { _ in
// updateProcessMetadataValue()
Expand All @@ -369,7 +375,7 @@ struct ModifyMetadataView: View {
}
.pickerStyle(MenuPickerStyle())
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Metadata key")
.onChange(of: processMetadataKey) { _ in
updateProcessMetadataValue()
Expand All @@ -384,7 +390,7 @@ struct ModifyMetadataView: View {
.font(.system(size: 12, design: .monospaced))
.background(Color(NSColor.textBackgroundColor))
.frame(height: 100)

.disabled(!processImage.inited)
.help("Metadata value")
// .onChange(of: newProcessMetadataValue) { _ in
// updateProcessMetadataValue()
Expand All @@ -399,7 +405,7 @@ struct ModifyMetadataView: View {
Text("Input").tag("Input")
}
.pickerStyle(SegmentedPickerStyle())
// .frame(width: 300, height: 30)
.disabled(!processImage.inited)
.onChange(of: processMetadataKeyInputType) { newValue in
if newValue == "Input" {
processMetadataKey = ""
Expand All @@ -415,7 +421,7 @@ struct ModifyMetadataView: View {
if processMetadataKeyInputType == "Input" {
TextField("Metadata key", text: $processMetadataKey)
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Metadata key")
// .onChange(of: processMetadataKey) { _ in
// updateProcessMetadataValue()
Expand All @@ -431,7 +437,7 @@ struct ModifyMetadataView: View {
}
.pickerStyle(MenuPickerStyle())
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Metadata key")
.onChange(of: processMetadataKey) { _ in
updateProcessMetadataValue()
Expand All @@ -447,6 +453,7 @@ struct ModifyMetadataView: View {
Text("Picker").tag("Picker")
Text("Input").tag("Input")
}
.disabled(!processImage.inited)
.pickerStyle(SegmentedPickerStyle())
// .frame(width: 300, height: 30)
.onChange(of: processMetadataKeyInputType) { newValue in
Expand All @@ -463,7 +470,7 @@ struct ModifyMetadataView: View {
if processMetadataKeyInputType == "Input" {
TextField("Metadata key", text: $processMetadataKey)
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Metadata key")
} else {
Picker("Metadata key", selection: $processMetadataKey) {
Expand All @@ -473,13 +480,13 @@ struct ModifyMetadataView: View {
}
.pickerStyle(MenuPickerStyle())
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Metadata key")
}

TextField("Metadata value", text: $newProcessMetadataValue)
// .frame(width: 300, height: 30)

.disabled(!processImage.inited)
.help("Metadata value")
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A multi-functional picture processor software for macOS. Written in Swift.
- [x] Image compression **``** | **`🔧 Improving`**
- [x] Modify image metadata **``** | **`🔧 Improving`****`🐛 Bug Occurred`**
- [ ] Image dark watermark support **`⏳ In Progress.`** | **`❓ Need help.`**
- [ ] Menu bar ite
- [ ] Menu bar item
- [ ] GPS location fix **`⏳ In Progress.`** | **`❓ Need help.`**
- [ ] Stitching images
- [ ] DAMA
Expand Down

0 comments on commit 45e95a7

Please sign in to comment.