Skip to content
Open
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
39 changes: 36 additions & 3 deletions native/ios-app/Poki/App/PokiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ struct RootView: View {
@State private var wide: HomeRoute = .chat
@State private var threadsOpen = false
@State private var detailsOpen = false
/// Poki's card under its picture: the model, the way of asking, and customization.
@State private var statusOpen = false
/// Where the card opens: under Poki's picture on the home page (global points), or under the top bar.
@State private var cardUnder: CGFloat?
@State private var statusShowsCustomization = false
@State private var customizationOpen = false
@State private var detailsPath = NavigationPath()
/// The first run is up, over everything (`FirstRunGuide`).
@State private var welcoming = false
Expand Down Expand Up @@ -174,6 +180,12 @@ struct RootView: View {
private func chatPage(split: Bool) -> some View {
ChatView(
sharedDraft: $draft,
openDetails: { under in
cardUnder = under
statusShowsCustomization = true
statusOpen = true
},
openCustomization: { customizationOpen = true },
openVoice: openLiveVoice,
openSetup: { fix(.setup, split: split) },
openSetupStep: { fix(.step($0), split: split) },
Expand All @@ -185,9 +197,9 @@ struct RootView: View {
sessionStore: sessionStore,
shortcutStore: shortcutStore
)
// The bear stops drawing where it is out of sight: behind the open drawer or the profile over the
// chat.
.environment(\.bearCovered, threadsOpen || welcoming || (detailsOpen && !showsSidebar))
// The bear stops drawing where it is out of sight: behind the open drawer, the profile or
// customization over the chat. Poki's card opens beside the picture and leaves it in sight.
.environment(\.bearCovered, threadsOpen || welcoming || customizationOpen || (detailsOpen && !showsSidebar))
}

@ViewBuilder private func destination(_ route: HomeRoute, split: Bool) -> some View {
Expand All @@ -198,6 +210,11 @@ struct RootView: View {
// The voice page keeps its own header and blue ground (not redrawn in ESP-340's first batch).
VoicePage(
back: split ? nil : { show(.chat) },
openDetails: {
cardUnder = nil
statusShowsCustomization = false
statusOpen = true
},
openModel: { openDetails([DetailsRoute.model]) },
select: { target in if target == .chat { show(.chat) } }
)
Expand Down Expand Up @@ -240,9 +257,20 @@ struct RootView: View {
// Every page's top scroll edge is the system's soft one: the chat, the conversations, and
// the pages pushed over them under the system's bar.
.softTopEdge()
.fullScreenCover(isPresented: $customizationOpen) {
BearCustomizationView()
.environment(\.bearOutfitPreview, true)
}
// Settings opens from the bottom of the conversations.
.environment(\.openPokiSettings, { openDetails() })
.environment(\.pokiDetailsOpen, detailsOpen)
.pokiStatusCard(
isPresented: $statusOpen,
under: cardUnder,
leading: sidebarWidth.map { $0 + 1 } ?? 0,
openModel: { openDetails([DetailsRoute.model]) },
openCustomization: statusShowsCustomization ? { customizationOpen = true } : nil
)
// Settings covers the whole screen on iPhone (ESP-469: nothing of the chat shows around it), with
// its Close button; beside the list on iPad it stays a sheet at a page's width (ESP-376).
.fullScreenCover(isPresented: Binding(get: { detailsOpen && !showsSidebar }, set: { detailsOpen = $0 })) {
Expand Down Expand Up @@ -453,6 +481,7 @@ struct RootView: View {
private func takeEntry() {
guard scenePhase == .active, let request = PokiEntry.shared.take(), !model.pairingUnderWay, !FirstRun.isDue() else { return }
detailsOpen = false
statusOpen = false
if let handoff = AskPoki.liveSessionID { show(.session(handoff)); return }
show(.chat)
guard request == .talk, !chat.running, !model.voice.isOn else { return }
Expand Down Expand Up @@ -511,6 +540,10 @@ struct RootView: View {
case "moreSettings", "details", "status":
// More Settings is gone: its rows are on Poki's profile, by what they are about.
openDetails()
case "statusCard":
cardUnder = nil
statusShowsCustomization = true
statusOpen = true
case "hands", "connection":
openDetails([DetailsRoute.connection])
case "rules", "approvals":
Expand Down
29 changes: 15 additions & 14 deletions native/ios-app/Poki/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ struct ChatView: View {
@Environment(AppModel.self) private var model
@Environment(ChatModel.self) private var chat
var sharedDraft: Binding<String>? = nil
/// Opens Poki's card: under Poki's picture over the greeting on the home page (the bottom of the
/// picture, in global points), under the top bar in the chat (nil).
var openDetails: (_ under: CGFloat?) -> Void = { _ in }
var openCustomization: (() -> Void)? = nil
var openVoice: () -> Void
var openSetup: () -> Void
var openSetupStep: (SetupStep) -> Void = { _ in }
Expand All @@ -29,19 +33,20 @@ struct ChatView: View {
private var voice: VoiceModel { model.voice }
/// The taps on Poki's picture, for the bear to answer.
@State private var pokes = 0
/// Where Poki's picture over the greeting ends, for the card to open under it.
@State private var homeBottom: CGFloat?
/// How far Poki's picture rises from the home page into the top bar.
@State private var flightRise: CGFloat = 0
@State private var customizationOpen = false
@Environment(\.bearCovered) private var bearCovered

private func tapPoki() {
writing = false
adding = false
pokes += 1
}

private func openCustomization() {
customizationOpen = true
private func showPokiStatus() {
tapPoki()
openDetails(isGreeting ? homeBottom : nil)
}

/// The message field has the keyboard.
Expand Down Expand Up @@ -115,11 +120,6 @@ struct ChatView: View {

var body: some View {
chatContent
.environment(\.bearCovered, bearCovered || customizationOpen)
.fullScreenCover(isPresented: $customizationOpen) {
BearCustomizationView()
.environment(\.bearOutfitPreview, true)
}
}

@ViewBuilder private var chatContent: some View {
Expand Down Expand Up @@ -162,7 +162,7 @@ struct ChatView: View {
if !bare {
ChatTopBar(status: status, home: home, busy: busy, openThreads: openThreads,
newConversation: { if home { restarts += 1 } else { chat.newConversation() } },
openDetails: tapPoki, openModel: openModel, openCustomization: openCustomization)
openDetails: showPokiStatus)
.logStartupAppearance(.topBar)
}
}
Expand Down Expand Up @@ -209,7 +209,9 @@ struct ChatView: View {
GeometryReader { proxy in
if !bare {
PokiFlight(status: status, home: home, writing: writing, places: anchors.mapValues { proxy[$0] }, pokes: pokes,
tap: tapPoki, openModel: openModel, openCustomization: openCustomization, travel: { flightRise = $0 })
tap: showPokiStatus,
openCustomization: openCustomization.map { action in { tapPoki(); action() } },
landed: { homeBottom = $0 }, travel: { flightRise = $0 })
}
}
}
Expand Down Expand Up @@ -1058,11 +1060,10 @@ struct MessageListHeader: View {
var subtitle: String? = nil
var title: String = "Poki"
var back: (() -> Void)? = nil
/// Settings › Models, for the menu's Add Model.
var openModel: () -> Void = {}
var openDetails: () -> Void

var body: some View {
PokiMenu(openModel: openModel) {
Button(action: openDetails) {
VStack(spacing: 4) {
PokiAvatar(size: 56)
HStack(alignment: .firstTextBaseline, spacing: 3) {
Expand Down
33 changes: 14 additions & 19 deletions native/ios-app/Poki/Chat/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ struct PokiFlight: View {
var places: [PicturePlace: CGRect]
var pokes: Int
var tap: () -> Void
var openModel: () -> Void = {}
var openCustomization: (() -> Void)? = nil
/// The bottom of the picture over the greeting, in global points, for Poki's card to open under it.
var landed: (CGFloat) -> Void = { _ in }
/// How far the picture rises from over the greeting to the top bar, for the greeting to rise with it.
var travel: (CGFloat) -> Void = { _ in }
@Environment(\.accessibilityReduceMotion) private var reduceMotion
Expand All @@ -172,23 +173,24 @@ struct PokiFlight: View {
.accessibilityHidden(true)
.overlay {
if home {
PokiMenu(openModel: openModel, tapped: tap, openCustomization: openCustomization) {
Button(action: tap) {
Color.clear.frame(width: side, height: side).contentShape(.circle)
}
.buttonStyle(.plain)
.accessibilityLabel(Text(verbatim: "Poki, " + PokiStatusCopy.word(status)))
.accessibilityIdentifier("home.poki")
} else if let openCustomization {
Button {
tap()
openCustomization()
} label: {
Button(action: openCustomization) {
Color.clear.frame(width: side, height: side).contentShape(.circle)
}
.buttonStyle(.plain)
.accessibilityLabel(Text("Customize Poki"))
.accessibilityIdentifier("chat.header.avatar")
}
}
.onGeometryChange(for: CGFloat?.self) { home ? $0.frame(in: .global).maxY : nil } action: {
if let bottom = $0 { landed(bottom) }
}
.position(x: place.midX, y: place.midY)
// The greeting's own animations, so the two move as one. A place that moves for any other
// reason (the keyboard) moves in that change's animation, as the greeting does.
Expand All @@ -212,29 +214,25 @@ struct PokiHead: View {
var sizes = HomeSizes()
var status: PokiStatus
var home: Bool
/// Settings › Models, for the menu's Add Model.
var openModel: () -> Void = {}
/// A tap on the pill: the bear says hi while the menu opens.
/// A tap on the pill: the bear says hi while Poki's card opens.
var openDetails: () -> Void = {}
var openCustomization: (() -> Void)? = nil
@Environment(\.accessibilityReduceMotion) private var reduceMotion

var body: some View {
VStack(spacing: 6) {
Color.clear.frame(width: sizes.avatar, height: sizes.avatar).picturePlace(.top)
.accessibilityHidden(true)
// Glass in a group is drawn by the group, so the capsule comes and goes rather than fading;
// its place stays, and the bar keeps its height on both pages.
ZStack {
if !home {
// The menu is the name pill alone: the system draws its own glass around a menu's
// label in a glass group, and a label that held the picture's place too put the
// whole of Poki in one pill. The glass is on the menu, so it opens from the pill.
PokiMenu(openModel: openModel, tapped: openDetails, openCustomization: openCustomization) {
Button(action: openDetails) {
Text(verbatim: "Poki")
.font(.caption.weight(.semibold)).foregroundStyle(Color(.label))
.padding(.horizontal, 12).frame(minHeight: 24)
.contentShape(Capsule())
}
.buttonStyle(.plain)
.glassSurface(in: Capsule())
.glassAppearing()
.accessibilityLabel(Text(verbatim: "Poki, " + PokiStatusCopy.word(status)))
Expand All @@ -245,6 +243,7 @@ struct PokiHead: View {
.frame(minHeight: 24)
.animation(HomeMotion.landing(home, reduceMotion), value: home)
}
.accessibilityElement(children: .contain)
}
}

Expand Down Expand Up @@ -273,9 +272,6 @@ struct ChatTopBar: View {
var newConversation: () -> Void
/// A tap on Poki's name opens the status card.
var openDetails: () -> Void
/// Settings › Models, for the menu's Add Model.
var openModel: () -> Void = {}
var openCustomization: (() -> Void)? = nil
@Environment(\.accessibilityReduceMotion) private var reduceMotion
/// Taps on New Conversation on the home page, for a light tap in the hand.
@State private var homeTaps = 0
Expand Down Expand Up @@ -311,8 +307,7 @@ struct ChatTopBar: View {
}
}
.padding(.top, (sizes.avatar - sizes.button) / 2)
PokiHead(status: status, home: home, openModel: openModel, openDetails: openDetails,
openCustomization: openCustomization)
PokiHead(status: status, home: home, openDetails: openDetails)
.allowsHitTesting(!home)
.accessibilityHidden(home)
.padding(.horizontal, sizes.button + 12)
Expand Down
3 changes: 2 additions & 1 deletion native/ios-app/Poki/Chat/VoicePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SwiftUI
struct VoicePage: View {
@Environment(AppModel.self) private var model
var back: (() -> Void)? = nil
var openDetails: () -> Void
/// Accounts and Models: voice needs a chat model to dictate, or an OpenAI key to talk live.
var openModel: () -> Void
var select: (RootPage) -> Void
Expand All @@ -21,7 +22,7 @@ struct VoicePage: View {
var body: some View {
let face = Self.sample ?? currentFace
VStack(spacing: 0) {
MessageListHeader(dark: true, back: back, openModel: openModel)
MessageListHeader(dark: true, back: back, openDetails: openDetails)
stage(face).frame(maxHeight: .infinity)
HoldButton(listening: face == .listening, hint: hint(face))
.gesture(hold)
Expand Down
Loading
Loading