CodeEditApp / CodeEditKit

CodeEditKit is an interface between CodeEdit and extensions
MIT License
93 stars 23 forks source link

Dev/foundation #14

Closed Wouter01 closed 1 year ago

Wouter01 commented 1 year ago

Description

This PR adds a base API for integrating extensions with CodeEdit. It offers the following:

It also adds Swiftlint to this package.

See https://github.com/CodeEditApp/CodeEdit/pull/1274 for CodeEditKit integration in CodeEdit

Note that the extension system is a WIP and is by no means done yet. Therefore, no docs will be added until the API gets stable.

Also note that a lot of these features aren't polished yet, but that isn't the goal of this PR. Instead, the goal is to have a base API and implementation that can be improved upon in the future.

Example API:

@main
final class SidebarExtensionExample: CodeEditExtension {
    var description: String = ""

    var entitlements: [Entitlement] = []
}

extension SidebarExtensionExample: SettingsExtension {
    var settings: some View {
        Toggle("Toggle 1", isOn: .constant(true))

        Toggle("Toggle 2", isOn: .constant(false))
    }
}

extension SidebarExtensionExample: SidebarExtension {
    var sidebars: some Sidebar {
        Inspector(id: "umbrellaInspector") {
            Form {
                Text("Hello, world!")
                Button("Print") {
                    NSLog("Print")
                }
                Button("Warning") {
                    Logger(subsystem: "DummyExt", category: "").warning("Warning")
                }

                Button("Info") {
                    Logger(subsystem: "DummyExt", category: "").info("Info")
                }

                Button("Fault") {
                    Logger(subsystem: "DummyExt", category: "").fault("Fault")
                }
            }
            .formStyle(.grouped)
        }
        .help("Umbrella Inspector")
        .icon("umbrella")

        Navigator(id: "carrotNavigator") {
            Form {
                Text("Hello, world!")
            }
            .formStyle(.grouped)
        }
        .help("Carrot Navigator")
        .icon("carrot")
    }
}

Related Issues

Checklist