Skip to content

Commit

Permalink
🎨 SwiftFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Dec 19, 2024
1 parent 9b2f592 commit 9a6d66c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public struct AutoScrollView<Content>: View where Content: View {
}

private var allowedAxes: Axis.Set {
if isHorizontalScrollingDisabled && isVerticalScrollingDisabled {
if isHorizontalScrollingDisabled, isVerticalScrollingDisabled {
axes
} else if isHorizontalScrollingDisabled {
axes.intersection(.vertical)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Luminare/Main Window/Sidebar/LuminareSidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct LuminareSidebar<Content>: View where Content: View {
@Environment(\.luminareContentMarginsTop) private var contentMarginsTop
@Environment(\.luminareContentMarginsBottom) private var contentMarginsBottom
@Environment(\.luminareSidebarOverflow) private var overflow

@ViewBuilder private var content: () -> Content

/// Initializes a ``LuminareSidebar``.
Expand Down Expand Up @@ -46,9 +46,9 @@ public struct LuminareSidebar<Content>: View where Content: View {
endPoint: .bottom
)
.frame(height: overflow)

Color.white

LinearGradient(
colors: [.clear, .white],
startPoint: .top,
Expand Down
18 changes: 9 additions & 9 deletions Sources/Luminare/Utilities/EnvironmentValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public extension EnvironmentValues {
@Entry var luminareWindow: NSWindow?
@Entry var luminareSidebarOverflow: CGFloat = 50
@Entry var luminareClickedOutside: Bool = false

@Entry var luminareWindowMinWidth: CGFloat = 100
@Entry var luminareWindowMaxWidth: CGFloat = .infinity
@Entry var luminareWindowMinHeight: CGFloat = 100
Expand All @@ -47,15 +47,15 @@ public extension EnvironmentValues {
// MARK: Sheet

@Entry var luminareSheetCornerRadii: RectangleCornerRadii = .init(12)

@Entry var luminareSheetPresentation: LuminareSheetPresentation = .windowCenter
@Entry var luminareSheetIsMovableByWindowBackground: Bool = false
@Entry var luminareSheetClosesOnDefocus: Bool = false

// MARK: Popup

@Entry var luminarePopupCornerRadii: RectangleCornerRadii = .init(12)

@Entry var luminarePopupPadding: CGFloat = 12

// MARK: Color Picker
Expand All @@ -70,17 +70,17 @@ public extension EnvironmentValues {
// MARK: General

@Entry var luminareCornerRadii: RectangleCornerRadii = .init(12)

@Entry var luminareMinHeight: CGFloat = 34
@Entry var luminareHorizontalPadding: CGFloat = 8
@Entry var luminareIsBordered: Bool = true
@Entry var luminareHasBackground: Bool = true
@Entry var luminareHasDividers: Bool = true

@Entry var luminareAspectRatio: CGFloat?
@Entry var luminareAspectRatioContentMode: ContentMode? = .fit
@Entry var luminareAspectRatioHasFixedHeight: Bool = true

@Entry var luminareContentMarginsTop: CGFloat = 0
@Entry var luminareContentMarginsLeading: CGFloat = 0
@Entry var luminareContentMarginsBottom: CGFloat = 0
Expand All @@ -90,7 +90,7 @@ public extension EnvironmentValues {

@Entry var luminareButtonCornerRadii: RectangleCornerRadii = .init(2)
@Entry var luminareCompactButtonCornerRadii: RectangleCornerRadii = .init(8)

@Entry var luminareButtonMaterial: Material? = nil
@Entry var luminareButtonHighlightOnHover: Bool = true

Expand Down Expand Up @@ -136,11 +136,11 @@ public extension EnvironmentValues {
// MARK: List

@Entry var luminareListItemCornerRadii: RectangleCornerRadii = .init(2)

@Entry var luminareListItemHeight: CGFloat = 50
@Entry var luminareListItemHighlightOnHover: Bool = true
@Entry var luminareListFixedHeightUntil: CGFloat? = nil

@Entry var luminareListRoundedTopCornerBehavior: LuminareListRoundedCornerBehavior = .never
@Entry var luminareListRoundedBottomCornerBehavior: LuminareListRoundedCornerBehavior = .never

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by KrLite on 2024/12/19.
//


import SwiftUI

public extension EdgeInsets {
Expand All @@ -19,7 +18,7 @@ public extension EdgeInsets {
trailing: length
)
}

init(_ edges: Edge.Set, _ length: CGFloat) {
self.init(
top: edges.contains(.top) ? length : 0,
Expand Down
14 changes: 7 additions & 7 deletions Sources/Luminare/Utilities/Extensions/View+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public extension View {
if let maxHeight { view.environment(\.luminareWindowMaxHeight, maxHeight) }
view
}

@ViewBuilder func luminareSizebarOverflow(_ overflow: CGFloat) -> some View {
environment(\.luminareSidebarOverflow, overflow)
}
Expand Down Expand Up @@ -238,15 +238,15 @@ public extension View {
@ViewBuilder func luminareHasDividers(_ hasDividers: Bool) -> some View {
environment(\.luminareHasDividers, hasDividers)
}

@ViewBuilder func luminareAspectRatio(unapplying: Bool) -> some View {
if unapplying {
environment(\.luminareAspectRatioContentMode, nil)
} else {
self
}
}

@ViewBuilder func luminareAspectRatio(
_ aspectRatio: CGFloat? = nil, contentMode: ContentMode, hasFixedHeight: Bool? = nil
) -> some View {
Expand All @@ -256,7 +256,7 @@ public extension View {
if let hasFixedHeight { view.environment(\.luminareAspectRatioHasFixedHeight, hasFixedHeight) }
view
}

@ViewBuilder func luminareAspectRatio(
_ aspectRatio: CGSize, contentMode: ContentMode, hasFixedHeight: Bool? = nil
) -> some View {
Expand All @@ -266,14 +266,14 @@ public extension View {
hasFixedHeight: hasFixedHeight
)
}

@ViewBuilder func luminareContentMargins(_ insets: EdgeInsets) -> some View {
environment(\.luminareContentMarginsTop, insets.top)
.environment(\.luminareContentMarginsLeading, insets.leading)
.environment(\.luminareContentMarginsBottom, insets.bottom)
.environment(\.luminareContentMarginsTrailing, insets.trailing)
}

@ViewBuilder func luminareContentMargins(_ edges: Edge.Set, _ length: CGFloat) -> some View {
let view = self
if edges.contains(.top) { view.environment(\.luminareContentMarginsTop, length) }
Expand All @@ -282,7 +282,7 @@ public extension View {
if edges.contains(.trailing) { view.environment(\.luminareContentMarginsTrailing, length) }
view
}

@ViewBuilder func luminareContentMargins(_ length: CGFloat) -> some View {
luminareContentMargins(.all, length)
}
Expand Down
21 changes: 10 additions & 11 deletions Sources/Luminare/Utilities/LuminareManagerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
// Created by KrLite on 2024/12/19.
//


import SwiftUI

public protocol LuminareManagerProtocol: View {
var luminare: LuminareWindow? { get set }
var isVisible: Bool { get }

var blurRadius: CGFloat? { get }
var minFrame: CGSize { get }
var maxFrame: CGSize { get }

mutating func show()
mutating func close()
mutating func toggle()
Expand All @@ -29,40 +28,40 @@ public extension LuminareManagerProtocol {
false
}
}

var blurRadius: CGFloat? {
nil
}

var minFrame: CGSize {
.init(width: 100, height: 100)
}

var maxFrame: CGSize {
.init(width: CGFloat.infinity, height: CGFloat.infinity)
}
}

public extension LuminareManagerProtocol {
mutating func show() {
if luminare == nil {
let body = self.body
let body = body
luminare = LuminareWindow(
blurRadius: blurRadius,
minFrame: minFrame,
maxFrame: maxFrame
) { body }
luminare?.center()
}

luminare?.show()
}

mutating func close() {
luminare?.close()
luminare = nil
}

mutating func toggle() {
if isVisible {
close()
Expand Down

0 comments on commit 9a6d66c

Please sign in to comment.