|
// |
|
// SwiftUISystemButtonStorybook.swift |
|
// TemplateAppTvOS |
|
// |
|
// Created by Mert Vurgun on 27.08.2024. |
|
// |
|
|
|
import Foundation |
|
import SwiftUI |
|
|
|
struct SwiftUISystemButtonStorybook: View { |
|
var body: some View { |
|
HStack(spacing: 0) { |
|
// Left Side |
|
VStack(spacing: 36) { |
|
createSystemButton() |
|
createBorderedButton() |
|
createTintedButton() |
|
createFilledButton() |
|
} |
|
.frame(maxWidth: .infinity, maxHeight: .infinity) |
|
.background(Color.white) |
|
|
|
// Right Side |
|
VStack(spacing: 36) { |
|
createPrimaryButton() |
|
createCancelButton() |
|
createDestructiveButton() |
|
createIconButton() |
|
createCustomButton() |
|
} |
|
.frame(maxWidth: .infinity, maxHeight: .infinity) |
|
.background(Color.black) |
|
} |
|
.edgesIgnoringSafeArea(.all) |
|
} |
|
|
|
// MARK: - Button Creation |
|
|
|
private func createSystemButton() -> some View { |
|
Button("System Button") { |
|
print("System Button tapped") |
|
} |
|
.buttonStyle(.bordered) |
|
.tint(.blue) |
|
} |
|
|
|
private func createBorderedButton() -> some View { |
|
Button("Bordered Button") { |
|
print("Bordered Button tapped") |
|
} |
|
.buttonStyle(.bordered) |
|
} |
|
|
|
private func createTintedButton() -> some View { |
|
Button("Tinted Button") { |
|
print("Tinted Button tapped") |
|
} |
|
.buttonStyle(.borderedProminent) |
|
.tint(.purple) |
|
} |
|
|
|
private func createFilledButton() -> some View { |
|
Button("Filled Button") { |
|
print("Filled Button tapped") |
|
} |
|
.buttonStyle(.borderedProminent) |
|
.tint(.green) |
|
} |
|
|
|
private func createPrimaryButton() -> some View { |
|
Button("Primary Button") { |
|
print("Primary Button tapped") |
|
} |
|
.buttonStyle(.borderedProminent) |
|
.tint(.blue) |
|
} |
|
|
|
private func createCancelButton() -> some View { |
|
Button("Cancel Button") { |
|
print("Cancel Button tapped") |
|
} |
|
.buttonStyle(.bordered) |
|
.tint(.gray) |
|
} |
|
|
|
private func createDestructiveButton() -> some View { |
|
Button("Destructive Button") { |
|
print("Destructive Button tapped") |
|
} |
|
.buttonStyle(.borderedProminent) |
|
.tint(.red) |
|
} |
|
|
|
private func createIconButton() -> some View { |
|
Button { |
|
print("Icon Button tapped") |
|
} label: { |
|
Label("Prominent Button", systemImage: "star.warning") |
|
} |
|
.buttonStyle(.borderedProminent) |
|
.tint(.orange) |
|
} |
|
|
|
private func createCustomButton() -> some View { |
|
Button { |
|
print("Custom Button tapped") |
|
} label: { |
|
HStack { |
|
Image(systemName: "star") |
|
Text("Custom Row") |
|
Image(systemName: "star.fill") |
|
} |
|
.foregroundColor(.black) |
|
.cornerRadius(10) |
|
} |
|
.tint(.red) |
|
} |
|
} |