chore: added style changes 05a151af
Steve · 2025-12-23 20:58 2 file(s) · +51 −18
Titan/Views/ContentView.swift +7 −11
48 48
            }
49 49
50 50
            HStack(spacing: 12) {
51 -
                // Back button - always visible, grayed out when disabled
51 +
                // Navigation buttons - always visible, grayed out when disabled
52 52
                Button(action: goBack) {
53 53
                    Image(systemName: "chevron.left")
54 54
                        .font(.title2)
56 56
                }
57 57
                .disabled(!canGoBack || isLoading)
58 58
59 -
                // Forward button - only visible when there's history to go forward
60 -
                if canGoForward {
61 -
                    Button(action: goForward) {
62 -
                        Image(systemName: "chevron.right")
63 -
                            .font(.title2)
64 -
                            .foregroundColor(isLoading ? .gray.opacity(0.4) : .orange)
65 -
                    }
66 -
                    .disabled(isLoading)
59 +
                Button(action: goForward) {
60 +
                    Image(systemName: "chevron.right")
61 +
                        .font(.title2)
62 +
                        .foregroundColor(canGoForward && !isLoading ? .orange : .gray.opacity(0.4))
67 63
                }
64 +
                .disabled(!canGoForward || isLoading)
68 65
69 66
                ZStack(alignment: .trailing) {
70 67
                    TextField("Enter Gemini URL", text: $urlText)
76 73
                        .onSubmit {
77 74
                            navigateTo(urlText)
78 75
                        }
79 -
80 76
                    if isLoading {
81 77
                        ProgressView()
82 78
                            .progressViewStyle(CircularProgressViewStyle())
84 80
                    }
85 81
                }
86 82
            }
87 -
            .padding(.horizontal)
83 +
            .padding(.horizontal, 30)
88 84
            .padding(.bottom, 8)
89 85
        }
90 86
        .onAppear {
Titan/Views/TitanContentView.swift +44 −7
5 5
6 6
import SwiftUI
7 7
8 +
struct PreformattedBlockView: View {
9 +
    let text: String
10 +
11 +
    private let maxFontSize: CGFloat = 12
12 +
    private let charWidthRatio: CGFloat = 0.6 // Monospace char width ≈ 0.6 * font size
13 +
    private let lineHeightRatio: CGFloat = 1.2
14 +
15 +
    private var lines: [String] {
16 +
        text.components(separatedBy: .newlines)
17 +
    }
18 +
19 +
    private var maxLineLength: Int {
20 +
        lines.map { $0.count }.max() ?? 1
21 +
    }
22 +
23 +
    private func fontSize(for width: CGFloat) -> CGFloat {
24 +
        let ideal = width / (CGFloat(maxLineLength) * charWidthRatio)
25 +
        return min(ideal, maxFontSize)
26 +
    }
27 +
28 +
    private func blockHeight(fontSize: CGFloat) -> CGFloat {
29 +
        CGFloat(lines.count) * fontSize * lineHeightRatio
30 +
    }
31 +
32 +
    var body: some View {
33 +
        GeometryReader { geometry in
34 +
            let size = fontSize(for: geometry.size.width)
35 +
36 +
            Text(text)
37 +
                .font(.system(size: size, design: .monospaced))
38 +
                .foregroundColor(.secondary)
39 +
                .fixedSize(horizontal: true, vertical: false)
40 +
        }
41 +
        .frame(height: blockHeight(fontSize: estimatedFontSize))
42 +
    }
43 +
44 +
    // Estimate based on typical screen width (~350pt usable)
45 +
    private var estimatedFontSize: CGFloat {
46 +
        fontSize(for: 350)
47 +
    }
48 +
}
49 +
8 50
struct TitanContentView: View {
9 51
    let content: String
10 52
    let baseURL: String
78 120
                .padding(.leading, 12)
79 121
80 122
        case .preformattedBlock(let text, _):
81 -
            ScrollView(.horizontal, showsIndicators: false) {
82 -
                Text(text)
83 -
                    .font(.system(.caption, design: .monospaced))
84 -
                    .foregroundColor(.secondary)
85 -
                    .fixedSize(horizontal: true, vertical: false)
86 -
            }
87 -
            .padding(.vertical, 4)
123 +
            PreformattedBlockView(text: text)
124 +
                .padding(.vertical, 4)
88 125
        }
89 126
    }
90 127
}