Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed May 27, 2024
1 parent b9d9ab1 commit 63d8c5c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
12 changes: 6 additions & 6 deletions Dev/Sources/SwiftUIDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ struct ContentView: View {
})
}

NavigationLink("Custom Filter") {
DemoFilterView(editingStack: {
horizontalStack
})
}

NavigationLink("Isolated", destination: IsolatedEditinView())

if #available(iOS 16, *) {
Expand All @@ -36,6 +30,12 @@ struct ContentView: View {
}
}

NavigationLink("Custom Filter") {
DemoFilterView(editingStack: {
horizontalStack
})
}

Section("Restoration Horizontal") {
Button("Crop") {
fullScreenView = .init {
Expand Down
23 changes: 8 additions & 15 deletions Dev/Sources/SwiftUIDemo/DemoFilterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@ import SwiftUI
import SwiftUISupport
import UIKit

struct CustomFilter: Filtering, Equatable, Codable {

init() {

}
struct DemoFilterView: View {

func apply(to image: CIImage, sourceImage: CIImage) -> CIImage {
image
.applyingFilter("CIColorInvert")
struct InvertFilter: Filtering, Equatable, Codable {
func apply(to image: CIImage, sourceImage: CIImage) -> CIImage {
image
.applyingFilter("CIColorInvert")
}
}

}


struct DemoFilterView: View {

@StateObject var editingStack: EditingStack
@State var toggle: Bool = false

Expand All @@ -39,9 +32,9 @@ struct DemoFilterView: View {
.onChange(of: toggle) { newValue in
editingStack.set(filters: {
if newValue {
$0.custom["custom"] = CustomFilter().asAny()
$0.additionalFilters["invert"] = InvertFilter().asAny()
} else {
$0.custom["custom"] = nil
$0.additionalFilters["invert"] = nil
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/BrightroomEngine/Core/EditingStack.Edit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension EditingStack {
public var vignette: FilterVignette?
public var fade: FilterFade?

public var custom: [String : AnyFilter] = [:]
public var additionalFilters: [String : AnyFilter] = [:]

func makeFilters() -> [AnyFilter] {
return (
Expand Down Expand Up @@ -95,7 +95,7 @@ extension EditingStack {
vignette?.asAny(),

] as [AnyFilter?])
+ (custom.values.map { $0 })
+ (additionalFilters.values.map { $0 })
)
.compactMap { $0 }
}
Expand Down

0 comments on commit 63d8c5c

Please sign in to comment.