Skip to content

Latest commit

 

History

History
124 lines (101 loc) · 3.64 KB

README.md

File metadata and controls

124 lines (101 loc) · 3.64 KB

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(...),
    ]
)