Giter Club home page Giter Club logo

neumorphic's Introduction

Neumorphic SwiftUI : Neumorphism Soft UI

Neumorphic is a SwiftUI utility to build Neumorphism Soft UI easily using custom view modifier and custom button style. It supports all shapes.

Hi, I’m Costa. It is simple to create outer shadow in SwiftUI by writing two lines of code. However, we can’t easily create inner shadow in SwiftUI. That’s the reason why I build this tool to make it simple and reusable.

Image of Neumorphic SwiftUI

Installation

Requirements .iOS(.v13),.macOS(.v10_15)

Swift Package Manager

  1. In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency.
  2. Paste the repository URL (https://github.com/costachung/neumorphic/) and click Next.
  3. For Rules, select version.
  4. Click Finish.

Swift Package

.package(url: "https://github.com/costachung/neumorphic/", .upToNextMajor(from: "1.0.0"))

Usage

Import Neumorphic package to your view.

import Neumorphic

Simply use .softOuterShadow and .softInnerShadow methods to create outer shadow and inner shadow respectively.

Create Rounded Rectangle with Outer Shadow

Neumorphic SwiftUI Outer Shadow

RoundedRectangle(cornerRadius: 20).fill(Neumorphic.shared.mainColor()).softOuterShadow()

Create Rounded Rectangle with Inner Shadow

Neumorphic SwiftUI Inner Shadow

RoundedRectangle(cornerRadius: 20).fill(Neumorphic.shared.mainColor()).softInnerShadow(RoundedRectangle(cornerRadius: 20))

Create Circles

Neumorphic SwiftUI Circles

  HStack {
      Circle().fill(Neumorphic.shared.mainColor()).softOuterShadow()
      Circle().fill(Neumorphic.shared.mainColor()).softInnerShadow(Circle())
  }

Create Soft Button

Neumorphic SwiftUI Button

Button(action: {}) {
    Text("Soft Button").fontWeight(.bold)
}
.softButtonStyle(RoundedRectangle(cornerRadius: 20))

Create Soft Button with custom style

Neumorphic SwiftUI Button

HStack {
    Button(action: {}) {
        Image(systemName: "heart.fill")
    }.softButtonStyle(Circle())

    Button(action: {}) {
        Image(systemName: "heart.fill")
    }.softButtonStyle(Circle(), mainColor: Color.red, textColor: Color.white, darkShadowColor: Color(rgb: 0x993333, alpha: 1), lightShadowColor:Color("redButtonLightShadow"))
}

Customization

softInnerShadow

You can change the color, spread of the shadow, and the shadow radius of the inner shadow.

softInnerShadow<S : Shape>(_ content: S, darkShadow: Color, lightShadow: Color, spread: CGFloat, radius: CGFloat)

softOuterShadow

You can change the color, offset of the shadow, and the shadow radius of the outer shadow.

softOuterShadow(darkShadow: Color, lightShadow: Color, offset: CGFloat, radius:CGFloat)

Example Project

Check out the neumorphic-ios-example XCode project to see how to build neumorphic UI and buttons. If you use the default shadow colors of Neumorphic, you can also get dark mode support for free.

Contacts

https://twitter.com/costachung

License

Neumorphic Package is released under the MIT license. See the LICENSE file for more info.

neumorphic's People

Contributors

costachung avatar

Watchers

Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.