Skip to content

Commit

Permalink
Fix button inconsistencies (#342)
Browse files Browse the repository at this point in the history
* Fixes inconsistencies from the initial PR that I noticed during testing

* (Possibly contentious) Move shadow modifiers inside views

* Add VStack after getting previews running
  • Loading branch information
ianthetechie authored Nov 5, 2024
1 parent 27dab0b commit 4c048c4
Show file tree
Hide file tree
Showing 18 changed files with 13 additions and 18 deletions.
1 change: 0 additions & 1 deletion apple/DemoApp/Demo/DemoNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ struct DemoNavigationView: View {
.font(.body.bold())
}
.disabled(routes?.isEmpty == true)
.shadow(radius: 10)
}
} else {
NavigationUIButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public struct NavigationUIButtonStyle: ButtonStyle {
.foregroundStyle(.primary)
.clipShape(Capsule())
.frame(minWidth: 52, minHeight: 52)
.shadow(radius: 8)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import FerrostarCore
import FerrostarCoreFFI
import SwiftUI

public struct MuteUIButton: View {
public struct NavigationUIMuteButton: View {
let isMuted: Bool
let action: () -> Void

Expand All @@ -12,21 +11,19 @@ public struct MuteUIButton: View {
}

public var body: some View {
Button(action: action) {
NavigationUIButton(action: action) {
Image(systemName: isMuted ? "speaker.slash.fill" : "speaker.2.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 18, height: 18)
.padding()
}
.foregroundColor(.black)
.background(Color.white)
.clipShape(Circle())
}
}

#Preview {
MuteUIButton(isMuted: true, action: {})
VStack {
NavigationUIMuteButton(isMuted: true, action: {})

MuteUIButton(isMuted: false, action: {})
NavigationUIMuteButton(isMuted: false, action: {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public struct NavigationUIZoomButton: View {
.foregroundColor(.primary)
.background(Color(.systemBackground))
.clipShape(Capsule())
.shadow(radius: 8)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public struct NavigatingInnerGridView: View, CustomizableNavigatingInnerGridView
topCenter: { topCenter?() },
topTrailing: {
if showMute {
MuteUIButton(isMuted: isMuted, action: onMute)
.shadow(radius: 8)
NavigationUIMuteButton(isMuted: isMuted, action: onMute)
}
},
midLeading: { midLeading?() },
Expand All @@ -99,7 +98,6 @@ public struct NavigatingInnerGridView: View, CustomizableNavigatingInnerGridView
midTrailing: {
if showZoom {
NavigationUIZoomButton(onZoomIn: onZoomIn, onZoomOut: onZoomOut)
.shadow(radius: 8)
} else {
Spacer()
}
Expand All @@ -112,7 +110,6 @@ public struct NavigatingInnerGridView: View, CustomizableNavigatingInnerGridView
.aspectRatio(contentMode: .fit)
.frame(width: 18, height: 18)
}
.shadow(radius: 8)
} else {
Spacer()
}
Expand Down
8 changes: 4 additions & 4 deletions apple/Tests/FerrostarSwiftUITests/Views/MuteButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ import XCTest
final class MuteUIButtonTests: XCTestCase {
func test_muted() {
assertView {
MuteUIButton(isMuted: true, action: {})
NavigationUIMuteButton(isMuted: true, action: {})
}
}

func test_unmuted() {
assertView {
MuteUIButton(isMuted: false, action: {})
NavigationUIMuteButton(isMuted: false, action: {})
}
}

// MARK: Dark Mode

func test_muted_darkMode() {
assertView(colorScheme: .dark) {
MuteUIButton(isMuted: true, action: {})
NavigationUIMuteButton(isMuted: true, action: {})
}
}

func test_unmuted_darkMode() {
assertView(colorScheme: .dark) {
MuteUIButton(isMuted: false, action: {})
NavigationUIMuteButton(isMuted: false, action: {})
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4c048c4

Please sign in to comment.