UI Adjustments

This commit is contained in:
Thomas Ricouard 2023-12-18 18:08:32 +01:00
parent fdf15e60f6
commit 1c9cf4077d
7 changed files with 249 additions and 180 deletions

View file

@ -96,7 +96,12 @@ public struct AppAccountsSelectorView: View {
AppAccountView(viewModel: viewModel) AppAccountView(viewModel: viewModel)
} }
} }
#if os(visionOS)
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(Material.regular))
#else
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
#endif
if accountCreationEnabled { if accountCreationEnabled {
Section { Section {
@ -111,7 +116,12 @@ public struct AppAccountsSelectorView: View {
} }
settingsButton settingsButton
} }
#if os(visionOS)
.listRowBackground(Rectangle()
.foregroundStyle(Material.regular))
#else
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
#endif
} }
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)

View file

@ -132,7 +132,10 @@ public struct NotificationsListView: View {
leading: .layoutPadding + 4, leading: .layoutPadding + 4,
bottom: 12, bottom: 12,
trailing: .layoutPadding)) trailing: .layoutPadding))
#if !os(visionOS) #if os(visionOS)
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(Material.regular))
#else
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
#endif #endif
.redacted(reason: .placeholder) .redacted(reason: .placeholder)
@ -158,7 +161,10 @@ public struct NotificationsListView: View {
leading: .layoutPadding + 4, leading: .layoutPadding + 4,
bottom: 12, bottom: 12,
trailing: .layoutPadding)) trailing: .layoutPadding))
#if !os(visionOS) #if os(visionOS)
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(notification.type == .mention && lockedType != .mention ? Material.thick : Material.regular))
#else
.listRowBackground(notification.type == .mention && lockedType != .mention ? .listRowBackground(notification.type == .mention && lockedType != .mention ?
theme.secondaryBackgroundColor : theme.primaryBackgroundColor) theme.secondaryBackgroundColor : theme.primaryBackgroundColor)
#endif #endif

View file

