Created
January 21, 2021 05:32
-
-
Save oocoocococo/5e74578052057007aa63507e931751a8 to your computer and use it in GitHub Desktop.
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
import SwiftUI | |
/// エフェクト情報 | |
struct SlotEffects { | |
var saturation: Double = 0.0 | |
var hueShift: Double = 0.0 | |
var bloom: Double = 0.0 | |
} | |
/// 写真情報 | |
class PhotoInfo: ObservableObject { | |
/// エフェクト情報 | |
@Published var slotEffects: SlotEffects = .init() | |
} | |
struct ContentView: View { | |
/// 写真情報 | |
@ObservedObject var photoInfo: PhotoInfo = PhotoInfo() | |
var body: some View { | |
Inspector(effects: $photoInfo.slotEffects) | |
.padding() | |
} // body | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
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
import SwiftUI | |
/// インスペクタービュー | |
struct Inspector: View { | |
/// エフェクト情報 | |
@Binding var effects: SlotEffects | |
var body: some View { | |
VStack { | |
// Saturation | |
VStack(alignment: .leading) { | |
Text("Saturation") | |
HStack() { | |
Slider(value: $effects.saturation, in: 0...100) | |
.frame(width: 220) | |
Spacer() | |
Text("\(effects.saturation, specifier: "%.0f")%") | |
} // HStack | |
} // VStack | |
.padding() | |
.background(Color(UIColor.secondarySystemFill)) | |
.cornerRadius(8.0) | |
// Hue Shift | |
VStack(alignment: .leading) { | |
Text("Hue Shift") | |
HStack { | |
Slider(value: $effects.hueShift, in: 0...360) | |
.frame(width: 220) | |
Spacer() | |
Text("\(effects.hueShift, specifier: "%.0f")°") | |
} // HStack | |
} // VStack | |
.padding() | |
.background(Color(UIColor.secondarySystemFill)) | |
.cornerRadius(8.0) | |
// Bloom | |
VStack(alignment: .leading) { | |
Text("Bloom") | |
HStack { | |
Slider(value: $effects.bloom, in: 0...100) | |
.frame(width: 220) | |
Spacer() | |
Text("\(effects.bloom, specifier: "%.0f")%") | |
} // HStack | |
} // VStack | |
.padding() | |
.background(Color(UIColor.secondarySystemFill)) | |
.cornerRadius(8.0) | |
} // VStack | |
} // body | |
} | |
struct Inspector_Previews: PreviewProvider { | |
/// コンテナ | |
/// | |
/// 値変動用のコンテナ | |
struct EffectsContainer: View { | |
/// エフェクト情報 | |
@State var effects: SlotEffects | |
var body: some View { | |
Inspector(effects: $effects) | |
} | |
} | |
static var previews: some View { | |
Group { | |
// 値を固定してプレビュー | |
Inspector(effects: .constant(SlotEffects(saturation: 25, hueShift: 135, bloom: 10))) | |
// 値を変動してプレビュー | |
EffectsContainer(effects: SlotEffects()) | |
} | |
.previewLayout(.sizeThatFits) | |
.padding(20) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment