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 ability to display the version as a footnote #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Sources/Models/WhatsNew+VersionTextConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import SwiftUI

// MARK: - WhatsNew+VersionTextConfiguration

public extension WhatsNew {

/// The WhatsNew VersionTextConfiguration
struct VersionTextConfiguration {

// MARK: Properties

/// The version text font
public var font: Font

/// The foreground color
public var foregroundColor: Color

// MARK: Initializer

/// Creates a new instance of `WhatsNew.VersionTextConfiguration`
/// - Parameters:
/// - font: The version text font. Default value `.footnote`
/// - foregroundColor: The foreground color. Default value `.primary`
public init(
font: Font = .footnote,
foregroundColor: Color = .primary
) {
self.font = font
self.foregroundColor = foregroundColor
}

}

}
9 changes: 7 additions & 2 deletions Sources/Models/WhatsNew.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public struct WhatsNew {

/// The optional SecondaryAction
public var secondaryAction: SecondaryAction?


public var versionTextConfiguration: WhatsNew.VersionTextConfiguration?

// MARK: Initializer

/// Creates a new instance of `WhatsNew`
Expand All @@ -31,18 +33,21 @@ public struct WhatsNew {
/// - items: The Features
/// - primaryAction: The PrimaryAction. Default value `.init()`
/// - secondaryAction: The optional SecondaryAction. Default value `nil`
/// - versionTextConfiguration: The optional version text configuration. Default value `nil`
public init(
version: Version = .current(),
title: Title,
features: [Feature],
primaryAction: PrimaryAction = .init(),
secondaryAction: SecondaryAction? = nil
secondaryAction: SecondaryAction? = nil,
versionTextConfiguration: WhatsNew.VersionTextConfiguration? = nil
) {
self.version = version
self.title = title
self.features = features
self.primaryAction = primaryAction
self.secondaryAction = secondaryAction
self.versionTextConfiguration = versionTextConfiguration
}

}
Expand Down
10 changes: 10 additions & 0 deletions Sources/View/WhatsNewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ extension WhatsNewView: View {
#endif
}
.edgesIgnoringSafeArea(.bottom)

// Version number
if let versionTextConfiguration = whatsNew.versionTextConfiguration {
VStack {
Spacer()
Text("v.\(whatsNew.version.description)")
.font(versionTextConfiguration.font)
.foregroundColor(versionTextConfiguration.foregroundColor)
}
}
}
.sheet(
item: self.$secondaryActionPresentedView,
Expand Down