Skip to content

Commit ac82fdb

Browse files
committed
Update floating control visibility to hide for ineligible case.
1 parent 4eceb20 commit ac82fdb

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

WooCommerce/Classes/POS/Presentation/PointOfSaleDashboardView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct PointOfSaleDashboardView: View {
9494
.padding(.bottom, Constants.floatingControlBottomPadding)
9595
.trackSize(size: $floatingSize)
9696
.accessibilitySortPriority(1)
97-
.renderedIf(viewState != .loading)
97+
.renderedIf(viewState.showsFloatingControl)
9898

9999
POSConnectivityView()
100100
}

WooCommerce/Classes/POS/ViewHelpers/PointOfSaleDashboardViewHelper.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,15 @@ struct PointOfSaleDashboardViewHelper {
3131
}
3232
}
3333
}
34+
35+
@available(iOS 17.0, *)
36+
extension PointOfSaleDashboardView.ViewState {
37+
var showsFloatingControl: Bool {
38+
switch self {
39+
case .content, .error, .unsupportedWidth:
40+
return true
41+
case .loading, .ineligible:
42+
return false
43+
}
44+
}
45+
}

WooCommerce/WooCommerceTests/POS/ViewHelpers/PointOfSaleDashboardViewHelperTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,27 @@ struct PointOfSaleDashboardViewHelperTests {
214214
// Then
215215
#expect(result == .ineligible(reason: .unsupportedIOSVersion))
216216
}
217+
218+
// MARK: - Floating Control Tests
219+
220+
@available(iOS 17.0, *)
221+
@Test(arguments: [
222+
(PointOfSaleDashboardView.ViewState.content, true),
223+
(PointOfSaleDashboardView.ViewState.error(PointOfSaleErrorState.errorOnLoadingProducts()), true),
224+
(PointOfSaleDashboardView.ViewState.unsupportedWidth, true)
225+
])
226+
func showsFloatingControl_when_content_error_or_unsupportedWidth_returns_true(viewState: PointOfSaleDashboardView.ViewState, expected: Bool) async throws {
227+
// When & Then
228+
#expect(viewState.showsFloatingControl == expected)
229+
}
230+
231+
@available(iOS 17.0, *)
232+
@Test(arguments: [
233+
(PointOfSaleDashboardView.ViewState.loading, false),
234+
(PointOfSaleDashboardView.ViewState.ineligible(reason: .unsupportedIOSVersion), false)
235+
])
236+
func showsFloatingControl_when_loading_or_ineligible_returns_false(viewState: PointOfSaleDashboardView.ViewState, expected: Bool) async throws {
237+
// When & Then
238+
#expect(viewState.showsFloatingControl == expected)
239+
}
217240
}

0 commit comments

Comments
 (0)