Mercurial > public > simoleon
comparison Simoleon/UI/FavoriteButton.swift @ 162:f5de15e06c77
Refactor code
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 31 Aug 2021 13:04:28 +0100 |
parents | 3913aff613e8 |
children |
comparison
equal
deleted
inserted
replaced
161:3913aff613e8 | 162:f5de15e06c77 |
---|---|
11 @ObservedObject var currencyConversion: CurrencyConversion | 11 @ObservedObject var currencyConversion: CurrencyConversion |
12 @State private var scale: CGFloat = 1 | 12 @State private var scale: CGFloat = 1 |
13 @Environment(\.managedObjectContext) private var viewContext | 13 @Environment(\.managedObjectContext) private var viewContext |
14 @FetchRequest(sortDescriptors: []) private var favoritePairs: FetchedResults<FavoritePair> | 14 @FetchRequest(sortDescriptors: []) private var favoritePairs: FetchedResults<FavoritePair> |
15 | 15 |
16 let hapticsHelper = HapticsHelper() | |
17 | |
16 var body: some View { | 18 var body: some View { |
17 Button(action: { | 19 Button(action: { |
18 animate() | 20 animate() |
19 if isFavorite() { | 21 if isFavorite() { |
20 remove() | 22 remove() |
21 } else { | 23 } else { |
22 add() | 24 add() |
23 } | 25 } |
26 | |
27 hapticsHelper.simpleSuccess() | |
24 }) { | 28 }) { |
25 RoundedRectangle(cornerRadius: 15) | 29 RoundedRectangle(cornerRadius: 15) |
26 .foregroundColor(Color(.secondarySystemBackground)) | 30 .foregroundColor(Color(.secondarySystemBackground)) |
27 .frame(width: 60, height: 60) | 31 .frame(width: 60, height: 60) |
28 .overlay( | 32 .overlay( |