Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core Customization #32

Closed
mickeyl opened this issue Nov 14, 2024 · 1 comment
Closed

Core Customization #32

mickeyl opened this issue Nov 14, 2024 · 1 comment

Comments

@mickeyl
Copy link

mickeyl commented Nov 14, 2024

First off, thanks for working on this package. While you would think an alert view is a trivial thing, it isn't ­– and I have noticed that you did walk the extra mile to provide a drop-in replacement for the built-in alert that looks and feels like the original on all supported platforms.

While that's great (it is!), I wonder how involved it would be to allow for some customisations to the core alert, e.g. in many alert reimplementations I have noticed a slight drop shadow around the edges that makes the view pop more ­– or customize the width (in percentage of the screen width) the alert is allowed to take up.

Update: I have since then found the configuration API, though it doesn't allow for a drop shadow or specifying the minimal width in percentage of screen width.

Update2: So I have found the proper place to get a drop shadow by applying a diff like that:

diff --git a/Sources/CustomAlert/Views/CustomAlert.swift b/Sources/CustomAlert/Views/CustomAlert.swift
index eb439bc..7621bf1 100644
--- a/Sources/CustomAlert/Views/CustomAlert.swift
+++ b/Sources/CustomAlert/Views/CustomAlert.swift
@@ -194,7 +194,7 @@ import SwiftUI
         }
         .frame(minWidth: minWidth, maxWidth: maxWidth)
         .background(BackgroundView(background: configuration.alert.background))
-        .cornerRadius(configuration.alert.cornerRadius)
+        .cornerRadius(configuration.alert.cornerRadius).shadow(radius: 20)
         .padding(configuration.padding)
         .transition(configuration.transition)
         .animation(.default, value: isPresented)

Now this is hardcoded, but it's probably pretty simple to enhance the configuration structure.

divadretlaw added a commit that referenced this issue Nov 16, 2024
@divadretlaw
Copy link
Owner

Hello, thank you for your suggestion and finding the place where to add it.

I created a custom alert configuration to apply a shadow.

.configureCustomAlert { configuration in
    configuration.alert.shadow = .init(radius: 20)
}

Will be available in 4.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants