Skip to content

Commit

Permalink
Allow manually added licenses in UI (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinP7r committed Apr 16, 2023
1 parent e09cee1 commit c28170c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Sources/AckGen/Acknowledgement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ public struct Acknowledgement: Codable {
return acks.sorted(by: { $0.title.lowercased() < $1.title.lowercased() })
}
}

extension Acknowledgement: Comparable {
public static func < (lhs: Acknowledgement, rhs: Acknowledgement) -> Bool {
lhs.title < rhs.title
}
}
10 changes: 8 additions & 2 deletions Sources/AckGenUI/AcknowledgementsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ public struct AcknowledgementsList: View {

private let title: String
private let plistName: String
private let otherAcknowledgements: [Acknowledgement]

public init(title: String = "Acknowledgements", plistName: String = "Acknowledgements") {
public init(
title: String = "Acknowledgements",
plistName: String = "Acknowledgements",
otherAcknowledgements: [AckGen.Acknowledgement] = []
) {
self.title = title
self.plistName = plistName
self.otherAcknowledgements = otherAcknowledgements
}

@State private var acknowledgements: [Acknowledgement] = []
Expand All @@ -29,7 +35,7 @@ public struct AcknowledgementsList: View {
}
.customNavigationTitle(title)
.onAppear {
self.acknowledgements = Acknowledgement.all(fromPlist: plistName)
self.acknowledgements = (Acknowledgement.all(fromPlist: plistName) + otherAcknowledgements).sorted()
}
}
}
Expand Down

0 comments on commit c28170c

Please sign in to comment.