Skip to content

diliedevs/DLDSwiftUI

Repository files navigation

DLDSwiftUI Logo

Swift Version Apple Platforms Current Tag License type @DiLieDevs on X

DLDSwiftUI

DLDSwiftUI is a small collection of SwiftUI helpers I reach for often when building Apple platform apps. It focuses on fluent view composition, small layout conveniences, color utilities, and conditional styling so common UI code stays short and readable.

The package currently supports:

  • macOS 14+
  • iOS 17+

It also re-exports:

That means import DLDSwiftUI gives you this package's helpers plus those libraries in one import.

Installation

Add the package in Xcode using this repository URL:

https://github.com/diliedevs/DLDSwiftUI.git

Or add it to Package.swift:

dependencies: [
    .package(url: "https://github.com/diliedevs/DLDSwiftUI.git", branch: "main")
]

Then add the product to your target:

dependencies: [
    .product(name: "DLDSwiftUI", package: "DLDSwiftUI")
]

What It Includes

DLDSwiftUI is intentionally made up of small helpers instead of a large component system.

  • View helpers like .if, .conditional, .macOS, .iOS, .inForm, .inList, and debug helpers.
  • Frame conveniences like .width(_:), .height(_:), .squared(to:), .fullWidth(), and .fullFrame().
  • Conditional style helpers for buttons, labels, menus, toggles, tables, gauges, progress views, group boxes, and control groups.
  • Color helpers for hex conversion, opacity shortcuts, color mixing, hue adjustment, grayscale conversion, tinting, shading, inversion, and DynamicColor bridging.
  • Image helpers for common resizable + scaledToFit and scaledToFill flows.
  • Small primitives like Separator, ReverseLabelStyle, VerticalLabelStyle, RoundRect, and EdgeInsets convenience initializers.
  • A BasicAction typealias for @MainActor () -> Void.

Usage

Conditional modifiers

import DLDSwiftUI
import SwiftUI

struct LibraryRow: View {
    let isSelected: Bool

    var body: some View {
        Label("Downloads", systemSymbol: .arrowDownCircle)
            .font(.headline.italic(isSelected))
            .if(isSelected) { view in
                view.foregroundStyle(.accent)
            }
            .padding(horizontal: 12, vertical: 8)
            .fullWidth(alignment: .leading)
    }
}

Conditional styles without branching view trees

Button("Continue") {
    // action
}
.buttonStyle(
    if: isPrimary,
    trueStyle: .borderedProminent,
    falseStyle: .bordered
)

Color utilities

let base = Color.blue
let accent = base.mixed(withColor: .mint, weight: 0.35)

print(accent.hexString)   // "#3a9ff2" style output
print(accent.noHashHex)   // "3a9ff2"
let tagColor = Color.orange
let background = tagColor.tinted(by: 0.75)
let border = tagColor.darker(by: 0.2)

Layout and shape helpers

VStack(alignment: .leading, spacing: 12) {
    Text("Inspector")
        .font(.title2.bold())

    Separator(in: .gray.quarter)

    Text("Selection details")
        .padding(.horizontal, 12)
        .padding(.vertical, 8)
        .background {
            RoundRect(cornerRadius: 12, style: .continuous)
                .fill(.background, strokeBorder: .gray.half)
        }
}
.padding(EdgeInsets(horizontal: 16, vertical: 12))

Image helpers

Image(systemSymbol: .photo)
    .resizedToFit(size: 24)
    .foregroundStyle(.secondary)

Platform-specific app icon helpers are also included:

#if os(macOS)
let icon = NSImage.appIcon
#elseif os(iOS)
let icon = UIImage.appIcon
#endif

Testing

Run the package tests with:

swift test

Why This Package Exists

SwiftUI code gets repetitive fast when you're constantly doing little things like conditional modifiers, small frame helpers, resizable image boilerplate, or color conversions. DLDSwiftUI gathers those tiny quality-of-life extensions into one package so app code reads more like intent and less like plumbing.

License

DLDSwiftUI is available under the MIT license, which permits commercial use, modification, distribution, and private use. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages