Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Normal/App/NormalApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ struct NormalApp: App {
if UITestSupport.seedLocationKey {
context.insert(Key(
name: "Test Place",
latitude: 37.33182,
longitude: -122.03118,
latitude: UITestSupport.locationKeyFarAway ? 40.7484 : 37.33182,
longitude: UITestSupport.locationKeyFarAway ? -73.9857 : -122.03118,
radiusMeters: 400,
radiusKind: .unblock
))
Expand Down
2 changes: 2 additions & 0 deletions Normal/App/UITestSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ enum UITestSupport {

static let seedLocationKey = arguments.contains("-uiTestSeedLocationKey")

static let locationKeyFarAway = arguments.contains("-uiTestLocationKeyFarAway")

static let seedGroupID = UUID(uuidString: "6E0A1C9B-2D4F-4B7A-9C3E-5F8D1A2B3C4D")!

static let skipBypassConfirm = arguments.contains("-uiTestSkipBypassConfirm")
Expand Down
37 changes: 37 additions & 0 deletions Normal/Shared/Components/CloseButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import SwiftUI

struct CloseButton: View {
enum Placement {
case toolbar
case inline
}

var placement: Placement = .toolbar
let action: () -> Void

var body: some View {
if #available(iOS 26.0, *) {
switch placement {
case .toolbar:
Button(role: .close, action: action)
case .inline:
Button(role: .close, action: action) {
Image(systemName: "xmark")
}
.buttonStyle(.glass)
.buttonBorderShape(.circle)
.controlSize(.large)
.accessibilityLabel("Close")
}
} else {
Button(action: action) {
Image(systemName: "xmark.circle.fill")
.font(.title2)
.symbolRenderingMode(placement == .toolbar ? .hierarchical : .monochrome)
.foregroundStyle(placement == .toolbar ? .secondary : .tertiary)
}
.buttonStyle(.plain)
.accessibilityLabel("Close")
}
}
}
25 changes: 15 additions & 10 deletions Normal/Views/BlockUnblockViews/KeySelect/LocationUnlockView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,11 @@ struct LocationUnlockView: View {
.navigationTitle("Location Key")
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden()
.toolbarBackground(.visible, for: .navigationBar)
.opaqueNavigationBarBeforeLiquidGlass()
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button(action: onClose) {
Image(systemName: "xmark.circle.fill")
.font(.title2)
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.secondary)
}
.accessibilityLabel("Close")
.accessibilityIdentifier("locationUnlock.close")
ToolbarItem(placement: .topBarTrailing) {
CloseButton(action: onClose)
.accessibilityIdentifier("locationUnlock.close")
}
}
.task {
Expand Down Expand Up @@ -183,3 +177,14 @@ struct LocationUnlockView: View {
: "Leave the highlighted area to unlock."
}
}

private extension View {
@ViewBuilder
func opaqueNavigationBarBeforeLiquidGlass() -> some View {
if #available(iOS 26.0, *) {
self
} else {
toolbarBackground(.visible, for: .navigationBar)
}
}
}
8 changes: 2 additions & 6 deletions Normal/Views/Key/LocationKeyInfoSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ struct LocationKeyInfoSheet: View {
}
}
Spacer()
Button { dismiss() } label: {
Image(systemName: "xmark.circle.fill")
.font(.title2)
.foregroundStyle(.tertiary)
}
.buttonStyle(.plain)
CloseButton(placement: .inline) { dismiss() }
.accessibilityIdentifier("locationKeyInfo.close")
}

HStack(spacing: DS.Spacing.md) {
Expand Down
10 changes: 8 additions & 2 deletions Normal/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ struct SettingsView: View {
NavigationStack {
tabView
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Close") { dismiss() }
if #available(iOS 26.0, *) {
ToolbarItem(placement: .topBarTrailing) {
Button(role: .close) { dismiss() }
}
} else {
ToolbarItem(placement: .confirmationAction) {
Button("Close") { dismiss() }
}
}
}
.alert("Emergency Unblock", isPresented: $showConfirmation) {
Expand Down
19 changes: 19 additions & 0 deletions NormalUITests/BlockingUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ final class BlockingUITests: XCTestCase {
require(app.staticTexts["No Active Blocks"], "Apps should be unblocked")
}

func testLocationKeyCheckCanBeClosedWhenOutOfRange() {
let app = launch(["-uiTestSeedLocationKey", "-uiTestLocationKeyFarAway"])
blockViaBypass(app)

app.buttons["home.unblockAll"].tap()
let locationRow = app.buttons["keySelect.row.LOCATION"]
require(locationRow, "The picker should offer the location key")
locationRow.tap()

require(app.staticTexts["You're not in an unlock area"], "Away from the key, the check should say so")
let close = app.buttons["locationUnlock.close"]
require(close, "The location check should have a close button")
XCTAssertEqual(close.label, "Close")
close.tap()

require(app.buttons["keySelect.row.QR"], "Closing should return to Choose Key")
XCTAssertFalse(close.exists, "The location check should be gone")
}

func testBlockingDisablesKeysTab() {
let app = launch()
blockViaBypass(app)
Expand Down
23 changes: 23 additions & 0 deletions NormalUITests/NormalUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,29 @@ final class NormalUITests: XCTestCase {
)
}

@MainActor
func testLocationKeyInfoClosesWithTheCloseButton() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding", "-uiTestSeedLocationKey"])
app.mainTab("Keys").tap()
app.buttons["keys.addButton"].tap()
let locationSegment = app.buttons["Location"]
require(locationSegment, "Location key type should be selectable")
locationSegment.tap()
app.buttons["key.locationButton"].tap()

let map = app.otherElements["locationPicker.map"].firstMatch
require(map, "Location picker should show the map")
sleep(2)
map.tap()

let close = app.buttons["locationKeyInfo.close"]
require(close, "Tapping a saved key's area should show its details")
XCTAssertEqual(close.label, "Close")
close.tap()
XCTAssertTrue(close.waitForNonExistence(timeout: timeout), "Close should dismiss the details")
require(map, "Closing the details should return to the map")
}

@MainActor
func testCustomDomainsEditorHiddenWhenToggleOff() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding"])
Expand Down
Loading