comparison 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
comparison
equal deleted inserted replaced
184:7cb2b0b2b3f3 185:2fc95efcb1ee
1 //
2 // FavoriteButton.swift
3 // Simoleon
4 //
5 // Created by Dennis Concepción Martín on 21/12/21.
6 //
7
8 import SwiftUI
9
10 struct FavoriteButton: View {
11 @State private var scale: CGFloat = 1
12
13 var body: some View {
14 Button(action: {}) {
15 RoundedRectangle(cornerRadius: 15)
16 .foregroundColor(Color(.secondarySystemBackground))
17 .frame(width: 60, height: 60)
18 .overlay(
19 VStack {
20 if isFavorite() {
21 Image(systemName: "star.fill")
22 } else {
23 Image(systemName: "star")
24 }
25 }
26 .font(.system(size: 28))
27 .foregroundColor(Color(.systemYellow))
28 )
29 }
30 .scaleEffect(scale)
31 .animation(.linear(duration: 0.2), value: scale)
32 }
33
34 // Add currency conversion to favorites
35 private func add() {
36
37 }
38
39 // Remove currency conversion from favorites
40 private func remove() {
41
42 }
43
44 // Check if currency conversion is in favorites
45 private func isFavorite() -> Bool {
46 return false
47 }
48
49 // Animate favorite button
50 private func animate() {
51 scale += 0.2
52 DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
53 scale -= 0.2
54 }
55 }
56 }
57
58 struct FavoriteButton_Previews: PreviewProvider {
59 static var previews: some View {
60 FavoriteButton()
61 }
62 }