This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| extension View { | |
| public func popup<PopupContent: View>( | |
| isPresented: Binding<Bool>, | |
| view: @escaping () -> PopupContent) -> some View { | |
| self.modifier( | |
| Popup( | |
| isPresented: isPresented, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct PopoverViewModifier<PopoverContent>: ViewModifier where PopoverContent: View { | |
| @Binding var isPresented: Bool | |
| let onDismiss: (() -> Void)? | |
| let content: () -> PopoverContent | |
| func body(content: Content) -> some View { | |
| content | |
| .background( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct DetailLoadingView: View { | |
| @Binding var coin: Coin? | |
| init(coin: Binding<Coin?>) { | |
| _coin = coin | |
| print("Itit detail loading view for \(coin.wrappedValue?.name)") | |
| } | |
| var body: some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Combine | |
| class HomeViewModel: ObservableObject { | |
| @Published var allCoins: [Coin] = [] | |
| @Published var portfolioCoins: [Coin] = [] | |
| @Published var searchText: String = "" | |
| private let dataService = CoinDataService() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension UIApplication { | |
| // dismiss keyboard | |
| func endEditing() { | |
| sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct SearchBarView: View { | |
| // MARK: - Properties | |
| @Binding var searchText: String | |
| // MARK: - Body | |
| var body: some View { | |
| HStack { | |
| Image(systemName: "magnifyingglass") | |
| .foregroundColor( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import UIKit | |
| import Combine | |
| class CoinImageService { | |
| @Published var image: UIImage? = nil | |
| private var imageSubscription: AnyCancellable? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import UIKit | |
| class LocalFileManager { | |
| static let instance = LocalFileManager() | |
| private init() { } | |
| func saveImage(image: UIImage, imageName: String, folderName: String) { | |
| // Create folder if not exist | |
| createFolder(folderName: folderName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Combine | |
| class HomeViewModel: ObservableObject { | |
| @Published var allCoins: [Coin] = [] | |
| @Published var portfolioCoins: [Coin] = [] | |
| private let dataService = CoinDataService() | |
| private var cancellable = Set<AnyCancellable>() | |