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 apple/Sources/Logseq/LGMediaPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct LGMediaPanel: View {
maxSelectionCount: 20, selectionBehavior: .ordered,
matching: .images)
} else {
let foreground = isDark ? sheetBackground : Color.white
let foreground = Color.white
Button(action: addSelectedPhotos) {
HStack(spacing: 8) {
if isImporting { ProgressView().tint(foreground) }
Expand All @@ -104,7 +104,7 @@ struct LGMediaPanel: View {
.foregroundStyle(foreground)
.padding(.horizontal, 20)
.frame(height: 44)
.background(LogseqThemePolicy.sheetAccent(isDark: isDark), in: Capsule())
.background(LogseqThemePolicy.accent, in: Capsule())
}
.disabled(isImporting)
.accessibilityIdentifier("media.add-selected")
Expand Down
21 changes: 15 additions & 6 deletions apple/Sources/Logseq/LGNavigationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ private struct LGNavigationContent: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.ignoresSafeArea(.all, edges: .bottom)
// Keep the layout mounted without drawing the capture controls
// beneath the native search bar and its Cancel button.
.opacity(searchVisible ? 0 : 1)
.animation(nil, value: searchVisible)
.allowsHitTesting(!searchVisible)
.accessibilityHidden(searchVisible)
} else {
Expand Down Expand Up @@ -1272,9 +1276,12 @@ private struct LGNativeSearchControllerBridge: UIViewControllerRepresentable {
}
if !controller.isActive {
needsInitialFocus = true
controller.isActive = true
// Let editing activate the integrated search bar so UIKit can
// coordinate its expansion with the keyboard in one transition.
if #available(iOS 26.0, *) { focusIfNeeded() }
if !controller.isActive { controller.isActive = true }
}
if needsInitialFocus, controller.searchBar.searchTextField.becomeFirstResponder() { needsInitialFocus = false }
if #unavailable(iOS 26.0) { focusIfNeeded() }
} else if !state.nativePresented, controller.isActive {
controller.isActive = false
} else if !state.isVisible, !controller.isActive {
Expand All @@ -1292,11 +1299,13 @@ private struct LGNativeSearchControllerBridge: UIViewControllerRepresentable {
host.navigationItem.searchController = nil
}

private func focusIfNeeded() {
guard state.nativePresented, needsInitialFocus else { return }
if controller.searchBar.searchTextField.becomeFirstResponder() { needsInitialFocus = false }
}

func didPresentSearchController(_ searchController: UISearchController) {
DispatchQueue.main.async { [weak self] in
guard let self, self.state.nativePresented else { return }
if searchController.searchBar.searchTextField.becomeFirstResponder() { self.needsInitialFocus = false }
}
DispatchQueue.main.async { [weak self] in self?.focusIfNeeded() }
}
func willDismissSearchController(_ searchController: UISearchController) {
needsInitialFocus = false
Expand Down
4 changes: 3 additions & 1 deletion apple/Sources/Logseq/LGPlatformPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private struct LGSheetSurface: ViewModifier {
content
.background(background.ignoresSafeArea())
.presentationBackground(background)
.tint(LogseqThemePolicy.sheetAccent(isDark: dark))
.tint(LogseqThemePolicy.accent)
}
}

Expand All @@ -168,9 +168,11 @@ struct LGJournalCalendar: View {
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") { dismiss() }
.foregroundStyle(.primary)
}
ToolbarItem(placement: .confirmationAction) {
Button("Today") { select(Date()) }
.foregroundStyle(.primary)
.accessibilityIdentifier("button.journal-calendar.today")
}
}
Expand Down
6 changes: 1 addition & 5 deletions apple/Sources/Logseq/LogseqThemeSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ enum LogseqThemePolicy {
: Color(red: 27.0 / 255, green: 104.0 / 255, blue: 152.0 / 255)
}

static func sheetAccent(isDark: Bool) -> Color {
isDark ? linkColor(isDark: true) : accent
}

static func sheetBackground(isDark: Bool) -> Color {
(isDark ? dark : light).background
isDark ? dark.background : Color(red: 242.0 / 255, green: 242.0 / 255, blue: 247.0 / 255)
}

static let light = LogseqThemePalette(
Expand Down
6 changes: 3 additions & 3 deletions apple/Tests/UI/settings-control-colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ import Vision
}
}
let dark = style == .dark
let background = dark ? (0, 45, 56) : (252, 252, 252)
let background = dark ? (0, 45, 56) : (242, 242, 247)
let gutter = CGRect(x: 7, y: (1 - spell.midY) * window.bounds.height - 4, width: 5, height: 8)
guard matchingPixels(in: gutter, where: { r, g, b in
abs(r - background.0) <= 3 && abs(g - background.1) <= 3 && abs(b - background.2) <= 3
}) > 20 else { throw failure("Settings sheet must use the graph background") }
let accent = dark ? (155, 211, 212) : (3, 125, 186)
}) > 20 else { throw failure("Settings sheet must use the themed canvas behind its groups") }
let accent = (3, 125, 186)
func usesAccent(_ r: Int, _ g: Int, _ b: Int) -> Bool {
abs(r - accent.0) <= 12 && abs(g - accent.1) <= 12 && abs(b - accent.2) <= 12
}
Expand Down
6 changes: 4 additions & 2 deletions shared/src/logseq/view_base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let property_title current ~attr ~title =
open Lui_protocol

let main_background = Lui_ui.Adaptive { light = "#FCFCFC"; dark = "#002D38" }
let sheet_background = Lui_ui.Adaptive { light = "#F2F2F7"; dark = "#002D38" }
let grouped_row_background = Lui_ui.Adaptive { light = "#FFFFFF"; dark = "#FFFFFF14" }
let dark_accent = "#9BD3D4"

Expand All @@ -22,12 +23,13 @@ let sheet ?height ?style_class ?detents ?detents_signal ?accessibility_identifie
match Lui_ui.profile context with
| { profile_os = IOS; profile_host = SwiftUIHost } ->
(* The Apple modal host reads theme tokens from the sheet's ancestors. *)
let accent = Lui_ui.Adaptive { light = "#037DBA"; dark = dark_accent } in
let accent = Lui_ui.Fixed "#037DBA" in
let list_sheet = Option.fold ~none:false
~some:(fun style -> List.mem "navigation-list" (String.split_on_char ' ' style)) style_class in
Lui_elements.themed ~tokens:[
(* The list presentation uses the background token for the modal itself. *)
"surface", (if list_sheet then grouped_row_background else main_background);
"background", sheet_background;
"surface", (if list_sheet then grouped_row_background else sheet_background);
"card", grouped_row_background;
"input", grouped_row_background;
"primary", accent;
Expand Down
Loading