@@ -20,10 +20,12 @@ private func getSwipeDirection(_ dx: CGFloat, _ dy: CGFloat) -> SwipeDirection {
2020}
2121
2222private func clearBubble( ) {
23- virtualKeyboardView. setBubble ( 0 , 0 , 0 , 0 , . clear, . clear, nil )
23+ virtualKeyboardView. setBubble ( 0 , 0 , 0 , 0 , . clear, . light , . clear, nil )
2424}
2525
2626struct KeyModifier : ViewModifier {
27+ @Environment ( \. colorScheme) var colorScheme
28+
2729 let threshold : CGFloat = 30
2830 let stepSize : CGFloat = 15
2931
@@ -60,11 +62,14 @@ struct KeyModifier: ViewModifier {
6062 } else {
6163 content
6264 }
63- } . frame ( width: width - hMargin, height: height - rowGap )
65+ } . frame ( width: width - hMargin, height: height - vMargin )
6466 . background ( isPressed ? pressedBackground : background)
6567 . cornerRadius ( radius)
6668 . foregroundColor ( isPressed ? pressedForeground : foreground)
67- . shadow ( color: shadow, radius: 0 , x: 0 , y: 1 )
69+ . overlay (
70+ ShadowView ( width: width - hMargin, height: 1 , radius: radius, color: shadow)
71+ . offset ( y: ( height - vMargin - radius + 1 ) / 2 )
72+ )
6873 . condition ( topRight != nil ) {
6974 $0. overlay (
7075 // padding right so that / doesn't overflow
@@ -89,7 +94,9 @@ struct KeyModifier: ViewModifier {
8994 lastLocation = value. startLocation. x
9095
9196 virtualKeyboardView. setBubble (
92- bubbleX, bubbleY, bubbleWidth, bubbleHeight, background, shadow, bubbleLabel)
97+ bubbleX, bubbleY, bubbleWidth, bubbleHeight,
98+ background, colorScheme, shadow,
99+ bubbleLabel)
93100
94101 // Schedule long press that can be interrupted by move.
95102 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.3 ) {
@@ -113,7 +120,8 @@ struct KeyModifier: ViewModifier {
113120 }
114121 if getSwipeDirection ( dx, dy) == . up {
115122 virtualKeyboardView. setBubble (
116- bubbleX, bubbleY, bubbleWidth, bubbleHeight, background, shadow, swipeUpLabel)
123+ bubbleX, bubbleY, bubbleWidth, bubbleHeight, background, colorScheme,
124+ shadow, swipeUpLabel)
117125 } else {
118126 clearBubble ( )
119127 }
0 commit comments