Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Add content width preference options #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions fullmoon/Models/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AppManager: ObservableObject {
@AppStorage("shouldPlayHaptics") var shouldPlayHaptics = true
@AppStorage("numberOfVisits") var numberOfVisits = 0
@AppStorage("numberOfVisitsOfLastRequest") var numberOfVisitsOfLastRequest = 0
@AppStorage("appContentWidth") var appContentWidth: AppContentWidth = .fill

var userInterfaceIdiom: LayoutType {
#if os(visionOS)
Expand Down Expand Up @@ -257,3 +258,16 @@ enum AppFontSize: String, CaseIterable {
}
}
}

enum AppContentWidth: String, CaseIterable {
case narrow, fill

func getMaxWidth() -> CGFloat? {
switch self {
case .narrow:
return 640
case .fill:
return nil
}
}
}
47 changes: 27 additions & 20 deletions fullmoon/Views/Chat/ConversationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,36 @@ struct ConversationView: View {
var body: some View {
ScrollViewReader { scrollView in
ScrollView(.vertical) {
VStack(alignment: .leading, spacing: 0) {
ForEach(thread.sortedMessages) { message in
MessageView(message: message)
.padding()
.id(message.id.uuidString)
}

if llm.running && !llm.output.isEmpty && thread.id == generatingThreadID {
VStack {
MessageView(message: Message(role: .assistant, content: llm.output + " 🌕"))
HStack {
Spacer(minLength: 0)
VStack(alignment: .leading, spacing: 0) {
ForEach(thread.sortedMessages) { message in
MessageView(message: message)
.padding()
.id(message.id.uuidString)
}
.padding()
.id("output")
.onAppear {
print("output appeared")
scrollInterrupted = false // reset interruption when a new output begins

if llm.running && !llm.output.isEmpty && thread.id == generatingThreadID {
VStack {
MessageView(message: Message(role: .assistant, content: llm.output + " 🌕"))
}
.padding()
.id("output")
.onAppear {
print("output appeared")
scrollInterrupted = false // reset interruption when a new output begins
}
}
}

Rectangle()
.fill(.clear)
.frame(height: 1)
.id("bottom")
Rectangle()
.fill(.clear)
.frame(height: 1)
.id("bottom")
}
#if os(macOS)
.frame(maxWidth: appManager.appContentWidth.getMaxWidth())
#endif
Spacer(minLength: 0)
}
.scrollTargetLayout()
}
Expand Down
13 changes: 13 additions & 0 deletions fullmoon/Views/Settings/AppearanceSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ struct AppearanceSettingsView: View {
}
#endif
}

#if os(macOS)
Section(header: Text("layout")) {
Picker(selection: $appManager.appContentWidth) {
ForEach(AppContentWidth.allCases.sorted(by: { $0.rawValue < $1.rawValue }), id: \.rawValue) { option in
Text(String(describing: option).lowercased())
.tag(option)
}
} label: {
Label("content width", systemImage: "macwindow")
}
}
#endif
}
.formStyle(.grouped)
.navigationTitle("appearance")
Expand Down