Skip to content

Commit

Permalink
Merge pull request #90 from Vline-App/footer_show_version
Browse files Browse the repository at this point in the history
Add ability to display the version as a footnote
  • Loading branch information
SvenTiigi authored Oct 10, 2024
2 parents 584e2fa + 834d4e5 commit d5361bb
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
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)
}
}
}
#if os(macOS)
.frame(minWidth: 400, maxWidth: 600)
Expand Down

0 comments on commit d5361bb

Please sign in to comment.