chore: updated styles for url input
782d2906
1 file(s) · +77 −54
| 62 | 62 | // Settings |
|
| 63 | 63 | @State private var showSettings = false |
|
| 64 | 64 | ||
| 65 | + | // URL input focus state |
|
| 66 | + | @FocusState private var isURLFocused: Bool |
|
| 67 | + | ||
| 65 | 68 | private let maxRedirects = 5 |
|
| 66 | 69 | ||
| 67 | 70 | var body: some View { |
|
| 92 | 95 | GlassEffectContainer { |
|
| 93 | 96 | HStack(spacing: 12) { |
|
| 94 | 97 | // Navigation buttons in a single pill |
|
| 95 | - | HStack(spacing: 0) { |
|
| 96 | - | Button(action: goBack) { |
|
| 97 | - | Image(systemName: "chevron.left") |
|
| 98 | - | .font(.title2) |
|
| 99 | - | .foregroundStyle(canGoBack && !isLoading ? themeSettings.toolbarButtonColor : themeSettings.toolbarButtonColor.opacity(0.3)) |
|
| 100 | - | .frame(width: 44, height: 44) |
|
| 101 | - | } |
|
| 102 | - | .disabled(!canGoBack || isLoading) |
|
| 98 | + | if !isURLFocused { |
|
| 99 | + | HStack(spacing: 0) { |
|
| 100 | + | Button(action: goBack) { |
|
| 101 | + | Image(systemName: "chevron.left") |
|
| 102 | + | .font(.title2) |
|
| 103 | + | .foregroundStyle(canGoBack && !isLoading ? themeSettings.toolbarButtonColor : themeSettings.toolbarButtonColor.opacity(0.3)) |
|
| 104 | + | .frame(width: 44, height: 44) |
|
| 105 | + | } |
|
| 106 | + | .disabled(!canGoBack || isLoading) |
|
| 103 | 107 | ||
| 104 | - | Divider() |
|
| 105 | - | .frame(height: 24) |
|
| 108 | + | Divider() |
|
| 109 | + | .frame(height: 24) |
|
| 106 | 110 | ||
| 107 | - | Button(action: goForward) { |
|
| 108 | - | Image(systemName: "chevron.right") |
|
| 109 | - | .font(.title2) |
|
| 110 | - | .foregroundStyle(canGoForward && !isLoading ? themeSettings.toolbarButtonColor : themeSettings.toolbarButtonColor.opacity(0.3)) |
|
| 111 | - | .frame(width: 44, height: 44) |
|
| 111 | + | Button(action: goForward) { |
|
| 112 | + | Image(systemName: "chevron.right") |
|
| 113 | + | .font(.title2) |
|
| 114 | + | .foregroundStyle(canGoForward && !isLoading ? themeSettings.toolbarButtonColor : themeSettings.toolbarButtonColor.opacity(0.3)) |
|
| 115 | + | .frame(width: 44, height: 44) |
|
| 116 | + | } |
|
| 117 | + | .disabled(!canGoForward || isLoading) |
|
| 112 | 118 | } |
|
| 113 | - | .disabled(!canGoForward || isLoading) |
|
| 119 | + | .glassEffect(.regular.interactive()) |
|
| 120 | + | .transition(.opacity.combined(with: .scale(scale: 0.8))) |
|
| 114 | 121 | } |
|
| 115 | - | .glassEffect(.regular.interactive()) |
|
| 116 | 122 | ||
| 117 | 123 | TextField("Enter Gemini URL", text: $urlText) |
|
| 124 | + | .focused($isURLFocused) |
|
| 118 | 125 | .autocapitalization(.none) |
|
| 119 | 126 | .disableAutocorrection(true) |
|
| 120 | 127 | .keyboardType(.URL) |
|
| 121 | 128 | .submitLabel(.go) |
|
| 122 | 129 | .onSubmit { |
|
| 130 | + | isURLFocused = false |
|
| 123 | 131 | navigateTo(urlText) |
|
| 124 | 132 | } |
|
| 125 | 133 | .padding(.horizontal, 12) |
|
| 126 | 134 | .padding(.vertical, 12) |
|
| 127 | 135 | .glassEffect(.regular, in: .capsule) |
|
| 128 | 136 | ||
| 129 | - | Menu { |
|
| 130 | - | ||
| 137 | + | if isURLFocused { |
|
| 131 | 138 | Button { |
|
| 132 | - | showSettings = true |
|
| 139 | + | isURLFocused = false |
|
| 133 | 140 | } label: { |
|
| 134 | - | Label("Settings", systemImage: "gear") |
|
| 141 | + | Image(systemName: "xmark.circle.fill") |
|
| 142 | + | .font(.title2) |
|
| 143 | + | .foregroundStyle(themeSettings.toolbarButtonColor) |
|
| 144 | + | .frame(width: 44, height: 44) |
|
| 135 | 145 | } |
|
| 136 | - | ||
| 137 | - | Divider() |
|
| 146 | + | .glassEffect(.regular.interactive()) |
|
| 147 | + | .transition(.opacity.combined(with: .scale(scale: 0.8))) |
|
| 148 | + | } else { |
|
| 149 | + | Menu { |
|
| 150 | + | ||
| 151 | + | Button { |
|
| 152 | + | showSettings = true |
|
| 153 | + | } label: { |
|
| 154 | + | Label("Settings", systemImage: "gear") |
|
| 155 | + | } |
|
| 156 | + | ||
| 157 | + | Divider() |
|
| 158 | + | ||
| 159 | + | Button { |
|
| 160 | + | showBookmarks = true |
|
| 161 | + | } label: { |
|
| 162 | + | Label("Bookmarks", systemImage: "book") |
|
| 163 | + | } |
|
| 164 | + | ||
| 165 | + | Button { |
|
| 166 | + | addCurrentPageToBookmarks() |
|
| 167 | + | } label: { |
|
| 168 | + | if bookmarkManager.isBookmarked(url: urlText) { |
|
| 169 | + | Label("Bookmarked", systemImage: "bookmark.fill") |
|
| 170 | + | } else { |
|
| 171 | + | Label("Add Bookmark", systemImage: "bookmark") |
|
| 172 | + | } |
|
| 173 | + | } |
|
| 174 | + | .disabled(urlText.isEmpty || bookmarkManager.isBookmarked(url: urlText)) |
|
| 138 | 175 | ||
| 139 | - | Button { |
|
| 140 | - | showBookmarks = true |
|
| 141 | - | } label: { |
|
| 142 | - | Label("Bookmarks", systemImage: "book") |
|
| 143 | - | } |
|
| 144 | - | ||
| 145 | - | Button { |
|
| 146 | - | addCurrentPageToBookmarks() |
|
| 147 | - | } label: { |
|
| 148 | - | if bookmarkManager.isBookmarked(url: urlText) { |
|
| 149 | - | Label("Bookmarked", systemImage: "bookmark.fill") |
|
| 150 | - | } else { |
|
| 151 | - | Label("Add Bookmark", systemImage: "bookmark") |
|
| 176 | + | Button { |
|
| 177 | + | showHistory = true |
|
| 178 | + | } label: { |
|
| 179 | + | Label("History", systemImage: "clock") |
|
| 152 | 180 | } |
|
| 153 | - | } |
|
| 154 | - | .disabled(urlText.isEmpty || bookmarkManager.isBookmarked(url: urlText)) |
|
| 155 | 181 | ||
| 156 | - | Button { |
|
| 157 | - | showHistory = true |
|
| 158 | - | } label: { |
|
| 159 | - | Label("History", systemImage: "clock") |
|
| 160 | - | } |
|
| 182 | + | Divider() |
|
| 161 | 183 | ||
| 162 | - | Divider() |
|
| 163 | - | ||
| 164 | - | Button { |
|
| 165 | - | navigateTo(themeSettings.homePage) |
|
| 184 | + | Button { |
|
| 185 | + | navigateTo(themeSettings.homePage) |
|
| 186 | + | } label: { |
|
| 187 | + | Label("Home", systemImage: "house") |
|
| 188 | + | } |
|
| 166 | 189 | } label: { |
|
| 167 | - | Label("Home", systemImage: "house") |
|
| 190 | + | Image(systemName: "ellipsis.circle") |
|
| 191 | + | .font(.title2) |
|
| 192 | + | .foregroundStyle(themeSettings.toolbarButtonColor) |
|
| 193 | + | .frame(width: 44, height: 44) |
|
| 168 | 194 | } |
|
| 169 | - | } label: { |
|
| 170 | - | Image(systemName: "ellipsis.circle") |
|
| 171 | - | .font(.title2) |
|
| 172 | - | .foregroundStyle(themeSettings.toolbarButtonColor) |
|
| 173 | - | .frame(width: 44, height: 44) |
|
| 195 | + | .glassEffect(.regular.interactive()) |
|
| 196 | + | .transition(.opacity.combined(with: .scale(scale: 0.8))) |
|
| 174 | 197 | } |
|
| 175 | - | .glassEffect(.regular.interactive()) |
|
| 176 | 198 | } |
|
| 199 | + | .animation(.easeInOut(duration: 0.25), value: isURLFocused) |
|
| 177 | 200 | } |
|
| 178 | 201 | .padding(.top, 8) |
|
| 179 | 202 | } |
|