Skip to content

Commit

Permalink
Merge pull request #29 from payan-app/snackbar-improvements
Browse files Browse the repository at this point in the history
refactor: update snackbar ui
  • Loading branch information
juandahurt authored Aug 24, 2022
2 parents cdc6420 + 538066a commit 0fb6218
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Sources/Purace/Styles/PuraceStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct PuraceStyle {
public static let X3 = SwiftUI.Color(hex: "3B140E") ?? .gray
public static let X4 = SwiftUI.Color(hex: "17293E") ?? .gray

public static let R1 = SwiftUI.Color(hex: "DB6262") ?? .red
public static let R1 = SwiftUI.Color(hex: "E24649") ?? .red

public static let allSkeletons: [SwiftUI.Color] = [Color.S1, Color.S2, Color.S3, Color.S4, Color.S5, Color.S6, Color.S7, Color.S8]
}
Expand Down
21 changes: 9 additions & 12 deletions Sources/Purace/Views/Basic/Snackbar/PuraceSnackbarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import SwiftUI

struct PuraceSnackbarView: View {
@State var yOffset: CGFloat = 100
@State var yOffset: CGFloat = 120
@State var opacity: Double = 0

let title: String
Expand Down Expand Up @@ -45,32 +45,29 @@ struct PuraceSnackbarView: View {
PuraceTextView(title, fontSize: 14, textColor: .white)
Spacer()
if let buttonTitle = buttonTitle {
PuraceButtonView(buttonTitle, fontSize: 14, type: .custom(.clear, .clear, .white)) {
PuraceButtonView(buttonTitle, fontSize: 14, type: .custom(.clear, .white.opacity(0.1), .white)) {
buttonOnTap?()
isVisible = false
}
}
}
.lineLimit(2)
.padding()
.frame(width: UIScreen.main.bounds.width - 40)
.background(getBackgroundColor())
.cornerRadius(5)
.onChange(of: isVisible, perform: { _ in
withAnimation(.spring()) {
yOffset = 100
opacity = 0
}
})
.opacity(opacity)
.offset(x: 0, y: yOffset)
.onAppear {
withAnimation(.spring()) {
yOffset = 0
opacity = 1
}
}
}
.edgesIgnoringSafeArea(.bottom)
}.onChange(of: isVisible, perform: { _ in
withAnimation(.spring()) {
yOffset = 120
opacity = 0
}
})
}
}

Expand Down

0 comments on commit 0fb6218

Please sign in to comment.