Skip to content

Commit

Permalink
Added KeyboardToolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Jul 25, 2023
1 parent af06567 commit 40395ff
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Sources/OversizeUI/Controls/KeyboardToolbar/KeyboardToolbar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright © 2021 Alexander Romanov
// KeyboardToolbar.swift, created on 25.07.2023
//

import SwiftUI

public struct KeyboardToolbar<A>: View where A: View {
private let actions: Group<A>?
private let doneAction: (() -> Void)?

public init(
@ViewBuilder actions: @escaping () -> A,
doneAction: (() -> Void)? = nil
) {
self.actions = Group { actions() }
self.doneAction = doneAction
}

public var body: some View {
HStack(spacing: .xSmall) {
if actions != nil {
HStack(spacing: .xxxSmall) {
actions
.buttonStyle(.quaternary)
.controlBorderShape(.capsule)
.controlSize(.mini)
}
}

Spacer()

if doneAction != nil {
Button {
doneAction?()
} label: {
Text("Done")
}
.buttonStyle(.quaternary)
.controlBorderShape(.capsule)
.accent()
.controlSize(.mini)
}
}
.padding(.horizontal, .small)
.padding(.vertical, .xxSmall)
.background(Color.surfacePrimary)
.shadowElevaton(.z1)
}
}

0 comments on commit 40395ff

Please sign in to comment.