Mercurial > public > simoleon
comparison Simoleon/Favorites.swift @ 95:04feeb708833
Minor UI updates
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 03 Aug 2021 15:02:40 +0100 |
parents | 529feb1fc8d5 |
children | 87f02d4f9c26 |
comparison
equal
deleted
inserted
replaced
94:507ed393a72c | 95:04feeb708833 |
---|---|
21 .font(.title) | 21 .font(.title) |
22 Text("Search a currency pair and add it to favourites.") | 22 Text("Search a currency pair and add it to favourites.") |
23 .padding(.top, 5) | 23 .padding(.top, 5) |
24 } | 24 } |
25 .multilineTextAlignment(.center) | 25 .multilineTextAlignment(.center) |
26 .foregroundColor(Color(.systemGray)) | 26 .foregroundColor(.secondary) |
27 .padding(.horizontal, 50) | 27 .padding(.horizontal, 50) |
28 } else { | 28 } else { |
29 List { | 29 List { |
30 ForEach(favorite) { favorite in | 30 ForEach(favorite) { favorite in |
31 NavigationLink(destination: Conversion(showNavigationView: false, currencyPair: favorite.currencyPair)) { | 31 NavigationLink(destination: Conversion(showNavigationView: false, currencyPair: favorite.currencyPair)) { |
44 #endif | 44 #endif |
45 } | 45 } |
46 .if(UIDevice.current.userInterfaceIdiom == .phone) { content in | 46 .if(UIDevice.current.userInterfaceIdiom == .phone) { content in |
47 NavigationView { content } | 47 NavigationView { content } |
48 } | 48 } |
49 .onAppear(perform: generateFavoritesToScreenshots) | 49 .onAppear { |
50 #if DEBUG | |
51 generateFavoritesToScreenshots() | |
52 #endif | |
53 } | |
50 } | 54 } |
51 | 55 |
52 private func removeFromFavorites(offsets: IndexSet) { | 56 private func removeFromFavorites(offsets: IndexSet) { |
53 withAnimation { | 57 withAnimation { |
54 offsets.map { favorite[$0] }.forEach(viewContext.delete) | 58 offsets.map { favorite[$0] }.forEach(viewContext.delete) |
59 let nsError = error as NSError | 63 let nsError = error as NSError |
60 fatalError("Unresolved error \(nsError), \(nsError.userInfo)") | 64 fatalError("Unresolved error \(nsError), \(nsError.userInfo)") |
61 } | 65 } |
62 } | 66 } |
63 } | 67 } |
64 | 68 |
69 #if DEBUG | |
65 private func generateFavoritesToScreenshots() { | 70 private func generateFavoritesToScreenshots() { |
66 #if DEBUG | |
67 if favorite.isEmpty { | 71 if favorite.isEmpty { |
68 let favoriteCurrencies = [ | 72 let favoriteCurrencies = [ |
69 "EUR/USD", "BTC/USD", "USD/HKD", "USD/JPY", "AUD/USD", "XAU/GBP", "DASH/ETH", "EUR/USD", | 73 "EUR/USD", "BTC/USD", "USD/HKD", "USD/JPY", "AUD/USD", |
70 "XAG/CAD", "XRP/RUB" | 74 "XAU/GBP", "DASH/ETH", "EUR/USD", "XAG/CAD" |
71 ] | 75 ] |
72 | 76 |
73 for favoriteCurrency in favoriteCurrencies { | 77 for favoriteCurrency in favoriteCurrencies { |
74 let favorite = Favorite(context: viewContext) | 78 let favorite = Favorite(context: viewContext) |
75 favorite.currencyPair = favoriteCurrency | 79 favorite.currencyPair = favoriteCurrency |
80 let nsError = error as NSError | 84 let nsError = error as NSError |
81 fatalError("Unresolved error \(nsError), \(nsError.userInfo)") | 85 fatalError("Unresolved error \(nsError), \(nsError.userInfo)") |
82 } | 86 } |
83 } | 87 } |
84 } | 88 } |
85 #endif | |
86 } | 89 } |
90 #endif | |
87 } | 91 } |
88 | 92 |
89 struct Favorites_Previews: PreviewProvider { | 93 struct Favorites_Previews: PreviewProvider { |
90 static var previews: some View { | 94 static var previews: some View { |
91 Favorites() | 95 Favorites() |