Skip to content

Commit

Permalink
Merge pull request #17 from juandahurt/collection
Browse files Browse the repository at this point in the history
feat: add card collection subtitle
  • Loading branch information
juandahurt authored Jun 13, 2022
2 parents 89b862d + 33b4c43 commit 05e98e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct CollectionCardExample: View {
Text("`PuraceCollectionCardView(cards: ...)`")
.padding()
PuraceCollectionCardView(
firstCardSize: .init(width: UIScreen.main.bounds.width * 0.7, height: UIScreen.main.bounds.width * 0.8),
firstCardSize: .init(width: UIScreen.main.bounds.width * 0.7, height: UIScreen.main.bounds.width * 0.85),
cards: [
MockCard("https://www.biografiasyvidas.com/biografia/c/fotos/caldas_francisco_jose_2.jpg"),
MockCard("https://upload.wikimedia.org/wikipedia/commons/a/ac/Froil%C3%A1n_Largacha_Hurtado.jpg"),
Expand All @@ -33,6 +33,7 @@ struct MockCard: PuraceCollectionCardData {
var deepLink: String = ""
var backgroundImage: URL?
var title: String = "Froilán Largacha Hurtado"
var subtitle: String = "From the Palacsdfdfsfdsfdffsfsfsddf sfs f e of Versailles to the Florida Kahlo museum"

init(_ url: String) {
self.backgroundImage = URL(string: url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public protocol PuraceCollectionCardData {
var backgroundImage: URL? { get }
/// Card's title
var title: String { get }
/// Card's subtitle
var subtitle: String { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ public struct PuraceCollectionCardView: View {
PuraceImageView(url: cards[index].backgroundImage) {
ZStack {
LinearGradient(gradient: Gradient(colors: [.clear, .black.opacity(0.35)]), startPoint: .top, endPoint: .center)
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 15) {
Spacer()
HStack {
PuraceTextView(cards[index].title, fontSize: 12, textColor: .white, weight: .medium)
PuraceTextView(cards[index].title, fontSize: 18, textColor: .white, weight: .regular)
Spacer(minLength: 0)
}
HStack {
PuraceTextView(cards[index].subtitle, fontSize: 12, textColor: .white, weight: .regular)
.lineLimit(2)
Spacer(minLength: 0)
}
}.padding()
Expand Down Expand Up @@ -114,7 +119,7 @@ public struct PuraceCollectionCardView: View {
}
})
.onEnded({ value in
if dragOpacity < 0.55 {
if dragOpacity < 0.75 {
next()
lastCardOpacity = 0
withAnimation(.linear(duration: 0.2).delay(0.4)) {
Expand Down

0 comments on commit 05e98e7

Please sign in to comment.