@ -59,7 +59,9 @@ public struct StatusDetailView: View {
.foregroundColor(theme.secondaryBackgroundColor) .foregroundColor(theme.secondaryBackgroundColor)
.frame(minHeight: reader.frame(in: .local).size.height - statusHeight) .frame(minHeight: reader.frame(in: .local).size.height - statusHeight)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
#if !os(visionOS)
.listRowBackground(theme.secondaryBackgroundColor) .listRowBackground(theme.secondaryBackgroundColor)
#endif
.listRowInsets(.init()) .listRowInsets(.init())
.accessibilityHidden(true) .accessibilityHidden(true)
@ -69,8 +71,10 @@ public struct StatusDetailView: View {
} }
.environment(\.defaultMinListRowHeight, 1) .environment(\.defaultMinListRowHeight, 1)
.listStyle(.plain) .listStyle(.plain)
#if !os(visionOS)
.scrollContentBackground(.hidden) .scrollContentBackground(.hidden)
.background(theme.primaryBackgroundColor) .background(theme.primaryBackgroundColor)
#endif
.onChange(of: viewModel.scrollToId) { _, newValue in .onChange(of: viewModel.scrollToId) { _, newValue in
if let newValue { if let newValue {
viewModel.scrollToId = nil viewModel.scrollToId = nil
@ -132,7 +136,9 @@ public struct StatusDetailView: View {
} }
} }
.id(status.id) .id(status.id)
#if !os(visionOS)
.listRowBackground(viewModel.highlightRowColor) .listRowBackground(viewModel.highlightRowColor)
#endif
.listRowInsets(.init(top: 12, .listRowInsets(.init(top: 12,
leading: .layoutPadding, leading: .layoutPadding,
bottom: 12, bottom: 12,
@ -149,7 +155,9 @@ public struct StatusDetailView: View {
await viewModel.fetch() await viewModel.fetch()
} }
} }
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
#endif
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
} }
@ -169,13 +177,17 @@ public struct StatusDetailView: View {
} }
.frame(height: 50) .frame(height: 50)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
#if !os(visionOS)
.listRowBackground(theme.secondaryBackgroundColor) .listRowBackground(theme.secondaryBackgroundColor)
#endif
.listRowInsets(.init()) .listRowInsets(.init())
} }
private var topPaddingView: some View { private var topPaddingView: some View {
HStack { EmptyView() } HStack { EmptyView() }
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor) .listRowBackground(theme.primaryBackgroundColor)
#endif
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
.listRowInsets(.init()) .listRowInsets(.init())
.frame(height: .layoutPadding) .frame(height: .layoutPadding)

View file

@ -31,12 +31,54 @@ struct StatusEditorAccessoryView: View {
var body: some View { var body: some View {
@Bindable var viewModel = focusedSEVM @Bindable var viewModel = focusedSEVM
VStack(spacing: 0) { VStack(spacing: 0) {
#if os(visionOS)
HStack {
contentView
}
.frame(height: 24)
.padding(16)
.background(.ultraThinMaterial)
.cornerRadius(8)
#else
Divider() Divider()
HStack { HStack {
contentView
}
.frame(height: 20)
.padding(.vertical, 12)
.background(.ultraThinMaterial)
#endif
}
.onAppear {
viewModel.setInitialLanguageSelection(preference: preferences.recentlyUsedLanguages.first ?? preferences.serverPreferences?.postLanguage)
}
}
@ViewBuilder
private var contentView: some View {
#if os(visionOS)
HStack(spacing: 8) {
actionsView
characterCountView
.padding(.leading, 16)
}
#else
ScrollView(.horizontal) { ScrollView(.horizontal) {
HStack(alignment: .center, spacing: 16) { HStack(alignment: .center, spacing: 16) {
actionsView
}
.padding(.horizontal, .layoutPadding)
}
Spacer()
characterCountView
.padding(.trailing, .layoutPadding)
#endif
}
@ViewBuilder
private var actionsView: some View {
@Bindable var viewModel = focusedSEVM
Menu { Menu {
Button { Button {
isPhotosPickerPresented = true isPhotosPickerPresented = true
@ -202,20 +244,6 @@ struct StatusEditorAccessoryView: View {
AIMenu.disabled(!viewModel.canPost) AIMenu.disabled(!viewModel.canPost)
} }
} }
.padding(.horizontal, .layoutPadding)
}
Spacer()
characterCountView
.padding(.trailing, .layoutPadding)
}
.frame(height: 20)
.padding(.vertical, 12)
.background(.ultraThinMaterial)
}
.onAppear {
viewModel.setInitialLanguageSelection(preference: preferences.recentlyUsedLanguages.first ?? preferences.serverPreferences?.postLanguage)
}
}
private var canAddNewSEVM: Bool { private var canAddNewSEVM: Bool {
guard followUpSEVMs.count < 5 else { return false } guard followUpSEVMs.count < 5 else { return false }

View file

@ -52,7 +52,9 @@ struct StatusEditorCoreView: View {
} }
.opacity(editorFocusState == assignedFocusState ? 1 : 0.6) .opacity(editorFocusState == assignedFocusState ? 1 : 0.6)
} }
#if !os(visionOS)
.background(theme.primaryBackgroundColor) .background(theme.primaryBackgroundColor)
#endif
.focused($editorFocusState, equals: assignedFocusState) .focused($editorFocusState, equals: assignedFocusState)
.onAppear { setupViewModel() } .onAppear { setupViewModel() }
} }

View file

@ -73,13 +73,21 @@ public struct StatusEditorView: View {
.scrollPosition(id: $scrollID, anchor: .top) .scrollPosition(id: $scrollID, anchor: .top)
.animation(.bouncy(duration: 0.3), value: editorFocusState) .animation(.bouncy(duration: 0.3), value: editorFocusState)
.animation(.bouncy(duration: 0.3), value: followUpSEVMs) .animation(.bouncy(duration: 0.3), value: followUpSEVMs)
#if !os(visionOS)
.background(theme.primaryBackgroundColor) .background(theme.primaryBackgroundColor)
#endif
.safeAreaInset(edge: .bottom) { .safeAreaInset(edge: .bottom) {
StatusEditorAutoCompleteView(viewModel: focusedSEVM) StatusEditorAutoCompleteView(viewModel: focusedSEVM)
} }
#if os(visionOS)
.ornament(attachmentAnchor: .scene(.bottom)) {
StatusEditorAccessoryView(isSpoilerTextFocused: $isSpoilerTextFocused, focusedSEVM: focusedSEVM, followUpSEVMs: $followUpSEVMs)
}
#else
.safeAreaInset(edge: .bottom) { .safeAreaInset(edge: .bottom) {
StatusEditorAccessoryView(isSpoilerTextFocused: $isSpoilerTextFocused, focusedSEVM: focusedSEVM, followUpSEVMs: $followUpSEVMs) StatusEditorAccessoryView(isSpoilerTextFocused: $isSpoilerTextFocused, focusedSEVM: focusedSEVM, followUpSEVMs: $followUpSEVMs)
} }
#endif
.accessibilitySortPriority(1) // Ensure that all elements inside the `ScrollView` occur earlier than the accessory views .accessibilitySortPriority(1) // Ensure that all elements inside the `ScrollView` occur earlier than the accessory views
.navigationTitle(focusedSEVM.mode.title) .navigationTitle(focusedSEVM.mode.title)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)

View file

@ -149,7 +149,10 @@ public struct StatusRowView: View {
StatusRowSwipeView(viewModel: viewModel, mode: .leading) StatusRowSwipeView(viewModel: viewModel, mode: .leading)
} }
} }
#if !os(visionOS) #if os(visionOS)
.listRowBackground(RoundedRectangle(cornerRadius: 8)
.foregroundStyle(Material.regular))
#else
.listRowBackground(viewModel.highlightRowColor) .listRowBackground(viewModel.highlightRowColor)
#endif #endif
.listRowInsets(.init(top: 12, .listRowInsets(.init(top: 12,