-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e234c0
commit f9f409b
Showing
9 changed files
with
133 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import SwiftUI | ||
import NeumorphismUI | ||
|
||
struct Concave: View { | ||
@EnvironmentObject var neumorphism: NeumorphismManager | ||
|
||
var body: some View { | ||
ZStack { | ||
neumorphism.color.edgesIgnoringSafeArea(.all) | ||
VStack(spacing: 16) { | ||
Rectangle() | ||
.fill(neumorphism.color) | ||
.neumorphismConcave(shapeType: .rectangle, color: nil) | ||
.frame(width: 256, height: 100) | ||
|
||
RoundedRectangle(cornerRadius: 16) | ||
.fill(neumorphism.color) | ||
.neumorphismConcave(shapeType: .roundedRectangle(cornerRadius: 16), color: nil) | ||
.frame(width: 256, height: 100) | ||
|
||
Circle() | ||
.fill(neumorphism.color) | ||
.neumorphismConcave(shapeType: .circle, color: nil) | ||
.frame(width: 150, height: 150) | ||
|
||
Ellipse() | ||
.fill(neumorphism.color) | ||
.neumorphismConcave(shapeType: .ellipse, color: nil) | ||
.frame(width: 300, height: 100) | ||
|
||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
struct DentView_Previews: PreviewProvider { | ||
static let neumorphism = NeumorphismManager( | ||
isDark: false, | ||
lightColor: Color(hex: "C1D2EB"), | ||
darkColor: Color(hex: "2C292C") | ||
) | ||
static var previews: some View { | ||
Concave() | ||
.environmentObject(neumorphism) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import SwiftUI | ||
|
||
@available(iOS 13.0, *) | ||
struct NeumorphismConcaveModifier: ViewModifier { | ||
@EnvironmentObject var neumorphism: NeumorphismManager | ||
|
||
private var shapeType: ShapeType | ||
private let color: Color? | ||
|
||
init(shapeType: ShapeType = .circle, color: Color? = nil) { | ||
self.shapeType = shapeType | ||
self.color = color | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.overlay( | ||
shapeType.anyShape | ||
.stroke(color ?? neumorphism.color, lineWidth: 4) | ||
.shadow(color: color?.darkerColor() ?? neumorphism.color.darkerColor(), | ||
radius: 4, x: 4, y: 4) | ||
.shadow(color: color?.lighterColor() ?? neumorphism.color.lighterColor(), | ||
radius: 4, x: -4, y: -4)) | ||
.clipShape(shapeType.anyShape) | ||
|
||
} | ||
} | ||
|
||
struct NeumorphismConcaveModifier_Previews: PreviewProvider { | ||
static let neumorphism = NeumorphismManager( | ||
lightColor: Color(hex: "C1D2EB"), | ||
darkColor: Color(hex: "2C292C") | ||
) | ||
static var previews: some View { | ||
ZStack { | ||
neumorphism.color | ||
Circle() | ||
.fill(neumorphism.color) | ||
.frame(width: 100, height: 100) | ||
.modifier(NeumorphismConcaveModifier(shapeType: .circle)) | ||
.environmentObject(neumorphism) | ||
.padding() | ||
} | ||
.frame(width: 100, height: 100) | ||
.padding() | ||
.previewLayout(.sizeThatFits) | ||
|
||
} | ||
} |