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
8 changes: 4 additions & 4 deletions AGENTS.md

Large diffs are not rendered by default.

14 changes: 1 addition & 13 deletions FitCheck/App/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,8 @@ final class AppState {
case failed(code: String, reason: ModelUnavailability? = nil)
}

/// The four tabs in the order the bar draws them. That order is what "next"
/// and "previous" mean, so it is the declaration order and nothing else.
enum Tab: CaseIterable {
enum Tab {
case home, closet, outfits, settings

/// The tab one step along the bar — `1` for the next, `-1` for the
/// previous — or `nil` at either end. A swipe never wraps round, because
/// the bar has no ring either: the last tab has nothing after it.
func adjacent(by step: Int) -> Tab? {
guard let index = Self.allCases.firstIndex(of: self) else { return nil }
let target = index + step
guard Self.allCases.indices.contains(target) else { return nil }
return Self.allCases[target]
}
}

// MARK: - Init
Expand Down
29 changes: 14 additions & 15 deletions FitCheck/App/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ private struct AppContent: View {
// selected — the way back now that no screen carries a New Fit Check
// button. Invisible, and it changes nothing else about the bar.
.background { TabBarRetapReader { retapHomeTab() } }
// A sideways swipe on the content selects the tab beside it, through
// the same `app.tab` a tap writes, so the change is the bar's own
// rather than an animation of this view's.
.background { TabSwipeReader { swipeTabs(by: $0) } }
.overlay(alignment: .bottom) {
if app.isSelecting, app.tab == .closet {
SelectionToolbar()
Expand Down Expand Up @@ -300,17 +296,6 @@ private struct AppContent: View {
app.reset()
}

/// One step along the bar, from a swipe.
///
/// Nothing happens while the selection toolbar is up: it stands in for the
/// bar, and leaving the closet would carry the tools onto a screen with
/// nothing selected on it.
private func swipeTabs(by step: Int) {
guard !app.isSelecting else { return }
guard let target = app.tab.adjacent(by: step) else { return }
app.tab = target
}

private func confirmDelete(_ item: ClothingItem) {
// Read the context *now* and capture the value. `@Environment` is only
// valid while the view graph is evaluating this view; a closure that
Expand Down Expand Up @@ -350,6 +335,20 @@ extension View {

// MARK: - Tab re-tap

/// An invisible view whose only job is to notice the window it lands in: the
/// re-tap recogniser has to live on the window to see a tap on the bar, which
/// is never this view's own.
///
/// It takes no touches of its own.
private final class WindowAnchor: UIView {
var onWindow: ((UIWindow) -> Void)?

override func didMoveToWindow() {
super.didMoveToWindow()
if let window { onWindow?(window) }
}
}

/// Runs `onRetap` when the wearer taps the tab bar item that is already
/// selected.
///
Expand Down
88 changes: 0 additions & 88 deletions FitCheck/App/TabSwipePolicy.swift

This file was deleted.

Loading
Loading