Skip to content

Commit

Permalink
chore: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelsalaja committed Sep 30, 2023
0 parents commit 92793c0
Show file tree
Hide file tree
Showing 24 changed files with 1,645 additions and 0 deletions.
421 changes: 421 additions & 0 deletions Layers.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Layers.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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>
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>
11 changes: 11 additions & 0 deletions Layers/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
13 changes: 13 additions & 0 deletions Layers/Assets.xcassets/AppIcon.appiconset/Contents.json
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
}
}
6 changes: 6 additions & 0 deletions Layers/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
22 changes: 22 additions & 0 deletions Layers/Components/LayerActions.swift
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
}
}
}
30 changes: 30 additions & 0 deletions Layers/Components/LayerBackground.swift
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()
}
}
211 changes: 211 additions & 0 deletions Layers/Components/LayerButton.swift
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()
}
24 changes: 24 additions & 0 deletions Layers/Components/LayerContent.swift
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
}
}
28 changes: 28 additions & 0 deletions Layers/Components/LayerHeader.swift
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!")
}
}
Loading

0 comments on commit 92793c0

Please sign in to comment.