From 53de1427392e218279692144da2336e8c6964834 Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 15 Jan 2025 08:35:59 +0530 Subject: [PATCH 1/3] Added view modifiers --- Sources/OrbView/Modifier/OrbView++.swift | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Sources/OrbView/Modifier/OrbView++.swift diff --git a/Sources/OrbView/Modifier/OrbView++.swift b/Sources/OrbView/Modifier/OrbView++.swift new file mode 100644 index 0000000..a0be528 --- /dev/null +++ b/Sources/OrbView/Modifier/OrbView++.swift @@ -0,0 +1,8 @@ +// +// File.swift +// Orb +// +// Created by Yasir on 15/01/25. +// + +import Foundation From a29b54fb33cdb157840bfed909b4cc7ed93b64ae Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 15 Jan 2025 08:43:25 +0530 Subject: [PATCH 2/3] Created View Modifiers --- Sources/Config/OrbConfiguration.swift | 26 --------------- Sources/OrbView/Modifier/OrbView++.swift | 42 +++++++++++++++++++++++- Sources/OrbView/OrbView.swift | 18 ++++++---- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/Sources/Config/OrbConfiguration.swift b/Sources/Config/OrbConfiguration.swift index ed262eb..30274a6 100644 --- a/Sources/Config/OrbConfiguration.swift +++ b/Sources/Config/OrbConfiguration.swift @@ -12,12 +12,6 @@ public struct OrbConfiguration { public let backgroundColors: [Color] public let particleColor: Color - public let showBackground: Bool - public let showWavyBlobs: Bool - public let showParticles: Bool - public let showGlowEffects: Bool - public let showShadow: Bool - public let coreGlowIntensity: Double public let speed: Double @@ -26,21 +20,11 @@ public struct OrbConfiguration { glowColor: Color, particleColor: Color, coreGlowIntensity: Double, - showBackground: Bool, - showWavyBlobs: Bool, - showParticles: Bool, - showGlowEffects: Bool, - showShadow: Bool, speed: Double ) { self.backgroundColors = backgroundColors self.glowColor = glowColor self.particleColor = particleColor - self.showBackground = showBackground - self.showWavyBlobs = showWavyBlobs - self.showParticles = showParticles - self.showGlowEffects = showGlowEffects - self.showShadow = showShadow self.coreGlowIntensity = coreGlowIntensity self.speed = speed } @@ -49,11 +33,6 @@ public struct OrbConfiguration { backgroundColors: [Color] = [.green, .blue, .pink], glowColor: Color = .white, coreGlowIntensity: Double = 1.0, - showBackground: Bool = true, - showWavyBlobs: Bool = true, - showParticles: Bool = true, - showGlowEffects: Bool = true, - showShadow: Bool = true, speed: Double = 60 ) { self.init( @@ -61,11 +40,6 @@ public struct OrbConfiguration { glowColor: glowColor, particleColor: .white, coreGlowIntensity: coreGlowIntensity, - showBackground: showBackground, - showWavyBlobs: showWavyBlobs, - showParticles: showParticles, - showGlowEffects: showGlowEffects, - showShadow: showShadow, speed: speed ) } diff --git a/Sources/OrbView/Modifier/OrbView++.swift b/Sources/OrbView/Modifier/OrbView++.swift index a0be528..cdd2e95 100644 --- a/Sources/OrbView/Modifier/OrbView++.swift +++ b/Sources/OrbView/Modifier/OrbView++.swift @@ -5,4 +5,44 @@ // Created by Yasir on 15/01/25. // -import Foundation +import SwiftUI + +/// Shows/hides the gradient background +public extension OrbView { + public func enableBackground(_ enable: Bool) -> Self { + self.showBackground = enable + return self + } +} + +/// Shows/hides organic movement elements +public extension OrbView { + public func enableWavyBlobs(_ enable: Bool) -> Self { + self.showWavyBlobs = enable + return self + } +} + +/// Shows/hides particle effects +public extension OrbView { + public func enableParticles(_ enable: Bool) -> Self { + self.showParticles = enable + return self + } +} + +/// Shows/hides glow effects +public extension OrbView { + public func enableGlowEffects(_ enable: Bool) -> Self { + self.showGlowEffects = enable + return self + } +} + +/// Shows/hides shadow effects +public extension OrbView { + public func enableShadow(_ enable: Bool) -> Self { + self.showShadow = enable + return self + } +} diff --git a/Sources/OrbView/OrbView.swift b/Sources/OrbView/OrbView.swift index 1530b56..e863d02 100644 --- a/Sources/OrbView/OrbView.swift +++ b/Sources/OrbView/OrbView.swift @@ -12,14 +12,20 @@ public struct OrbView: View { public init(configuration: OrbConfiguration = OrbConfiguration()) { self.config = configuration } - + + @State package var showBackground: Bool = true + @State package var showWavyBlobs: Bool = true + @State package var showParticles: Bool = true + @State package var showGlowEffects: Bool = true + @State package var showShadow: Bool = true + public var body: some View { GeometryReader { geometry in let size = min(geometry.size.width, geometry.size.height) ZStack { // Base gradient background layer - if config.showBackground { + if showBackground { background } @@ -27,18 +33,18 @@ public struct OrbView: View { baseDepthGlows(size: size) // Adds organic movement with flowing blob shapes - if config.showWavyBlobs { + if showWavyBlobs { wavyBlob wavyBlobTwo } // Adds bright, energetic core glow animations - if config.showGlowEffects { + if showGlowEffects { coreGlowEffects(size: size) } // Overlays floating particle effects for additional dynamism - if config.showParticles { + if showParticles { particleView .frame(maxWidth: size, maxHeight: size) } @@ -55,7 +61,7 @@ public struct OrbView: View { // Adding realistic, layered shadows so its brighter near the core, and softer as it grows outwards .modifier( RealisticShadowModifier( - colors: config.showShadow ? config.backgroundColors : [.clear], + colors: showShadow ? config.backgroundColors : [.clear], radius: size * 0.08 ) ) From 4a71bbf8e7bded40e8fb6dcae52e09705d866194 Mon Sep 17 00:00:00 2001 From: Mohammad Yasir Date: Wed, 15 Jan 2025 09:20:26 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8b25cfa..586a62c 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ struct ContentView: View { ![image](https://github.com/user-attachments/assets/4b51ca16-889b-4a0a-80e5-9256c51825b8) -The `OrbView` can be customized using `OrbConfiguration`: +The `OrbView` can be customized using `OrbConfiguration` and OrbView modifiers: ```swift @@ -67,16 +67,16 @@ let configuration = OrbConfiguration( backgroundColors: [.purple, .blue, .pink], // Custom gradient colors glowColor: .white, // Glow effect color particleColor: .white, // Particle effect color - coreGlowIntensity: 1.2, // Intensity of the core glow - showBackground: true, // Toggle background visibility - showWavyBlobs: true, // Toggle organic movement elements - showParticles: true, // Toggle particle effects - showGlowEffects: true, // Toggle glow effects - showShadow: true, // Toggle shadow effects - speed: 60 // Animation speed + coreGlowIntensity: 1.2, // Intensity of the core glow + speed: 60 // Animation speed ) OrbView(configuration: configuration) + .enableBackground(true) // Shows/hides the gradient background + .enableWavyBlobs(true) // Shows/hides organic movement elements + .enableParticles(true) // Shows/hides particle effects + .enableGlowEffects(true) // Shows/hides glow effects + .enableShadow(true) // Shows/hides shadow effects .frame(width: 200, height: 200) ``` @@ -88,11 +88,6 @@ OrbView(configuration: configuration) | `glowColor` | `Color` | `.white` | Color of the glow effects | | `particleColor` | `Color` | `.white` | Color of the particle effects | | `coreGlowIntensity` | `Double` | `1.0` | Intensity of the core glow effect (higher = brighter) | -| `showBackground` | `Bool` | `true` | Shows/hides the gradient background | -| `showWavyBlobs` | `Bool` | `true` | Shows/hides organic movement elements | -| `showParticles` | `Bool` | `true` | Shows/hides particle effects | -| `showGlowEffects` | `Bool` | `true` | Shows/hides glow effects | -| `showShadow` | `Bool` | `true` | Shows/hides shadow effects | | `speed` | `Double` | `60` | Animation speed (higher = faster) | ### Preset Configurations @@ -107,6 +102,8 @@ let mysticOrb = OrbConfiguration( coreGlowIntensity: 1.2 ) +OrbView(configuration: mysticOrb) + // Nature let natureOrb = OrbConfiguration( backgroundColors: [.green, .mint, .teal], @@ -114,6 +111,8 @@ let natureOrb = OrbConfiguration( speed: 45 ) +OrbView(configuration: natureOrb) + // Sunset let sunsetOrb = OrbConfiguration( backgroundColors: [.orange, .red, .pink], @@ -121,6 +120,8 @@ let sunsetOrb = OrbConfiguration( coreGlowIntensity: 0.8 ) +OrbView(configuration: sunsetOrb) + // Ocean let oceanOrb = OrbConfiguration( backgroundColors: [.blue, .cyan, .teal], @@ -128,15 +129,19 @@ let oceanOrb = OrbConfiguration( speed: 75 ) +OrbView(configuration: oceanOrb) + // Minimal let minimalOrb = OrbConfiguration( backgroundColors: [.gray, .white], glowColor: .white, - showWavyBlobs: false, - showParticles: false, speed: 30 ) +OrbView(configuration: minimalOrb) +.enableWavyBlobs(false) +.enableParticles(false) + // Cosmic let cosmicOrb = OrbConfiguration( backgroundColors: [.purple, .pink, .blue], @@ -145,6 +150,8 @@ let cosmicOrb = OrbConfiguration( speed: 90 ) +OrbView(configuration: cosmicOrb) + // Fire let fireOrb = OrbConfiguration( backgroundColors: [.red, .orange, .yellow], @@ -153,22 +160,28 @@ let fireOrb = OrbConfiguration( speed: 80 ) +OrbView(configuration: fireOrb) + // Arctic let arcticOrb = OrbConfiguration( backgroundColors: [.cyan, .white, .blue], glowColor: .white, coreGlowIntensity: 0.75, - showParticles: true, speed: 40 ) +OrbView(configuration: arcticOrb) +.enableParticles(false) + // Shadow let shadowOrb = OrbConfiguration( backgroundColors: [.black, .gray], glowColor: .gray, - coreGlowIntensity: 0.7, - showParticles: false + coreGlowIntensity: 0.7 ) + +OrbView(configuration: shadowOrb) +.enableParticles(false) ``` ## Requirements