diff --git a/CharcoalSwiftUISample/Sources/CharcoalSwiftUISample/HintsView.swift b/CharcoalSwiftUISample/Sources/CharcoalSwiftUISample/HintsView.swift index fcbd4545a..d6562c33d 100644 --- a/CharcoalSwiftUISample/Sources/CharcoalSwiftUISample/HintsView.swift +++ b/CharcoalSwiftUISample/Sources/CharcoalSwiftUISample/HintsView.swift @@ -7,6 +7,8 @@ public struct HintsView: View { @State var isPresented2 = true @State var isPresented3 = true + + @State var isPresented4 = true public var body: some View { ScrollView { @@ -17,7 +19,11 @@ public struct HintsView: View { CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresented2) - CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresented3) + CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresented3, alignment: .leading) + + CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresented4, buttonStyle: .default, action: CharcoalAction(title: "Button") { + isPresented = false + }) } .padding() } diff --git a/CharcoalUIKitSample/Sources/CharcoalUIKitSample/Views/Hints/Hints.swift b/CharcoalUIKitSample/Sources/CharcoalUIKitSample/Views/Hints/Hints.swift index 0fa86a13f..3ec6f2ae3 100644 --- a/CharcoalUIKitSample/Sources/CharcoalUIKitSample/Views/Hints/Hints.swift +++ b/CharcoalUIKitSample/Sources/CharcoalUIKitSample/Views/Hints/Hints.swift @@ -73,7 +73,6 @@ final class HintsViewController: UIViewController { hint.widthAnchor.constraint(equalTo: stackView.widthAnchor).isActive = true } } - } @available(iOS 17.0, *) diff --git a/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalButton.swift b/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalButton.swift new file mode 100644 index 000000000..f7e0d7ed5 --- /dev/null +++ b/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalButton.swift @@ -0,0 +1,38 @@ +import SwiftUI + +public protocol CharcoalButtonModifier: ViewModifier {} + +public enum CharcoalButtonStyle { + case primary(Configuration) + case `default` + + @ViewBuilder + func apply(_ content: Content) -> some View { + switch self { + case let .primary(configuration): + content.charcoalPrimaryButton(size: configuration.size, isFixed: configuration.isFixed, primaryColor: configuration.primaryColor) + case .default: + content.charcoalDefaultButton(size: .medium, isFixed: true) + } + } +} + +extension CharcoalButtonStyle { + public struct Configuration { + public var size: CharcoalButtonSize + public var isFixed: Bool + public var primaryColor: Color + + public init(size: CharcoalButtonSize = .medium, isFixed: Bool = true, primaryColor: Color) { + self.size = size + self.isFixed = isFixed + self.primaryColor = primaryColor + } + } +} + +extension View { + func charcoalButtonStyle(_ style: CharcoalButtonStyle) -> some View { + style.apply(self) + } +} diff --git a/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalNavigationButton.swift b/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalNavigationButton.swift index e9b9ddcba..b85557653 100644 --- a/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalNavigationButton.swift +++ b/Sources/CharcoalSwiftUI/Components/Buttons/CharcoalNavigationButton.swift @@ -92,7 +92,7 @@ struct CharcoalNavigationButtonStyleModifier: ViewModifier { public extension View { /// Set the style of the button to Charcoal's navigation button - /// + /// /// - Parameters: /// - size: The size of the button /// - isFixed: Whether the button should have a fixed width diff --git a/Sources/CharcoalSwiftUI/Components/CharcoalSpinner.swift b/Sources/CharcoalSwiftUI/Components/CharcoalSpinner.swift index b920a69df..357b08901 100644 --- a/Sources/CharcoalSwiftUI/Components/CharcoalSpinner.swift +++ b/Sources/CharcoalSwiftUI/Components/CharcoalSpinner.swift @@ -115,33 +115,33 @@ public extension View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var isPresenting = true - @Previewable @State var isBigPresenting = true - @Previewable @State var isTransparentPresenting = true - - ZStack { - Color.gray.opacity(0.2) - VStack { - Button { - isPresenting.toggle() - } label: { - Text("Toggle Spinner") - } - VStack {} - .frame(width: 100, height: 100) - .charcoalSpinner(isPresenting: $isPresenting) + @available(iOS 17, *) + #Preview { + @Previewable @State var isPresenting = true + @Previewable @State var isBigPresenting = true + @Previewable @State var isTransparentPresenting = true - VStack {} - .frame(width: 100, height: 150) - .charcoalSpinner(isPresenting: $isBigPresenting, spinnerSize: 100) + ZStack { + Color.gray.opacity(0.2) + VStack { + Button { + isPresenting.toggle() + } label: { + Text("Toggle Spinner") + } + VStack {} + .frame(width: 100, height: 100) + .charcoalSpinner(isPresenting: $isPresenting) - VStack {} - .frame(width: 100, height: 100) - .charcoalSpinner(isPresenting: $isTransparentPresenting, transparentBackground: true) + VStack {} + .frame(width: 100, height: 150) + .charcoalSpinner(isPresenting: $isBigPresenting, spinnerSize: 100) + + VStack {} + .frame(width: 100, height: 100) + .charcoalSpinner(isPresenting: $isTransparentPresenting, transparentBackground: true) + } } + .ignoresSafeArea() } - .ignoresSafeArea() -} #endif diff --git a/Sources/CharcoalSwiftUI/Components/CharcoalTextField.swift b/Sources/CharcoalSwiftUI/Components/CharcoalTextField.swift index 4b70363c3..7bcd9ad69 100644 --- a/Sources/CharcoalSwiftUI/Components/CharcoalTextField.swift +++ b/Sources/CharcoalSwiftUI/Components/CharcoalTextField.swift @@ -89,37 +89,37 @@ public extension View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var text1 = "" - @Previewable @State var text2 = "" + @available(iOS 17, *) + #Preview { + @Previewable @State var text1 = "" + @Previewable @State var text2 = "" - VStack(spacing: 16) { - TextField("Simple text field", text: $text1) - .charcoalTextField() - TextField("Placeholder", text: $text2) - .charcoalTextField( - label: .constant("Label"), - countLabel: .init( - get: { "\(text2.count)/10" }, - set: { _ in } - ), - assistiveText: .init( - get: { text2.count > 10 ? "Error" : "OK" }, - set: { _ in } - ), - hasError: .init( - get: { text2.count > 10 }, - set: { _ in } + VStack(spacing: 16) { + TextField("Simple text field", text: $text1) + .charcoalTextField() + TextField("Placeholder", text: $text2) + .charcoalTextField( + label: .constant("Label"), + countLabel: .init( + get: { "\(text2.count)/10" }, + set: { _ in } + ), + assistiveText: .init( + get: { text2.count > 10 ? "Error" : "OK" }, + set: { _ in } + ), + hasError: .init( + get: { text2.count > 10 }, + set: { _ in } + ) ) - ) - TextField("", text: .constant("Text")) - .disabled(true) - .charcoalTextField( - label: .constant("Label"), - countLabel: .constant("0/10"), - assistiveText: .constant("Assistive text") - ) - }.padding() -} + TextField("", text: .constant("Text")) + .disabled(true) + .charcoalTextField( + label: .constant("Label"), + countLabel: .constant("0/10"), + assistiveText: .constant("Assistive text") + ) + }.padding() + } #endif diff --git a/Sources/CharcoalSwiftUI/Components/Hint/CharcoalHint.swift b/Sources/CharcoalSwiftUI/Components/Hint/CharcoalHint.swift index ee13a2c57..c973c1054 100644 --- a/Sources/CharcoalSwiftUI/Components/Hint/CharcoalHint.swift +++ b/Sources/CharcoalSwiftUI/Components/Hint/CharcoalHint.swift @@ -1,15 +1,15 @@ import SwiftUI public struct CharcoalHint: View { - /// The text of the tooltip + /// The text of the hint view let text: String - /// The text of the tooltip + /// The subtitle text of the hint view let subtitle: String? let icon: CharcoalAsset.Images = .info16 - /// The corner radius of the tooltip + /// The corner radius of the hint view let cornerRadius: CGFloat = 8 let maxWidth: CGFloat? @@ -19,13 +19,18 @@ public struct CharcoalHint: View { let action: CharcoalAction? - @State var timer: Timer? + /// The alignment of hint view + let alignment: Alignment + + let buttonStyle: CharcoalButtonStyle public init( text: String, subtitle: String? = nil, maxWidth: CGFloat? = nil, isPresenting: Binding, + alignment: Alignment = .center, + buttonStyle: CharcoalButtonStyle = .primary(.init(primaryColor: Color(CharcoalAsset.ColorPaletteGenerated.brand.color))), action: CharcoalAction? = nil ) { self.text = text @@ -33,6 +38,8 @@ public struct CharcoalHint: View { self.maxWidth = maxWidth _isPresenting = isPresenting self.action = action + self.alignment = alignment + self.buttonStyle = buttonStyle } public var body: some View { @@ -53,11 +60,10 @@ public struct CharcoalHint: View { action.actionCallback() }) { Text(action.title) - } - .charcoalPrimaryButton(size: .small) + }.charcoalButtonStyle(buttonStyle) } } - .frame(maxWidth: maxWidth) + .frame(maxWidth: maxWidth, alignment: alignment) .padding(EdgeInsets(top: 12, leading: 16, bottom: 12, trailing: 16)) .background(charcoalColor: .surface3) .cornerRadius(cornerRadius, corners: .allCorners) @@ -66,23 +72,27 @@ public struct CharcoalHint: View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var isPresenting = true - @Previewable @State var isPresenting2 = true - @Previewable @State var isPresenting3 = true + @available(iOS 17, *) + #Preview { + @Previewable @State var isPresenting = true + @Previewable @State var isPresenting2 = true + @Previewable @State var isPresenting3 = true + @Previewable @State var isPresenting4 = true + @Previewable @State var textOfLabel = "Hello" - @Previewable @State var textOfLabel = "Hello" + VStack { + CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting, action: CharcoalAction(title: "Button", actionCallback: { + isPresenting = false + })) - VStack { - CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting, action: CharcoalAction(title: "Button", actionCallback: { - isPresenting = false - })) + CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting2, buttonStyle: .default, action: CharcoalAction(title: "Button", actionCallback: { + isPresenting2 = false + })) - CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting2) + CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting3) - CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresenting3) + CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresenting4, alignment: .leading) - }.padding() -} + }.padding() + } #endif diff --git a/Sources/CharcoalSwiftUI/Components/Toast/CharcoalSnackBar.swift b/Sources/CharcoalSwiftUI/Components/Toast/CharcoalSnackBar.swift index 0162f6b8f..cf7246e2e 100644 --- a/Sources/CharcoalSwiftUI/Components/Toast/CharcoalSnackBar.swift +++ b/Sources/CharcoalSwiftUI/Components/Toast/CharcoalSnackBar.swift @@ -204,79 +204,79 @@ public extension View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var isPresenting = true + @available(iOS 17, *) + #Preview { + @Previewable @State var isPresenting = true - @Previewable @State var isPresenting2 = true + @Previewable @State var isPresenting2 = true - @Previewable @State var isPresenting3 = true + @Previewable @State var isPresenting3 = true - @Previewable @State var textOfLabel = "Hello" + @Previewable @State var textOfLabel = "Hello" - NavigationView(content: { - TabView { - ZStack { + NavigationView(content: { + TabView { ZStack { - Button { - isPresenting.toggle() - isPresenting3.toggle() - } label: { - Text("Toggle SnackBar") - } - } - .charcoalSnackBar( - isPresenting: $isPresenting, - screenEdge: .top, - text: "ブックマークしました", - thumbnailImage: Image(uiImage: CharcoalAsset.ColorPaletteGenerated.border.color.imageWithColor(width: 64, height: 64)), - action: { + ZStack { Button { - print("Tapped") + isPresenting.toggle() + isPresenting3.toggle() } label: { - Text("編集") + Text("Toggle SnackBar") } } - ) - .charcoalSnackBar( - isPresenting: $isPresenting2, - screenEdge: .bottom, - text: "ブックマークしました", - dismissAfter: 2, - action: { - Button { - print("Tapped") - } label: { - Text("編集") + .charcoalSnackBar( + isPresenting: $isPresenting, + screenEdge: .top, + text: "ブックマークしました", + thumbnailImage: Image(uiImage: CharcoalAsset.ColorPaletteGenerated.border.color.imageWithColor(width: 64, height: 64)), + action: { + Button { + print("Tapped") + } label: { + Text("編集") + } } - } - ) - .charcoalSnackBar( - isPresenting: $isPresenting3, - screenEdgeSpacing: 275, - text: "ブックマークしました" - ) - } - - .tabItem { - Image(systemName: "1.circle") - Text("First") - } - - Text("Second Tab") - .tabItem { - Image(systemName: "2.circle") - Text("Second") + ) + .charcoalSnackBar( + isPresenting: $isPresenting2, + screenEdge: .bottom, + text: "ブックマークしました", + dismissAfter: 2, + action: { + Button { + print("Tapped") + } label: { + Text("編集") + } + } + ) + .charcoalSnackBar( + isPresenting: $isPresenting3, + screenEdgeSpacing: 275, + text: "ブックマークしました" + ) } - Text("Third Tab") .tabItem { - Image(systemName: "3.circle") - Text("Third") + Image(systemName: "1.circle") + Text("First") } - } - .navigationTitle("Snackbar") - }) - .charcoalOverlayContainer() -} + + Text("Second Tab") + .tabItem { + Image(systemName: "2.circle") + Text("Second") + } + + Text("Third Tab") + .tabItem { + Image(systemName: "3.circle") + Text("Third") + } + } + .navigationTitle("Snackbar") + }) + .charcoalOverlayContainer() + } #endif diff --git a/Sources/CharcoalSwiftUI/Components/Toast/CharcoalToast.swift b/Sources/CharcoalSwiftUI/Components/Toast/CharcoalToast.swift index 4eb346d94..3318d6a73 100644 --- a/Sources/CharcoalSwiftUI/Components/Toast/CharcoalToast.swift +++ b/Sources/CharcoalSwiftUI/Components/Toast/CharcoalToast.swift @@ -213,61 +213,61 @@ public extension View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var isPresenting = true + @available(iOS 17, *) + #Preview { + @Previewable @State var isPresenting = true - @Previewable @State var isPresenting2 = true + @Previewable @State var isPresenting2 = true - @Previewable @State var isPresenting3 = true + @Previewable @State var isPresenting3 = true - @Previewable @State var textOfLabel = "Hello" + @Previewable @State var textOfLabel = "Hello" - ZStack { - Color.clear ZStack { - Button { - isPresenting.toggle() - isPresenting3.toggle() - } label: { - Text("Toggle SnackBar") - } - } - .charcoalToast( - isPresenting: $isPresenting, - screenEdge: .top, - text: "テキストメッセージ", - action: { + Color.clear + ZStack { Button { - isPresenting = false + isPresenting.toggle() + isPresenting3.toggle() } label: { - Image(charcoalIcon: .remove16) - .renderingMode(.template) + Text("Toggle SnackBar") } } - ) - .charcoalToast( - isPresenting: $isPresenting2, - screenEdgeSpacing: 192, - text: "テキストメッセージ", - dismissAfter: 2, - appearance: .error, - action: { - Button { - isPresenting2 = false - } label: { - Image(charcoalIcon: .remove16) - .renderingMode(.template) + .charcoalToast( + isPresenting: $isPresenting, + screenEdge: .top, + text: "テキストメッセージ", + action: { + Button { + isPresenting = false + } label: { + Image(charcoalIcon: .remove16) + .renderingMode(.template) + } } - } - ) - .charcoalToast( - isPresenting: $isPresenting3, - screenEdgeSpacing: 275, - text: "テキストメッセージ", - animationConfiguration: .init(enablePositionAnimation: false, animation: .easeInOut(duration: 0.2)) - ) + ) + .charcoalToast( + isPresenting: $isPresenting2, + screenEdgeSpacing: 192, + text: "テキストメッセージ", + dismissAfter: 2, + appearance: .error, + action: { + Button { + isPresenting2 = false + } label: { + Image(charcoalIcon: .remove16) + .renderingMode(.template) + } + } + ) + .charcoalToast( + isPresenting: $isPresenting3, + screenEdgeSpacing: 275, + text: "テキストメッセージ", + animationConfiguration: .init(enablePositionAnimation: false, animation: .easeInOut(duration: 0.2)) + ) + } + .charcoalOverlayContainer() } - .charcoalOverlayContainer() -} #endif diff --git a/Sources/CharcoalSwiftUI/Components/Tooltip/CharcoalTooltip.swift b/Sources/CharcoalSwiftUI/Components/Tooltip/CharcoalTooltip.swift index 2948c94bb..264cbb63a 100644 --- a/Sources/CharcoalSwiftUI/Components/Tooltip/CharcoalTooltip.swift +++ b/Sources/CharcoalSwiftUI/Components/Tooltip/CharcoalTooltip.swift @@ -215,89 +215,89 @@ public extension View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var isPresenting = true - @Previewable @State var isPresenting2 = true - @Previewable @State var isPresenting3 = true - @Previewable @State var isPresenting4 = true - @Previewable @State var isPresenting5 = true - @Previewable @State var isPresenting6 = true - - @Previewable @State var textOfLabel = "Hello" - - GeometryReader { proxy in - ScrollView { - ZStack(alignment: .topLeading) { - Color.clear + @available(iOS 17, *) + #Preview { + @Previewable @State var isPresenting = true + @Previewable @State var isPresenting2 = true + @Previewable @State var isPresenting3 = true + @Previewable @State var isPresenting4 = true + @Previewable @State var isPresenting5 = true + @Previewable @State var isPresenting6 = true + + @Previewable @State var textOfLabel = "Hello" + + GeometryReader { proxy in + ScrollView { + ZStack(alignment: .topLeading) { + Color.clear + + VStack { + Text(textOfLabel) - VStack { - Text(textOfLabel) + Button { + textOfLabel = ["Changed", "Hello"].randomElement()! + } label: { + Text("Change Label") + } + } Button { - textOfLabel = ["Changed", "Hello"].randomElement()! + isPresenting.toggle() } label: { - Text("Change Label") + Image(charcoalIcon: .question24) } - } + .charcoalTooltip(isPresenting: $isPresenting, text: "Hello World") + .offset(CGSize(width: 20.0, height: 80.0)) - Button { - isPresenting.toggle() - } label: { - Image(charcoalIcon: .question24) - } - .charcoalTooltip(isPresenting: $isPresenting, text: "Hello World") - .offset(CGSize(width: 20.0, height: 80.0)) + Button { + isPresenting2.toggle() + } label: { + Text("Help") + } + .charcoalDefaultButton() + .charcoalTooltip(isPresenting: $isPresenting2, text: "Hello World This is a tooltip") + .offset(CGSize(width: 100.0, height: 150.0)) - Button { - isPresenting2.toggle() - } label: { - Text("Help") - } - .charcoalDefaultButton() - .charcoalTooltip(isPresenting: $isPresenting2, text: "Hello World This is a tooltip") - .offset(CGSize(width: 100.0, height: 150.0)) - - Button { - isPresenting3.toggle() - } label: { - Text("Right") - } - .charcoalPrimaryButton(size: .medium) - .charcoalTooltip(isPresenting: $isPresenting3, text: "here is testing it's multiple line feature") - .offset(CGSize(width: proxy.size.width - 100, height: 100.0)) - - Button { - isPresenting4.toggle() - } label: { - Image(charcoalIcon: .question24) - } - .charcoalTooltip(isPresenting: $isPresenting4, text: "Hello World This is a tooltip and here is testing it's multiple line feature") - .offset(CGSize(width: proxy.size.width - 30, height: proxy.size.height - 40)) + Button { + isPresenting3.toggle() + } label: { + Text("Right") + } + .charcoalPrimaryButton(size: .medium) + .charcoalTooltip(isPresenting: $isPresenting3, text: "here is testing it's multiple line feature") + .offset(CGSize(width: proxy.size.width - 100, height: 100.0)) - Button { - isPresenting5.toggle() - } label: { - Text("Bottom") - } - .charcoalPrimaryButton(size: .medium) - .charcoalTooltip( - isPresenting: $isPresenting5, - text: "Hello World This is a tooltip and here is testing it's multiple line feature", - dismissAfter: 2 - ) - .offset(CGSize(width: proxy.size.width - 240, height: proxy.size.height - 40)) - - Button { - isPresenting6.toggle() - } label: { - Image(charcoalIcon: .question24) + Button { + isPresenting4.toggle() + } label: { + Image(charcoalIcon: .question24) + } + .charcoalTooltip(isPresenting: $isPresenting4, text: "Hello World This is a tooltip and here is testing it's multiple line feature") + .offset(CGSize(width: proxy.size.width - 30, height: proxy.size.height - 40)) + + Button { + isPresenting5.toggle() + } label: { + Text("Bottom") + } + .charcoalPrimaryButton(size: .medium) + .charcoalTooltip( + isPresenting: $isPresenting5, + text: "Hello World This is a tooltip and here is testing it's multiple line feature", + dismissAfter: 2 + ) + .offset(CGSize(width: proxy.size.width - 240, height: proxy.size.height - 40)) + + Button { + isPresenting6.toggle() + } label: { + Image(charcoalIcon: .question24) + } + .charcoalTooltip(isPresenting: $isPresenting6, text: "Hello World This is a tooltip and here is testing it's multiple line feature") + .offset(CGSize(width: proxy.size.width - 380, height: proxy.size.height - 240)) } - .charcoalTooltip(isPresenting: $isPresenting6, text: "Hello World This is a tooltip and here is testing it's multiple line feature") - .offset(CGSize(width: proxy.size.width - 380, height: proxy.size.height - 240)) } } + .charcoalOverlayContainer() } - .charcoalOverlayContainer() -} #endif diff --git a/Sources/CharcoalSwiftUI/Modal/CharcoalModalView.swift b/Sources/CharcoalSwiftUI/Modal/CharcoalModalView.swift index 3f1d9e8d5..cea9cd561 100644 --- a/Sources/CharcoalSwiftUI/Modal/CharcoalModalView.swift +++ b/Sources/CharcoalSwiftUI/Modal/CharcoalModalView.swift @@ -215,48 +215,48 @@ public extension View { } #if compiler(>=6.0) -@available(iOS 17, *) -#Preview { - @Previewable @State var isPresented = false - @Previewable @State var text1 = "" + @available(iOS 17, *) + #Preview { + @Previewable @State var isPresented = false + @Previewable @State var text1 = "" - ZStack { - Button(action: { - isPresented = true - }, label: { - Text("Show") - .padding() - }) - .charcoalModal( - title: "Title", - style: .center, - isPresented: $isPresented, - actions: { - Button(action: { - isPresented = false - }, label: { - Text("OK").frame(maxWidth: .infinity) - }).charcoalPrimaryButton(size: .medium) + ZStack { + Button(action: { + isPresented = true + }, label: { + Text("Show") + .padding() + }) + .charcoalModal( + title: "Title", + style: .center, + isPresented: $isPresented, + actions: { + Button(action: { + isPresented = false + }, label: { + Text("OK").frame(maxWidth: .infinity) + }).charcoalPrimaryButton(size: .medium) - Button(action: { - isPresented = false - }, label: { - Text("Dismiss").frame(maxWidth: .infinity) - }).charcoalDefaultButton(size: .medium) - } - ) { - NavigationView { - VStack(spacing: 10) { - Text("Hello This is a center dialog from Charcoal") - .charcoalTypography16Regular() - .frame(maxWidth: .infinity) + Button(action: { + isPresented = false + }, label: { + Text("Dismiss").frame(maxWidth: .infinity) + }).charcoalDefaultButton(size: .medium) + } + ) { + NavigationView { + VStack(spacing: 10) { + Text("Hello This is a center dialog from Charcoal") + .charcoalTypography16Regular() + .frame(maxWidth: .infinity) - TextField("Simple text field", text: $text1).charcoalTextField() - }.padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) - .navigationTitle("SwiftUI") - .navigationBarTitleDisplayMode(.inline) + TextField("Simple text field", text: $text1).charcoalTextField() + }.padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) + .navigationTitle("SwiftUI") + .navigationBarTitleDisplayMode(.inline) + } } } } -} #endif diff --git a/Sources/CharcoalUIKit/Components/Hints/HintView.swift b/Sources/CharcoalUIKit/Components/Hints/HintView.swift index bd3713ae2..0efb5b90a 100644 --- a/Sources/CharcoalUIKit/Components/Hints/HintView.swift +++ b/Sources/CharcoalUIKit/Components/Hints/HintView.swift @@ -47,7 +47,7 @@ public class CharcoalHintView: UIView { self.action = action self.text = text super.init(frame: .zero) - self.hStackView.spacing = 4 + hStackView.spacing = 4 if let action = action { actionButton.setTitle(action.title, for: .normal) } @@ -102,7 +102,6 @@ public class CharcoalHintView: UIView { hStackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -padding.bottom), hStackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -padding.right) ]) - // Add thumbnail view addThumbnailView() @@ -126,12 +125,12 @@ public class CharcoalHintView: UIView { stackView.distribution = .fill stackView.alignment = .center stackView.spacing = 8.0 - + stackView.widthAnchor.constraint(equalToConstant: 300).isActive = true let snackbar = CharcoalHintView(text: "Hello World") stackView.addArrangedSubview(snackbar) - + let snackbar2 = CharcoalHintView(text: "ブックマークしました") stackView.addArrangedSubview(snackbar2) snackbar2.widthAnchor.constraint(equalTo: stackView.widthAnchor).isActive = true @@ -149,6 +148,6 @@ public class CharcoalHintView: UIView { ) stackView.addArrangedSubview(snackbar4) snackbar4.widthAnchor.constraint(equalTo: stackView.widthAnchor).isActive = true - + return stackView }