Skip to content

NuPlay/LinkPreview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkPreview(SwiftUI)

version Swift: 5.1+ iOS: 14.0+ license

Preview with Link's meta information.

IMG_0458 example
Image Gif

Get Started

import SwiftUI
import LinkPreview

struct LinkPreview_Test: View {
    @State private var size: CGFloat = 350
    
    var body: some View {
        ZStack(alignment: .bottom){
            ScrollView{
                VStack{
                    LinkPreview(url: URL(string: "https://github.com/NuPlay/RichText"))
                        .backgroundColor(.blue)
                        .primaryFontColor(.white)
                        .secondaryFontColor(.white.opacity(0.6))
                        .titleLineLimit(3)
                        .frame(width: size, alignment: .center)
                    
                    LinkPreview(url: URL(string: "https://github.com/NuPlay/ExpandableText"))
                        .titleLineLimit(20)
                        .frame(width: size, alignment: .center)
                        .type(.small)
                    
                    LinkPreview(url: URL(string: "https://github.com/NuPlay/SwiftUI-SlideText"))
                }
                .padding(.horizontal, 24)
            }
            
            Slider(value: $size , in: 100...400, step: 1)
                .padding(.horizontal, 24)
        }
    }
}

Modifier(optional)

Modifier Default
.backgroundColor(_ backgroundColor: Color) Color(.systemGray5)
.primaryFontColor(_ primaryFontColor: Color) .primary
.secondaryFontColor(_ secondaryFontColor: Color) .gray
.titleLineLimit(_ titleLineLimit: Int) 3
.type(_ type: LinkPreviewType(customType[.large, .small, .auto])) .auto