MusliData 2.1.0

MusliData 2.1.0

Kosrat D. Ahmad维护。



MusliData 2.1.0

  • 作者:
  • Kosrat D. Ahmad

MusliData

CI Status Version License Platform

MusliData 是一个伊斯兰库,提供定时祈祷(固定和计算)、离线地理编码、位置搜索、阿扎卡尔(穆斯林壁龛)和安拉99个美名的功能。

固定和计算祈时:世界上的大多数城市通过使用基于位置(经度和纬度)的一些计算来找到他们的祈时,但有些其他城市有固定的祈时时间表。此库包含大多数固定和计算祈时。现在您可以贡献它以改进它,并且也可以在穆斯林社区或穆斯林应用程序中使用它。

示例

要运行示例项目,请克隆仓库,然后首先从示例目录中运行 pod install

需求

  • iOS 10.0+
  • Xcode 10.0+

安装

MuslimData可以通过CocoaPods使用。要安装它,只需将以下行添加到Podfile中

pod 'MuslimData'

使用方法

位置辅助工具

存在一些位置辅助方法,提供离线位置搜索、地理编码、反向地理编码,以及检查城市的固定祈祷时间。

搜索位置

您可以在全球范围内的任何城市或地点进行搜索,这在用户没有网络连接或用户位置已关闭时非常有用,您可以在其中进行搜索

LocationHelper.shared.citySearch(city: "London") { locations, error in
    guard let locations = locations, locations.count > 0 else {
        print("City could not be found!")
        return
    }
    print("locations: \(locations)")
}

重要提示:搜索结果始终在Location对象中的hasFixedPrayerTimes属性返回false,因此您需要手动检查搜索结果中选定的位置,如下例所示

// Check the selected location to know that it has fixed prayer times or not.
LocationHelper.shared.cityHasFixedPrayerTimes(countryCode: location.countryCode, city: location.city) { hasFixed in
    location.hasFixedPrayerTimes = hasFixed
}

地理编码器

使用地理编码器通过名称查找城市位置。

// Use geocoder to find city location by name.
LocationHelper.shared.geocoder(countryCode: "GB", city: "London") { location in
    guard let location = location else {
        print("City name can not be geocode")
        return
    }
    print("location: \(location)")
}

反向地理编码器

使用反向地理编码器通过经纬度查找城市名称。

// Use reverse geocoder to find city name by latitude and longitude.
LocationHelper.shared.geocoder(latitude: 36.654090, longitude: 44.541278) { location in
    guard let location = location else {
        print("City name can nnot be geocode by latitude and longitude")
        return
    }
    print("location: \(location)")
}

是否具有固定祈祷时间

检查一个城市是否具有固定祈祷时间。

// Check a city to know that it has fixed prayer times or not
LocationHelper.shared.cityHasFixedPrayerTimes(countryCode: "IQ", city: "Duhok") { hasFixed in
    print("City has fixed prayer times: \(hasFixed)")
}

祈祷时间

您可以通过传递 (Location, PrayerAttribute, 和 Date) 对象到 getPrayerTimes 方法,轻松获取一个位置祈祷时间。

// Create location object.
let location = Location(latitude: 36.123, longitude: 44.123, city: "Erbil", countryCode: "IQ",
                        countryName: "Iraq", hasFixedPrayerTimes: true)

// Crate prayer attributes object.
let attributes = PrayerAttribute(method: .makkah, asrMethod: .shafii, adjustAngle: .angleBased)

// Get prayer times
PrayerTime.getPrayerTimes(location: location, date: Date(), attributes: attributes) { prayerTime, error in
    guard error == nil else {
        print("Prayer tims didn't found for the specified properties.")
        return
    }
    print("prayer times: \(prayerTime!)")
    print("Fromat prayer times: \(prayerTime!.formatPrayers(.time12))")
    print("Format one prayer time: \(prayerTime!.isha.toTime(format: .time24))")
    print("next prayer index: \(prayerTime!.nextPrayerIndex())")
    print("next prayer interval: \(prayerTime!.nextPrayerInterval())")
    print("next prayer time remaining: \(prayerTime!.nextPrayerTimeRemaining())")
}

Azkars (Hisnul Muslim)

从 (Hisnul Muslim 书) 获取所有 azkars,按 (Category, Chapter, 和 Item) 分类,并且这些 azkars 可用于以下语言 (en, ar, ckb, fa, 和 ru)。

Azkar 类别

获取所有 Azkar 类别,并针对给定语言进行本地化。

// Get azkar categories from MuslimData library
Azkars.azkarCategories(language: .en) { azkarCategories, error in
    guard error == nil else {
        print("Azkar categories didn't find: \(error!)")
        return
    }
    print("Azkar Categories: \(azkarCategories!)")
}

Azkar 章节内容

获取 Azkar 章节内容,并针对给定语言进行本地化。

// Get azkar chapters from MuslimData library
Azkars.azkarChapters(language: .en) { azkarChapters, error in
    guard error == nil else {
        print("Azkar chapters didn't found: \(error!)")
        return
    }
    print("Azkar Chapters: \(azkarChapters!)")
}

获取特定类别下的 Azkar 章节内容,并针对给定语言进行本地化。

// Get azkar chapters for a specific category from MuslimData library
Azkars.azkarChapters(language: .en, categoryId: 2) { azkarChapters, error in
    guard error == nil else {
        print("Azkar chapters didn't found: \(error!)")
        return
    }
    print("Azkar Chapters for a category: \(azkarChapters!)")
}

Azkar 条目

获取特定章节的 Azkar 条目,并针对给定语言进行本地化。

// Get azkar items for a specific chapter from MuslimData library
Azkars.azkarItems(language: .en, chapterId: 2) { azkarItems, error in
    guard error == nil else {
        print("Azkar items didn't found: \(error!)")
        return
    }
    print("azkar items: \(azkarItems!)")
}

安拉之名

获取99个安拉之名及其对应的翻译,现在支持以下语言(enarckbfa,和 ru)。

// Get 99 names of allah from MuslimData library
Names.names(language: .en) { names, error in
    guard error == nil else {
        print("Names of Allah didn't found: \(error!)")
        return
    }
    print("Names of Allah: \(names)")
} 

作者

Kosrat D. Ahmad, [email protected]

许可协议

MuslimData可在MIT许可下使用。更多信息请参阅LICENSE文件。