Store and People open natively, from the Mac's sidebar and the iPhone's apps sheet
Task 10 of the native slice 2 part 1 plan. - BaseSession holds one StoreModel and one PeopleModel per account (TeamModels), so People's count and an install in progress outlast the screens; ended with the account (the Store stops polling). The Store's Base name follows /api/v1/me. - TeamChoice: Store and People show natively, never through openURL; once a read has said this Base has no such route (404, P3) they open on the web, as slice 1 did. Settings and every app open as before. - Mac: MacMainView gains a MacPane (Ask, Store, People). The sidebar's Ask Base, Store and People rows select it, the chosen one marked; the pane's bar says which, with Base's mark for Ask only; People's count sits beside its row once loaded. A 404 while shown goes back to Ask and opens the web page. - iPhone: AppsSheet wraps its content in a NavigationStack. Its "Your team" (DRAFT string) lists Store and People, which push their screens, People with its count once loaded, and Settings, which opens on the web as its tile did. Tests (TeamChoiceTests): Store and People show and never open a URL; Settings opens; an older Base's 404 opens the web page; Your team lists Base's own pages, with People's count only once loaded. Snapshots: base-mac gains window-store and window-people (mockups mac-store, mac-people); base-phone's apps sheet re-recorded with Your team (now a fixed 402 x 820: a NavigationStack has no height of its own). Gate: swift test -j 4 --filter 'AskViewTests|OpenerTests|TeamChoiceTests|SessionTests': 41 passed; build-iphone.sh simulator succeeded; snapshots.sh record mac MacSnapshots and record iphone PhoneSnapshots (reviewed), then compare mac and compare iphone: passed. check-strings.py: ok. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Task 10: Store and People natively from the sidebar and the apps sheet
19 files changed,
+322
−35
native/apple/Sources/BaseKit/Mac/MacMainView.swift+93 −19native/apple/Sources/BaseKit/Phone/PhoneAskScreen.swift+87 −10native/apple/Sources/BaseKit/Resources/Localizable.xcstrings+12 −0native/apple/Sources/BaseKit/Session/BaseSession.swift+9 −1native/apple/Sources/BaseKit/Team/StoreModel.swift+3 −1native/apple/Sources/BaseKit/Team/TeamChoice.swift+47 −0native/apple/Sources/BaseMac/BaseMacApp.swift+1 −1native/apple/Sources/BasePhone/BasePhoneApp.swift+1 −1native/apple/Tests/BaseKitTests/OpenerTests.swift+50 −0native/apple/Tests/BaseSnapshots/MacSnapshots.swift+16 −2native/apple/Tests/BaseSnapshots/TeamSnapshots.swift+3 −0native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-default.pngbinary
CI passed — run details
CI log
=== build === CGO_ENABLED=0 go build ./... === vet === go vet ./... === fmt-check === === staticcheck === go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... === govulncheck === go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./... No vulnerabilities found. === gitleaks === [90m9:05PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m9:05PM[0m [32mINF[0m [1m1 commits scanned.[0m [90m9:05PM[0m [32mINF[0m [1mscanned ~2937441 bytes (2.94 MB) in 287ms[0m [90m9:05PM[0m [32mINF[0m [1mno leaks found[0m === budget === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size budget size: 22 directories within budget === script-test === scripts/prepare-apps_test.sh ok releases lookup failure stops before ship ok app owned elsewhere stops the script ok apps listing failure stops before create ok ambiguous release dir is refused ok explicit version resolves the ambiguity ok releases match is exact, not substring ok shipped version is only promoted, existing app not created ok fresh account creates, ships, promotes to edge, enables ok failing promote stops the script ok ship is retried while uploads are rate limited all passed hack/fonts_test.sh fonts_test: ok === test === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./... receipt: test step 9.214s against a 60s target (the gate's other steps are not in this figure) receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed receipt: slow package 8.445s amadan.net/oficina/base/internal/webtest receipt: slow package 623ms amadan.net/oficina/base/internal/equipo receipt: slow package 586ms amadan.net/oficina/base/internal/operations receipt: slow package 346ms amadan.net/oficina/base/internal/issuer receipt: slow package 202ms amadan.net/oficina/base/internal/consumer receipt: slow test 1.52s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.08s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 620ms amadan.net/oficina/base/internal/webtest TestAskUploadStalledBodyFreesItsSlot receipt: slow test 510ms amadan.net/oficina/base/internal/operations TestOperationsRefusals receipt: slow test 500ms amadan.net/oficina/base/internal/equipo TestUploadRefusals === native === strings: copy review's strings.json is not here (git-ignored); its comparison skipped strings: 148 in the catalog, 145 used worktree-lib_test: ok
diff --git a/native/apple/Sources/BaseKit/Mac/MacMainView.swift b/native/apple/Sources/BaseKit/Mac/MacMainView.swift| index bee739a..4e59231 100644 |
| --- a/native/apple/Sources/BaseKit/Mac/MacMainView.swift |
| +++ b/native/apple/Sources/BaseKit/Mac/MacMainView.swift |
| @@ -3,19 +3,25 @@ import RastrilloApple |
| import SwiftUI |
| /// The Mac's window (B, mockup `mac-main-b`): the sky, a floating glass |
| -/// sidebar with the apps, and Ask in the middle as a sheet. The sidebar |
| -/// toggle sits in Ask's bar. |
| +/// sidebar with the apps, and in the middle a sheet: Ask, or the team's |
| +/// Store or People (slice 2, mockups `mac-store`, `mac-people`). The |
| +/// sidebar toggle sits in the pane's bar. |
| public struct MacMainView: View { |
| let me: Me? |
| let home: HomeData? |
| let ask: AskModel? |
| + let team: TeamModels? |
| let transport: NativeTransport? |
| let actions: BaseActions |
| @Binding var sidebarShown: Bool |
| + @State private var pane: MacPane |
| @Environment(\.colorScheme) private var scheme |
| - public init(me: Me?, home: HomeData?, ask: AskModel?, transport: NativeTransport?, actions: BaseActions, sidebarShown: Binding<Bool>) { |
| - self.me = me; self.home = home; self.ask = ask; self.transport = transport; self.actions = actions; _sidebarShown = sidebarShown |
| + public init(me: Me?, home: HomeData?, ask: AskModel?, team: TeamModels? = nil, transport: NativeTransport?, actions: BaseActions, |
| + sidebarShown: Binding<Bool>, pane: MacPane = .ask) { |
| + self.me = me; self.home = home; self.ask = ask; self.team = team; self.transport = transport; self.actions = actions |
| + _sidebarShown = sidebarShown |
| + _pane = State(initialValue: pane) |
| } |
| public var body: some View { |
| @@ -23,25 +29,35 @@ public struct MacMainView: View { |
| Sky() |
| HStack(spacing: 10) { |
| if sidebarShown { |
| - MacSidebar(me: me, home: home, waiting: ask?.waitingJobs ?? 0, transport: transport, actions: actions) |
| + MacSidebar(me: me, home: home, waiting: ask?.waitingJobs ?? 0, team: team, pane: $pane, transport: transport, actions: actions) |
| .frame(width: 236) |
| .transition(.move(edge: .leading).combined(with: .opacity)) |
| } |
| - pane |
| + sheet |
| } |
| .padding(10) |
| } |
| .animation(.easeOut(duration: 0.2), value: sidebarShown) |
| + // An older Base answered 404 (P3): the page opens on the web, and |
| + // the window goes back to Ask. |
| + .onChange(of: team?.store.notOnThisBase ?? false) { _, gone in fallBack(gone, .store, "store") } |
| + .onChange(of: team?.people.notOnThisBase ?? false) { _, gone in fallBack(gone, .people, "people") } |
| } |
| - private var pane: some View { |
| + private func fallBack(_ gone: Bool, _ which: MacPane, _ id: String) { |
| + guard gone, pane == which, let app = home?.own.first(where: { $0.id == id }) else { return } |
| + pane = .ask |
| + actions.open(app) |
| + } |
| + |
| + private var sheet: some View { |
| let p = Palette(scheme) |
| return VStack(spacing: 0) { |
| HStack(spacing: 10) { |
| if !sidebarShown { Color.clear.frame(width: 64, height: 1) } // the window's buttons |
| HStack(spacing: 9) { |
| - BaseMark(size: 16) |
| - Text(BaseText.text("native.sidebar.ask")).font(BaseFont.heading(17, .semibold, relativeTo: .headline)) |
| + if pane == .ask { BaseMark(size: 16) } |
| + Text(BaseText.text(title)).font(BaseFont.heading(17, .semibold, relativeTo: .headline)) |
| } |
| .accessibilityElement(children: .combine) |
| .accessibilityAddTraits(.isHeader) |
| @@ -61,17 +77,32 @@ public struct MacMainView: View { |
| .padding(.leading, 20).padding(.trailing, 12) |
| .frame(height: 52) |
| .overlay(alignment: .bottom) { Rectangle().fill(p[.rule]).frame(height: 1).padding(.horizontal, 12) } |
| - if let ask { |
| - AskView(model: ask, layout: .window, timeZone: me?.base.timeZone, actions: AskActions(setUp: actions.setUpAsk, setUpOnWeb: actions.setUpAskOnWeb)) |
| - .frame(maxWidth: 760) |
| - .frame(maxWidth: .infinity) |
| - } else { |
| - Spacer() |
| + switch (pane, team) { |
| + case (.store, let team?): |
| + StoreView(model: team.store, layout: .window) |
| + case (.people, let team?): |
| + PeopleView(model: team.people, baseName: me?.base.name ?? "", layout: .window) |
| + default: |
| + if let ask { |
| + AskView(model: ask, layout: .window, timeZone: me?.base.timeZone, actions: AskActions(setUp: actions.setUpAsk, setUpOnWeb: actions.setUpAskOnWeb)) |
| + .frame(maxWidth: 760) |
| + .frame(maxWidth: .infinity) |
| + } else { |
| + Spacer() |
| + } |
| } |
| } |
| .foregroundStyle(p[.frost]) |
| .glassSheet(cornerRadius: 18) |
| } |
| + |
| + private var title: String { |
| + switch pane { |
| + case .ask: "native.sidebar.ask" |
| + case .store: "native.store.title" |
| + case .people: "native.people.title" |
| + } |
| + } |
| } |
| /// The floating sidebar: Ask Base (with its badge), Getting started while |
| @@ -81,6 +112,8 @@ struct MacSidebar: View { |
| let me: Me? |
| let home: HomeData? |
| let waiting: Int |
| + let team: TeamModels? |
| + @Binding var pane: MacPane |
| let transport: NativeTransport? |
| let actions: BaseActions |
| @State private var switching = false |
| @@ -101,7 +134,7 @@ struct MacSidebar: View { |
| } |
| if let home, !home.own.isEmpty { |
| heading(BaseText.format("native.sidebar.team", ["team": me?.base.name ?? ""]), p) |
| - ForEach(home.own.filter { $0.id != "settings" }) { app in appRow(app, p) } |
| + ForEach(home.own.filter { $0.id != "settings" }) { app in teamRow(app, p) } |
| } |
| } |
| .padding(.horizontal, 10) |
| @@ -112,9 +145,17 @@ struct MacSidebar: View { |
| .foregroundStyle(p[.frost]) |
| .glass(cornerRadius: 18) |
| .accountChoices(actions: actions, switching: $switching, confirmingSignOut: $confirmingSignOut) |
| + // People's count beside its row, once it has loaded. |
| + .task { if let people = team?.people, people.people == nil { people.appear() } } |
| } |
| private func askRow(_ p: Palette) -> some View { |
| + Button { pane = .ask } label: { askLabel(p) } |
| + .buttonStyle(.plain) |
| + .accessibilityAddTraits(pane == .ask ? .isSelected : []) |
| + } |
| + |
| + private func askLabel(_ p: Palette) -> some View { |
| HStack(spacing: 10) { |
| BaseMark(size: 16).frame(width: 22, height: 22) |
| Text(BaseText.text("native.sidebar.ask")).font(BaseFont.body(14, .semibold)) |
| @@ -129,10 +170,31 @@ struct MacSidebar: View { |
| } |
| } |
| .padding(.horizontal, 10).frame(minHeight: 32) |
| - .background(p[.hover], in: RoundedRectangle(cornerRadius: 9, style: .continuous)) |
| - .overlay { RoundedRectangle(cornerRadius: 9, style: .continuous).strokeBorder(p[.accentEdge], lineWidth: 1) } |
| + .modifier(SelectedRow(selected: pane == .ask)) |
| + .contentShape(Rectangle()) |
| .accessibilityElement(children: .combine) |
| - .accessibilityAddTraits(.isSelected) |
| + } |
| + |
| + /// Store or People: the pane, natively; an older Base's on the web. |
| + private func teamRow(_ app: HomeData.App, _ p: Palette) -> some View { |
| + let selected = TeamChoice.outcome(app, team: team) == .show(pane) && pane != .ask |
| + return Button { |
| + TeamChoice.choose(app, team: team, show: { pane = $0 }, open: actions.open) |
| + } label: { |
| + HStack(spacing: 10) { |
| + AppIcon(app, size: 22, transport: transport) |
| + Text(verbatim: app.name).font(BaseFont.body(14, selected ? .semibold : .regular)) |
| + Spacer(minLength: 0) |
| + if let count = TeamChoice.count(app, team: team) { |
| + Text(verbatim: "\(count)").font(BaseFont.body(12.5, relativeTo: .caption)).foregroundStyle(p[.haze]) |
| + } |
| + } |
| + .padding(.horizontal, 10).frame(minHeight: 32) |
| + .modifier(SelectedRow(selected: selected)) |
| + .contentShape(Rectangle()) |
| + } |
| + .buttonStyle(SidebarRowStyle()) |
| + .accessibilityAddTraits(selected ? .isSelected : []) |
| } |
| private func steps(_ home: HomeData, _ p: Palette) -> some View { |
| @@ -196,6 +258,18 @@ struct MacSidebar: View { |
| } |
| } |
| +/// The chosen sidebar row: the hover's tint with the accent's edge. |
| +struct SelectedRow: ViewModifier { |
| + let selected: Bool |
| + @Environment(\.colorScheme) private var scheme |
| + func body(content: Content) -> some View { |
| + let p = Palette(scheme) |
| + content |
| + .background(selected ? p[.hover] : .clear, in: RoundedRectangle(cornerRadius: 9, style: .continuous)) |
| + .overlay { if selected { RoundedRectangle(cornerRadius: 9, style: .continuous).strokeBorder(p[.accentEdge], lineWidth: 1) } } |
| + } |
| +} |
| + |
| /// A sidebar row: the hover's tint while pressed or pointed at. |
| struct SidebarRowStyle: ButtonStyle { |
| @State private var hovering = false |
diff --git a/native/apple/Sources/BaseKit/Phone/PhoneAskScreen.swift b/native/apple/Sources/BaseKit/Phone/PhoneAskScreen.swift| index 2ae918c..8c59822 100644 |
| --- a/native/apple/Sources/BaseKit/Phone/PhoneAskScreen.swift |
| +++ b/native/apple/Sources/BaseKit/Phone/PhoneAskScreen.swift |
| @@ -10,6 +10,7 @@ public struct PhoneAskScreen: View { |
| let me: Me? |
| let home: HomeData? |
| let ask: AskModel? |
| + let team: TeamModels? |
| let transport: NativeTransport? |
| let actions: BaseActions |
| @State private var appsShown: Bool |
| @@ -17,8 +18,8 @@ public struct PhoneAskScreen: View { |
| @State private var confirmingSignOut = false |
| @Environment(\.colorScheme) private var scheme |
| - public init(me: Me?, home: HomeData?, ask: AskModel?, transport: NativeTransport?, actions: BaseActions, appsShown: Bool = false) { |
| - self.me = me; self.home = home; self.ask = ask; self.transport = transport; self.actions = actions |
| + public init(me: Me?, home: HomeData?, ask: AskModel?, team: TeamModels? = nil, transport: NativeTransport?, actions: BaseActions, appsShown: Bool = false) { |
| + self.me = me; self.home = home; self.ask = ask; self.team = team; self.transport = transport; self.actions = actions |
| _appsShown = State(initialValue: appsShown) |
| } |
| @@ -47,7 +48,7 @@ public struct PhoneAskScreen: View { |
| .foregroundStyle(p[.frost]) |
| .scrollDismissesKeyboard(.interactively) |
| .sheet(isPresented: $appsShown) { |
| - AppsSheet(me: me, home: home, transport: transport, actions: actions) { appsShown = false } |
| + AppsSheet(me: me, home: home, team: team, transport: transport, actions: actions) { appsShown = false } |
| .presentationDetents([.medium, .large]) |
| .presentationDragIndicator(.visible) |
| .presentationBackground { Palette(scheme)[.menuBase] } |
| @@ -103,25 +104,67 @@ struct RoundGlass<Content: View>: View { |
| } |
| /// The Apps sheet (mockup `phone-apps`): the team's name, Getting started |
| -/// while a step is open, and every app in four columns, Base's own pages |
| -/// (Store, People, Settings) on a row of their own; each opens through |
| -/// Opener (P12). |
| +/// while a step is open, every app in four columns, each opening through |
| +/// Opener (P12), and "Your team": Store and People, pushed natively (with |
| +/// People's count once it has loaded), and Settings on the web. |
| public struct AppsSheet: View { |
| let me: Me? |
| let home: HomeData? |
| + let team: TeamModels? |
| let transport: NativeTransport? |
| let actions: BaseActions |
| let close: () -> Void |
| + @State private var path: [MacPane] |
| @Environment(\.colorScheme) private var scheme |
| @Environment(\.dynamicTypeSize) private var typeSize |
| - public init(me: Me?, home: HomeData?, transport: NativeTransport?, actions: BaseActions, close: @escaping () -> Void) { |
| - self.me = me; self.home = home; self.transport = transport; self.actions = actions; self.close = close |
| + public init(me: Me?, home: HomeData?, team: TeamModels? = nil, transport: NativeTransport?, actions: BaseActions, |
| + path: [MacPane] = [], close: @escaping () -> Void) { |
| + self.me = me; self.home = home; self.team = team; self.transport = transport; self.actions = actions; self.close = close |
| + _path = State(initialValue: path) |
| } |
| public var body: some View { |
| + NavigationStack(path: $path) { |
| + content |
| + .navigationDestination(for: MacPane.self) { pane in destination(pane) } |
| + .navigationTitle(Text(verbatim: me?.base.name ?? "")) |
| + #if os(iOS) |
| + .toolbar(.hidden, for: .navigationBar) |
| + #endif |
| + } |
| + // People's count beside its row, once it has loaded. |
| + .task { if let people = team?.people, people.people == nil { people.appear() } } |
| + // An older Base answered 404 (P3): back, and the page on the web. |
| + .onChange(of: team?.store.notOnThisBase ?? false) { _, gone in fallBack(gone, .store, "store") } |
| + .onChange(of: team?.people.notOnThisBase ?? false) { _, gone in fallBack(gone, .people, "people") } |
| + } |
| + |
| + private func fallBack(_ gone: Bool, _ which: MacPane, _ id: String) { |
| + guard gone, path.last == which, let app = home?.own.first(where: { $0.id == id }) else { return } |
| + path.removeLast() |
| + actions.open(app) |
| + } |
| + |
| + @ViewBuilder private func destination(_ pane: MacPane) -> some View { |
| + let p = Palette(scheme) |
| + Group { |
| + switch (pane, team) { |
| + case (.store, let team?): StoreView(model: team.store, layout: .phone) |
| + case (.people, let team?): PeopleView(model: team.people, baseName: me?.base.name ?? "", layout: .phone) |
| + default: EmptyView() |
| + } |
| + } |
| + .frame(maxWidth: .infinity, maxHeight: .infinity) |
| + .background(p[.menuBase]) |
| + #if os(iOS) |
| + .navigationBarTitleDisplayMode(.inline) |
| + #endif |
| + } |
| + |
| + private var content: some View { |
| let p = Palette(scheme) |
| - ScrollView { |
| + return ScrollView { |
| VStack(alignment: .leading, spacing: 14) { |
| HStack(spacing: 10) { |
| Text(verbatim: me?.base.name ?? "").font(BaseFont.heading(20, .semibold, relativeTo: .title3)) |
| @@ -151,7 +194,7 @@ public struct AppsSheet: View { |
| } |
| if let home { |
| grid(home.launchable) |
| - grid(home.own) |
| + yourTeam(TeamChoice.yourTeam(home), p) |
| } |
| } |
| .padding(.horizontal, 18).padding(.top, 20).padding(.bottom, 24) |
| @@ -160,6 +203,40 @@ public struct AppsSheet: View { |
| .background(p[.menuBase]) |
| } |
| + /// "Your team": a row each for Store, People and Settings. |
| + @ViewBuilder private func yourTeam(_ apps: [HomeData.App], _ p: Palette) -> some View { |
| + if !apps.isEmpty { |
| + VStack(alignment: .leading, spacing: 8) { |
| + Text(BaseText.text("native.phone.your_team")).font(BaseFont.body(13, .semibold, relativeTo: .footnote)).foregroundStyle(p[.haze]) |
| + .accessibilityAddTraits(.isHeader) |
| + TeamGroup { |
| + ForEach(apps) { app in teamRow(app, p) } |
| + } |
| + } |
| + } |
| + } |
| + |
| + private func teamRow(_ app: HomeData.App, _ p: Palette) -> some View { |
| + let count = TeamChoice.count(app, team: team) |
| + let pushes = TeamChoice.outcome(app, team: team) != .open |
| + return Button { |
| + TeamChoice.choose(app, team: team, show: { path.append($0) }, open: actions.open) |
| + } label: { |
| + HStack(spacing: 12) { |
| + AppIcon(app, size: 30, transport: transport) |
| + Text(verbatim: app.name).font(BaseFont.body(16, .semibold)) |
| + Spacer(minLength: 4) |
| + if let count { Text(verbatim: "\(count)").font(BaseFont.body(14, relativeTo: .subheadline)).foregroundStyle(p[.haze]) } |
| + Image(systemName: pushes ? "chevron.right" : "arrow.up.right").font(.system(size: 13, weight: .semibold)).foregroundStyle(p[.haze]) |
| + .accessibilityHidden(true) |
| + } |
| + .frame(minHeight: 52) |
| + .contentShape(Rectangle()) |
| + } |
| + .buttonStyle(.plain) |
| + .accessibilityElement(children: .combine) |
| + } |
| + |
| private func grid(_ apps: [HomeData.App]) -> some View { |
| let columns = typeSize.isAccessibilitySize ? 2 : 4 |
| return LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 0, alignment: .top), count: columns), spacing: 16) { |
diff --git a/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings b/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings| index f89af09..79de746 100644 |
| --- a/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings |
| @@ -997,6 +997,18 @@ |
| } |
| } |
| }, |
| + "native.phone.your_team": { |
| + "comment": "DRAFT 2026-11-28 (slice 2 part 1, for Luna). The iPhone's apps sheet: the heading over Store, People and Settings.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Your team" |
| + } |
| + } |
| + } |
| + }, |
| "native.settings.account.signed_in_as": { |
| "comment": "Account tab: the label beside the person's name and email.", |
| "extractionState": "manual", |
diff --git a/native/apple/Sources/BaseKit/Session/BaseSession.swift b/native/apple/Sources/BaseKit/Session/BaseSession.swift| index c09546e..cecdb95 100644 |
| --- a/native/apple/Sources/BaseKit/Session/BaseSession.swift |
| +++ b/native/apple/Sources/BaseKit/Session/BaseSession.swift |
| @@ -32,6 +32,8 @@ import RastrilloApple |
| public private(set) var ask: AskModel? |
| public private(set) var me: Me? |
| public private(set) var home: HomeData? |
| + /// Store and People, natively (slice 2). |
| + public private(set) var team: TeamModels? |
| @ObservationIgnored public private(set) var askSetup: AskSetup? |
| @ObservationIgnored private var transport: SwappableTransport? |
| @@ -143,6 +145,7 @@ import RastrilloApple |
| } |
| self.ask = ask |
| askSetup = setup |
| + team = TeamModels(store: StoreModel(client: client, baseName: ""), people: PeopleModel(client: client)) |
| refreshing = Task { await self.refresh() } |
| } |
| @@ -155,6 +158,8 @@ import RastrilloApple |
| settingUp?.cancel() |
| settingUp = nil |
| ask?.dispose() |
| + team?.end() |
| + team = nil |
| ask = nil; askSetup = nil; client = nil; transport = nil; account = nil |
| signedIn = nil; me = nil; home = nil |
| } |
| @@ -169,7 +174,10 @@ import RastrilloApple |
| await ask?.resume() |
| let (newMe, newHome) = await (me, home) |
| guard generation == epoch, !Task.isCancelled else { return } |
| - if let newMe { self.me = newMe } |
| + if let newMe { |
| + self.me = newMe |
| + team?.store.baseName = newMe.base.name |
| + } |
| if let newHome { self.home = newHome } |
| // Ask set up (or renewed) with Oficina ID, if it wants it. |
| await askSetup?.runIfNeeded() |
diff --git a/native/apple/Sources/BaseKit/Team/StoreModel.swift b/native/apple/Sources/BaseKit/Team/StoreModel.swift| index 72c6b47..8d9ec55 100644 |
| --- a/native/apple/Sources/BaseKit/Team/StoreModel.swift |
| +++ b/native/apple/Sources/BaseKit/Team/StoreModel.swift |
| @@ -31,7 +31,9 @@ import SwiftUI |
| public private(set) var work: Task<Void, Never>? |
| let client: BaseClient |
| - let baseName: String |
| + /// The Base's name, for Uninstall's words: the session sets it once |
| + /// `/api/v1/me` has said. |
| + public var baseName: String |
| let schedule: @MainActor (Duration, @escaping @MainActor () -> Void) -> Void |
| let announce: @MainActor (String) -> Void |
| let hold: @MainActor (Duration) async -> Void |
diff --git a/native/apple/Sources/BaseKit/Team/TeamChoice.swift b/native/apple/Sources/BaseKit/Team/TeamChoice.swift| new file mode 100644 |
| index 0000000..3bb2863 |
| --- /dev/null |
| +++ b/native/apple/Sources/BaseKit/Team/TeamChoice.swift |
| @@ -0,0 +1,47 @@ |
| +import Foundation |
| + |
| +/// The Mac window's pane: Ask, or the team's Store or People (spec 7.4). |
| +public enum MacPane: Hashable, Sendable { case ask, store, people } |
| + |
| +/// The session's Store and People, one of each per account, so the |
| +/// apps sheet's People count and a Store mid-install outlast the screens. |
| +@MainActor public final class TeamModels { |
| + public let store: StoreModel |
| + public let people: PeopleModel |
| + public init(store: StoreModel, people: PeopleModel) { self.store = store; self.people = people } |
| + |
| + /// The account ended: the Store stops polling. |
| + func end() { store.disappear() } |
| +} |
| + |
| +/// Where choosing one of Base's own pages goes. Store and People show |
| +/// natively; once a read has said this Base has no such route (an older |
| +/// Base, P3), they open on the web as slice 1 did. Settings, and every |
| +/// app, open as before. |
| +public enum TeamChoice { |
| + public enum Outcome: Equatable, Sendable { case show(MacPane), open } |
| + |
| + @MainActor public static func outcome(_ app: HomeData.App, team: TeamModels?) -> Outcome { |
| + guard app.kind == .own, let team else { return .open } |
| + switch app.id { |
| + case "store": return team.store.notOnThisBase ? .open : .show(.store) |
| + case "people": return team.people.notOnThisBase ? .open : .show(.people) |
| + default: return .open |
| + } |
| + } |
| + |
| + @MainActor public static func choose(_ app: HomeData.App, team: TeamModels?, show: (MacPane) -> Void, open: (HomeData.App) -> Void) { |
| + switch outcome(app, team: team) { |
| + case .show(let pane): show(pane) |
| + case .open: open(app) |
| + } |
| + } |
| + |
| + /// The apps sheet's "Your team": Base's own pages, in Home's order. |
| + public static func yourTeam(_ home: HomeData?) -> [HomeData.App] { home?.own ?? [] } |
| + |
| + /// A row's count: People's, once it has loaded; nothing before. |
| + @MainActor public static func count(_ app: HomeData.App, team: TeamModels?) -> Int? { |
| + app.id == "people" ? team?.people.count : nil |
| + } |
| +} |
diff --git a/native/apple/Sources/BaseMac/BaseMacApp.swift b/native/apple/Sources/BaseMac/BaseMacApp.swift| index f0991a8..8dfb2f1 100644 |
| --- a/native/apple/Sources/BaseMac/BaseMacApp.swift |
| +++ b/native/apple/Sources/BaseMac/BaseMacApp.swift |
| @@ -139,7 +139,7 @@ struct MacRoot: View { |
| var body: some View { |
| Group { |
| if let state = session.signedIn { |
| - MacMainView(me: session.me, home: session.home, ask: session.ask, transport: session.iconTransport, |
| + MacMainView(me: session.me, home: session.home, ask: session.ask, team: session.team, transport: session.iconTransport, |
| actions: actions, sidebarShown: $sidebarShown) |
| .overlay(alignment: .top) { |
| NativeOfflineBanner(origin: state.origin, message: BaseText.text("native.offline")).padding(.top, 8) |
diff --git a/native/apple/Sources/BasePhone/BasePhoneApp.swift b/native/apple/Sources/BasePhone/BasePhoneApp.swift| index fde8074..7fdac07 100644 |
| --- a/native/apple/Sources/BasePhone/BasePhoneApp.swift |
| +++ b/native/apple/Sources/BasePhone/BasePhoneApp.swift |
| @@ -37,7 +37,7 @@ struct PhoneRoot: View { |
| let actions = PhoneActions.make(session: session) |
| Group { |
| if let state = session.signedIn { |
| - PhoneAskScreen(me: session.me, home: session.home, ask: session.ask, transport: session.iconTransport, actions: actions) |
| + PhoneAskScreen(me: session.me, home: session.home, ask: session.ask, team: session.team, transport: session.iconTransport, actions: actions) |
| .safeAreaInset(edge: .top, spacing: 0) { |
| NativeOfflineBanner(origin: state.origin, message: BaseText.text("native.offline")) |
| } |
diff --git a/native/apple/Tests/BaseKitTests/OpenerTests.swift b/native/apple/Tests/BaseKitTests/OpenerTests.swift| index 0bc2307..887c960 100644 |
| --- a/native/apple/Tests/BaseKitTests/OpenerTests.swift |
| +++ b/native/apple/Tests/BaseKitTests/OpenerTests.swift |
| @@ -1,5 +1,7 @@ |
| @testable import BaseKit |
| import Foundation |
| +import RastrilloApple |
| +import RastrilloTestSupport |
| import XCTest |
| /// P12: where each of Home's apps opens. |
| @@ -75,3 +77,51 @@ final class OpenerTests: XCTestCase { |
| XCTAssertEqual(pages, ["/store"]) |
| } |
| } |
| + |
| +/// Task 10: Store and People open natively, in the Mac's pane or pushed |
| +/// from the iPhone's apps sheet; an older Base's open on the web (P3). |
| +@MainActor final class TeamChoiceTests: XCTestCase { |
| + let home = try! JSONDecoder().decode(HomeData.self, from: Fixture.data("home.json")) |
| + func own(_ id: String) -> HomeData.App { HomeData.App(id: id, kind: .own, name: id.capitalized, url: URL(string: "https://fennel.base.example/\(id)")) } |
| + |
| + func team(_ steps: [ScriptedTransport.Step] = []) -> TeamModels { |
| + let client = BaseClient(transport: ScriptedTransport(steps)) {} |
| + return TeamModels(store: StoreModel(client: client, baseName: "Fennel & Rye", schedule: { _, _ in }, announce: { _ in }), |
| + people: PeopleModel(client: client, announce: { _ in })) |
| + } |
| + |
| + func testStoreAndPeopleShowNativelyAndNeverOpenAURL() { |
| + let team = team() |
| + var opened: [String] = [] |
| + var shown: [MacPane] = [] |
| + for id in ["store", "people", "settings"] { |
| + TeamChoice.choose(own(id), team: team, show: { shown.append($0) }, open: { opened.append($0.id) }) |
| + } |
| + XCTAssertEqual(shown, [.store, .people]) |
| + XCTAssertEqual(opened, ["settings"], "Settings opens on the web, as before") |
| + XCTAssertEqual(TeamChoice.outcome(home.apps.first!, team: team), .open, "an app opens as before") |
| + XCTAssertEqual(TeamChoice.outcome(own("store"), team: nil), .open, "no session's models: the web") |
| + } |
| + |
| + func testAnOlderBaseOpensTheWebPage() async { |
| + let team = team([.respond(status: 404), .respond(status: 404)]) |
| + team.store.appear() |
| + await team.store.work?.value |
| + team.people.appear() |
| + await team.people.work?.value |
| + XCTAssertEqual(TeamChoice.outcome(own("store"), team: team), .open) |
| + XCTAssertEqual(TeamChoice.outcome(own("people"), team: team), .open) |
| + } |
| + |
| + func testTheAppsSheetListsYourTeamWithPeoplesCountOnceLoaded() async { |
| + let team = team([json(200, #"{"owner":true,"people":[{"id":"a","initial":"A","name":"","email":"a@x","role":"owner"},{"id":"b","initial":"B","name":"","email":"b@x","role":"member"}]}"#)]) |
| + let json = #"{"apps":[{"id":"docs","kind":"oficina","name":"Docs"},{"id":"store","kind":"own","name":"Store"},{"id":"people","kind":"own","name":"People"},{"id":"settings","kind":"own","name":"Settings"}]}"# |
| + let home = try! JSONDecoder().decode(HomeData.self, from: Data(json.utf8)) |
| + let rows = TeamChoice.yourTeam(home) |
| + XCTAssertEqual(rows.map(\.id), ["store", "people", "settings"], "Base's own pages, in Home's order") |
| + XCTAssertEqual(rows.map { TeamChoice.count($0, team: team) }, [nil, nil, nil], "no count before People has loaded") |
| + team.people.appear() |
| + await team.people.work?.value |
| + XCTAssertEqual(rows.map { TeamChoice.count($0, team: team) }, [nil, 2, nil]) |
| + } |
| +} |
diff --git a/native/apple/Tests/BaseSnapshots/MacSnapshots.swift b/native/apple/Tests/BaseSnapshots/MacSnapshots.swift| index d1b2176..9475dd5 100644 |
| --- a/native/apple/Tests/BaseSnapshots/MacSnapshots.swift |
| +++ b/native/apple/Tests/BaseSnapshots/MacSnapshots.swift |
| @@ -22,6 +22,16 @@ final class MacSnapshots: XCTestCase { |
| MacMainView(me: HomeFixtures.me, home: HomeFixtures.home, ask: AskFixtures.thread(), transport: nil, |
| actions: .none, sidebarShown: .constant(true)).skyFrozen() |
| }, |
| + // Slice 2 Task 10 (mockups mac-store, mac-people): the team's |
| + // pages in the window's pane, chosen from the sidebar. |
| + SnapshotScreen("window-store", mac: .fixed(width: 1280, height: 800), iphone: nil) { |
| + MacMainView(me: HomeFixtures.me, home: HomeFixtures.home, ask: AskFixtures.thread(), team: TeamFixtures.team(), transport: nil, |
| + actions: .none, sidebarShown: .constant(true), pane: .store).skyFrozen() |
| + }, |
| + SnapshotScreen("window-people", mac: .fixed(width: 1280, height: 800), iphone: nil) { |
| + MacMainView(me: HomeFixtures.me, home: HomeFixtures.home, ask: AskFixtures.thread(), team: TeamFixtures.team(), transport: nil, |
| + actions: .none, sidebarShown: .constant(true), pane: .people).skyFrozen() |
| + }, |
| SnapshotScreen("menubar", mac: .fixed(width: 410, height: 560), iphone: nil) { |
| MenuPanel(me: HomeFixtures.me, ask: AskFixtures.thread(), shortcut: "⌃Space", openBase: {}, actions: .none).skyFrozen() |
| }, |
| @@ -89,8 +99,12 @@ final class PhoneSnapshots: XCTestCase { |
| SnapshotScreen("ask", mac: nil, iphone: .fixed(width: 402, height: 874)) { |
| PhoneAskScreen(me: HomeFixtures.me, home: HomeFixtures.home, ask: AskFixtures.thread(), transport: nil, actions: .none).skyFrozen() |
| }, |
| - SnapshotScreen("apps", mac: nil, iphone: .width(402)) { |
| - AppsSheet(me: HomeFixtures.me, home: HomeFixtures.home, transport: nil, actions: .none) {}.skyFrozen() |
| + // In a NavigationStack since slice 2 (Your team pushes Store and |
| + // People), which has no height of its own: the large detent's. |
| + // Drawn as a screen, the stack keeps the status bar's space at |
| + // the top, which a presented sheet doesn't have. |
| + SnapshotScreen("apps", mac: nil, iphone: .fixed(width: 402, height: 820)) { |
| + AppsSheet(me: HomeFixtures.me, home: HomeFixtures.home, team: TeamFixtures.team(), transport: nil, actions: .none) {}.skyFrozen() |
| }, |
| SnapshotScreen("job", mac: nil, iphone: .fixed(width: 402, height: 437)) { |
| JobView(job: AskFixtures.job, timeZone: AskFixtures.zone, close: {}, now: SnapshotSettings.now) |
diff --git a/native/apple/Tests/BaseSnapshots/TeamSnapshots.swift b/native/apple/Tests/BaseSnapshots/TeamSnapshots.swift| index 8807992..c56ccb2 100644 |
| --- a/native/apple/Tests/BaseSnapshots/TeamSnapshots.swift |
| +++ b/native/apple/Tests/BaseSnapshots/TeamSnapshots.swift |
| @@ -78,6 +78,9 @@ struct TeamFrame<Content: View>: View { |
| store: data, schedule: { _, _ in }, announce: { _ in }) |
| } |
| + /// The session's Store and People, the owner's, as loaded. |
| + static func team() -> TeamModels { TeamModels(store: store(owner: true), people: people(owner: true)) } |
| + |
| static func people(owner: Bool) -> PeopleModel { |
| let data = PeopleData(owner: owner, people: [ |
| Person(id: "m1", initial: "A", name: "Ana Murphy", email: "ana@fennelandrye.ie", role: .member), |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-dark-default.png| new file mode 100644 |
| index 0000000..7f27e14 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-light-default.png| new file mode 100644 |
| index 0000000..130c50a |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-people-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-dark-default.png| new file mode 100644 |
| index 0000000..f832f0b |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-light-default.png| new file mode 100644 |
| index 0000000..0d5823d |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-mac/mac/window-store-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-ax3.png| index cc5d530..5feb2d0 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-ax3.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-ax3.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-default.png| index 761d1f9..109fbd4 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-ax3.png| index d541b48..c622605 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-ax3.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-ax3.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-default.png| index 570c957..6ebfff9 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-phone/iphone/apps-light-default.png differ |