ios: unify iPad chat toolbar
This commit is contained in:
@@ -25,7 +25,6 @@ public struct SplitView: View {
|
|||||||
} else {
|
} else {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
SybilSidebarView(viewModel: viewModel)
|
SybilSidebarView(viewModel: viewModel)
|
||||||
.navigationTitle("Sybil")
|
|
||||||
} detail: {
|
} detail: {
|
||||||
SybilWorkspaceView(viewModel: viewModel)
|
SybilWorkspaceView(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,8 @@ import SwiftUI
|
|||||||
|
|
||||||
struct SybilWorkspaceView: View {
|
struct SybilWorkspaceView: View {
|
||||||
@Bindable var viewModel: SybilViewModel
|
@Bindable var viewModel: SybilViewModel
|
||||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
|
||||||
@FocusState private var composerFocused: Bool
|
@FocusState private var composerFocused: Bool
|
||||||
|
|
||||||
private var isCompact: Bool {
|
|
||||||
horizontalSizeClass == .compact
|
|
||||||
}
|
|
||||||
|
|
||||||
private var isSettingsSelected: Bool {
|
private var isSettingsSelected: Bool {
|
||||||
if case .settings = viewModel.selectedItem {
|
if case .settings = viewModel.selectedItem {
|
||||||
return true
|
return true
|
||||||
@@ -18,7 +13,7 @@ struct SybilWorkspaceView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var showsHeader: Bool {
|
private var showsHeader: Bool {
|
||||||
!isCompact || viewModel.errorMessage != nil
|
viewModel.errorMessage != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -55,20 +50,23 @@ struct SybilWorkspaceView: View {
|
|||||||
composerBar
|
composerBar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle(isCompact ? "" : viewModel.selectedTitle)
|
.navigationTitle("")
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
if isCompact {
|
ToolbarItem(placement: .principal) {
|
||||||
ToolbarItem(placement: .principal) {
|
Text(viewModel.selectedTitle)
|
||||||
Text(viewModel.selectedTitle)
|
.font(.sybil(.headline, weight: .semibold))
|
||||||
.font(.sybil(.headline, weight: .semibold))
|
.foregroundStyle(SybilTheme.text)
|
||||||
.foregroundStyle(SybilTheme.text)
|
.lineLimit(1)
|
||||||
.lineLimit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if isCompact && !viewModel.isSearchMode && !isSettingsSelected {
|
if !isSettingsSelected {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
compactProviderModelMenu
|
if viewModel.isSearchMode {
|
||||||
|
searchModeChip
|
||||||
|
} else {
|
||||||
|
providerModelMenu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,30 +81,6 @@ struct SybilWorkspaceView: View {
|
|||||||
|
|
||||||
private var header: some View {
|
private var header: some View {
|
||||||
VStack(alignment: .leading, spacing: 12) {
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
if !isCompact {
|
|
||||||
HStack(alignment: .top, spacing: 12) {
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
if !viewModel.isSearchMode && !isSettingsSelected {
|
|
||||||
providerControls
|
|
||||||
} else if viewModel.isSearchMode {
|
|
||||||
Label("Search mode", systemImage: "globe")
|
|
||||||
.font(.sybil(.caption, weight: .medium))
|
|
||||||
.foregroundStyle(SybilTheme.accent)
|
|
||||||
.padding(.horizontal, 10)
|
|
||||||
.padding(.vertical, 7)
|
|
||||||
.background(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.fill(SybilTheme.accent.opacity(0.10))
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.stroke(SybilTheme.accent.opacity(0.24), lineWidth: 1)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let error = viewModel.errorMessage {
|
if let error = viewModel.errorMessage {
|
||||||
Text(error)
|
Text(error)
|
||||||
.font(.sybil(.footnote))
|
.font(.sybil(.footnote))
|
||||||
@@ -119,7 +93,7 @@ struct SybilWorkspaceView: View {
|
|||||||
.background(SybilTheme.panelGradient.opacity(0.58))
|
.background(SybilTheme.panelGradient.opacity(0.58))
|
||||||
}
|
}
|
||||||
|
|
||||||
private var compactProviderModelMenu: some View {
|
private var providerModelMenu: some View {
|
||||||
Menu {
|
Menu {
|
||||||
Text("\(viewModel.provider.displayName) • \(viewModel.model)")
|
Text("\(viewModel.provider.displayName) • \(viewModel.model)")
|
||||||
.font(.sybil(.caption))
|
.font(.sybil(.caption))
|
||||||
@@ -163,55 +137,20 @@ struct SybilWorkspaceView: View {
|
|||||||
.accessibilityLabel("Provider and model")
|
.accessibilityLabel("Provider and model")
|
||||||
}
|
}
|
||||||
|
|
||||||
private var providerControls: some View {
|
private var searchModeChip: some View {
|
||||||
HStack(spacing: 8) {
|
Label("Search", systemImage: "globe")
|
||||||
Menu {
|
.font(.sybil(.caption, weight: .medium))
|
||||||
ForEach(Provider.allCases, id: \.self) { candidate in
|
.foregroundStyle(SybilTheme.accent)
|
||||||
Button(candidate.displayName) {
|
.padding(.horizontal, 10)
|
||||||
viewModel.setProvider(candidate)
|
.padding(.vertical, 7)
|
||||||
}
|
.background(
|
||||||
}
|
Capsule()
|
||||||
} label: {
|
.fill(SybilTheme.accent.opacity(0.10))
|
||||||
Label(viewModel.provider.displayName, systemImage: "chevron.down")
|
.overlay(
|
||||||
.labelStyle(.titleAndIcon)
|
Capsule()
|
||||||
.font(.sybil(.caption, weight: .medium))
|
.stroke(SybilTheme.accent.opacity(0.24), lineWidth: 1)
|
||||||
.foregroundStyle(SybilTheme.text)
|
|
||||||
.padding(.horizontal, 10)
|
|
||||||
.padding(.vertical, 7)
|
|
||||||
.background(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.fill(SybilTheme.surface.opacity(0.78))
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.stroke(SybilTheme.border.opacity(0.88), lineWidth: 1)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
|
|
||||||
Menu {
|
|
||||||
ForEach(viewModel.providerModelOptions, id: \.self) { model in
|
|
||||||
Button(model) {
|
|
||||||
viewModel.setModel(model)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} label: {
|
|
||||||
Label(viewModel.model, systemImage: "chevron.down")
|
|
||||||
.labelStyle(.titleAndIcon)
|
|
||||||
.font(.sybil(.caption, weight: .medium))
|
|
||||||
.foregroundStyle(SybilTheme.text)
|
|
||||||
.lineLimit(1)
|
|
||||||
.padding(.horizontal, 10)
|
|
||||||
.padding(.vertical, 7)
|
|
||||||
.background(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.fill(SybilTheme.surface.opacity(0.78))
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.stroke(SybilTheme.border.opacity(0.88), lineWidth: 1)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var composerBar: some View {
|
private var composerBar: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user