### GlassEffectContainer and glassEffectID: SwiftUI for Coordinated Glass Transitions Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt GlassEffectContainer manages the blending and transitions of multiple glass elements. The glassEffectID modifier links related glass elements, enabling coherent morphing animations when views appear, disappear, or change. This example demonstrates coordinating transitions between a main content area and detail views. ```swift import SwiftUI struct CoordinatedGlassExample: View { @State private var showDetails = false @Namespace private var glassNamespace var body: some View { GlassEffectContainer(spacing: 20) { VStack { // Primary glass element Text("Main Content") .padding() .glassEffect(.clear.interactive()) .glassEffectID("MainPanel", in: glassNamespace) if showDetails { // Secondary elements share the namespace HStack { Text("Detail A") .padding() .glassEffect(.clear.interactive()) .glassEffectID("DetailA", in: glassNamespace) Text("Detail B") .padding() .glassEffect(.clear.interactive()) .glassEffectID("DetailB", in: glassNamespace) } } Button("Toggle Details") { withAnimation { showDetails.toggle() } } } } } } ``` -------------------------------- ### glassCircleButton: SwiftUI View Modifier for Circular Glass Buttons Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt The glassCircleButton modifier applies a consistent circular glass button style. It sets foreground color, frame dimensions, content shape, glass effect, and clipping to a circle. It accepts optional diameter and tint parameters. Usage examples demonstrate default and custom configurations. ```swift import SwiftUI extension View { func glassCircleButton(diameter: CGFloat = 64, tint: Color = .white) -> some View { self .foregroundStyle(tint) .frame(width: diameter, height: diameter) .contentShape(Circle()) .glassEffect(.clear.interactive()) .clipShape(Circle()) } } // Usage examples Button { /* action */ } label: { Image(systemName: "heart") } .glassCircleButton() // Default: 64pt diameter, white tint Button { /* action */ } label: { Image(systemName: "star.fill") } .glassCircleButton(diameter: 48, tint: .yellow) // Custom size and color ``` -------------------------------- ### Basic SwiftUI App Entry Point Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md The standard entry point for a SwiftUI application. This file typically sets up the initial view hierarchy and injects any necessary dependencies or data. ```swift import SwiftUI @main struct LiquidGlassExampleApp: App { var body: some Scene { WindowGroup { MainView() } } } ``` -------------------------------- ### Background View Implementation Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Implements the full-bleed background of the application, utilizing bundled assets. This view is responsible for displaying the scenic background image. ```swift import SwiftUI struct BackgroundView: View { var body: some View { Image("forest") .resizable() .ignoresSafeArea() .scaledToFill() } } ``` -------------------------------- ### Coordinate Glass Elements with GlassEffectContainer and glassEffectID Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Shows how to use `GlassEffectContainer` and `.glassEffectID(_, in:)` to share a visual identity between glass elements. This is crucial for coordinating transitions and ensuring a coherent look across different states or views. ```swift import SwiftUI struct CoordinatedGlassView: View { @Namespace var namespace @State private var isExpanded = false var body: some View { GlassEffectContainer(namespace: namespace) { VStack { if !isExpanded { Text("Collapsed View") .glassEffect() .glassEffectID("element1", in: namespace) } else { Text("Expanded View") .glassEffect() .glassEffectID("element1", in: namespace) } Button(isExpanded ? "Collapse" : "Expand") { withAnimation { isExpanded.toggle() } } } } } } ``` -------------------------------- ### Main View Composition in SwiftUI Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Composes the main UI elements of the application, including the background, quote text, and action buttons, typically using layout containers like `ZStack` and `VStack`. ```swift import SwiftUI struct MainView: View { var body: some View { ZStack { BackgroundView() VStack { Spacer() QuoteView() Spacer() ActionButtonsView() } .padding() } } } ``` -------------------------------- ### Animate Symbol Transitions with .contentTransition Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Illustrates how to achieve smooth symbol replacements for interactive elements using `.contentTransition(.symbolEffect(.replace))`. This modifier is applied to views containing SFSymbols to animate their changes. ```swift import SwiftUI struct StatefulActionButton: View { @State private var isLiked = false var body: some View { Button { withAnimation { isLiked.toggle() } } label: { Image(systemName: isLiked ? "heart.fill" : "heart") .contentTransition(.symbolEffect(.replace)) } .foregroundStyle(isLiked ? .red : .primary) } } ``` -------------------------------- ### Apply Glass Effect in SwiftUI Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Demonstrates how to apply the Liquid Glass effect to a SwiftUI view using the `.glassEffect()` modifier. This modifier creates a reflective, depth-aware glass surface. ```swift import SwiftUI struct ContentView: View { var body: some View { Text("Hello, Glass!") .padding() .background(Color.blue) .cornerRadius(10) .glassEffect() } } ``` -------------------------------- ### MainView: Root Container View in SwiftUI Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt MainView is the root container that arranges UI elements using ZStack for background and VStack for content. It takes a quote string as input and composes BackgroundView and QuoteView. ```swift import SwiftUI struct MainView: View { let quote: String var body: some View { ZStack { BackgroundView() VStack(spacing: 16) { QuoteView(quote: quote) ActionButtonsView() } } } } // Usage in App entry point @main struct LiquidGlassExampleApp: App { var body: some Scene { WindowGroup { MainView(quote: "Liquid Glass Example") } } } ``` -------------------------------- ### ExpandedActionsView: SwiftUI View for Share, Save, Like Buttons Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt ExpandedActionsView displays share, save, and like buttons with a glass effect. It uses bindings to manage the toggle states of save and like buttons and a namespace for coordinated transitions. Dependencies include SwiftUI and custom modifiers like .glassCircleButton() and .glassEffectID(). ```swift import SwiftUI struct ExpandedActionsView: View { @Binding var isSaved: Bool @Binding var isLiked: Bool let namespace: Namespace.ID var body: some View { HStack(spacing: 16) { // Share Button Button { print("Share tapped") } label: { Image(systemName: "square.and.arrow.up") .actionIcon() } .glassCircleButton() .glassEffectID("Share", in: namespace) // Save Button Button { isSaved.toggle() } label: { Image(systemName: isSaved ? "bookmark.fill" : "bookmark") .actionIcon() } .glassCircleButton() .glassEffectID("Save", in: namespace) // Like Button with color tint Button { isLiked.toggle() } label: { Image(systemName: isLiked ? "heart.fill" : "heart") .actionIcon() } .glassCircleButton(tint: isLiked ? .red : .white) .glassEffectID("Like", in: namespace) } } } ``` -------------------------------- ### Action Buttons View Container Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Hosts the `GlassEffectContainer` and the expandable action cluster. This view manages the local UI state for controlling the visibility of additional actions. ```swift import SwiftUI struct ActionButtonsView: View { @State private var isExpanded = false var body: some View { GlassEffectContainer { VStack { if isExpanded { ExpandedActionsView() } Button { withAnimation { isExpanded.toggle() } } label: { Image(systemName: isExpanded ? "xmark.circle.fill" : "ellipsis.circle.fill") .font(.largeTitle) .contentTransition(.symbolEffect(.replace)) } .buttonStyle(.plain) } .padding() .background(.ultraThinMaterial) .clipShape(RoundedRectangle(cornerRadius: 20)) .glassEffect() } } } ``` -------------------------------- ### Reusable View Modifiers for Glass Effects Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Provides reusable view modifiers for creating glass-styled circular buttons and action icons. These modifiers encapsulate common styling and behavior patterns. ```swift import SwiftUI extension View { func glassCircleButton() -> some View { self.padding(12) .background(.ultraThinMaterial) .clipShape(Circle()) .glassEffect() } func actionIcon() -> some View { self.font(.title2) .frame(width: 44, height: 44) .background(.ultraThinMaterial) .clipShape(Circle()) .glassEffect() } } ``` -------------------------------- ### Quote View with Glass Surface Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Displays the quote text centered on a glass surface. This view combines text display with the `.glassEffect()` modifier. ```swift import SwiftUI struct QuoteView: View { var body: some View { Text("\"The only way to do great work is to love what you do.\" - Steve Jobs") .font(.title) .multilineTextAlignment(.center) .padding(40) .background(.ultraThinMaterial) .cornerRadius(20) .glassEffect() .padding(.horizontal) } } ``` -------------------------------- ### ActionButtonsView: Expandable Glass Button Cluster in SwiftUI Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt ActionButtonsView manages an expandable cluster of action buttons using GlassEffectContainer for coordinated glass transitions. It uses @State for managing button states and @Namespace for coordinating glass effect IDs. ```swift import SwiftUI struct ActionButtonsView: View { @State private var isSaved: Bool = false @State private var isLiked: Bool = false @State private var isMoreShown: Bool = false @Namespace private var namespace var body: some View { GlassEffectContainer(spacing: 20) { VStack(spacing: 16) { if isMoreShown { ExpandedActionsView( isSaved: $isSaved, isLiked: $isLiked, namespace: namespace ) } // Toggle button to expand/collapse Button { withAnimation { isMoreShown.toggle() } } label: { Image(systemName: isMoreShown ? "multiply" : "ellipsis") .actionIcon() } .glassCircleButton() .glassEffectID("ToggleButton", in: namespace) } } .padding() } } ``` -------------------------------- ### Expanded Actions View with Glass Buttons Source: https://github.com/mertozseven/liquidglassswiftui/blob/main/README.md Represents the Share, Save, and Like buttons, each with individualized glass IDs and behaviors. This view is shown when the action cluster is expanded. ```swift import SwiftUI struct ExpandedActionsView: View { @Namespace private var namespace @State private var isSaved = false @State private var isLiked = false var body: some View { HStack { ShareButton() Spacer() SaveButton(isSaved: $isSaved) Spacer() LikeButton(isLiked: $isLiked) } .padding(.bottom) } } struct ShareButton: View { var body: some View { Button { print("Share tapped") } label: { Image(systemName: "square.and.arrow.up") .actionIcon() } } } struct SaveButton: View { @Binding var isSaved: Bool var body: some View { Button { isSaved.toggle() } label: { Image(systemName: isSaved ? "bookmark.fill" : "bookmark") .actionIcon() } .foregroundStyle(isSaved ? .yellow : .primary) } } struct LikeButton: View { @Binding var isLiked: Bool var body: some View { Button { isLiked.toggle() } label: { Image(systemName: isLiked ? "heart.fill" : "heart") .actionIcon() } .foregroundStyle(isLiked ? .red : .primary) } } ``` -------------------------------- ### QuoteView: Glass Effect Text Panel in SwiftUI Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt QuoteView presents centered text with a glass effect overlay using the `.glassEffect(.clear.interactive())` modifier. This creates a reflective, depth-aware surface for the text, giving a floating panel appearance. ```swift import SwiftUI struct QuoteView: View { let quote: String var body: some View { Text(quote) .font(.largeTitle) .fontDesign(.serif) .foregroundStyle(.white) .multilineTextAlignment(.center) .padding() .glassEffect(.clear.interactive()) } } // Usage QuoteView(quote: "The best way to predict the future is to create it.") ``` -------------------------------- ### BackgroundView: Full-Bleed Image Background in SwiftUI Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt BackgroundView displays a full-screen background image using an Image asset. It utilizes resizable, scaledToFill, and ignoresSafeArea modifiers to ensure the image covers the entire screen. ```swift import SwiftUI struct BackgroundView: View { var body: some View { Image(.forest) .resizable() .scaledToFill() .ignoresSafeArea() } } // Preview #Preview { BackgroundView() } ``` -------------------------------- ### actionIcon: SwiftUI View Modifier for SF Symbol Icons Source: https://context7.com/mertozseven/liquidglassswiftui/llms.txt The actionIcon modifier styles SF Symbol icons for action buttons, setting font size and enabling smooth symbol replacement transitions. It accepts an optional font parameter. This modifier ensures consistent icon appearance and animated state changes. ```swift import SwiftUI extension View { func actionIcon(font: Font = .title2) -> some View { self .font(font) .contentTransition(.symbolEffect(.replace)) } } // Usage - Icon animates smoothly when state changes Image(systemName: isLiked ? "heart.fill" : "heart") .actionIcon() // Custom font size Image(systemName: "bookmark") .actionIcon(font: .title) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.