Это краткий справочник по разработке приложения Quran Majeed во Flutter, а не пошаговое руководство.
- Уведомление о времени молитвы
- Коран Маджид
- Направление Киблы
Вы можете скачать финальное приложение здесь
https://play.google.com/store/apps/details?id=com.app.macuaqiblacompass01
Другие источники
Получить список всех сур Корана Маджид
http://api.alquran.cloud/v1/сура
Пакеты, которые я использовал
flutter_qiblah: ^2.1.0 adhan: ^2.0.0-nullsafety.2 geolocator: ^9.0.2 intl: ^0.17.0 geocoding: ^2.0.5 awesome_notifications: ^0.7.3 hijri: ^3.0.0
flutter_qiblah используется для определения направления Киблы. он запрашивает местоположение пользователя, а затем возвращает виджет, который вращается соответствующим образом
MaterialApp(
...
home: Scaffold(
body: FutureBuilder(
future: _deviceSupport,
builder: (_, AsyncSnapshot<bool?> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting)
return LoadingIndicator();
if (snapshot.hasError)
return Center(
child: Text("Error: ${snapshot.error.toString()}"),
);
if (snapshot.data!)
return QiblahCompass();
else
return QiblahMaps();
},
),
),
);
flutter_qiblah используется для определения направления Киблы. он запрашивает местоположение пользователя, а затем возвращает виджет, который вращается соответствующим образом
import 'package:adhan/adhan.dart'; main() { print('My Prayer Times'); final myCoordinates = Coordinates(23.9088, 89.1220); // Replace with your own location lat, lng. final params = CalculationMethod.karachi.getParameters(); params.madhab = Madhab.hanafi; final prayerTimes = PrayerTimes.today(myCoordinates, params); print("---Today's Prayer Times in Your Local Timezone(${prayerTimes.fajr.timeZoneName})---"); print(DateFormat.jm().format(prayerTimes.fajr)); print(DateFormat.jm().format(prayerTimes.sunrise)); print(DateFormat.jm().format(prayerTimes.dhuhr)); print(DateFormat.jm().format(prayerTimes.asr)); print(DateFormat.jm().format(prayerTimes.maghrib)); print(DateFormat.jm().format(prayerTimes.isha)) }
Этот пакет используется для получения текущей даты в исламском календаре.
//Suppose current gregorian data/time is: Mon May 29 00:27:33 2018 var _today = HijriCalendar.now(); print(_today.hYear); // 1439 print(_today.hMonth); // 9 print(_today.hDay); // 14 print(_today.getDayName()); // 14 // Get month length in days print(_today.lengthOfMonth); // 30 days print(_today.toFormat("MMMM dd yyyy")); //Ramadan 14 1439
Как получать уведомления о времени молитвы (5 раз и каждый день)
это простой пакет для добавления уведомлений в ваше приложение
Создайте канал в файле main.dart
AwesomeNotifications().initialize( // set the icon to null if you want to use the default app icon 'resource://drawable/res_app_icon', [ NotificationChannel( channelGroupKey: 'basic_channel_group', channelKey: 'basic_channel', channelName: 'Basic notifications', channelDescription: 'Notification channel for basic tests', defaultColor: Color(0xFF9D50DD), ledColor: Colors.white) ], // Channel groups are only visual and are not required channelGroups: [ NotificationChannelGroup( channelGroupKey: 'basic_channel_group', channelGroupName: 'Basic group') ], debug: true );
Приведенный ниже код является примером того, как вы можете запланировать уведомления для молитвы, это будет постоянно показывать уведомления каждый день fajrTime,убедитесь, что вы создали 5 уведомлений для каждой молитвы
AwesomeNotifications() .isNotificationAllowed() .then((isAllowed) async { if (!isAllowed) { AwesomeNotifications() .requestPermissionToSendNotifications(); }else{ AwesomeNotifications().createNotification( schedule: NotificationCalendar( preciseAlarm: true,allowWhileIdle: true,repeats: true,hour: fajrTime.hour,minute: fajrTime.fajr.minute, second:fajrTime.second, ), content: NotificationContent( showWhen: false, wakeUpScreen: true, displayOnBackground: true, displayOnForeground: true, category: NotificationCategory.Reminder, id: Random().nextInt(99999), channelKey: 'adan_channel', title: NeextPrayer.prayer.toString(), body: 'Salah time'.tr, actionType: ActionType.KeepOnTop)); }
Есть вопросы? Связаться с нами
Fluttydev: компания по разработке приложений Flutter
WhatsApp: https://wa.me/message/R7BL7MR7S34TB1