batoulapps / adhan-swift

High precision Islamic prayer time library for Swift
MIT License
185 stars 45 forks source link

Im Having trouble getting this to work with swiftUI #29

Closed Brahmah closed 4 years ago

Brahmah commented 4 years ago

Help would highly be appreciated, Thanks!

` import ModalView import SwiftUI import Adhan

struct ContentView: View {

var body: some View {

    VStack {

            let cal = Calendar(identifier: Calendar.Identifier.gregorian)
            let date = cal.dateComponents([.year, .month, .day], from: Date())
            let coordinates = Coordinates(latitude: 35.78056, longitude: -78.6389)
            var params = CalculationMethod.muslimWorldLeague.params

             params.madhab = .hanafi   // ERROR: IS NOT CONVERTIBLE TO MADHAB

            if let prayers = PrayerTimes(coordinates: coordinates, date: date, calculationParameters: params) {
                let formatter = DateFormatter()
                formatter.timeStyle = .medium
                formatter.timeZone = TimeZone(identifier: "America/New_York")!

                Text("Fajr %@", formatter.string(from: prayers.fajr))
                NSLog("sunrise %@", formatter.string(from: prayers.sunrise))
                NSLog("dhuhr %@", formatter.string(from: prayers.dhuhr))
                NSLog("asr %@", formatter.string(from: prayers.asr))
                NSLog("maghrib %@", formatter.string(from: prayers.maghrib))
                NSLog("isha %@", formatter.string(from: prayers.isha))
            }

    }
}

}

`

z3bi commented 4 years ago

Sorry for the late response. Here is a gist of Adhan working in SwiftUI

https://gist.github.com/z3bi/7651f59bdad966820a8b2d307e5596f9

Brahmah commented 4 years ago

Thanks!, will try it out later.