Download this file
| 1 | import SwiftUI |
| 2 | |
| 3 | // đŸ¤– The in-place offer for an app whose code changed while its surface was |
| 4 | // on screen (FeedWebCache.handleAppsChanged): a page can't swap app code in |
| 5 | // place, and reloading it out from under someone is worse than asking — so |
| 6 | // the pane grows this bar inline, occupying layout space above the webview |
| 7 | // (never a floating overlay), with the web sidebar banner's copy and |
| 8 | // choices. Reload picks the new version up now; Later hides the bar, and the |
| 9 | // page still reloads on its next return from parked. |
| 10 | struct AppUpdateBar: View { |
| 11 | @ObservedObject var bridge: WebBridge |
| 12 | |
| 13 | var body: some View { |
| 14 | if let kind = bridge.appUpdateKind, !bridge.appUpdateDismissed { |
| 15 | HStack(spacing: 16) { |
| 16 | Text(kind == "updated" ? "App updated." : "Apps changed.") |
| 17 | .font(.subheadline) |
| 18 | Spacer(minLength: 0) |
| 19 | Button("Reload") { bridge.reloadForAppUpdate() } |
| 20 | .font(.subheadline.weight(.semibold)) |
| 21 | Button("Later") { bridge.appUpdateDismissed = true } |
| 22 | .font(.subheadline) |
| 23 | } |
| 24 | .padding(.horizontal, 14) |
| 25 | .padding(.vertical, 10) |
| 26 | .background(.bar) |
| 27 | .overlay(Divider(), alignment: .bottom) |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |