Make language picker sheet half-height, fix appearance in non-pure-black dark mode
This commit is contained in:
parent
d85f74f365
commit
2eb9e63724
|
@ -119,6 +119,7 @@ public final class ComposeController: ViewController {
|
||||||
.environment(\.managedObjectContext, DraftsPersistentContainer.shared.viewContext)
|
.environment(\.managedObjectContext, DraftsPersistentContainer.shared.viewContext)
|
||||||
.environmentObject(draft)
|
.environmentObject(draft)
|
||||||
.environmentObject(mastodonController.instanceFeatures)
|
.environmentObject(mastodonController.instanceFeatures)
|
||||||
|
.environment(\.composeUIConfig, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func canPaste(itemProviders: [NSItemProvider]) -> Bool {
|
public func canPaste(itemProviders: [NSItemProvider]) -> Bool {
|
||||||
|
@ -450,3 +451,13 @@ private struct GlobalFrameOutsideListPrefKey: PreferenceKey {
|
||||||
value = nextValue()
|
value = nextValue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct ComposeUIConfigEnvironmentKey: EnvironmentKey {
|
||||||
|
static let defaultValue = ComposeUIConfig()
|
||||||
|
}
|
||||||
|
extension EnvironmentValues {
|
||||||
|
var composeUIConfig: ComposeUIConfig {
|
||||||
|
get { self[ComposeUIConfigEnvironmentKey.self] }
|
||||||
|
set { self[ComposeUIConfigEnvironmentKey.self] = newValue }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct LanguagePicker: View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
LanguagePickerList(languageCode: languageCode, hasChangedSelection: $hasChangedSelection, isPresented: $isShowingSheet)
|
LanguagePickerList(languageCode: languageCode, hasChangedSelection: $hasChangedSelection, isPresented: $isShowingSheet)
|
||||||
}
|
}
|
||||||
|
.presentationDetents([.large, .medium])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +79,8 @@ private struct LanguagePickerList: View {
|
||||||
@Binding var languageCode: Locale.LanguageCode
|
@Binding var languageCode: Locale.LanguageCode
|
||||||
@Binding var hasChangedSelection: Bool
|
@Binding var hasChangedSelection: Bool
|
||||||
@Binding var isPresented: Bool
|
@Binding var isPresented: Bool
|
||||||
|
@Environment(\.composeUIConfig.groupedBackgroundColor) private var groupedBackgroundColor
|
||||||
|
@Environment(\.composeUIConfig.groupedCellBackgroundColor) private var groupedCellBackgroundColor
|
||||||
@State private var recentLangs: [Lang] = []
|
@State private var recentLangs: [Lang] = []
|
||||||
@State private var langs: [Lang] = []
|
@State private var langs: [Lang] = []
|
||||||
@State private var filteredLangs: [Lang]?
|
@State private var filteredLangs: [Lang]?
|
||||||
|
@ -102,6 +105,7 @@ private struct LanguagePickerList: View {
|
||||||
ForEach(recentLangs) { lang in
|
ForEach(recentLangs) { lang in
|
||||||
button(for: lang)
|
button(for: lang)
|
||||||
}
|
}
|
||||||
|
.listRowBackground(groupedCellBackgroundColor)
|
||||||
} header: {
|
} header: {
|
||||||
Text("Recently Used")
|
Text("Recently Used")
|
||||||
}
|
}
|
||||||
|
@ -110,11 +114,16 @@ private struct LanguagePickerList: View {
|
||||||
ForEach(filteredLangs ?? langs) { lang in
|
ForEach(filteredLangs ?? langs) { lang in
|
||||||
button(for: lang)
|
button(for: lang)
|
||||||
}
|
}
|
||||||
|
.listRowBackground(groupedCellBackgroundColor)
|
||||||
} header: {
|
} header: {
|
||||||
Text("All Languages")
|
Text("All Languages")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.listStyle(.insetGrouped)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(groupedBackgroundColor.edgesIgnoringSafeArea(.all))
|
||||||
.searchable(text: $query)
|
.searchable(text: $query)
|
||||||
|
.scrollDismissesKeyboard(.interactively)
|
||||||
.navigationTitle("Post Language")
|
.navigationTitle("Post Language")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
|
Loading…
Reference in New Issue