forked from shadowfacts/Tusker
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)
|
||||
.environmentObject(draft)
|
||||
.environmentObject(mastodonController.instanceFeatures)
|
||||
.environment(\.composeUIConfig, config)
|
||||
}
|
||||
|
||||
public func canPaste(itemProviders: [NSItemProvider]) -> Bool {
|
||||
|
@ -450,3 +451,13 @@ private struct GlobalFrameOutsideListPrefKey: PreferenceKey {
|
|||
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 {
|
||||
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 hasChangedSelection: 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 langs: [Lang] = []
|
||||
@State private var filteredLangs: [Lang]?
|
||||
|
@ -102,6 +105,7 @@ private struct LanguagePickerList: View {
|
|||
ForEach(recentLangs) { lang in
|
||||
button(for: lang)
|
||||
}
|
||||
.listRowBackground(groupedCellBackgroundColor)
|
||||
} header: {
|
||||
Text("Recently Used")
|
||||
}
|
||||
|
@ -110,11 +114,16 @@ private struct LanguagePickerList: View {
|
|||
ForEach(filteredLangs ?? langs) { lang in
|
||||
button(for: lang)
|
||||
}
|
||||
.listRowBackground(groupedCellBackgroundColor)
|
||||
} header: {
|
||||
Text("All Languages")
|
||||
}
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(groupedBackgroundColor.edgesIgnoringSafeArea(.all))
|
||||
.searchable(text: $query)
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
.navigationTitle("Post Language")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
|
|
Loading…
Reference in New Issue