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
| // MARK:- SHSessionDelegate | |
| extension HomeViewModel: SHSessionDelegate { | |
| func session(_ session: SHSession, didFind match: SHMatch) { | |
| guard let mediaItem = match.mediaItems.first else { return } | |
| async { | |
| if mediaItems.contains(where: { $0.shazamID == mediaItem.shazamID }) { | |
| // Song already identified and in the list. Do nothing. | |
| } else { |
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
| public func startRecognition() { | |
| feedback.prepare() | |
| // 1 | |
| do { | |
| if engine.isRunning { | |
| stopRecognition() | |
| return | |
| } |
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
| // MARK: Audio Recognition | |
| extension HomeViewModel { | |
| // 1 | |
| private func prepareAudioRecording() throws { | |
| let audioSession = AVAudioSession.sharedInstance() | |
| try audioSession.setCategory(.record) | |
| try audioSession.setActive(true, options: .notifyOthersOnDeactivation) | |
| } |
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 Combine | |
| import ShazamKit | |
| import AVKit | |
| @MainActor | |
| class HomeViewModel: NSObject, ObservableObject { | |
| // 1 | |
| @Published private(set) var mediaItems: [SHMediaItem] = [] | |
| // 2 |
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
| name: Swift | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: |
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
| workflows: | |
| ios-workflow: | |
| name: iOS Workflow | |
| environment: | |
| vars: | |
| XCODE_PROJECT: "CICDExample.xcodeproj" | |
| XCODE_SCHEME: "CICDExample" | |
| BUNDLE_ID: "com.rudrankriyam.cicdexample" | |
| APP_STORE_CONNECT_ISSUER_ID: Encrypted(...) | |
| APP_STORE_CONNECT_KEY_IDENTIFIER: Encrypted(...) |
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
| struct RGBView: View { | |
| @State var targetRed = random() | |
| @State var targetGreen = random() | |
| @State var targetBlue = random() | |
| @State var yourRed = rgbColor | |
| @State var yourGreen = rgbColor | |
| @State var yourBlue = rgbColor | |
| // rest of the thousands of lines of code |
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
| class RGBViewModel: ObservableObject { | |
| @Published var targetColor: RGBColorProtocol | |
| @Published var userColor: RGBColorProtocol | |
| init(targetColor: RGBColorProtocol, userColor: RGBColorProtocol) { | |
| self.targetColor = targetColor | |
| self.userColor = userColor | |
| } | |
| } |
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
| class RGBRandomColor: RGBColorProtocol { | |
| var red: Double = Constants.random | |
| var green: Double = Constants.random | |
| var blue: Double = Constants.random | |
| } | |
| class RGBUserColor: RGBColorProtocol { | |
| static let initial: Double = 188/255 | |
| var red: Double = RGBInitialColor.initial |
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
| protocol GradientProtocol { | |
| var startColor: ColorProtocol { get set } | |
| var endColor: ColorProtocol { get set } | |
| func new() -> Gradient | |
| } | |
| extension GradientProtocol { | |
| func new() -> Gradient { | |
| Gradient(colors: [startColor.new(), endColor.new()]) |