@@ -19,6 +19,7 @@ public struct KeyboardKey: View {
1919 blackKeyColor: Color = . black,
2020 pressedColor: Color = . red,
2121 flatTop: Bool = false ,
22+ alignment: Alignment = . bottom,
2223 isActivatedExternally: Bool = false ) {
2324 self . pitch = pitch
2425 self . isActivated = isActivated
@@ -37,6 +38,7 @@ public struct KeyboardKey: View {
3738 self . blackKeyColor = blackKeyColor
3839 self . pressedColor = pressedColor
3940 self . flatTop = flatTop
41+ self . alignment = alignment
4042 self . isActivatedExternally = isActivatedExternally
4143 }
4244
@@ -46,6 +48,7 @@ public struct KeyboardKey: View {
4648 var blackKeyColor : Color
4749 var pressedColor : Color
4850 var flatTop : Bool
51+ var alignment : Alignment
4952 var text : String
5053 var isActivatedExternally : Bool
5154
@@ -81,7 +84,7 @@ public struct KeyboardKey: View {
8184
8285 public var body : some View {
8386 GeometryReader { proxy in
84- ZStack ( alignment: proxy . size . height > proxy . size . width ? . bottom : . trailing ) {
87+ ZStack ( alignment: alignment ) {
8588 Rectangle ( )
8689 . foregroundColor ( keyColor)
8790 . padding ( . top, flatTop ? relativeCornerRadius ( in: proxy. size) : 0 )
@@ -91,9 +94,7 @@ public struct KeyboardKey: View {
9194 Text ( text)
9295 . font ( Font ( . init( . system, size: relativeFontSize ( in: proxy. size) ) ) )
9396 . foregroundColor ( textColor)
94- . padding ( EdgeInsets ( top: 0 , leading: 0 ,
95- bottom: isTall ( size: proxy. size) ? proxy. size. height * relativeTextPadding : 0 ,
96- trailing: isTall ( size: proxy. size) ? 0 : proxy. size. width * relativeTextPadding) )
97+ . padding ( relativeFontSize ( in: proxy. size) / 3.0 )
9798 }
9899
99100 }
0 commit comments