Skip to content

Commit

Permalink
feat: PromptBarButton
Browse files Browse the repository at this point in the history
  • Loading branch information
buzsh committed Mar 8, 2024
1 parent 8db4aad commit 652f082
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
4 changes: 4 additions & 0 deletions SwiftDiffusion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
2975DF112B8BE7C30031690E /* CheckpointMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2975DF102B8BE7C30031690E /* CheckpointMenu.swift */; };
2975DF142B8C08800031690E /* VaeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2975DF132B8C08800031690E /* VaeModel.swift */; };
2975DF162B8C0BAB0031690E /* VaeModelMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2975DF152B8C0BAB0031690E /* VaeModelMenu.swift */; };
2991FDD92B9BC38800D553F6 /* PromptBarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2991FDD82B9BC38800D553F6 /* PromptBarButton.swift */; };
29949F252B9655F4004F8D60 /* SidebarModel+Delete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29949F242B9655F4004F8D60 /* SidebarModel+Delete.swift */; };
29949F272B965E49004F8D60 /* SidebarModel+Create.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29949F262B965E49004F8D60 /* SidebarModel+Create.swift */; };
2996D0942B6ED5B000B487D5 /* SwiftDiffusionApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2996D0932B6ED5B000B487D5 /* SwiftDiffusionApp.swift */; };
Expand Down Expand Up @@ -238,6 +239,7 @@
2975DF102B8BE7C30031690E /* CheckpointMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckpointMenu.swift; sourceTree = "<group>"; };
2975DF132B8C08800031690E /* VaeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaeModel.swift; sourceTree = "<group>"; };
2975DF152B8C0BAB0031690E /* VaeModelMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaeModelMenu.swift; sourceTree = "<group>"; };
2991FDD82B9BC38800D553F6 /* PromptBarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptBarButton.swift; sourceTree = "<group>"; };
29949F242B9655F4004F8D60 /* SidebarModel+Delete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SidebarModel+Delete.swift"; sourceTree = "<group>"; };
29949F262B965E49004F8D60 /* SidebarModel+Create.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SidebarModel+Create.swift"; sourceTree = "<group>"; };
2996D0902B6ED5B000B487D5 /* SwiftDiffusion.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftDiffusion.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -352,6 +354,7 @@
29145E702B77D94900BFA64B /* PromptBars */ = {
isa = PBXGroup;
children = (
2991FDD82B9BC38800D553F6 /* PromptBarButton.swift */,
29145E722B77D99400BFA64B /* PromptControlBar.swift */,
29708F932B803350004A95AD /* PasteGenerationDataStatusBar.swift */,
);
Expand Down Expand Up @@ -1253,6 +1256,7 @@
292A30DD2B9017F700344DA8 /* WorkspaceItemView.swift in Sources */,
29A7BDE12B8A40F200F9144B /* ApiCheckpointRow.swift in Sources */,
2971966B2B71A5AC000F7960 /* Delay.swift in Sources */,
2991FDD92B9BC38800D553F6 /* PromptBarButton.swift in Sources */,
29A1E0BF2B81057300B18AC1 /* ScriptManagerObserver.swift in Sources */,
29F91D2F2B8D25160047B3C9 /* SidebarStoredItemView.swift in Sources */,
292CE8092B81771B00116D60 /* CheckpointModelPreferences.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// PromptBarButton.swift
// SwiftDiffusion
//
// Created by Justin Bush on 3/8/24.
//

import SwiftUI

enum AlignSymbol {
case leading, trailing
}

struct PromptBarButton: View {
let title: String
let symbol: SFSymbol
var align: AlignSymbol = .leading
let action: () -> Void

var body: some View {
Button(action: action) {
if align == .leading { symbol.image }
Text(title)
if align == .trailing { symbol.image }
}
.buttonStyle(.accessoryBar)
}
}

#Preview {
return HStack {
PromptBarButton(title: "Close", symbol: .close, align: .leading, action: {

})

Spacer()

PromptBarButton(title: "Save", symbol: .save, align: .trailing, action: {

})
}
.padding()
.frame(width: 400)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,6 @@ struct PromptControlBarView: View {
}
}

enum AlignSymbol {
case leading, trailing
}

struct PromptBarButton: View {
let title: String
let symbol: SFSymbol
var align: AlignSymbol = .leading
let action: () -> Void

var body: some View {
Button(action: action) {
if align == .leading { symbol.image }
Text(title)
if align == .trailing { symbol.image }
}
.buttonStyle(.accessoryBar)
}
}

struct PromptControlBar: View {
@Environment(\.modelContext) private var modelContext
@EnvironmentObject var currentPrompt: PromptModel
Expand Down

0 comments on commit 652f082

Please sign in to comment.