Mercurial > public > simoleon
diff Simoleon/Helpers/FavoriteButton.swift @ 185:2fc95efcb1ee
connect backend
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Wed, 22 Dec 2021 16:12:23 +0100 |
parents | |
children | 13d5a8deb6c2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/Helpers/FavoriteButton.swift Wed Dec 22 16:12:23 2021 +0100 @@ -0,0 +1,62 @@ +// +// FavoriteButton.swift +// Simoleon +// +// Created by Dennis Concepción Martín on 21/12/21. +// + +import SwiftUI + +struct FavoriteButton: View { + @State private var scale: CGFloat = 1 + + var body: some View { + Button(action: {}) { + RoundedRectangle(cornerRadius: 15) + .foregroundColor(Color(.secondarySystemBackground)) + .frame(width: 60, height: 60) + .overlay( + VStack { + if isFavorite() { + Image(systemName: "star.fill") + } else { + Image(systemName: "star") + } + } + .font(.system(size: 28)) + .foregroundColor(Color(.systemYellow)) + ) + } + .scaleEffect(scale) + .animation(.linear(duration: 0.2), value: scale) + } + + // Add currency conversion to favorites + private func add() { + + } + + // Remove currency conversion from favorites + private func remove() { + + } + + // Check if currency conversion is in favorites + private func isFavorite() -> Bool { + return false + } + + // Animate favorite button + private func animate() { + scale += 0.2 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + scale -= 0.2 + } + } +} + +struct FavoriteButton_Previews: PreviewProvider { + static var previews: some View { + FavoriteButton() + } +}