diff --git a/MC1/Views/Chats/ChatsView.swift b/MC1/Views/Chats/ChatsView.swift index 8f036c542c..1e7f4d90ab 100644 --- a/MC1/Views/Chats/ChatsView.swift +++ b/MC1/Views/Chats/ChatsView.swift @@ -17,7 +17,8 @@ struct ChatsView: View { columnVisibility: columnVisibility, tabBarPlacement: tabBarPlacement, preferredColumn: preferredCompactColumn, - hasSelection: appState.navigation.chatsSelectedRoute != nil + hasSelection: appState.navigation.chatsSelectedRoute != nil, + sectionIsSelected: appState.navigation.selectedTab == AppTab.chats.rawValue ) } diff --git a/MC1/Views/Chats/Mentions/ChatConversationMentionOverlay.swift b/MC1/Views/Chats/Mentions/ChatConversationMentionOverlay.swift index f6e663cdeb..b834c72c0b 100644 --- a/MC1/Views/Chats/Mentions/ChatConversationMentionOverlay.swift +++ b/MC1/Views/Chats/Mentions/ChatConversationMentionOverlay.swift @@ -3,8 +3,8 @@ import SwiftUI /// Floating mention suggestions overlay for the chat input. struct ChatConversationMentionOverlay: View { - /// Clearance above the compose bar when the keyboard is down (bar ~height). - private static let composeBarClearance: CGFloat = 60 + /// Space under the card. The timeline safe area ends at the composer, so this is only the gap. + private static let gapAboveComposer: CGFloat = 0 let suggestions: [ContactDTO] let onSelectMention: (ContactDTO) -> Void @@ -17,9 +17,7 @@ struct ChatConversationMentionOverlay: View { onSelectMention(contact) } .padding(.horizontal) - // Clearance above the compose bar, then `chatKeyboardLift` for the keyboard. - .padding(.bottom, Self.composeBarClearance) - .chatKeyboardLiftPadding() + .padding(.bottom, Self.gapAboveComposer) .transition( .asymmetric( insertion: .move(edge: .bottom) @@ -28,8 +26,6 @@ struct ChatConversationMentionOverlay: View { removal: .move(edge: .bottom).combined(with: .opacity) ) ) - // `ChatWindowBottomInset` keeps suggestions above the bar once the container inset is ignored. - ChatWindowBottomInset() } .animation(.spring(response: 0.3, dampingFraction: 0.8), value: suggestions.isEmpty) } diff --git a/MC1/Views/Chats/Navigation/SectionSplitPresentation.swift b/MC1/Views/Chats/Navigation/SectionSplitPresentation.swift index 8f6d4a8c9e..b1f05a6f15 100644 --- a/MC1/Views/Chats/Navigation/SectionSplitPresentation.swift +++ b/MC1/Views/Chats/Navigation/SectionSplitPresentation.swift @@ -20,8 +20,12 @@ enum SectionSplitPresentation { columnVisibility: NavigationSplitViewVisibility, tabBarPlacement: TabBarPlacement?, preferredColumn: NavigationSplitViewColumn, - hasSelection: Bool + hasSelection: Bool, + sectionIsSelected: Bool ) -> Visibility { + // An unselected section returns automatic. The tab stays mounted, so a hidden + // preference would hide the bar on the selected tab. + guard sectionIsSelected else { return .automatic } let collapsedDetail = sizeClass == .compact && preferredColumn == .detail && hasSelection diff --git a/MC1/Views/Components/MapToolboxPlacement.swift b/MC1/Views/Components/MapToolboxPlacement.swift index a3046ea4f2..ab7273a216 100644 --- a/MC1/Views/Components/MapToolboxPlacement.swift +++ b/MC1/Views/Components/MapToolboxPlacement.swift @@ -1,6 +1,31 @@ import SwiftUI enum MapToolboxColumn { + /// The vertical tab bar capsule keeps this margin from the screen edge. + /// The home-indicator inset is taller, so the safe-area bottom sits above it. + static let verticalTabBarScreenMargin: CGFloat = 24 + + /// Matches the pad `MapControlsToolbar` puts around the glass. + static let toolbarGlassPadding: CGFloat = 16 + + static var sharedTabBarBottomPadding: CGFloat { + verticalTabBarScreenMargin - toolbarGlassPadding + } + + /// The system's own inset stays between the capsules. Other sides keep their pad. + static func barFacingInset(sharesTabBarBottom: Bool, edge: HorizontalEdge?) -> EdgeInsets { + guard sharesTabBarBottom else { return EdgeInsets() } + let pull = -toolbarGlassPadding + switch edge { + case .leading: + return EdgeInsets(top: 0, leading: pull, bottom: 0, trailing: 0) + case .trailing: + return EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: pull) + case nil: + return EdgeInsets() + } + } + static func alignsLeading(_ verticalBarEdge: HorizontalEdge?) -> Bool { verticalBarEdge == .leading } @@ -20,10 +45,50 @@ enum MapToolboxColumn { static func hidesTabBar(_ verticalBarEdge: HorizontalEdge?) -> Bool { verticalBarEdge != nil } + + static func inset(on edge: HorizontalEdge?, of insets: EdgeInsets) -> CGFloat { + switch edge { + case .leading: + insets.leading + case .trailing: + insets.trailing + case nil: + 0 + } + } + + /// Share the tab bar bottom only while the toolbox stays beside a visible bar. + /// A preferred edge with no inset has no column. + static func sharesTabBarBottom( + followsVerticalBar: Bool, + pinsToBottom: Bool, + verticalBarEdge: HorizontalEdge?, + edgeInset: CGFloat + ) -> Bool { + !followsVerticalBar + && pinsToBottom + && verticalBarEdge != nil + && edgeInset > 0 + } + + /// Following the bar uses that column. Sharing keeps the safe area and sits on the bar's side. + static func alignmentEdge( + columnEdge: HorizontalEdge?, + sharesTabBarBottom: Bool, + verticalBarEdge: HorizontalEdge? + ) -> HorizontalEdge? { + if columnEdge != nil { + return columnEdge + } + if sharesTabBarBottom { + return verticalBarEdge + } + return nil + } } /// Bottom-corner toolbox, unless `pinsToBottom` is false. `followsVerticalBar` -/// moves it into a vertical-bar column and hides the tab bar; false leaves both visible. +/// moves it into a vertical-bar column and hides the tab bar. Beside a visible bar, both stay visible and share its bottom without the facing pad. struct MapToolboxPlacement: View { var bottomPadding: CGFloat = 0 var pinsToBottom: Bool = true @@ -40,7 +105,9 @@ struct MapToolboxPlacement: View { ) } else { ToolboxStack( - verticalBarEdge: nil, + columnEdge: nil, + alignmentEdge: nil, + sharesTabBarBottom: false, bottomPadding: bottomPadding, pinsToBottom: pinsToBottom, content: content @@ -51,6 +118,7 @@ struct MapToolboxPlacement: View { @available(iOS 27.1, *) private struct VerticalBarToolbox: View { @Environment(\.toolbarVerticalEdge) private var toolbarVerticalEdge + @State private var edgeInset: CGFloat = 0 var bottomPadding: CGFloat var pinsToBottom: Bool @@ -58,18 +126,37 @@ struct MapToolboxPlacement: View { @ViewBuilder var content: () -> Toolbox var body: some View { + let barEdge = toolbarVerticalEdge + let columnEdge: HorizontalEdge? = followsVerticalBar ? barEdge : nil + let sharesTabBarBottom = MapToolboxColumn.sharesTabBarBottom( + followsVerticalBar: followsVerticalBar, + pinsToBottom: pinsToBottom, + verticalBarEdge: barEdge, + edgeInset: edgeInset + ) ToolboxStack( - verticalBarEdge: followsVerticalBar ? toolbarVerticalEdge : nil, + columnEdge: columnEdge, + alignmentEdge: MapToolboxColumn.alignmentEdge( + columnEdge: columnEdge, + sharesTabBarBottom: sharesTabBarBottom, + verticalBarEdge: barEdge + ), + sharesTabBarBottom: sharesTabBarBottom, bottomPadding: bottomPadding, pinsToBottom: pinsToBottom, content: content ) + .onGeometryChange(for: CGFloat.self) { proxy in + MapToolboxColumn.inset(on: barEdge, of: proxy.safeAreaInsets) + } action: { edgeInset = $0 } } } } private struct ToolboxStack: View { - var verticalBarEdge: HorizontalEdge? + var columnEdge: HorizontalEdge? + var alignmentEdge: HorizontalEdge? + var sharesTabBarBottom: Bool var bottomPadding: CGFloat var pinsToBottom: Bool @ViewBuilder var content: () -> Content @@ -85,18 +172,29 @@ private struct ToolboxStack: View { row } } - .modifier(ToolboxColumnSafeArea(edge: verticalBarEdge)) - .padding(.bottom, pinsToBottom ? bottomPadding : 0) - .modifier(VerticalBarTabBarHider(edge: verticalBarEdge)) + .modifier(ToolboxColumnSafeArea(edge: columnEdge)) + .modifier( + ToolboxBottomAlignment( + sharesTabBarBottom: sharesTabBarBottom, + extraPadding: pinsToBottom ? bottomPadding : 0 + ) + ) + .modifier(VerticalBarTabBarHider(edge: columnEdge)) } private var row: some View { HStack { - if !MapToolboxColumn.alignsLeading(verticalBarEdge) { + if !MapToolboxColumn.alignsLeading(alignmentEdge) { Spacer() } content() - if MapToolboxColumn.alignsLeading(verticalBarEdge) { + .padding( + MapToolboxColumn.barFacingInset( + sharesTabBarBottom: sharesTabBarBottom, + edge: alignmentEdge + ) + ) + if MapToolboxColumn.alignsLeading(alignmentEdge) { Spacer() } } @@ -115,6 +213,21 @@ private struct ToolboxColumnSafeArea: ViewModifier { } } +private struct ToolboxBottomAlignment: ViewModifier { + var sharesTabBarBottom: Bool + var extraPadding: CGFloat + + func body(content: Content) -> some View { + if sharesTabBarBottom { + content + .padding(.bottom, MapToolboxColumn.sharedTabBarBottomPadding + extraPadding) + .ignoresSafeArea(.container, edges: .bottom) + } else { + content.padding(.bottom, extraPadding) + } + } +} + private struct VerticalBarTabBarHider: ViewModifier { var edge: HorizontalEdge? diff --git a/MC1Tests/Views/AdaptiveNavigationTests.swift b/MC1Tests/Views/AdaptiveNavigationTests.swift index b775e84677..7549935239 100644 --- a/MC1Tests/Views/AdaptiveNavigationTests.swift +++ b/MC1Tests/Views/AdaptiveNavigationTests.swift @@ -24,16 +24,19 @@ struct AdaptiveNavigationTests { // MARK: - Presentation recipe - @Test - func `collapsed compact detail hides tabs`() { + @Test(arguments: [true, false]) + func `collapsed compact detail hides tabs only for the selected section`( + sectionIsSelected: Bool + ) { let visibility = SectionSplitPresentation.tabBarVisibility( sizeClass: .compact, columnVisibility: .all, tabBarPlacement: .bottomBar, preferredColumn: .detail, - hasSelection: true + hasSelection: true, + sectionIsSelected: sectionIsSelected ) - #expect(visibility == .hidden) + #expect(visibility == (sectionIsSelected ? .hidden : .automatic)) } @Test @@ -43,7 +46,8 @@ struct AdaptiveNavigationTests { columnVisibility: .all, tabBarPlacement: .bottomBar, preferredColumn: .sidebar, - hasSelection: false + hasSelection: false, + sectionIsSelected: true ) #expect(visibility == .automatic) } @@ -59,7 +63,8 @@ struct AdaptiveNavigationTests { columnVisibility: columnVisibility, tabBarPlacement: placement, preferredColumn: .sidebar, - hasSelection: hasSelection + hasSelection: hasSelection, + sectionIsSelected: true ) let hidesBottomTabs = placement == .bottomBar && columnVisibility == .detailOnly && hasSelection #expect(visibility == (hidesBottomTabs ? .hidden : .automatic)) diff --git a/MC1Tests/Views/Chats/Components/ChatNativeSplitLayoutTests.swift b/MC1Tests/Views/Chats/Components/ChatNativeSplitLayoutTests.swift index 72252e3027..311310ea49 100644 --- a/MC1Tests/Views/Chats/Components/ChatNativeSplitLayoutTests.swift +++ b/MC1Tests/Views/Chats/Components/ChatNativeSplitLayoutTests.swift @@ -896,7 +896,8 @@ private final class ChatNativeSplitHarnessModel { columnVisibility: columnVisibility, tabBarPlacement: placement, preferredColumn: preferredCompactColumn, - hasSelection: selectedRoute != nil + hasSelection: selectedRoute != nil, + sectionIsSelected: true ) } diff --git a/MC1Tests/Views/Map/MapToolboxColumnTests.swift b/MC1Tests/Views/Map/MapToolboxColumnTests.swift new file mode 100644 index 0000000000..85858c79c2 --- /dev/null +++ b/MC1Tests/Views/Map/MapToolboxColumnTests.swift @@ -0,0 +1,94 @@ +import CoreGraphics +@testable import MC1 +import SwiftUI +import Testing + +@Suite("Map toolbox column") +struct MapToolboxColumnTests { + @Test + func `beside a visible vertical bar the toolbox shares its bottom`() { + let shares = MapToolboxColumn.sharesTabBarBottom( + followsVerticalBar: false, + pinsToBottom: true, + verticalBarEdge: .trailing, + edgeInset: 72 + ) + #expect(shares) + #expect( + MapToolboxColumn.alignmentEdge( + columnEdge: nil, + sharesTabBarBottom: shares, + verticalBarEdge: .trailing + ) == .trailing + ) + } + + @Test + func `a leading bar keeps the toolbox on that side without taking the column`() { + let shares = MapToolboxColumn.sharesTabBarBottom( + followsVerticalBar: false, + pinsToBottom: true, + verticalBarEdge: .leading, + edgeInset: 72 + ) + #expect(shares) + #expect(MapToolboxColumn.safeAreaEdge(nil) == nil) + #expect( + MapToolboxColumn.alignmentEdge( + columnEdge: nil, + sharesTabBarBottom: true, + verticalBarEdge: .leading + ) == .leading + ) + } + + @Test(arguments: [ + (true, true, HorizontalEdge?.some(.trailing), CGFloat(72)), + (false, false, HorizontalEdge?.some(.trailing), CGFloat(72)), + (false, true, HorizontalEdge?.none, CGFloat(72)), + (false, true, HorizontalEdge?.some(.trailing), CGFloat(0)), + ]) + func `other placements keep the safe-area bottom`( + followsVerticalBar: Bool, + pinsToBottom: Bool, + verticalBarEdge: HorizontalEdge?, + edgeInset: CGFloat + ) { + #expect( + !MapToolboxColumn.sharesTabBarBottom( + followsVerticalBar: followsVerticalBar, + pinsToBottom: pinsToBottom, + verticalBarEdge: verticalBarEdge, + edgeInset: edgeInset + ) + ) + } + + @Test + func `following the bar still uses its column`() { + #expect( + MapToolboxColumn.alignmentEdge( + columnEdge: .trailing, + sharesTabBarBottom: false, + verticalBarEdge: .trailing + ) == .trailing + ) + #expect(MapToolboxColumn.hidesTabBar(.trailing)) + #expect(MapToolboxColumn.safeAreaEdge(.trailing) == .trailing) + } + + @Test + func `sharing pulls back only the pad that faces the bar`() { + let trailing = MapToolboxColumn.barFacingInset(sharesTabBarBottom: true, edge: .trailing) + #expect(trailing.trailing == -MapToolboxColumn.toolbarGlassPadding) + #expect(trailing.leading == 0) + #expect(trailing.top == 0) + #expect(trailing.bottom == 0) + + let leading = MapToolboxColumn.barFacingInset(sharesTabBarBottom: true, edge: .leading) + #expect(leading.leading == -MapToolboxColumn.toolbarGlassPadding) + #expect(leading.trailing == 0) + + #expect(MapToolboxColumn.barFacingInset(sharesTabBarBottom: false, edge: .trailing) == EdgeInsets()) + } +} diff --git a/Makefile b/Makefile index da215c274c..5b10e87df7 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ SCHEME := MC1 PROJECT := MC1.xcodeproj # The full app suite runs on the project-standard iOS 27 simulator. Override SIM to retarget. -SIM ?= platform=iOS Simulator,name=iPhone 17e,OS=27.0 +SIM ?= platform=iOS Simulator,name=iPhone 17e,OS=27.2 # Additional test options, including result-bundle paths and repetition settings. XCODEBUILD_TEST_ARGS ?= diff --git a/project.yml b/project.yml index b02aefa0e7..1e84f36fde 100644 --- a/project.yml +++ b/project.yml @@ -75,7 +75,7 @@ targets: base: SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: YES ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon - MARKETING_VERSION: 1.7.0 + MARKETING_VERSION: 1.7.1 CURRENT_PROJECT_VERSION: 1 VERSIONING_SYSTEM: apple-generic TARGETED_DEVICE_FAMILY: "1,2" @@ -113,7 +113,7 @@ targets: settings: base: INFOPLIST_FILE: MC1Tests/Info.plist - MARKETING_VERSION: 1.7.0 + MARKETING_VERSION: 1.7.1 CURRENT_PROJECT_VERSION: 1 VERSIONING_SYSTEM: apple-generic TEST_HOST: "$(BUILT_PRODUCTS_DIR)/MC1.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/MC1" @@ -127,7 +127,7 @@ targets: - path: Shared settings: base: - MARKETING_VERSION: 1.7.0 + MARKETING_VERSION: 1.7.1 CURRENT_PROJECT_VERSION: 1 VERSIONING_SYSTEM: apple-generic TARGETED_DEVICE_FAMILY: "1,2"