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

Add the possibility to add a View instead of just a text to WhatsNew.Title #97

Open
velco-greg opened this issue Jan 22, 2025 · 0 comments
Assignees

Comments

@velco-greg
Copy link

Is your feature request related to a problem?

It's only possible to pass a text/localized Text to the title.
It would be great to pass a View, that way a combo Text + Image content could be presented on top of the feature List.

What solution would you like?

Having a new constructor with a Content in parameter instead of title, where Content is a View
Something like that:

init(
        version: Version = .current(),
        topContent: @escaping () -> Content,
        features: [Feature],
        primaryAction: PrimaryAction = .init(),
        secondaryAction: SecondaryAction? = nil
    )

It would make that great framework more flexible in terms of customization (even if I imagine that you want to stick to Apple design).

What alternatives have you considered?

Title could accept an optional Image with the actual Text, and it could be displayed in a VStack.

struct Title: Hashable {
        // MARK: Properties
        
        /// The title Text
        public var text: Text

        public var image: Image?
        
        /// The foreground color
        public var foregroundColor: Color
        
        // MARK: Initializer
        
        /// Creates a new instance of `WhatsNew.Title`
        /// - Parameters:
        ///   - text: The title Text
        ///   - foregroundColor: The foreground color. Default value `.primary`
        public init(
            text: Text,
            image: Image? = nil,
            foregroundColor: Color = .primary
        ) {
            self.text = text
            self.image = image
            self.foregroundColor = foregroundColor
        }

Then in WhatsNewView :

private extension WhatsNewView {
    
    /// The Title View
    var title: some View {
        VStack {
             self.whatsnew.title.image.view()
             Text(
            whatsNewText: self.whatsNew.title.text
        )
        .font(.largeTitle.bold())
        .multilineTextAlignment(.center)
        .fixedSize(horizontal: false, vertical: true)
        }
    }
    
}

Any additional context?

No response

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