Swiftpack.co - Swift-at-Night/ElViewKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Swift-at-Night.
Swift-at-Night/ElViewKit 0.2.0
A Swift package providing some view for SwiftUI: URLImage, BlurView etc.
⭐️ 1
🕓 3 years ago
.package(url: "https://github.com/Swift-at-Night/ElViewKit.git", from: "0.2.0")

screenshot

ElViewKit

Swift Package Swift 5.3 SwiftUI 2 Xcode 12 iOS 13+

A Swift package providing some view for SwiftUI.

Requirements

  • Xcode 12+
  • iOS13+ (Some features may require iOS14)

Features

View

URLImage

URLImage("https://someurl")

The view that shows image based on URL.

IMPORTANT You have to set URLImage.defaultName before loading URL image. I recommend that you set the value inside of initializer.

BlurView

BlurView(style: .regular)

The view that has blur effect. This view allows you to blur a specific area

Corner

Corner(alignment: .bottomRight) {
    // Content
    Text("Swift@Night")
}

The view that moves content to a specific corner.

Modifier

Image resizer

Image("backgroundImage")
    .resizedToFill(width: 100, height: 50)
  • resizedToFit: Resize image and adjust aspect ratio as .fit. You don't need to call resizable()
  • resizedToFill: Resize image and adjust aspect ratio as .fill. You don't need to call resizable()

NOTE When you set width value only, the image shows square image.

How to use

Xcode project

Xcode > File > Swift Packages > Add Package Dependency > Enter repository URL: https://github.com/Swift-at-Night/ElViewKit

IMPORTANT The version of the package must be 0.1.2 or later

  • Example
import ElViewKit
import SwiftUI

struct SomeView: View {
    var body: some View {
        ZStack {
            // Image Modifier
            Image("backgroundImage")
                .resizedToFill(width: UIScreen.main.bounds.width,
                               height: UIScreen.main.bounds.height)
                .edgesIgnoringSafeArea(.all)
                
            // Blur View
            BlurView(style: .regular).edgesIgnoringSafeArea(.all)
        
            // URL Image
            URLImage("https://avatars1.githubusercontent.com/u/68183707?s=200&v=4")
                .frame(width: 100, height: 100)
                .clipped()
                .overlay (

                    // Corner
                    Corner(alignment: .bottomRight) {
                        Image(systemName: "moon.circle.fill")
                            .resizedToFill(width: 50)
                            .foregroundColor(.gray)
                    }
                    
                )
        }            
    }
    
    init() {
        // URL Image
        URLImage.defaultName = "defaultImage"
    }
}

Other Swift Package

Your Swift Package > Package.swift > Add new package to dependencies > Add "ElViewKit" to the target > Then, now you can import ElViewKit in your source file.

  • Example
import PackageDescription

let package = Package(
    name: "SomePackage",
    products: [ 
        ... 
    ],
    dependencies: [
        .package(url: "https://github.com/Swift-at-Night/ElViewKit", from: "0.1.2") // 1. Add dependency to your swift package
    ],
    targets: [
        .target(
            name: "SomePackage",
            dependencies: ["ElViewKit"]),   // 2. Add ElViewKit to the target as dependency
        .testTarget(...),
    ]
)

GitHub

link
Stars: 1
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

0.2.0
3 years ago
  • Add Corner
    • moves content to a specific corner

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics