Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CodeEdit/Assets.xcassets/custom.breakpoint.symbolset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"symbols" : [
{
"filename" : "custom.breakpoint.svg",
"idiom" : "universal"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct FindNavigatorModeSelector: View {
} label: {
HStack(spacing: 2) {
if index > 0 {
chevron
// chevron
}
Text(selectedMode[index].title)
.foregroundColor(selectedMode[index].needSelectionHightlight ? Color.accentColor : .primary)
Expand Down
40 changes: 37 additions & 3 deletions CodeEditModules/Modules/StatusBar/src/Model/StatusBarModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,36 @@
import GitClient
import SwiftUI

public enum StatusBarTab: String, CaseIterable, Identifiable {
case terminal
case debugger
case output

public var id: String { return self.rawValue }
public static var allOptions: [String] {
return StatusBarTab.allCases.map { $0.rawValue.capitalized }
}
}

private enum StatusBarStorageKey: String {
case isExpanded
case isMaximized
case currentHeight
case selectedTab
}

/// # StatusBarModel
///
/// A model class to host and manage data for the ``StatusBarView``
///
public class StatusBarModel: ObservableObject {
/// The selected tab in the main section.
/// - **0**: Terminal
/// - **1**: Debugger
/// - **2**: Output
@AppStorage(StatusBarStorageKey.selectedTab.rawValue)
public var selectedTab: Int = 1

// TODO: Implement logic for updating values
/// Returns number of errors during comilation
@Published
Expand All @@ -39,17 +64,25 @@ public class StatusBarModel: ObservableObject {
public var currentCol: Int = 1 // Implementation missing

/// Returns true when the drawer is visible
@Published
@AppStorage(StatusBarStorageKey.isExpanded.rawValue)
public var isExpanded: Bool = false

/// Returns true when the drawer is visible
@AppStorage(StatusBarStorageKey.isMaximized.rawValue)
public var isMaximized: Bool = false

/// The current height of the drawer. Zero if hidden
@Published
@AppStorage(StatusBarStorageKey.currentHeight.rawValue)
public var currentHeight: Double = 0

/// Indicates whether the drawer is beeing resized or not
@Published
public var isDragging: Bool = false

/// Search value to filter in drawer
@Published
public var searchText = ""

/// Returns the font for status bar items to use
private(set) var toolbarFont: Font = .system(size: 11)

Expand All @@ -60,7 +93,8 @@ public class StatusBarModel: ObservableObject {
private(set) var workspaceURL: URL

/// The maximum height of the drawer
private(set) var maxHeight: Double = 500
/// when isMaximized is true the height gets set to maxHeight
private(set) var maxHeight: Double = 5000

/// The default height of the drawer
private(set) var standardHeight: Double = 300
Expand Down
19 changes: 9 additions & 10 deletions CodeEditModules/Modules/StatusBar/src/StatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import GitClient
import Design

/// # StatusBarView
///
Expand Down Expand Up @@ -46,16 +47,14 @@ public struct StatusBarView: View {
.foregroundStyle(.bar)
HStack(spacing: 15) {
HStack(spacing: 5) {
StatusBarLabelButton(
model: model,
title: model.errorCount.formatted(),
image: "xmark.octagon"
)
StatusBarLabelButton(
model: model,
title: model.warningCount.formatted(),
image: "exclamationmark.triangle"
)
Image("custom.breakpoint")
.foregroundColor(.accentColor)

Divider()
.frame(maxHeight: 12)
.padding(.horizontal, 7)

SegmentedControl($model.selectedTab, options: StatusBarTab.allOptions)
}
if model.selectedBranch != nil {
StatusBarBranchPicker(model: model)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// FilterTextField.swift
//
//
// Created by Stef Kors on 12/04/2022.
//

import SwiftUI

struct FilterTextField: View {
let title: String

@Binding
var text: String

var body: some View {
HStack {
Image(systemName: "line.3.horizontal.decrease.circle")
.foregroundColor(Color(nsColor: .secondaryLabelColor))
textField
if !text.isEmpty { clearButton }
}
.padding(.horizontal, 5)
.padding(.vertical, 3)
.overlay(
RoundedRectangle(cornerRadius: 4)
.stroke(Color.gray, lineWidth: 0.5).cornerRadius(4)
)
}

private var textField: some View {
TextField(title, text: $text)
.disableAutocorrection(true)
.textFieldStyle(PlainTextFieldStyle())
}

private var clearButton: some View {
Button {
self.text = ""
} label: {
Image(systemName: "xmark.circle.fill")
}
.foregroundColor(.secondary)
.buttonStyle(PlainButtonStyle())
}
}

struct FilterTextField_Previews: PreviewProvider {
static var previews: some View {
FilterTextField(title: "Filter", text: .constant(""))
FilterTextField(title: "Filter", text: .constant("codeedi"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// StatusBarClearButton.swift
//
//
// Created by Stef Kors on 12/04/2022.
//

import SwiftUI

internal struct StatusBarClearButton: View {
@ObservedObject
private var model: StatusBarModel

internal init(model: StatusBarModel) {
self.model = model
}

internal var body: some View {
Button(action: clearTerminal, label: {
Image(systemName: "trash")
.foregroundColor(.secondary)
}).buttonStyle(.plain)
}

internal func clearTerminal() {
// TODO: implement
}
}

struct StatusBarClearButton_Previews: PreviewProvider {
static var previews: some View {
let url = URL(string: "~/Developer")!
StatusBarClearButton(model: StatusBarModel(workspaceURL: url))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,39 @@ internal struct StatusBarDrawer: View {
@ObservedObject
private var model: StatusBarModel

@State
private var searchText = ""

internal init(model: StatusBarModel) {
self.model = model
}

var height: CGFloat {
if model.isMaximized {
return model.maxHeight
}
if model.isExpanded {
return model.currentHeight
}
return 0
}

internal var body: some View {
TerminalEmulatorView(url: model.workspaceURL)
.frame(minHeight: 0,
idealHeight: model.isExpanded ? model.currentHeight : 0,
maxHeight: model.isExpanded ? model.currentHeight : 0)
idealHeight: height,
maxHeight: height)
.safeAreaInset(edge: .bottom) {
HStack(alignment: .center, spacing: 10) {
FilterTextField(title: "Filter", text: $searchText)
.frame(maxWidth: 300)
Spacer()
StatusBarClearButton(model: model)
Divider()
StatusBarMaximizeButton(model: model)
}
.padding(.all, 10)
.frame(maxHeight: 34)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// StatusBarMaximizeButton.swift
//
//
// Created by Stef Kors on 12/04/2022.
//

import SwiftUI

internal struct StatusBarMaximizeButton: View {
@ObservedObject
private var model: StatusBarModel

internal init(model: StatusBarModel) {
self.model = model
}

internal var body: some View {
Button(action: toggleMaximize, label: {
Image(systemName: "arrowtriangle.up.square")
.foregroundColor(model.isMaximized ? .accentColor : .primary)
}).buttonStyle(.plain)
}

internal func toggleMaximize() {
model.isMaximized.toggle()
}
}

struct StatusBarMaximizeButton_Previews: PreviewProvider {
static var previews: some View {
let url = URL(string: "~/Developer")!
StatusBarMaximizeButton(model: StatusBarModel(workspaceURL: url))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// StatusBarTabButton.swift
//
//
// Created by Stef Kors on 12/04/2022.
//

import SwiftUI

struct StatusBarTabButton: View {
var body: some View {
Text("Hello, World!")
}
}

struct StatusBarTabButton_Previews: PreviewProvider {
static var previews: some View {
StatusBarTabButton()
}
}