Swift Package Index


Add profile placeholder when there is no image 😎


  • The latest stable release is 1.0.0. Released 5 months ago.
  • The last commit to master was 20 days ago.

Swift Version Compatibility

  • 1.0.0
    5.3
    5.2
    5.1
    5.0
    4.2
  • master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 1.0.0
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
  • master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

ProfilePlaceholderView

Add profile placeholder when there is no image 😎

Example Contacts app

List of contacts #1. #2. #3.

Installation

It requires iOS 13 and Xcode 11!

In Xcode go to File -> Swift Packages -> Add Package Dependency and paste in the repo's url: https://github.com/cs4alhaider/ProfilePlaceholderView

Usage

import ProfilePlaceholderView

Then add .withProfilePlaceholderView( ... ) under Image like:

struct ContactRow: View {
    let contact: Contact
    
    var body: some View {
        HStack {
            Image(contact.imageString ?? "")
                .resizable()
                .withProfilePlaceholderView(name: contact.name) // HERE YOU CAN PASS MANY THINGS ALSO
                .clipShape(Circle())
                .frame(width: 60, height: 60)
            
            Text(contact.name)
                .font(.headline)
        }
    }
}

or, if you don't want to use any image and you just need a placeholder, then do this:

struct ContactRow: View {
    let contact: Contact
    
    var body: some View {
        HStack {
            ProfilePlaceholderView(name: contact.name)
                .clipShape(Circle())
                .frame(width: 60, height: 60)
            
            Text(contact.name)
                .font(.headline)
        }
    }
}

Check the Example project for more details

Author

Abdullah Alhaider, cs.alhaider@gmail.com

License

This project is under the MIT license. See the LICENSE file for more info.