2023-07-09 12:56:16 +05:30
|
|
|
import 'dart:io';
|
2023-10-10 14:33:26 +05:30
|
|
|
|
2023-06-17 20:57:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2023-07-08 15:19:13 +03:00
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
2023-09-18 16:26:08 +03:00
|
|
|
import 'package:geolocator/geolocator.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:iconsax/iconsax.dart';
|
2023-07-26 22:20:30 +03:00
|
|
|
import 'package:intl/intl.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
2023-07-09 23:41:51 +03:00
|
|
|
import 'package:rain/app/controller/controller.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
import 'package:rain/app/data/weather.dart';
|
2023-09-03 09:08:43 +03:00
|
|
|
import 'package:rain/app/modules/settings/widgets/setting_card.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
import 'package:rain/main.dart';
|
|
|
|
import 'package:rain/theme/theme_controller.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
class SettingsPage extends StatefulWidget {
|
|
|
|
const SettingsPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<SettingsPage> createState() => _SettingsPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettingsPageState extends State<SettingsPage> {
|
|
|
|
final themeController = Get.put(ThemeController());
|
2023-09-01 20:18:40 +03:00
|
|
|
final weatherController = Get.put(WeatherController());
|
2023-06-17 20:57:57 +03:00
|
|
|
String? appVersion;
|
|
|
|
|
|
|
|
Future<void> infoVersion() async {
|
2023-08-04 21:19:30 +03:00
|
|
|
final packageInfo = await PackageInfo.fromPlatform();
|
2023-06-17 20:57:57 +03:00
|
|
|
setState(() {
|
|
|
|
appVersion = packageInfo.version;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-26 22:04:19 +03:00
|
|
|
void urlLauncher(String uri) async {
|
|
|
|
final Uri url = Uri.parse(uri);
|
|
|
|
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
|
|
|
|
throw Exception('Could not launch $url');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-17 20:57:57 +03:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
infoVersion();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2023-07-04 21:22:29 +03:00
|
|
|
updateLanguage(Locale locale) {
|
|
|
|
settings.language = '$locale';
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() => isar.settings.putSync(settings));
|
2023-07-04 21:22:29 +03:00
|
|
|
Get.updateLocale(locale);
|
|
|
|
Get.back();
|
|
|
|
}
|
|
|
|
|
2023-06-17 20:57:57 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.brush_1),
|
2023-06-27 22:41:25 +03:00
|
|
|
text: 'appearance'.tr,
|
|
|
|
onPressed: () {
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, setState) {
|
2023-07-15 21:51:32 +03:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Padding(
|
2023-09-29 15:45:50 +03:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
2023-07-15 21:51:32 +03:00
|
|
|
child: Text(
|
|
|
|
'appearance'.tr,
|
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 20,
|
|
|
|
),
|
2023-07-14 20:19:43 +03:00
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.moon),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'theme'.tr,
|
2023-09-28 22:23:36 +03:00
|
|
|
dropdown: true,
|
|
|
|
dropdownName: settings.theme?.tr,
|
2023-10-10 12:54:55 +03:00
|
|
|
dropdownList: <String>[
|
|
|
|
'system'.tr,
|
|
|
|
'dark'.tr,
|
|
|
|
'light'.tr
|
|
|
|
],
|
2023-09-28 22:23:36 +03:00
|
|
|
dropdownCange: (String? newValue) {
|
2023-10-10 12:54:55 +03:00
|
|
|
ThemeMode themeMode =
|
|
|
|
newValue?.tr == 'system'.tr
|
|
|
|
? ThemeMode.system
|
|
|
|
: newValue?.tr == 'dark'.tr
|
|
|
|
? ThemeMode.dark
|
|
|
|
: ThemeMode.light;
|
2023-09-28 22:23:36 +03:00
|
|
|
String theme = newValue?.tr == 'system'.tr
|
|
|
|
? 'system'
|
|
|
|
: newValue?.tr == 'dark'.tr
|
|
|
|
? 'dark'
|
|
|
|
: 'light';
|
|
|
|
themeController.saveTheme(theme);
|
|
|
|
themeController.changeThemeMode(themeMode);
|
|
|
|
setState(() {});
|
2023-07-15 21:51:32 +03:00
|
|
|
},
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.mobile),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'amoledTheme'.tr,
|
|
|
|
switcher: true,
|
|
|
|
value: settings.amoledTheme,
|
|
|
|
onChange: (value) {
|
|
|
|
themeController.saveOledTheme(value);
|
2023-10-10 12:54:55 +03:00
|
|
|
MyApp.updateAppState(context,
|
|
|
|
newAmoledTheme: value);
|
2023-07-15 21:51:32 +03:00
|
|
|
},
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-19 18:59:53 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.colorfilter),
|
2023-07-19 18:59:53 +03:00
|
|
|
text: 'materialColor'.tr,
|
|
|
|
switcher: true,
|
|
|
|
value: settings.materialColor,
|
|
|
|
onChange: (value) {
|
|
|
|
themeController.saveMaterialTheme(value);
|
2023-10-10 12:54:55 +03:00
|
|
|
MyApp.updateAppState(context,
|
|
|
|
newMaterialColor: value);
|
2023-07-19 18:59:53 +03:00
|
|
|
},
|
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
),
|
2023-06-27 22:41:25 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2023-06-17 20:57:57 +03:00
|
|
|
},
|
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.code),
|
2023-06-27 22:41:25 +03:00
|
|
|
text: 'functions'.tr,
|
|
|
|
onPressed: () {
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, setState) {
|
2023-07-15 21:51:32 +03:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Padding(
|
2023-09-29 15:45:50 +03:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
2023-07-15 21:51:32 +03:00
|
|
|
child: Text(
|
|
|
|
'functions'.tr,
|
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 20,
|
|
|
|
),
|
2023-07-14 20:19:43 +03:00
|
|
|
),
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.map_1),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'location'.tr,
|
|
|
|
switcher: true,
|
|
|
|
value: settings.location,
|
2023-09-18 16:26:08 +03:00
|
|
|
onChange: (value) async {
|
|
|
|
if (value) {
|
2023-10-10 12:54:55 +03:00
|
|
|
bool serviceEnabled = await Geolocator
|
|
|
|
.isLocationServiceEnabled();
|
2023-09-18 16:26:08 +03:00
|
|
|
if (!serviceEnabled) {
|
2023-09-21 09:14:34 +03:00
|
|
|
if (!mounted) return;
|
|
|
|
await showAdaptiveDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertDialog.adaptive(
|
|
|
|
title: Text(
|
2023-09-24 18:52:15 +03:00
|
|
|
'location'.tr,
|
2023-09-21 09:14:34 +03:00
|
|
|
style: context.textTheme.titleLarge,
|
|
|
|
),
|
2023-10-10 12:54:55 +03:00
|
|
|
content: Text('no_location'.tr,
|
|
|
|
style: context
|
|
|
|
.textTheme.titleMedium),
|
2023-09-21 09:14:34 +03:00
|
|
|
actions: [
|
|
|
|
TextButton(
|
2023-10-10 12:54:55 +03:00
|
|
|
onPressed: () =>
|
|
|
|
Get.back(result: false),
|
2023-09-24 18:52:15 +03:00
|
|
|
child: Text('cancel'.tr,
|
2023-10-10 12:54:55 +03:00
|
|
|
style: context.theme
|
|
|
|
.textTheme.titleMedium
|
|
|
|
?.copyWith(
|
|
|
|
color: Colors
|
|
|
|
.blueAccent))),
|
2023-09-21 09:14:34 +03:00
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
2023-10-10 12:54:55 +03:00
|
|
|
Geolocator
|
|
|
|
.openLocationSettings();
|
2023-09-21 09:14:34 +03:00
|
|
|
Get.back(result: true);
|
|
|
|
},
|
2023-09-24 18:52:15 +03:00
|
|
|
child: Text('settings'.tr,
|
2023-10-10 12:54:55 +03:00
|
|
|
style: context.theme
|
|
|
|
.textTheme.titleMedium
|
|
|
|
?.copyWith(
|
|
|
|
color:
|
|
|
|
Colors.green))),
|
2023-09-21 09:14:34 +03:00
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2023-09-18 16:26:08 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
weatherController.getCurrentLocation();
|
|
|
|
}
|
|
|
|
isar.writeTxnSync(() {
|
2023-07-15 21:51:32 +03:00
|
|
|
settings.location = value;
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-15 21:51:32 +03:00
|
|
|
});
|
|
|
|
setState(() {});
|
|
|
|
},
|
2023-07-09 23:41:51 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.notification_1),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'notifications'.tr,
|
|
|
|
switcher: true,
|
|
|
|
value: settings.notifications,
|
|
|
|
onChange: (value) async {
|
2023-10-10 12:54:55 +03:00
|
|
|
final resultExact =
|
|
|
|
await flutterLocalNotificationsPlugin
|
|
|
|
.resolvePlatformSpecificImplementation<
|
|
|
|
AndroidFlutterLocalNotificationsPlugin>()
|
|
|
|
?.requestExactAlarmsPermission();
|
2023-07-15 21:51:32 +03:00
|
|
|
final result = Platform.isIOS
|
|
|
|
? await flutterLocalNotificationsPlugin
|
2023-10-10 12:54:55 +03:00
|
|
|
.resolvePlatformSpecificImplementation<
|
|
|
|
IOSFlutterLocalNotificationsPlugin>()
|
2023-07-15 21:51:32 +03:00
|
|
|
?.requestPermissions()
|
|
|
|
: await flutterLocalNotificationsPlugin
|
2023-10-10 12:54:55 +03:00
|
|
|
.resolvePlatformSpecificImplementation<
|
|
|
|
AndroidFlutterLocalNotificationsPlugin>()
|
2023-10-06 20:20:43 +03:00
|
|
|
?.requestNotificationsPermission();
|
2023-10-07 13:50:54 +03:00
|
|
|
if (result != null && resultExact != null) {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-07-15 21:51:32 +03:00
|
|
|
settings.notifications = value;
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-15 21:51:32 +03:00
|
|
|
});
|
|
|
|
if (value) {
|
2023-10-10 12:54:55 +03:00
|
|
|
weatherController.notlification(
|
|
|
|
weatherController.mainWeather);
|
2023-07-15 21:51:32 +03:00
|
|
|
} else {
|
|
|
|
flutterLocalNotificationsPlugin.cancelAll();
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
},
|
2023-07-08 15:19:13 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.notification_status),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'timeRange'.tr,
|
|
|
|
dropdown: true,
|
|
|
|
dropdownName: '$timeRange',
|
|
|
|
dropdownList: const <String>[
|
|
|
|
'1',
|
|
|
|
'2',
|
|
|
|
'3',
|
|
|
|
'4',
|
|
|
|
'5',
|
|
|
|
],
|
|
|
|
dropdownCange: (String? newValue) {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-07-15 21:51:32 +03:00
|
|
|
settings.timeRange = int.parse(newValue!);
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-09 23:41:51 +03:00
|
|
|
});
|
2023-10-10 12:54:55 +03:00
|
|
|
MyApp.updateAppState(context,
|
|
|
|
newTimeRange: int.parse(newValue!));
|
2023-07-15 21:51:32 +03:00
|
|
|
if (settings.notifications) {
|
|
|
|
flutterLocalNotificationsPlugin.cancelAll();
|
2023-10-10 12:54:55 +03:00
|
|
|
weatherController.notlification(
|
|
|
|
weatherController.mainWeather);
|
2023-07-09 23:41:51 +03:00
|
|
|
}
|
2023-07-15 21:51:32 +03:00
|
|
|
},
|
2023-07-09 23:41:51 +03:00
|
|
|
),
|
2023-07-26 22:20:30 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.timer_start),
|
2023-07-26 22:20:30 +03:00
|
|
|
text: 'timeStart'.tr,
|
|
|
|
info: true,
|
|
|
|
infoSettings: true,
|
|
|
|
textInfo: settings.timeformat == '12'
|
2023-10-10 12:54:55 +03:00
|
|
|
? DateFormat.jm().format(DateFormat.Hm()
|
|
|
|
.parse(weatherController
|
|
|
|
.timeConvert(timeStart)
|
|
|
|
.format(context)))
|
|
|
|
: DateFormat.Hm().format(DateFormat.Hm()
|
|
|
|
.parse(weatherController
|
|
|
|
.timeConvert(timeStart)
|
|
|
|
.format(context))),
|
2023-07-26 22:20:30 +03:00
|
|
|
onPressed: () async {
|
2023-10-10 12:54:55 +03:00
|
|
|
final TimeOfDay? timeStartPicker =
|
|
|
|
await showTimePicker(
|
2023-07-26 22:20:30 +03:00
|
|
|
context: context,
|
2023-10-10 12:54:55 +03:00
|
|
|
initialTime:
|
|
|
|
weatherController.timeConvert(timeStart),
|
2023-07-26 22:34:22 +03:00
|
|
|
builder: (context, child) {
|
|
|
|
final Widget mediaQueryWrapper = MediaQuery(
|
|
|
|
data: MediaQuery.of(context).copyWith(
|
2023-10-10 12:54:55 +03:00
|
|
|
alwaysUse24HourFormat:
|
|
|
|
settings.timeformat == '12'
|
|
|
|
? false
|
|
|
|
: true,
|
2023-07-26 22:34:22 +03:00
|
|
|
),
|
|
|
|
child: child!,
|
|
|
|
);
|
|
|
|
return mediaQueryWrapper;
|
|
|
|
},
|
2023-07-26 22:20:30 +03:00
|
|
|
);
|
|
|
|
if (timeStartPicker != null) {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-10-10 12:54:55 +03:00
|
|
|
settings.timeStart =
|
|
|
|
timeStartPicker.format(context);
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-26 22:20:30 +03:00
|
|
|
});
|
2023-09-29 15:45:50 +03:00
|
|
|
if (!mounted) return;
|
2023-10-10 12:54:55 +03:00
|
|
|
MyApp.updateAppState(context,
|
|
|
|
newTimeStart:
|
|
|
|
timeStartPicker.format(context));
|
2023-07-26 22:20:30 +03:00
|
|
|
if (settings.notifications) {
|
|
|
|
flutterLocalNotificationsPlugin.cancelAll();
|
2023-10-10 12:54:55 +03:00
|
|
|
weatherController.notlification(
|
|
|
|
weatherController.mainWeather);
|
2023-07-26 22:20:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.timer_pause),
|
2023-07-26 22:20:30 +03:00
|
|
|
text: 'timeEnd'.tr,
|
|
|
|
info: true,
|
|
|
|
infoSettings: true,
|
|
|
|
textInfo: settings.timeformat == '12'
|
2023-10-10 12:54:55 +03:00
|
|
|
? DateFormat.jm().format(DateFormat.Hm()
|
|
|
|
.parse(weatherController
|
|
|
|
.timeConvert(timeEnd)
|
|
|
|
.format(context)))
|
|
|
|
: DateFormat.Hm().format(DateFormat.Hm()
|
|
|
|
.parse(weatherController
|
|
|
|
.timeConvert(timeEnd)
|
|
|
|
.format(context))),
|
2023-07-26 22:20:30 +03:00
|
|
|
onPressed: () async {
|
2023-10-10 12:54:55 +03:00
|
|
|
final TimeOfDay? timeEndPicker =
|
|
|
|
await showTimePicker(
|
2023-07-26 22:20:30 +03:00
|
|
|
context: context,
|
2023-10-10 12:54:55 +03:00
|
|
|
initialTime:
|
|
|
|
weatherController.timeConvert(timeEnd),
|
2023-07-26 22:34:22 +03:00
|
|
|
builder: (context, child) {
|
|
|
|
final Widget mediaQueryWrapper = MediaQuery(
|
|
|
|
data: MediaQuery.of(context).copyWith(
|
2023-10-10 12:54:55 +03:00
|
|
|
alwaysUse24HourFormat:
|
|
|
|
settings.timeformat == '12'
|
|
|
|
? false
|
|
|
|
: true,
|
2023-07-26 22:34:22 +03:00
|
|
|
),
|
|
|
|
child: child!,
|
|
|
|
);
|
|
|
|
return mediaQueryWrapper;
|
|
|
|
},
|
2023-07-26 22:20:30 +03:00
|
|
|
);
|
|
|
|
if (timeEndPicker != null) {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-10-10 12:54:55 +03:00
|
|
|
settings.timeEnd =
|
|
|
|
timeEndPicker.format(context);
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-26 22:20:30 +03:00
|
|
|
});
|
2023-09-29 15:45:50 +03:00
|
|
|
if (!mounted) return;
|
2023-10-10 12:54:55 +03:00
|
|
|
MyApp.updateAppState(context,
|
|
|
|
newTimeEnd:
|
|
|
|
timeEndPicker.format(context));
|
2023-07-26 22:20:30 +03:00
|
|
|
if (settings.notifications) {
|
|
|
|
flutterLocalNotificationsPlugin.cancelAll();
|
2023-10-10 12:54:55 +03:00
|
|
|
weatherController.notlification(
|
|
|
|
weatherController.mainWeather);
|
2023-07-26 22:20:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
),
|
2023-06-27 22:41:25 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2023-06-17 20:57:57 +03:00
|
|
|
},
|
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.d_square),
|
2023-06-27 22:41:25 +03:00
|
|
|
text: 'data'.tr,
|
|
|
|
onPressed: () {
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, setState) {
|
2023-07-15 21:51:32 +03:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Padding(
|
2023-09-29 15:45:50 +03:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
2023-07-15 21:51:32 +03:00
|
|
|
child: Text(
|
|
|
|
'data'.tr,
|
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 20,
|
|
|
|
),
|
2023-07-14 20:19:43 +03:00
|
|
|
),
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.sun_1),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'degrees'.tr,
|
|
|
|
dropdown: true,
|
|
|
|
dropdownName: settings.degrees.tr,
|
2023-10-10 12:54:55 +03:00
|
|
|
dropdownList: <String>[
|
|
|
|
'celsius'.tr,
|
|
|
|
'fahrenheit'.tr
|
|
|
|
],
|
2023-08-03 20:52:20 +03:00
|
|
|
dropdownCange: (String? newValue) async {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-10-10 12:54:55 +03:00
|
|
|
settings.degrees = newValue == 'celsius'.tr
|
|
|
|
? 'celsius'
|
|
|
|
: 'fahrenheit';
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-15 21:51:32 +03:00
|
|
|
});
|
2023-09-01 20:18:40 +03:00
|
|
|
await weatherController.deleteAll(false);
|
|
|
|
await weatherController.setLocation();
|
|
|
|
await weatherController.updateCacheCard(true);
|
2023-07-15 21:51:32 +03:00
|
|
|
setState(() {});
|
|
|
|
},
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.rulerpen),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'measurements'.tr,
|
|
|
|
dropdown: true,
|
|
|
|
dropdownName: settings.measurements.tr,
|
2023-10-10 12:54:55 +03:00
|
|
|
dropdownList: <String>[
|
|
|
|
'metric'.tr,
|
|
|
|
'imperial'.tr
|
|
|
|
],
|
2023-08-04 21:19:30 +03:00
|
|
|
dropdownCange: (String? newValue) async {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-10-10 12:54:55 +03:00
|
|
|
settings.measurements =
|
|
|
|
newValue == 'metric'.tr
|
|
|
|
? 'metric'
|
|
|
|
: 'imperial';
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-15 21:51:32 +03:00
|
|
|
});
|
2023-09-01 20:18:40 +03:00
|
|
|
await weatherController.deleteAll(false);
|
|
|
|
await weatherController.setLocation();
|
|
|
|
await weatherController.updateCacheCard(true);
|
2023-07-15 21:51:32 +03:00
|
|
|
setState(() {});
|
|
|
|
},
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.clock),
|
2023-07-15 21:51:32 +03:00
|
|
|
text: 'timeformat'.tr,
|
|
|
|
dropdown: true,
|
|
|
|
dropdownName: settings.timeformat.tr,
|
|
|
|
dropdownList: <String>['12'.tr, '24'.tr],
|
|
|
|
dropdownCange: (String? newValue) {
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.writeTxnSync(() {
|
2023-10-10 12:54:55 +03:00
|
|
|
settings.timeformat =
|
|
|
|
newValue == '12'.tr ? '12' : '24';
|
2023-09-18 16:26:08 +03:00
|
|
|
isar.settings.putSync(settings);
|
2023-07-15 21:51:32 +03:00
|
|
|
});
|
|
|
|
setState(() {});
|
|
|
|
},
|
2023-06-27 22:41:25 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
),
|
2023-06-27 22:41:25 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2023-06-17 20:57:57 +03:00
|
|
|
},
|
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.language_square),
|
2023-07-02 21:53:03 +03:00
|
|
|
text: 'language'.tr,
|
|
|
|
info: true,
|
2023-07-09 23:41:51 +03:00
|
|
|
infoSettings: true,
|
2023-10-10 12:54:55 +03:00
|
|
|
textInfo: appLanguages.firstWhere(
|
|
|
|
(element) => (element['locale'] == locale),
|
2023-07-09 12:56:16 +05:30
|
|
|
orElse: () => appLanguages.first)['name'],
|
2023-07-04 21:22:29 +03:00
|
|
|
onPressed: () {
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, setState) {
|
2023-07-10 21:33:43 +03:00
|
|
|
return ListView(
|
|
|
|
children: [
|
|
|
|
Padding(
|
2023-09-29 15:45:50 +03:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
2023-07-10 21:33:43 +03:00
|
|
|
child: Text(
|
|
|
|
'language'.tr,
|
2023-07-14 20:19:43 +03:00
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 20,
|
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
textAlign: TextAlign.center,
|
2023-07-04 21:22:29 +03:00
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
),
|
|
|
|
ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
physics: const BouncingScrollPhysics(),
|
|
|
|
itemCount: appLanguages.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Card(
|
2023-07-15 20:23:36 +03:00
|
|
|
elevation: 4,
|
2023-10-10 12:54:55 +03:00
|
|
|
margin: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 10, vertical: 5),
|
2023-09-08 20:35:56 +03:00
|
|
|
child: ListTile(
|
2023-09-24 18:52:15 +03:00
|
|
|
title: Text(
|
|
|
|
appLanguages[index]['name'],
|
|
|
|
style: context.textTheme.labelLarge,
|
|
|
|
textAlign: TextAlign.center,
|
2023-07-04 21:22:29 +03:00
|
|
|
),
|
2023-09-08 20:35:56 +03:00
|
|
|
onTap: () {
|
2023-10-10 12:54:55 +03:00
|
|
|
MyApp.updateAppState(context,
|
|
|
|
newLocale: appLanguages[index]
|
|
|
|
['locale']);
|
|
|
|
updateLanguage(
|
|
|
|
appLanguages[index]['locale']);
|
2023-07-10 21:33:43 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
],
|
2023-07-04 21:22:29 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2023-07-02 21:53:03 +03:00
|
|
|
),
|
2023-07-15 21:51:32 +03:00
|
|
|
SettingCard(
|
2023-09-26 21:53:03 +03:00
|
|
|
icon: const Icon(Iconsax.dollar_square),
|
|
|
|
text: 'support'.tr,
|
|
|
|
onPressed: () {
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, setState) {
|
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Padding(
|
2023-09-29 15:45:50 +03:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
2023-09-26 21:53:03 +03:00
|
|
|
child: Text(
|
|
|
|
'support'.tr,
|
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
|
|
|
icon: const Icon(Iconsax.card),
|
|
|
|
text: 'DonationAlerts',
|
2023-10-10 12:54:55 +03:00
|
|
|
onPressed: () => urlLauncher(
|
|
|
|
'https://www.donationalerts.com/r/yoshimok'),
|
2023-09-26 21:53:03 +03:00
|
|
|
),
|
|
|
|
SettingCard(
|
|
|
|
elevation: 4,
|
|
|
|
icon: const Icon(Iconsax.wallet),
|
|
|
|
text: 'ЮMoney',
|
2023-10-10 12:54:55 +03:00
|
|
|
onPressed: () => urlLauncher(
|
|
|
|
'https://yoomoney.ru/to/4100117672775961'),
|
2023-09-26 21:53:03 +03:00
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SettingCard(
|
|
|
|
icon: const Icon(Iconsax.hierarchy_square_2),
|
2023-06-17 20:57:57 +03:00
|
|
|
text: 'version'.tr,
|
|
|
|
info: true,
|
|
|
|
textInfo: '$appVersion',
|
|
|
|
),
|
2023-10-10 14:33:26 +05:30
|
|
|
SettingCard(
|
|
|
|
icon: const Icon(Iconsax.document),
|
|
|
|
text: 'license'.tr,
|
|
|
|
onPressed: () => Get.to(
|
|
|
|
LicensePage(
|
2023-10-10 12:54:55 +03:00
|
|
|
applicationIcon: Container(
|
2023-10-10 14:33:26 +05:30
|
|
|
width: 100,
|
|
|
|
height: 100,
|
2023-10-10 12:54:55 +03:00
|
|
|
margin: const EdgeInsets.symmetric(vertical: 5),
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
|
|
|
image: DecorationImage(
|
|
|
|
image: AssetImage('assets/icons/icon.png'))),
|
2023-10-10 14:33:26 +05:30
|
|
|
),
|
|
|
|
applicationName: 'Rain',
|
|
|
|
applicationVersion: appVersion,
|
|
|
|
),
|
2023-10-10 12:54:55 +03:00
|
|
|
transition: Transition.downToUp,
|
2023-10-10 14:33:26 +05:30
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
2023-10-10 12:54:55 +03:00
|
|
|
SettingCard(
|
|
|
|
icon: Image.asset(
|
|
|
|
'assets/images/github.png',
|
|
|
|
scale: 20,
|
|
|
|
),
|
|
|
|
text: '${'project'.tr} GitHub',
|
|
|
|
onPressed: () =>
|
|
|
|
urlLauncher('https://github.com/DarkMooNight/Rain'),
|
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|