-
Notifications
You must be signed in to change notification settings - Fork 6
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
0 parents
commit 92793c0
Showing
24 changed files
with
1,645 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Layers.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
Layers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
14 changes: 14 additions & 0 deletions
14
Layers.xcodeproj/xcuserdata/raphaelsalaja.xcuserdatad/xcschemes/xcschememanagement.plist
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>Layers.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,22 @@ | ||
// | ||
// LayerActions.swift | ||
// Eyedee | ||
// | ||
// Created by Raphael Salaja on 29/09/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LayerActions: View { | ||
@State var content: AnyView | ||
|
||
public init<Content>(@ViewBuilder content: @escaping () -> Content) where Content: View { | ||
self.content = AnyView(content()) | ||
} | ||
|
||
var body: some View { | ||
HStack { | ||
content | ||
} | ||
} | ||
} |
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,30 @@ | ||
// | ||
// LayerBackground.swift | ||
// Eyedee | ||
// | ||
// Created by Raphael Salaja on 29/09/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LayerBackground: View { | ||
@State var content: AnyView | ||
|
||
public init<Content>(@ViewBuilder content: @escaping () -> Content) where Content: View { | ||
self.content = AnyView(content()) | ||
} | ||
|
||
var body: some View { | ||
ZStack { | ||
Color(.black.opacity(0.25)).ignoresSafeArea() | ||
|
||
content | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
LayerBackground { | ||
LayerPlayground() | ||
} | ||
} |
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,211 @@ | ||
// | ||
// LayerButton.swift | ||
// Eyedee | ||
// | ||
// Created by Raphael Salaja on 19/09/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// A custom button control with text, an optional icon, and various styling options. | ||
/// | ||
/// The `LayerButton` allows you to create buttons with customizable text, icons, and visual appearance. | ||
/// It provides options to specify the button's action, background color, and disabled state. | ||
/// | ||
/// Example usage: | ||
/// ```swift | ||
/// struct ContentView: View { | ||
/// var body: some View { | ||
/// LayerButton(text: "Submit", action: { | ||
/// // Perform button action here | ||
/// }) | ||
/// } | ||
/// } | ||
/// ``` | ||
/// | ||
/// - Parameters: | ||
/// - id: The unique identifier for the button, used in animations | ||
/// - text: The text displayed on the button. | ||
/// - action: The closure to execute when the button is tapped. | ||
/// - color: The background color of the button. | ||
/// - icon: The name of the system image to display as an icon (optional). | ||
/// - disabled: A boolean indicating whether the button should be disabled (default is `false`). | ||
/// | ||
/// The `LayerButton` supports various styling options, including font size, text alignment, | ||
/// padding, background color, and the option to display an icon alongside the text. | ||
/// | ||
struct LayerButton: View { | ||
enum LayerButtonType { | ||
case single | ||
case select | ||
} | ||
|
||
@State var id: String | ||
@State var text: String | ||
@State var action: () -> Void | ||
@State var color: Color | ||
@State var icon: String | ||
@State var disabled: Bool | ||
@State var type: LayerButtonType | ||
|
||
@State var selected: Bool = false | ||
|
||
internal init( | ||
id: String = UUID().uuidString, | ||
text: String = "Button", | ||
color: Color = Color(.systemBlue), | ||
icon: String = "", | ||
disabled: Bool = false, | ||
type: LayerButtonType = .single, | ||
action: @escaping () -> Void = {} | ||
) { | ||
self.id = id | ||
self.text = text | ||
self.action = action | ||
self.color = color | ||
self.icon = icon | ||
self.disabled = disabled | ||
self.type = type | ||
} | ||
|
||
func selectOperation() { | ||
action | ||
|
||
withAnimation(.snappy(duration: 0.25)) { | ||
selected.toggle() | ||
} | ||
} | ||
|
||
var body: some View { | ||
if type == .single { | ||
single | ||
} else { | ||
select | ||
} | ||
} | ||
|
||
var single: some View { | ||
Button(action: action) { | ||
VStack(alignment: .center) { | ||
HStack(alignment: .center) { | ||
Spacer(minLength: 0) | ||
|
||
if icon != "" { | ||
Image(systemName: icon) | ||
.font(.body) | ||
.fontWeight(.bold) | ||
.foregroundColor(color.isDark ? Color.white : Color.black) | ||
} | ||
|
||
Text(text) | ||
.font(.body) | ||
.fontWeight(.bold) | ||
.fontDesign(.rounded) | ||
.transition(.scale(scale: 1.0)) | ||
.matchedGeometryEffect( | ||
id: "layer.button.text.\(id)", | ||
in: LayerConstants.Animations.Namespaces.namespace | ||
) | ||
.foregroundColor(color.isDark ? Color.white : Color.black) | ||
|
||
Spacer(minLength: 0) | ||
} | ||
} | ||
.padding(16) | ||
.frame(maxWidth: .infinity) | ||
.background(disabled ? color.opacity(0.5) : color) | ||
.clipShape(RoundedRectangle(cornerRadius: 100, style: .continuous)) | ||
} | ||
.disabled(disabled) | ||
.buttonStyle(ScaleButtonStyle()) | ||
} | ||
|
||
var select: some View { | ||
Button(action: selectOperation) { | ||
VStack(alignment: .center) { | ||
HStack(alignment: .center) { | ||
if icon != "" { | ||
Image(systemName: icon) | ||
.font(.body) | ||
.fontWeight(.bold) | ||
.foregroundColor(Color(.systemGray)) | ||
} | ||
|
||
HStack { | ||
Text(text) | ||
.font(.body) | ||
.fontWeight(.bold) | ||
.multilineTextAlignment(.leading) | ||
.fontDesign(.rounded) | ||
.foregroundColor(Color.black) | ||
.transition(.slide) | ||
.minimumScaleFactor(0.1) | ||
|
||
Spacer(minLength: 0) | ||
} | ||
.matchedGeometryEffect( | ||
id: "layer.button.select.\(id)", | ||
in: LayerConstants.Animations.Namespaces.namespace | ||
) | ||
|
||
if selected { | ||
Image(systemName: "checkmark.circle.fill") | ||
.font(.title3) | ||
.frame(width: 16, height: 16) | ||
.fontWeight(.black) | ||
.foregroundColor(color) | ||
.transition( | ||
.asymmetric( | ||
insertion: | ||
.scale(scale: 1.0) | ||
.combined(with: .offset(x: 32)), | ||
removal: | ||
.scale(scale: 1.0) | ||
.combined(with: .offset(x: 48)) | ||
) | ||
) | ||
.matchedGeometryEffect( | ||
id: "layer.button.select.icon.\(id)", | ||
in: LayerConstants.Animations.Namespaces.namespace | ||
) | ||
} | ||
} | ||
} | ||
.padding(16) | ||
.frame(maxWidth: .infinity) | ||
.background(selected ? Color(.systemGray6) : Color.white) | ||
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) | ||
} | ||
.transition(.scale(scale: 1.0)) | ||
.buttonStyle(.plain) | ||
} | ||
} | ||
|
||
#Preview("Select", traits: .sizeThatFitsLayout) { | ||
VStack { | ||
LayerButton( | ||
icon: "plus", | ||
type: .select | ||
) | ||
LayerButton( | ||
icon: "plus", | ||
type: .select | ||
) | ||
LayerButton( | ||
icon: "plus", | ||
type: .select | ||
) | ||
LayerButton( | ||
icon: "plus", | ||
type: .select | ||
) | ||
LayerButton( | ||
icon: "plus", | ||
type: .select | ||
) | ||
}.padding() | ||
} | ||
|
||
#Preview("Action", traits: .sizeThatFitsLayout) { | ||
LayerButton().padding() | ||
} |
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,24 @@ | ||
// | ||
// LayerContent.swift | ||
// Eyedee | ||
// | ||
// Created by Raphael Salaja on 29/09/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LayerContent: View { | ||
@State var content: AnyView | ||
|
||
init() { | ||
self.content = AnyView(EmptyView()) | ||
} | ||
|
||
internal init<Content>(@ViewBuilder content: @escaping () -> Content) where Content: View { | ||
self.content = AnyView(content()) | ||
} | ||
|
||
var body: some View { | ||
content | ||
} | ||
} |
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,28 @@ | ||
// | ||
// LayerHeader.swift | ||
// Eyedee | ||
// | ||
// Created by Raphael Salaja on 29/09/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LayerHeader: View { | ||
@State var content: AnyView | ||
|
||
public init<Content>(@ViewBuilder content: @escaping () -> Content) where Content: View { | ||
self.content = AnyView(content()) | ||
} | ||
|
||
var body: some View { | ||
HStack { | ||
content | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
LayerHeader { | ||
Text("Hello, World!") | ||
} | ||
} |
Oops, something went wrong.