### Basic Shiny App Integration Example in SwiftUI Source: https://context7.com/maustinstar/shiny/llms.txt Provides a fundamental example of integrating Shiny into a SwiftUI application. It sets up a basic app structure with navigation links to different Shiny effect demos (Rainbow, Iridescent, Glossy). Each demo view applies the `.shiny()` modifier with a specified gradient. ```swift import SwiftUI import Shiny @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { NavigationView { List { NavigationLink("Rainbow Effect") { DemoView(gradient: .rainbow, title: "Rainbow") } NavigationLink("Iridescent Effect") { DemoView(gradient: .iridescent, title: "Iridescent") } NavigationLink("Glossy Effect") { DemoView(gradient: .glossy(.systemBlue), title: "Glossy") } } .navigationTitle("Shiny Demo") } } } struct DemoView: View { let gradient: Gradient let title: String var body: some View { VStack { Text(title) .font(.system(size: 60, weight: .bold)) .shiny(gradient) Text("Move to see the effect") .font(.caption) .foregroundColor(.secondary) .padding(.top) } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(UIColor.systemBackground)) } } ``` -------------------------------- ### Glossy Text on Matte Black Card using Swift Source: https://github.com/maustinstar/shiny/blob/master/Docs/examples.md Applies a glossy effect to the text 'shiny' and a matte black effect to a rounded rectangle background using the .shiny() modifier. ```swift Text("shiny") .font(.largeTitle) .fontWeight(.bold).shiny(.glossy(.black)) .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.matte(.black))) ``` -------------------------------- ### Rainbow Text on Silver Card using Swift Source: https://github.com/maustinstar/shiny/blob/master/Docs/examples.md Applies a rainbow effect to the text 'shiny' and a hyper-glossy effect to a silver rounded rectangle background using the .shiny() modifier. ```swift Text("shiny") .font(.largeTitle) .fontWeight(.bold).shiny() .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.hyperGlossy(UIColor.systemGray5))) ``` -------------------------------- ### Iridescent Text on Glossy Black Card using Swift Source: https://github.com/maustinstar/shiny/blob/master/Docs/examples.md Applies an iridescent effect to the text 'shiny' and a glossy black effect to a rounded rectangle background using the .shiny() modifier. ```swift Text("shiny") .font(.largeTitle) .fontWeight(.bold).shiny(.iridescent) .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.glossy(.black))) ``` -------------------------------- ### Apply hyperGlossy Gradient Style in Swift Source: https://context7.com/maustinstar/shiny/llms.txt Demonstrates creating an intense glossy effect with sharp white highlights using the .hyperGlossy() modifier. The intensity parameter (0.0 to 1.0) controls highlight brightness. Shows three practical examples: a premium text label, an Apple Cash card simulation, and intensity comparison circles to visualize the effect of different intensity values. ```swift import SwiftUI import Shiny struct HyperGlossyView: View { var body: some View { // Maximum intensity (default) Text("PREMIUM") .font(.title) .fontWeight(.black) .foregroundColor(.white) .frame(width: 250, height: 120) .background( RoundedRectangle(cornerRadius: 20) .fill(Color.black) .shiny(.hyperGlossy(UIColor.systemGray5)) ) } } struct AppleCashCardView: View { var body: some View { VStack(alignment: .leading, spacing: 12) { HStack { Text("Apple Cash") .font(.headline) .foregroundColor(.white) Spacer() Image(systemName: "applelogo") .foregroundColor(.white) } Spacer() Text("$1,234.56") .font(.largeTitle) .fontWeight(.bold) .foregroundColor(.white) } .padding(24) .frame(width: 340, height: 200) .background( RoundedRectangle(cornerRadius: 24) .fill(Color(red: 0.1, green: 0.1, blue: 0.1)) .shiny(.hyperGlossy(UIColor.systemGray6, intensity: 1.0)) ) .shadow(color: Color.black.opacity(0.3), radius: 15, y: 8) } } struct IntensityComparisonView: View { var body: some View { HStack(spacing: 20) { // Low intensity Circle() .frame(width: 80, height: 80) .shiny(.hyperGlossy(UIColor.systemBlue, intensity: 0.3)) // Medium intensity Circle() .frame(width: 80, height: 80) .shiny(.hyperGlossy(UIColor.systemBlue, intensity: 0.6)) // Full intensity Circle() .frame(width: 80, height: 80) .shiny(.hyperGlossy(UIColor.systemBlue, intensity: 1.0)) } } } ``` -------------------------------- ### Basic SwiftUI View Integration with Shiny Source: https://github.com/maustinstar/shiny/blob/master/README.md Demonstrates the fundamental usage of the Shiny package in SwiftUI. It shows how to import the 'Shiny' module and apply the `.shiny()` modifier to a Text view to enable the effect. ```swift import Shiny ... Text("Hello, shiny world! ✨").shiny() ``` -------------------------------- ### Swift Package Manager Integration for Shiny Source: https://context7.com/maustinstar/shiny/llms.txt Shows how to add the Shiny library to your Xcode project or Swift package using the Swift Package Manager. This involves specifying the repository URL and version in the Package.swift file. It defines dependencies for iOS and macOS platforms. ```swift import PackageDescription let package = Package( name: "MyApp", platforms: [ .iOS(.v14), .macOS(.v11) ], dependencies: [ .package( url: "https://github.com/maustinstar/shiny.git", from: "0.0.1" ) ], targets: [ .target( name: "MyApp", dependencies: ["Shiny"]) ] ) ``` -------------------------------- ### Create Custom Gradient Effects in Swift Source: https://context7.com/maustinstar/shiny/llms.txt Demonstrates creating custom gradient effects by passing SwiftUI Gradient objects to the .shiny() modifier. Shows three approaches: a rainbow gradient with seven colors, a two-tone gold gradient with transparency, and an advanced gradient with multiple stops and varying opacity levels for sophisticated visual effects. ```swift import SwiftUI import Shiny struct CustomGradientView: View { var body: some View { // Custom gradient with specific colors let customGradient = Gradient(colors: [ .purple, .blue, .cyan, .green, .yellow, .orange, .red ]) Text("Custom Gradient") .font(.largeTitle) .fontWeight(.bold) .shiny(customGradient) } } struct DualToneGradientView: View { var body: some View { // Two-tone gradient effect let goldGradient = Gradient(colors: [ Color(red: 1.0, green: 0.84, blue: 0.0), Color(red: 1.0, green: 0.65, blue: 0.0), Color(red: 0.85, green: 0.65, blue: 0.13), Color.clear ]) RoundedRectangle(cornerRadius: 16) .frame(width: 300, height: 180) .shiny(goldGradient) } } struct AdvancedCustomView: View { var body: some View { // Gradient with transparency and multiple stops let complexGradient = Gradient(stops: [ .init(color: Color.white.opacity(0.9), location: 0.0), .init(color: Color.blue.opacity(0.7), location: 0.2), .init(color: Color.purple.opacity(0.5), location: 0.4), .init(color: Color.pink.opacity(0.3), location: 0.6), .init(color: Color.clear, location: 1.0) ]) Text("ADVANCED") .font(.system(size: 48, weight: .heavy)) .shiny(complexGradient) .frame(width: 320, height: 200) .background(Color.black) .cornerRadius(20) } } ``` -------------------------------- ### Gradient Styles Source: https://context7.com/maustinstar/shiny/llms.txt Shiny provides several pre-built gradient styles that can be applied using the `.shiny()` modifier to customize the motion-based effects. ```APIDOC ## Gradient Styles ### Description Shiny provides several pre-built gradient styles that can be applied using the `.shiny()` modifier to customize the motion-based effects. ### Styles #### `.rainbow` A vibrant multi-color gradient that cycles through the full spectrum of system colors, creating a bold rainbow effect that moves with device orientation or mouse position. This is the default style if no style is specified. ```swift import SwiftUI import Shiny struct RainbowTextView: View { var body: some View { Text("shiny") .font(.largeTitle) .fontWeight(.bold) .shiny(.rainbow) // Explicit rainbow style .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.hyperGlossy(UIColor.systemGray5)) ) } } // Default behavior (rainbow is the default) struct DefaultShinyView: View { var body: some View { Text("Rainbow by default") .shiny() // Uses .rainbow automatically } } ``` #### `.iridescent` A subtle, translucent gradient featuring soft blues and purples with varying opacity, perfect for adding a delicate sparkle effect without overwhelming the base view design. ```swift import SwiftUI import Shiny struct IridescentCardView: View { var body: some View { VStack(spacing: 16) { Text("Premium Card") .font(.title2) .fontWeight(.semibold) .foregroundColor(.white) Text("**** **** **** 1234") .font(.title3) .foregroundColor(.white) } .frame(width: 300, height: 180) .background( RoundedRectangle(cornerRadius: 20) .fill(Color.black) .shiny(.iridescent) ) .shadow(radius: 10) } } // Iridescent text effect struct IridescentTextView: View { var body: some View { Text("shiny") .font(.largeTitle) .fontWeight(.bold) .shiny(.iridescent) .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.glossy(.black)) ) } } ``` #### `.matte(color)` A flat, non-reflective gradient effect with a customizable base color. * **color** (UIColor) - The base color for the matte gradient. #### `.glossy(color)` A smooth, reflective gradient with a customizable base color, simulating a glossy surface. * **color** (UIColor) - The base color for the glossy gradient. #### `.hyperGlossy(color)` An intensified glossy effect with higher reflectivity and a more pronounced highlight, using a customizable base color. * **color** (UIColor) - The base color for the hyper-glossy gradient. ### Usage Apply these styles as arguments to the `.shiny()` modifier: ```swift Text("My View") .shiny(.glossy(UIColor.red)) Rectangle() .shiny(.hyperGlossy(UIColor.blue)) ``` ``` -------------------------------- ### Shiny Gradient Style: Iridescent Source: https://context7.com/maustinstar/shiny/llms.txt Shows how to apply the `.iridescent` gradient style for subtle, translucent effects, and also demonstrates its use on text combined with other gradient styles for backgrounds. This style is useful for delicate sparkle effects. ```swift import SwiftUI import Shiny struct IridescentCardView: View { var body: some View { VStack(spacing: 16) { Text("Premium Card") .font(.title2) .fontWeight(.semibold) .foregroundColor(.white) Text("**** **** **** 1234") .font(.title3) .foregroundColor(.white) } .frame(width: 300, height: 180) .background( RoundedRectangle(cornerRadius: 20) .fill(Color.black) .shiny(.iridescent) ) .shadow(radius: 10) } } // Iridescent text effect struct IridescentTextView: View { var body: some View { Text("shiny") .font(.largeTitle) .fontWeight(.bold) .shiny(.iridescent) .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.glossy(.black)) ) } } ``` -------------------------------- ### Add Shiny Package Dependency to Swift Package Source: https://github.com/maustinstar/shiny/blob/master/README.md This outlines the process of adding the Shiny package as a dependency for a Swift package. It involves modifying the Package.swift file to include the repository URL and version. ```swift .package(url: "https://github.com/maustinstar/shiny.git", from: "0.0.1"), ``` -------------------------------- ### Shiny Gradient Styles: Rainbow and Hyper-Glossy Source: https://context7.com/maustinstar/shiny/llms.txt Illustrates the usage of the `.rainbow` and `.hyperGlossy` gradient styles within the Shiny library. The rainbow style is the default, while hyper-glossy can be customized with a color. ```swift import SwiftUI import Shiny struct RainbowTextView: View { var body: some View { Text("shiny") .font(.largeTitle) .fontWeight(.bold) .shiny(.rainbow) // Explicit rainbow style .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.hyperGlossy(UIColor.systemGray5)) ) } } // Default behavior (rainbow is the default) struct DefaultShinyView: View { var body: some View { Text("Rainbow by default") .shiny() // Uses .rainbow automatically } } ``` -------------------------------- ### Create Glossy Surface Effect with Shiny Library Source: https://context7.com/maustinstar/shiny/llms.txt Generates a glossy surface effect with white highlights from a base UIColor with adjustable intensity (0.0 to 1.0, default 0.5). Models a focused light source with reflective properties. Can be combined with interactive states and shadows for enhanced visual depth. ```swift import SwiftUI import Shiny struct GlossyButtonView: View { @State private var isPressed = false var body: some View { Button(action: { isPressed.toggle() }) { Text("Tap Me") .font(.headline) .foregroundColor(.white) .padding(.horizontal, 30) .padding(.vertical, 15) } .background( RoundedRectangle(cornerRadius: 12) .fill(Color.blue) .shiny(.glossy(UIColor.systemBlue, intensity: 0.7)) ) .scaleEffect(isPressed ? 0.95 : 1.0) } } struct GlossyCardStackView: View { var body: some View { VStack(spacing: 30) { // Subtle glossy effect cardView(color: .systemIndigo, intensity: 0.3) // Medium glossy effect cardView(color: .systemPurple, intensity: 0.5) // Strong glossy effect cardView(color: .systemPink, intensity: 0.8) } } func cardView(color: UIColor, intensity: CGFloat) -> some View { RoundedRectangle(cornerRadius: 20) .frame(width: 280, height: 160) .shiny(.glossy(color, intensity: intensity)) .shadow(color: Color.black.opacity(0.2), radius: 8, y: 4) } } ``` -------------------------------- ### Advanced SwiftUI View Styling with Shiny Source: https://github.com/maustinstar/shiny/blob/master/README.md Illustrates a more advanced application of the Shiny package, combining text styling with background effects. It applies `.shiny()` to a Text view and uses `.shiny(.hyperGlossy(UIColor.systemGray5))` to style a RoundedRectangle background, creating a 'rainbow text on silver card' effect. ```swift Text("shiny") .font(.largeTitle) .fontWeight(.bold).shiny() .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.hyperGlossy(UIColor.systemGray5))) ``` -------------------------------- ### Create Matte Surface Effect with Shiny Library Source: https://context7.com/maustinstar/shiny/llms.txt Generates a matte surface effect from a base UIColor with adjustable intensity (0.0 to 1.0, default 0.5). Models dispersed light for a soft, non-reflective appearance. Supports default intensity and custom intensity values applied to SwiftUI shapes and containers. ```swift import SwiftUI import Shiny struct MatteCardView: View { var body: some View { // Default intensity (0.5) Text("Matte Card") .font(.title) .fontWeight(.bold) .foregroundColor(.white) .frame(width: 200, height: 100) .background( RoundedRectangle(cornerRadius: 16) .shiny(.matte(UIColor.systemBlue)) ) } } struct CustomMatteView: View { var body: some View { VStack(spacing: 20) { // Low intensity matte Circle() .frame(width: 100, height: 100) .shiny(.matte(UIColor.systemRed, intensity: 0.3)) // High intensity matte Circle() .frame(width: 100, height: 100) .shiny(.matte(UIColor.systemGreen, intensity: 0.9)) // Combined matte text on matte background Text("shiny") .font(.largeTitle) .fontWeight(.bold) .shiny(.glossy(.black)) .background( RoundedRectangle(cornerRadius: 14.0) .frame(width: 200.0, height: 70.0) .shiny(.matte(.black)) ) } } } ``` -------------------------------- ### Add Shiny Package Dependency to Xcode Project Source: https://github.com/maustinstar/shiny/blob/master/README.md This describes how to add the Shiny package as a dependency within an Xcode project. It involves using the 'Add Package Dependency' feature in Xcode's File menu. ```swift File > Swift Packages > Add Package Dependency: https://github.com/maustinstar/shiny ``` -------------------------------- ### Apply Shiny Modifier to SwiftUI Views Source: https://context7.com/maustinstar/shiny/llms.txt Demonstrates the basic usage of the `.shiny()` modifier to apply default or custom gradient styles to SwiftUI views. It shows how to apply the modifier to Text and a custom button shape. ```swift import SwiftUI import Shiny struct ContentView: View { var body: some View { VStack(spacing: 20) { // Basic usage with default rainbow gradient Text("Hello, World!") .font(.largeTitle) .fontWeight(.bold) .shiny() // With custom gradient style Text("Shiny Button") .font(.headline) .padding() .background( RoundedRectangle(cornerRadius: 10) .fill(Color.blue) .shiny(.glossy(UIColor.systemBlue)) ) } .padding() } } ``` -------------------------------- ### Cross-Platform SwiftUI View with Shiny Effects Source: https://context7.com/maustinstar/shiny/llms.txt Demonstrates how to use the Shiny modifier in SwiftUI for cross-platform compatibility. The code adapts to iOS (device motion) and macOS (mouse tracking) automatically, requiring no developer-specific code for platform differences. It showcases applying the `.shiny()` modifier to Text and RoundedRectangle views. ```swift import SwiftUI import Shiny struct CrossPlatformView: View { var body: some View { VStack(spacing: 20) { Text("Cross-Platform Shiny") .font(.title) .fontWeight(.bold) .shiny() #if os(iOS) Text("Tilt your device to see the effect") .font(.caption) .foregroundColor(.gray) #elseif os(macOS) Text("Move your mouse to see the effect") .font(.caption) .foregroundColor(.gray) #endif // Works identically on both platforms RoundedRectangle(cornerRadius: 20) .frame(width: 250, height: 150) .shiny(.glossy(UIColor.systemBlue)) } .padding() } } // iOS-specific types automatically converted on macOS struct AdaptiveColorView: View { var body: some View { VStack { // UIColor on iOS, NSColor on macOS (handled internally) #if os(iOS) Text("iOS Version") .shiny(.matte(UIColor.systemTeal)) #elseif os(macOS) Text("macOS Version") .shiny(.matte(NSColor.systemTeal)) #endif } } } ``` -------------------------------- ### View Modifier: .shiny() Source: https://context7.com/maustinstar/shiny/llms.txt The core API for applying motion-based shiny effects to any SwiftUI view. This modifier wraps the view in a ShinyView container that tracks motion input and renders a dynamic gradient overlay. ```APIDOC ## View Modifier: .shiny() ### Description The core API that applies motion-based shiny effects to any SwiftUI view. This modifier wraps the view in a ShinyView container that tracks motion input and renders a dynamic gradient overlay that responds to device movement or mouse position. ### Method SwiftUI Modifier ### Endpoint N/A (SwiftUI Modifier) ### Parameters #### Query Parameters - **gradientStyle** (ShinyGradientStyle) - Optional - Specifies the gradient style to apply. Defaults to `.rainbow`. ### Request Example ```swift import SwiftUI import Shiny struct ContentView: View { var body: some View { VStack(spacing: 20) { // Basic usage with default rainbow gradient Text("Hello, World!") .font(.largeTitle) .fontWeight(.bold) .shiny() // With custom gradient style Text("Shiny Button") .font(.headline) .padding() .background( RoundedRectangle(cornerRadius: 10) .fill(Color.blue) .shiny(.glossy(UIColor.systemBlue)) ) } .padding() } } ``` ### Response #### Success Response (N/A - SwiftUI Modifier) Applies a visual effect to the view. #### Response Example (See Request Example for view rendering) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.