Repository: CodeEditApp/CodeEdit
File: CodeEdit/Features/NavigatorArea/ProjectNavigator/ProjectNavigatorToolbarBottom.swift (Swift)

Code before:
//
//  Created by TAY KAI QUAN on 23/7/22.
//

import SwiftUI

struct ProjectNavigatorToolbarBottom: View {
    @Environment(\.controlActiveState)
    private var activeState

    @Environment(\.colorScheme)
    private var colorScheme

    @EnvironmentObject var workspace: WorkspaceDocument
    @EnvironmentObject var editorManager: EditorManager

    @State var recentsFilter: Bool = false

    var body: some View {
        HStack(spacing: 5) {
            addNewFileButton
            PaneTextField(
                "Filter",
                text: $workspace.navigatorFilter,
                leadingAccessories: {
                    FilterDropDownIconButton(menu: {
                        ForEach([(true, "Folders on top"), (false, "Alphabetically")], id: \.0) { value, title in
                            Button {
                                // Avoid calling the handleFilterChange method
                                if workspace.sortFoldersOnTop != value {
                                    workspace.sortFoldersOnTop = value
                                }
                            } label: {
                                HStack {
                                    if value == workspace.sortFoldersOnTop {
                                        Image(systemName: "checkmark")
                                    }
                                    Text(title)
                                }
                            }
                        }
                    }, isOn: !workspace.navigatorFilter.isEmpty)
                    .padding(.leading, 4)
                    .foregroundStyle(
                        workspace.navigatorFilter.isEmpty
                        ? Color(nsColor: .secondaryLabelColor)
                        : Color(nsColor: .controlAccentColor)
                    )
                    .help("Show files with matching name")
                },
                trailingAccessories: {

Review comment (suggestion):
I tried modifying the `FilterDropDownIconButton` to have a Picker, but couldn't figure out how to remove the selected value label from it.

Code after:
//
//  Created by TAY KAI QUAN on 23/7/22.
//

import SwiftUI

struct ProjectNavigatorToolbarBottom: View {
    @Environment(\.controlActiveState)
    private var activeState

    @Environment(\.colorScheme)
    private var colorScheme

    @EnvironmentObject var workspace: WorkspaceDocument
    @EnvironmentObject var editorManager: EditorManager

    @State var recentsFilter: Bool = false

    var body: some View {
        HStack(spacing: 5) {
            addNewFileButton
            PaneTextField(
                "Filter",
                text: $workspace.navigatorFilter,
                leadingAccessories: {
                    FilterDropDownIconButton(menu: {
                        ForEach([(true, "Folders on top"), (false, "Alphabetically")], id: \.0) { value, title in
                            Toggle(title, isOn: Binding(get: {
                                workspace.sortFoldersOnTop == value
                            }, set: { _ in
                                // Avoid calling the handleFilterChange method
                                if workspace.sortFoldersOnTop != value {
                                    workspace.sortFoldersOnTop = value
                                }
                            }))
                        }
                    }, isOn: !workspace.navigatorFilter.isEmpty)
                    .padding(.leading, 4)
                    .foregroundStyle(
                        workspace.navigatorFilter.isEmpty
                        ? Color(nsColor: .secondaryLabelColor)
                        : Color(nsColor: .controlAccentColor)
                    )
                    .help("Show files with matching name")
                },
                trailingAccessories: {
                    HStack(spacing: 0) {
                        Toggle(isOn: $recentsFilter) {
                            Image(systemName: "clock")
                        }
                        .help("Show only recent files")