2026-02-06 18:59:53 +00:00
|
|
|
|
import SwiftUI
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#if os(macOS)
|
2026-02-06 18:59:53 +00:00
|
|
|
|
import AppKit
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#elseif os(iOS)
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
#endif
|
2026-02-06 18:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
extension ContentView {
|
2026-02-12 09:15:40 +00:00
|
|
|
|
private var compactActiveProviderName: String {
|
|
|
|
|
|
activeProviderName.components(separatedBy: " (").first ?? activeProviderName
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#if os(iOS)
|
|
|
|
|
|
private var isIPadToolbarLayout: Bool {
|
2026-02-18 22:56:46 +00:00
|
|
|
|
guard UIDevice.current.userInterfaceIdiom == .pad else { return false }
|
|
|
|
|
|
// During first render on iOS, horizontalSizeClass can transiently be nil.
|
|
|
|
|
|
// Treat nil as regular so the full iPad toolbar appears immediately.
|
|
|
|
|
|
if horizontalSizeClass == .compact { return false }
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var iPhoneToolbarWidth: CGFloat {
|
|
|
|
|
|
UIApplication.shared.connectedScenes
|
|
|
|
|
|
.compactMap { $0 as? UIWindowScene }
|
|
|
|
|
|
.first(where: { $0.activationState == .foregroundActive })?
|
|
|
|
|
|
.screen.bounds.width ?? 390
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var iPhonePromotedActionsCount: Int {
|
|
|
|
|
|
switch iPhoneToolbarWidth {
|
|
|
|
|
|
case 430...: return 4
|
|
|
|
|
|
case 395...: return 3
|
|
|
|
|
|
default: return 2
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var iPhoneLanguagePickerWidth: CGFloat {
|
|
|
|
|
|
switch iPhoneToolbarWidth {
|
|
|
|
|
|
case 430...: return 100
|
|
|
|
|
|
case 395...: return 90
|
|
|
|
|
|
default: return 78
|
|
|
|
|
|
}
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var iPadToolbarMaxWidth: CGFloat {
|
|
|
|
|
|
let screenWidth = UIApplication.shared.connectedScenes
|
|
|
|
|
|
.compactMap { $0 as? UIWindowScene }
|
|
|
|
|
|
.first(where: { $0.activationState == .foregroundActive })?
|
|
|
|
|
|
.screen.bounds.width ?? 1024
|
|
|
|
|
|
let target = screenWidth * 0.72
|
|
|
|
|
|
return min(max(target, 560), 980)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var iPadPromotedActionsCount: Int {
|
|
|
|
|
|
switch iPadToolbarMaxWidth {
|
2026-02-18 22:56:46 +00:00
|
|
|
|
case 920...: return 5
|
|
|
|
|
|
case 840...: return 5
|
|
|
|
|
|
case 760...: return 4
|
2026-02-07 10:51:52 +00:00
|
|
|
|
case 680...: return 4
|
|
|
|
|
|
case 620...: return 3
|
|
|
|
|
|
default: return 2
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 18:46:08 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var newTabControl: some View {
|
|
|
|
|
|
Button(action: { viewModel.addNewTab() }) {
|
|
|
|
|
|
Image(systemName: "plus.square.on.square")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("New Tab (Cmd+T)")
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("t", modifiers: .command)
|
2026-02-11 10:20:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var settingsControl: some View {
|
|
|
|
|
|
Button(action: { showSettingsSheet = true }) {
|
|
|
|
|
|
Image(systemName: "gearshape")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Settings (Cmd+,)")
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut(",", modifiers: .command)
|
2026-02-07 18:46:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var languagePickerControl: some View {
|
2026-02-09 10:21:50 +00:00
|
|
|
|
Picker("Language", selection: currentLanguagePickerBinding) {
|
2026-02-13 11:02:39 +00:00
|
|
|
|
ForEach(["swift", "python", "javascript", "typescript", "php", "java", "kotlin", "go", "ruby", "rust", "cobol", "dotenv", "proto", "graphql", "rst", "nginx", "sql", "html", "expressionengine", "css", "c", "cpp", "csharp", "objective-c", "json", "xml", "yaml", "toml", "csv", "ini", "vim", "log", "ipynb", "markdown", "bash", "zsh", "powershell", "standard", "plain"], id: \.self) { lang in
|
2026-02-07 10:51:52 +00:00
|
|
|
|
let label: String = {
|
|
|
|
|
|
switch lang {
|
2026-02-07 23:20:47 +00:00
|
|
|
|
case "php": return "PHP"
|
2026-02-08 22:41:39 +00:00
|
|
|
|
case "cobol": return "COBOL"
|
|
|
|
|
|
case "dotenv": return "Dotenv"
|
|
|
|
|
|
case "proto": return "Proto"
|
|
|
|
|
|
case "graphql": return "GraphQL"
|
|
|
|
|
|
case "rst": return "reStructuredText"
|
|
|
|
|
|
case "nginx": return "Nginx"
|
2026-02-07 10:51:52 +00:00
|
|
|
|
case "objective-c": return "Objective-C"
|
|
|
|
|
|
case "csharp": return "C#"
|
2026-02-09 10:21:50 +00:00
|
|
|
|
case "c": return "C"
|
2026-02-07 10:51:52 +00:00
|
|
|
|
case "cpp": return "C++"
|
|
|
|
|
|
case "json": return "JSON"
|
|
|
|
|
|
case "xml": return "XML"
|
|
|
|
|
|
case "yaml": return "YAML"
|
|
|
|
|
|
case "toml": return "TOML"
|
2026-02-07 23:20:47 +00:00
|
|
|
|
case "csv": return "CSV"
|
2026-02-07 10:51:52 +00:00
|
|
|
|
case "ini": return "INI"
|
|
|
|
|
|
case "sql": return "SQL"
|
2026-02-08 11:14:49 +00:00
|
|
|
|
case "vim": return "Vim"
|
|
|
|
|
|
case "log": return "Log"
|
|
|
|
|
|
case "ipynb": return "Jupyter Notebook"
|
2026-02-07 10:51:52 +00:00
|
|
|
|
case "html": return "HTML"
|
2026-02-13 11:02:39 +00:00
|
|
|
|
case "expressionengine": return "ExpressionEngine"
|
2026-02-07 10:51:52 +00:00
|
|
|
|
case "css": return "CSS"
|
|
|
|
|
|
case "standard": return "Standard"
|
|
|
|
|
|
default: return lang.capitalized
|
|
|
|
|
|
}
|
|
|
|
|
|
}()
|
|
|
|
|
|
Text(label).tag(lang)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.labelsHidden()
|
|
|
|
|
|
.help("Language")
|
2026-02-18 22:56:46 +00:00
|
|
|
|
.frame(width: isIPadToolbarLayout ? 160 : iPhoneLanguagePickerWidth)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var activeProviderBadgeControl: some View {
|
2026-02-12 09:15:40 +00:00
|
|
|
|
Text(compactActiveProviderName)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
.font(.caption)
|
|
|
|
|
|
.foregroundColor(.secondary)
|
2026-02-12 09:15:40 +00:00
|
|
|
|
.lineLimit(1)
|
|
|
|
|
|
.truncationMode(.tail)
|
|
|
|
|
|
.minimumScaleFactor(0.9)
|
|
|
|
|
|
.fixedSize(horizontal: true, vertical: false)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
.padding(.horizontal, 6)
|
|
|
|
|
|
.padding(.vertical, 2)
|
|
|
|
|
|
.background(Color.secondary.opacity(0.12), in: Capsule())
|
|
|
|
|
|
.help("Active provider")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var clearEditorControl: some View {
|
|
|
|
|
|
Button(action: {
|
2026-02-12 22:20:39 +00:00
|
|
|
|
requestClearEditorContent()
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "trash")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Clear Editor")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-09 10:21:50 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var insertTemplateControl: some View {
|
|
|
|
|
|
Button(action: { insertTemplateForCurrentLanguage() }) {
|
|
|
|
|
|
Image(systemName: "doc.badge.plus")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Insert Template for Current Language")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-16 19:02:43 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var lineWrapControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
viewModel.isLineWrapEnabled.toggle()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "text.justify")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Enable Wrap / Disable Wrap (Cmd+Opt+L)")
|
|
|
|
|
|
.keyboardShortcut("l", modifiers: [.command, .option])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var openFileControl: some View {
|
|
|
|
|
|
Button(action: { openFileFromToolbar() }) {
|
|
|
|
|
|
Image(systemName: "folder")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Open File… (Cmd+O)")
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("o", modifiers: .command)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var saveFileControl: some View {
|
|
|
|
|
|
Button(action: { saveCurrentTabFromToolbar() }) {
|
|
|
|
|
|
Image(systemName: "square.and.arrow.down")
|
|
|
|
|
|
}
|
|
|
|
|
|
.disabled(viewModel.selectedTab == nil)
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Save File (Cmd+S)")
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("s", modifiers: .command)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var toggleSidebarControl: some View {
|
|
|
|
|
|
Button(action: { toggleSidebarFromToolbar() }) {
|
|
|
|
|
|
Image(systemName: "sidebar.left")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Toggle Sidebar (Cmd+Opt+S)")
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("s", modifiers: [.command, .option])
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var toggleProjectSidebarControl: some View {
|
|
|
|
|
|
Button(action: { showProjectStructureSidebar.toggle() }) {
|
|
|
|
|
|
Image(systemName: "sidebar.right")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Toggle Project Structure Sidebar")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var findReplaceControl: some View {
|
|
|
|
|
|
Button(action: { showFindReplace = true }) {
|
|
|
|
|
|
Image(systemName: "magnifyingglass")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Find & Replace (Cmd+F)")
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("f", modifiers: .command)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-16 21:12:55 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var brainDumpControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
viewModel.isBrainDumpMode.toggle()
|
|
|
|
|
|
UserDefaults.standard.set(viewModel.isBrainDumpMode, forKey: "BrainDumpModeEnabled")
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "note.text")
|
|
|
|
|
|
.symbolVariant(viewModel.isBrainDumpMode ? .fill : .none)
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Brain Dump Mode")
|
|
|
|
|
|
.accessibilityLabel("Brain Dump Mode")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-18 18:59:25 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var codeCompletionControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
toggleAutoCompletion()
|
|
|
|
|
|
}) {
|
2026-02-19 08:09:35 +00:00
|
|
|
|
Image(systemName: "bolt.horizontal.circle")
|
2026-02-18 18:59:25 +00:00
|
|
|
|
.symbolVariant(isAutoCompletionEnabled ? .fill : .none)
|
|
|
|
|
|
}
|
2026-02-19 08:09:35 +00:00
|
|
|
|
.help(isAutoCompletionEnabled ? "Disable Code Completion" : "Enable Code Completion")
|
2026-02-18 18:59:25 +00:00
|
|
|
|
.accessibilityLabel("Code Completion")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-18 22:56:46 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var performanceModeControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
forceLargeFileMode.toggle()
|
|
|
|
|
|
updateLargeFileMode(for: currentContentBinding.wrappedValue)
|
|
|
|
|
|
recordDiagnostic("Toolbar toggled performance mode: \(forceLargeFileMode ? "on" : "off")")
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: forceLargeFileMode ? "speedometer" : "speedometer")
|
|
|
|
|
|
.symbolVariant(forceLargeFileMode ? .fill : .none)
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Performance Mode")
|
|
|
|
|
|
.accessibilityLabel("Performance Mode")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var keyboardAccessoryControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showKeyboardAccessoryBarIOS.toggle()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: showKeyboardAccessoryBarIOS ? "keyboard.chevron.compact.down.fill" : "keyboard.chevron.compact.down")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help(showKeyboardAccessoryBarIOS ? "Hide Keyboard Snippet Bar" : "Show Keyboard Snippet Bar")
|
|
|
|
|
|
.accessibilityLabel("Keyboard Snippet Bar")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-16 21:12:55 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var welcomeTourControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showWelcomeTour = true
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "sparkles.rectangle.stack")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Welcome Tour")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var translucentWindowControl: some View {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
enableTranslucentWindow.toggle()
|
|
|
|
|
|
UserDefaults.standard.set(enableTranslucentWindow, forKey: "EnableTranslucentWindow")
|
|
|
|
|
|
NotificationCenter.default.post(name: .toggleTranslucencyRequested, object: enableTranslucentWindow)
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: enableTranslucentWindow ? "rectangle.fill" : "rectangle")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Toggle Translucent Window Background")
|
|
|
|
|
|
.accessibilityLabel("Translucent Window Background")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var iPadPromotedActions: some View {
|
|
|
|
|
|
if iPadPromotedActionsCount >= 1 { openFileControl }
|
|
|
|
|
|
if iPadPromotedActionsCount >= 2 { saveFileControl }
|
|
|
|
|
|
if iPadPromotedActionsCount >= 3 { toggleSidebarControl }
|
|
|
|
|
|
if iPadPromotedActionsCount >= 4 { toggleProjectSidebarControl }
|
|
|
|
|
|
if iPadPromotedActionsCount >= 5 { findReplaceControl }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var moreActionsControl: some View {
|
|
|
|
|
|
Menu {
|
2026-02-16 21:12:55 +00:00
|
|
|
|
Button(action: {
|
|
|
|
|
|
showSettingsSheet = true
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label("Settings", systemImage: "gearshape")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
requestClearEditorContent()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label("Clear Editor", systemImage: "trash")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-09 10:21:50 +00:00
|
|
|
|
Button(action: { insertTemplateForCurrentLanguage() }) {
|
|
|
|
|
|
Label("Insert Template", systemImage: "doc.badge.plus")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
Button(action: { openFileFromToolbar() }) {
|
|
|
|
|
|
Label("Open File…", systemImage: "folder")
|
|
|
|
|
|
}
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("o", modifiers: .command)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: { saveCurrentTabFromToolbar() }) {
|
|
|
|
|
|
Label("Save File", systemImage: "square.and.arrow.down")
|
|
|
|
|
|
}
|
|
|
|
|
|
.disabled(viewModel.selectedTab == nil)
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("s", modifiers: .command)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: { toggleSidebarFromToolbar() }) {
|
|
|
|
|
|
Label("Toggle Sidebar", systemImage: "sidebar.left")
|
|
|
|
|
|
}
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("s", modifiers: [.command, .option])
|
2026-02-07 10:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: { showProjectStructureSidebar.toggle() }) {
|
|
|
|
|
|
Label("Toggle Project Structure Sidebar", systemImage: "sidebar.right")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: { showFindReplace = true }) {
|
|
|
|
|
|
Label("Find & Replace", systemImage: "magnifyingglass")
|
|
|
|
|
|
}
|
2026-02-16 19:02:43 +00:00
|
|
|
|
.keyboardShortcut("f", modifiers: .command)
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: { viewModel.isLineWrapEnabled.toggle() }) {
|
|
|
|
|
|
Label("Enable Wrap / Disable Wrap", systemImage: "text.justify")
|
|
|
|
|
|
}
|
|
|
|
|
|
.keyboardShortcut("l", modifiers: [.command, .option])
|
2026-02-07 10:51:52 +00:00
|
|
|
|
|
2026-02-18 22:56:46 +00:00
|
|
|
|
Button(action: { toggleAutoCompletion() }) {
|
|
|
|
|
|
Label(isAutoCompletionEnabled ? "Disable Code Completion" : "Enable Code Completion", systemImage: "text.badge.plus")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showKeyboardAccessoryBarIOS.toggle()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label(
|
|
|
|
|
|
showKeyboardAccessoryBarIOS ? "Hide Keyboard Snippet Bar" : "Show Keyboard Snippet Bar",
|
|
|
|
|
|
systemImage: showKeyboardAccessoryBarIOS ? "keyboard.chevron.compact.down.fill" : "keyboard.chevron.compact.down"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
forceLargeFileMode.toggle()
|
|
|
|
|
|
updateLargeFileMode(for: currentContentBinding.wrappedValue)
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label(forceLargeFileMode ? "Disable Performance Mode" : "Enable Performance Mode", systemImage: "speedometer")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showBottomActionBarIOS.toggle()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label(showBottomActionBarIOS ? "Hide Bottom Action Bar" : "Show Bottom Action Bar", systemImage: "rectangle.bottomthird.inset.filled")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
Button(action: {
|
|
|
|
|
|
viewModel.isBrainDumpMode.toggle()
|
|
|
|
|
|
UserDefaults.standard.set(viewModel.isBrainDumpMode, forKey: "BrainDumpModeEnabled")
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label("Brain Dump Mode", systemImage: "note.text")
|
|
|
|
|
|
}
|
2026-02-12 23:28:35 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showWelcomeTour = true
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label("Welcome Tour", systemImage: "sparkles.rectangle.stack")
|
|
|
|
|
|
}
|
2026-02-07 10:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
enableTranslucentWindow.toggle()
|
|
|
|
|
|
UserDefaults.standard.set(enableTranslucentWindow, forKey: "EnableTranslucentWindow")
|
|
|
|
|
|
NotificationCenter.default.post(name: .toggleTranslucencyRequested, object: enableTranslucentWindow)
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Label("Translucent Window Background", systemImage: enableTranslucentWindow ? "rectangle.fill" : "rectangle")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} label: {
|
|
|
|
|
|
Image(systemName: "ellipsis.circle")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("More Actions")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var iOSToolbarControls: some View {
|
2026-02-16 19:02:43 +00:00
|
|
|
|
openFileControl
|
2026-02-18 22:56:46 +00:00
|
|
|
|
if iPhonePromotedActionsCount >= 2 { newTabControl }
|
|
|
|
|
|
if iPhonePromotedActionsCount >= 3 { saveFileControl }
|
|
|
|
|
|
if iPhonePromotedActionsCount >= 4 { findReplaceControl }
|
|
|
|
|
|
keyboardAccessoryControl
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var iPhonePrimaryToolbarCluster: some View {
|
|
|
|
|
|
GlassSurface(
|
|
|
|
|
|
enabled: shouldUseLiquidGlass,
|
|
|
|
|
|
material: primaryGlassMaterial,
|
|
|
|
|
|
fallbackColor: toolbarFallbackColor,
|
|
|
|
|
|
shape: .capsule
|
|
|
|
|
|
) {
|
|
|
|
|
|
HStack(spacing: 12) {
|
|
|
|
|
|
languagePickerControl
|
|
|
|
|
|
iOSToolbarControls
|
|
|
|
|
|
}
|
|
|
|
|
|
.padding(.horizontal, 12)
|
|
|
|
|
|
.padding(.vertical, 8)
|
|
|
|
|
|
}
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
|
|
private var iPadDistributedToolbarControls: some View {
|
|
|
|
|
|
languagePickerControl
|
2026-02-18 22:56:46 +00:00
|
|
|
|
if iPadPromotedActionsCount >= 4 { newTabControl }
|
2026-02-07 10:51:52 +00:00
|
|
|
|
Spacer(minLength: 18)
|
|
|
|
|
|
iPadPromotedActions
|
2026-02-18 22:56:46 +00:00
|
|
|
|
Spacer(minLength: 8)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
#endif
|
2026-02-06 18:59:53 +00:00
|
|
|
|
@ToolbarContentBuilder
|
|
|
|
|
|
var editorToolbarContent: some ToolbarContent {
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#if os(iOS)
|
2026-02-16 21:12:55 +00:00
|
|
|
|
if isIPadToolbarLayout {
|
2026-02-18 22:56:46 +00:00
|
|
|
|
ToolbarItem(placement: .topBarTrailing) {
|
|
|
|
|
|
HStack(spacing: 10) {
|
|
|
|
|
|
GlassSurface(
|
|
|
|
|
|
enabled: shouldUseLiquidGlass,
|
|
|
|
|
|
material: primaryGlassMaterial,
|
|
|
|
|
|
fallbackColor: toolbarFallbackColor,
|
|
|
|
|
|
shape: .capsule
|
|
|
|
|
|
) {
|
|
|
|
|
|
HStack(spacing: 12) {
|
|
|
|
|
|
iPadDistributedToolbarControls
|
|
|
|
|
|
}
|
|
|
|
|
|
.padding(.horizontal, 14)
|
|
|
|
|
|
.padding(.vertical, 9)
|
|
|
|
|
|
.frame(maxWidth: iPadToolbarMaxWidth, alignment: .trailing)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GlassSurface(
|
|
|
|
|
|
enabled: shouldUseLiquidGlass,
|
|
|
|
|
|
material: primaryGlassMaterial,
|
|
|
|
|
|
fallbackColor: toolbarFallbackColor,
|
|
|
|
|
|
shape: .circle
|
|
|
|
|
|
) {
|
|
|
|
|
|
moreActionsControl
|
|
|
|
|
|
.padding(8)
|
|
|
|
|
|
}
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
2026-02-18 22:56:46 +00:00
|
|
|
|
.scaleEffect(toolbarDensityScale, anchor: .trailing)
|
|
|
|
|
|
.opacity(toolbarDensityOpacity)
|
|
|
|
|
|
.animation(.easeOut(duration: 0.18), value: toolbarDensityScale)
|
|
|
|
|
|
.animation(.easeOut(duration: 0.18), value: toolbarDensityOpacity)
|
2026-02-16 21:12:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2026-02-18 22:56:46 +00:00
|
|
|
|
ToolbarItem(placement: .topBarTrailing) {
|
|
|
|
|
|
HStack(spacing: 10) {
|
|
|
|
|
|
iPhonePrimaryToolbarCluster
|
|
|
|
|
|
GlassSurface(
|
|
|
|
|
|
enabled: shouldUseLiquidGlass,
|
|
|
|
|
|
material: primaryGlassMaterial,
|
|
|
|
|
|
fallbackColor: toolbarFallbackColor,
|
|
|
|
|
|
shape: .circle
|
|
|
|
|
|
) {
|
|
|
|
|
|
moreActionsControl
|
|
|
|
|
|
.padding(8)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.scaleEffect(toolbarDensityScale, anchor: .trailing)
|
|
|
|
|
|
.opacity(toolbarDensityOpacity)
|
|
|
|
|
|
.animation(.easeOut(duration: 0.18), value: toolbarDensityScale)
|
|
|
|
|
|
.animation(.easeOut(duration: 0.18), value: toolbarDensityOpacity)
|
2026-02-07 10:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
2026-02-06 18:59:53 +00:00
|
|
|
|
ToolbarItemGroup(placement: .automatic) {
|
2026-02-09 10:21:50 +00:00
|
|
|
|
Picker("Language", selection: currentLanguagePickerBinding) {
|
2026-02-13 11:02:39 +00:00
|
|
|
|
ForEach(["swift", "python", "javascript", "typescript", "php", "java", "kotlin", "go", "ruby", "rust", "cobol", "dotenv", "proto", "graphql", "rst", "nginx", "sql", "html", "expressionengine", "css", "c", "cpp", "csharp", "objective-c", "json", "xml", "yaml", "toml", "csv", "ini", "vim", "log", "ipynb", "markdown", "bash", "zsh", "powershell", "standard", "plain"], id: \.self) { lang in
|
2026-02-06 18:59:53 +00:00
|
|
|
|
let label: String = {
|
|
|
|
|
|
switch lang {
|
2026-02-07 23:20:47 +00:00
|
|
|
|
case "php": return "PHP"
|
2026-02-08 22:41:39 +00:00
|
|
|
|
case "cobol": return "COBOL"
|
|
|
|
|
|
case "dotenv": return "Dotenv"
|
|
|
|
|
|
case "proto": return "Proto"
|
|
|
|
|
|
case "graphql": return "GraphQL"
|
|
|
|
|
|
case "rst": return "reStructuredText"
|
|
|
|
|
|
case "nginx": return "Nginx"
|
2026-02-06 18:59:53 +00:00
|
|
|
|
case "objective-c": return "Objective‑C"
|
|
|
|
|
|
case "csharp": return "C#"
|
2026-02-09 10:21:50 +00:00
|
|
|
|
case "c": return "C"
|
2026-02-06 18:59:53 +00:00
|
|
|
|
case "cpp": return "C++"
|
|
|
|
|
|
case "json": return "JSON"
|
|
|
|
|
|
case "xml": return "XML"
|
|
|
|
|
|
case "yaml": return "YAML"
|
|
|
|
|
|
case "toml": return "TOML"
|
2026-02-07 23:20:47 +00:00
|
|
|
|
case "csv": return "CSV"
|
2026-02-06 18:59:53 +00:00
|
|
|
|
case "ini": return "INI"
|
|
|
|
|
|
case "sql": return "SQL"
|
2026-02-08 11:14:49 +00:00
|
|
|
|
case "vim": return "Vim"
|
|
|
|
|
|
case "log": return "Log"
|
|
|
|
|
|
case "ipynb": return "Jupyter Notebook"
|
2026-02-06 18:59:53 +00:00
|
|
|
|
case "html": return "HTML"
|
2026-02-13 11:02:39 +00:00
|
|
|
|
case "expressionengine": return "ExpressionEngine"
|
2026-02-06 18:59:53 +00:00
|
|
|
|
case "css": return "CSS"
|
|
|
|
|
|
case "standard": return "Standard"
|
|
|
|
|
|
default: return lang.capitalized
|
|
|
|
|
|
}
|
|
|
|
|
|
}()
|
|
|
|
|
|
Text(label).tag(lang)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.labelsHidden()
|
|
|
|
|
|
.help("Language")
|
|
|
|
|
|
.controlSize(.large)
|
|
|
|
|
|
.frame(width: 140)
|
|
|
|
|
|
.padding(.vertical, 2)
|
|
|
|
|
|
|
2026-02-12 09:15:40 +00:00
|
|
|
|
Text(compactActiveProviderName)
|
2026-02-06 18:59:53 +00:00
|
|
|
|
.font(.caption)
|
|
|
|
|
|
.foregroundColor(.secondary)
|
2026-02-12 09:15:40 +00:00
|
|
|
|
.lineLimit(1)
|
|
|
|
|
|
.truncationMode(.tail)
|
|
|
|
|
|
.minimumScaleFactor(0.9)
|
|
|
|
|
|
.fixedSize(horizontal: true, vertical: false)
|
2026-02-06 18:59:53 +00:00
|
|
|
|
.padding(.horizontal, 6)
|
|
|
|
|
|
.padding(.vertical, 2)
|
|
|
|
|
|
.background(Color.secondary.opacity(0.12), in: Capsule())
|
2026-02-12 23:28:35 +00:00
|
|
|
|
.padding(.leading, 6)
|
2026-02-06 18:59:53 +00:00
|
|
|
|
.help("Active provider")
|
|
|
|
|
|
|
2026-02-11 10:20:17 +00:00
|
|
|
|
Button(action: {
|
|
|
|
|
|
openSettings()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "gearshape")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Settings")
|
|
|
|
|
|
|
2026-02-14 13:24:01 +00:00
|
|
|
|
if ReleaseRuntimePolicy.isUpdaterEnabledForCurrentDistribution {
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showUpdaterDialog(checkNow: true)
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "arrow.triangle.2.circlepath.circle")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Check for Updates")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-11 10:20:17 +00:00
|
|
|
|
Button(action: { adjustEditorFontSize(-1) }) {
|
|
|
|
|
|
Image(systemName: "textformat.size.smaller")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Decrease Font Size")
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: { adjustEditorFontSize(1) }) {
|
|
|
|
|
|
Image(systemName: "textformat.size.larger")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Increase Font Size")
|
|
|
|
|
|
|
2026-02-06 18:59:53 +00:00
|
|
|
|
Button(action: {
|
2026-02-12 22:20:39 +00:00
|
|
|
|
requestClearEditorContent()
|
2026-02-06 18:59:53 +00:00
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "trash")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Clear Editor")
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
2026-02-09 10:21:50 +00:00
|
|
|
|
insertTemplateForCurrentLanguage()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "doc.badge.plus")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Insert Template for Current Language")
|
|
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
Button(action: { openFileFromToolbar() }) {
|
2026-02-06 18:59:53 +00:00
|
|
|
|
Image(systemName: "folder")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Open File… (Cmd+O)")
|
2026-02-06 18:59:53 +00:00
|
|
|
|
|
2026-02-07 18:46:08 +00:00
|
|
|
|
Button(action: { viewModel.addNewTab() }) {
|
|
|
|
|
|
Image(systemName: "plus.square.on.square")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("New Tab (Cmd+T)")
|
2026-02-07 18:46:08 +00:00
|
|
|
|
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#if os(macOS)
|
2026-02-06 18:59:53 +00:00
|
|
|
|
Button(action: {
|
|
|
|
|
|
openWindow(id: "blank-window")
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "macwindow.badge.plus")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("New Window (Cmd+N)")
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#endif
|
2026-02-06 18:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
2026-02-07 10:51:52 +00:00
|
|
|
|
saveCurrentTabFromToolbar()
|
2026-02-06 18:59:53 +00:00
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "square.and.arrow.down")
|
|
|
|
|
|
}
|
|
|
|
|
|
.disabled(viewModel.selectedTab == nil)
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Save File (Cmd+S)")
|
2026-02-06 18:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
2026-02-07 10:51:52 +00:00
|
|
|
|
toggleSidebarFromToolbar()
|
2026-02-06 18:59:53 +00:00
|
|
|
|
}) {
|
2026-02-06 19:20:03 +00:00
|
|
|
|
Image(systemName: "sidebar.left")
|
|
|
|
|
|
.symbolVariant(viewModel.showSidebar ? .fill : .none)
|
2026-02-06 18:59:53 +00:00
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Toggle Sidebar (Cmd+Opt+S)")
|
2026-02-06 18:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showProjectStructureSidebar.toggle()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "sidebar.right")
|
|
|
|
|
|
.symbolVariant(showProjectStructureSidebar ? .fill : .none)
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Toggle Project Structure Sidebar")
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
showFindReplace = true
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "magnifyingglass")
|
|
|
|
|
|
}
|
2026-02-11 10:20:17 +00:00
|
|
|
|
.help("Find & Replace (Cmd+F)")
|
2026-02-06 18:59:53 +00:00
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
2026-02-18 18:59:25 +00:00
|
|
|
|
toggleAutoCompletion()
|
|
|
|
|
|
}) {
|
2026-02-19 08:09:35 +00:00
|
|
|
|
Image(systemName: "bolt.horizontal.circle")
|
2026-02-18 18:59:25 +00:00
|
|
|
|
.symbolVariant(isAutoCompletionEnabled ? .fill : .none)
|
|
|
|
|
|
}
|
2026-02-19 08:09:35 +00:00
|
|
|
|
.help(isAutoCompletionEnabled ? "Disable Code Completion" : "Enable Code Completion")
|
2026-02-18 18:59:25 +00:00
|
|
|
|
.accessibilityLabel("Code Completion")
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
2026-02-19 08:58:59 +00:00
|
|
|
|
showBracketHelperBarMac.toggle()
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: "chevron.left.chevron.right")
|
|
|
|
|
|
.symbolVariant(showBracketHelperBarMac ? .fill : .none)
|
|
|
|
|
|
}
|
|
|
|
|
|
.help(showBracketHelperBarMac ? "Hide Bracket Helper Bar" : "Show Bracket Helper Bar")
|
|
|
|
|
|
.accessibilityLabel("Bracket Helper Bar")
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
2026-02-06 18:59:53 +00:00
|
|
|
|
viewModel.isBrainDumpMode.toggle()
|
|
|
|
|
|
UserDefaults.standard.set(viewModel.isBrainDumpMode, forKey: "BrainDumpModeEnabled")
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: viewModel.isBrainDumpMode ? "note.text" : "note.text")
|
|
|
|
|
|
.symbolVariant(viewModel.isBrainDumpMode ? .fill : .none)
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Brain Dump Mode")
|
|
|
|
|
|
.accessibilityLabel("Brain Dump Mode")
|
|
|
|
|
|
|
|
|
|
|
|
Button(action: {
|
|
|
|
|
|
enableTranslucentWindow.toggle()
|
|
|
|
|
|
UserDefaults.standard.set(enableTranslucentWindow, forKey: "EnableTranslucentWindow")
|
|
|
|
|
|
NotificationCenter.default.post(name: .toggleTranslucencyRequested, object: enableTranslucentWindow)
|
|
|
|
|
|
}) {
|
|
|
|
|
|
Image(systemName: enableTranslucentWindow ? "rectangle.fill" : "rectangle")
|
|
|
|
|
|
}
|
|
|
|
|
|
.help("Toggle Translucent Window Background")
|
|
|
|
|
|
.accessibilityLabel("Translucent Window Background")
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-02-07 10:51:52 +00:00
|
|
|
|
#endif
|
2026-02-06 18:59:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|