Rain/lib/app/modules/settings/view/settings.dart

1093 lines
54 KiB
Dart
Raw Normal View History

2023-07-09 12:56:16 +05:30
import 'dart:io';
2023-06-17 20:57:57 +03:00
import 'package:flutter/material.dart';
2024-05-18 21:58:53 +03:00
import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
2023-07-08 15:19:13 +03:00
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
2024-08-04 11:48:25 +03:00
import 'package:gap/gap.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';
2024-08-12 21:03:35 +03:00
import 'package:iconsax_plus/iconsax_plus.dart';
2023-07-26 22:20:30 +03:00
import 'package:intl/intl.dart';
2024-08-12 21:03:35 +03:00
import 'package:line_awesome_flutter/line_awesome_flutter.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';
2023-10-12 16:30:28 +03:00
import 'package:rain/utils/color_converter.dart';
2023-06-17 20:57:57 +03:00
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;
2023-10-12 20:48:23 +03:00
String? colorBackground;
String? colorText;
2023-06-17 20:57:57 +03:00
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(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.brush_1),
2023-06-27 22:41:25 +03:00
text: 'appearance'.tr,
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'appearance'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2023-07-15 21:51:32 +03:00
),
2023-07-14 20:19:43 +03:00
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.moon),
2024-07-09 23:03:40 +03:00
text: 'theme'.tr,
dropdown: true,
dropdownName: settings.theme?.tr,
dropdownList: <String>[
'system'.tr,
'dark'.tr,
'light'.tr
],
dropdownCange: (String? newValue) {
final newThemeMode = newValue?.tr;
final darkTheme = 'dark'.tr;
final systemTheme = 'system'.tr;
ThemeMode themeMode =
newThemeMode == systemTheme
? ThemeMode.system
: newThemeMode == darkTheme
? ThemeMode.dark
: ThemeMode.light;
String theme = newThemeMode == systemTheme
? 'system'
: newThemeMode == darkTheme
? 'dark'
: 'light';
themeController.saveTheme(theme);
themeController.changeThemeMode(themeMode);
setState(() {});
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.mobile),
2024-07-09 23:03:40 +03:00
text: 'amoledTheme'.tr,
switcher: true,
value: settings.amoledTheme,
onChange: (value) {
themeController.saveOledTheme(value);
MyApp.updateAppState(context,
newAmoledTheme: value);
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.colorfilter),
2024-07-09 23:03:40 +03:00
text: 'materialColor'.tr,
switcher: true,
value: settings.materialColor,
onChange: (value) {
themeController.saveMaterialTheme(value);
MyApp.updateAppState(context,
newMaterialColor: value);
},
),
2024-07-10 21:59:36 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.additem),
2024-07-10 21:59:36 +03:00
text: 'largeElement'.tr,
switcher: true,
value: settings.largeElement,
onChange: (value) {
settings.largeElement = value;
isar.writeTxnSync(
() => isar.settings.putSync(settings),
);
MyApp.updateAppState(
context,
newLargeElement: value,
);
setState(() {});
},
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
),
);
},
),
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(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.code_1),
2023-06-27 22:41:25 +03:00
text: 'functions'.tr,
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'functions'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2023-07-15 21:51:32 +03:00
),
2023-07-14 20:19:43 +03:00
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.map),
2024-07-09 23:03:40 +03:00
text: 'location'.tr,
switcher: true,
value: settings.location,
onChange: (value) async {
if (value) {
bool serviceEnabled = await Geolocator
.isLocationServiceEnabled();
if (!serviceEnabled) {
if (!context.mounted) return;
await showAdaptiveDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog.adaptive(
title: Text(
'location'.tr,
2024-07-10 21:59:36 +03:00
style:
context.textTheme.titleLarge,
),
2024-07-09 23:03:40 +03:00
content: Text('no_location'.tr,
2023-12-03 16:19:42 +03:00
style: context
2024-07-09 23:03:40 +03:00
.textTheme.titleMedium),
actions: [
TextButton(
onPressed: () =>
Get.back(result: false),
child: Text(
'cancel'.tr,
style: context
.textTheme.titleMedium
?.copyWith(
2024-07-10 21:59:36 +03:00
color: Colors
.blueAccent),
2024-07-09 23:03:40 +03:00
),
),
2024-07-09 23:03:40 +03:00
TextButton(
onPressed: () {
Geolocator
.openLocationSettings();
Get.back(result: true);
},
child: Text(
'settings'.tr,
style: context
.textTheme.titleMedium
?.copyWith(
color: Colors.green),
),
),
],
);
},
);
2024-07-10 21:59:36 +03:00
2024-07-09 23:03:40 +03:00
return;
}
weatherController.getCurrentLocation();
2023-09-18 16:26:08 +03:00
}
isar.writeTxnSync(() {
2024-07-09 23:03:40 +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(() {});
2024-07-09 23:03:40 +03:00
},
2023-10-12 11:36:18 +05:30
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(
IconsaxPlusLinear.notification_1),
2024-07-09 23:03:40 +03:00
text: 'notifications'.tr,
switcher: true,
value: settings.notifications,
onChange: (value) async {
final resultExact =
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestExactAlarmsPermission();
final result = Platform.isIOS
? await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions()
: await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestNotificationsPermission();
if (result != null && resultExact != null) {
isar.writeTxnSync(() {
settings.notifications = value;
isar.settings.putSync(settings);
});
if (value) {
weatherController.notification(
weatherController.mainWeather);
} else {
2024-07-10 21:59:36 +03:00
flutterLocalNotificationsPlugin
.cancelAll();
2024-07-09 23:03:40 +03:00
}
setState(() {});
2023-07-26 22:20:30 +03:00
}
2024-07-09 23:03:40 +03:00
},
2023-10-12 11:36:18 +05:30
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(
IconsaxPlusLinear.notification_status),
2024-07-09 23:03:40 +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(() {
2024-07-09 23:03:40 +03:00
settings.timeRange = int.parse(newValue!);
2023-09-18 16:26:08 +03:00
isar.settings.putSync(settings);
2023-07-26 22:20:30 +03:00
});
2023-12-03 16:19:42 +03:00
MyApp.updateAppState(context,
2024-07-09 23:03:40 +03:00
newTimeRange: int.parse(newValue!));
2023-07-26 22:20:30 +03:00
if (settings.notifications) {
flutterLocalNotificationsPlugin.cancelAll();
2024-07-07 14:49:45 +03:00
weatherController.notification(
2023-12-03 16:19:42 +03:00
weatherController.mainWeather);
2023-07-26 22:20:30 +03:00
}
2024-07-09 23:03:40 +03:00
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.timer_start),
2024-07-09 23:03:40 +03:00
text: 'timeStart'.tr,
info: true,
infoSettings: true,
infoWidget: _TextInfo(
info: settings.timeformat == '12'
2024-07-10 21:59:36 +03:00
? DateFormat.jm(locale.languageCode)
.format(
DateFormat.Hm(locale.languageCode)
.parse(weatherController
.timeConvert(timeStart)
.format(context)))
: DateFormat.Hm(locale.languageCode)
.format(
DateFormat.Hm(locale.languageCode)
.parse(weatherController
.timeConvert(timeStart)
.format(context))),
2024-07-09 23:03:40 +03:00
),
onPressed: () async {
final TimeOfDay? timeStartPicker =
await showTimePicker(
context: context,
2024-07-10 21:59:36 +03:00
initialTime: weatherController
.timeConvert(timeStart),
2024-07-09 23:03:40 +03:00
builder: (context, child) {
2024-07-10 21:59:36 +03:00
final Widget mediaQueryWrapper =
MediaQuery(
2024-07-09 23:03:40 +03:00
data: MediaQuery.of(context).copyWith(
alwaysUse24HourFormat:
settings.timeformat == '12'
? false
: true,
),
child: child!,
);
return mediaQueryWrapper;
},
);
if (timeStartPicker != null) {
isar.writeTxnSync(() {
settings.timeStart =
timeStartPicker.format(context);
isar.settings.putSync(settings);
});
if (!context.mounted) return;
MyApp.updateAppState(context,
newTimeStart:
timeStartPicker.format(context));
if (settings.notifications) {
2024-07-10 21:59:36 +03:00
flutterLocalNotificationsPlugin
.cancelAll();
2024-07-09 23:03:40 +03:00
weatherController.notification(
weatherController.mainWeather);
}
}
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.timer_pause),
2024-07-09 23:03:40 +03:00
text: 'timeEnd'.tr,
info: true,
infoSettings: true,
infoWidget: _TextInfo(
info: settings.timeformat == '12'
2024-07-10 21:59:36 +03:00
? DateFormat.jm(locale.languageCode)
.format(
DateFormat.Hm(locale.languageCode)
.parse(weatherController
.timeConvert(timeEnd)
.format(context)))
: DateFormat.Hm(locale.languageCode)
.format(
DateFormat.Hm(locale.languageCode)
.parse(weatherController
.timeConvert(timeEnd)
.format(context))),
2024-07-09 23:03:40 +03:00
),
onPressed: () async {
final TimeOfDay? timeEndPicker =
await showTimePicker(
context: context,
initialTime:
weatherController.timeConvert(timeEnd),
builder: (context, child) {
2024-07-10 21:59:36 +03:00
final Widget mediaQueryWrapper =
MediaQuery(
2024-07-09 23:03:40 +03:00
data: MediaQuery.of(context).copyWith(
alwaysUse24HourFormat:
settings.timeformat == '12'
? false
: true,
),
child: child!,
);
return mediaQueryWrapper;
},
);
if (timeEndPicker != null) {
isar.writeTxnSync(() {
settings.timeEnd =
timeEndPicker.format(context);
isar.settings.putSync(settings);
});
if (!context.mounted) return;
MyApp.updateAppState(context,
newTimeEnd:
timeEndPicker.format(context));
if (settings.notifications) {
2024-07-10 21:59:36 +03:00
flutterLocalNotificationsPlugin
.cancelAll();
2024-07-09 23:03:40 +03:00
weatherController.notification(
weatherController.mainWeather);
}
}
},
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
),
);
},
),
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(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.d_square),
2023-06-27 22:41:25 +03:00
text: 'data'.tr,
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'data'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2023-07-15 21:51:32 +03:00
),
2023-07-14 20:19:43 +03:00
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.cloud_notif),
2024-07-09 23:03:40 +03:00
text: 'roundDegree'.tr,
switcher: true,
value: settings.roundDegree,
onChange: (value) {
settings.roundDegree = value;
isar.writeTxnSync(
() => isar.settings.putSync(settings),
);
MyApp.updateAppState(
context,
newRoundDegree: value,
);
setState(() {});
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.sun_1),
2024-07-09 23:03:40 +03:00
text: 'degrees'.tr,
dropdown: true,
dropdownName: settings.degrees.tr,
dropdownList: <String>[
'celsius'.tr,
'fahrenheit'.tr
],
dropdownCange: (String? newValue) async {
isar.writeTxnSync(() {
settings.degrees = newValue == 'celsius'.tr
? 'celsius'
: 'fahrenheit';
isar.settings.putSync(settings);
});
await weatherController.deleteAll(false);
await weatherController.setLocation();
await weatherController.updateCacheCard(true);
setState(() {});
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.rulerpen),
2024-07-09 23:03:40 +03:00
text: 'measurements'.tr,
dropdown: true,
dropdownName: settings.measurements.tr,
dropdownList: <String>[
'metric'.tr,
'imperial'.tr
],
dropdownCange: (String? newValue) async {
isar.writeTxnSync(() {
settings.measurements =
newValue == 'metric'.tr
? 'metric'
: 'imperial';
isar.settings.putSync(settings);
});
await weatherController.deleteAll(false);
await weatherController.setLocation();
await weatherController.updateCacheCard(true);
setState(() {});
},
),
2024-08-02 22:52:33 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.wind),
2024-08-02 22:52:33 +03:00
text: 'wind'.tr,
dropdown: true,
dropdownName: settings.wind.tr,
dropdownList: <String>['kph'.tr, 'm/s'.tr],
dropdownCange: (String? newValue) async {
isar.writeTxnSync(() {
settings.wind =
newValue == 'kph'.tr ? 'kph' : 'm/s';
isar.settings.putSync(settings);
});
setState(() {});
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.ruler),
2024-08-02 22:52:33 +03:00
text: 'pressure'.tr,
dropdown: true,
dropdownName: settings.pressure.tr,
dropdownList: <String>['hPa'.tr, 'mmHg'.tr],
dropdownCange: (String? newValue) async {
isar.writeTxnSync(() {
settings.pressure =
newValue == 'hPa'.tr ? 'hPa' : 'mmHg';
isar.settings.putSync(settings);
});
setState(() {});
},
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.clock_1),
2024-07-09 23:03:40 +03:00
text: 'timeformat'.tr,
dropdown: true,
dropdownName: settings.timeformat.tr,
dropdownList: <String>['12'.tr, '24'.tr],
dropdownCange: (String? newValue) {
isar.writeTxnSync(() {
settings.timeformat =
newValue == '12'.tr ? '12' : '24';
isar.settings.putSync(settings);
});
setState(() {});
},
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
),
);
},
),
2023-06-27 22:41:25 +03:00
);
},
);
2023-06-17 20:57:57 +03:00
},
),
2023-10-12 12:11:20 +05:30
SettingCard(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.setting_3),
2023-10-12 16:30:28 +03:00
text: 'widget'.tr,
2023-10-12 12:11:20 +05:30
onPressed: () {
2023-10-12 17:30:22 +03:00
showModalBottomSheet(
2023-10-12 12:11:20 +05:30
context: context,
2023-10-12 17:30:22 +03:00
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'widget'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2023-10-12 16:30:28 +03:00
),
2023-10-12 11:36:18 +05:30
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon:
const Icon(IconsaxPlusLinear.bucket_square),
2024-07-09 23:03:40 +03:00
text: 'widgetBackground'.tr,
info: true,
infoWidget: CircleAvatar(
backgroundColor: context.theme.indicatorColor,
radius: 11,
child: CircleAvatar(
2024-07-10 21:59:36 +03:00
backgroundColor:
widgetBackgroundColor.isEmpty
? context.theme.primaryColor
: HexColor.fromHex(
widgetBackgroundColor),
2024-07-09 23:03:40 +03:00
radius: 10,
),
2023-10-12 17:30:22 +03:00
),
2024-07-09 23:03:40 +03:00
onPressed: () {
colorBackground = null;
showDialog(
context: context,
builder: (context) => Dialog(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(
vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'widgetBackground'.tr,
style: context
.textTheme.titleMedium
?.copyWith(fontSize: 18),
),
2023-10-12 17:30:22 +03:00
),
2024-07-09 23:03:40 +03:00
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(
horizontal: 15),
2024-07-09 23:03:40 +03:00
child: Theme(
data: context.theme.copyWith(
inputDecorationTheme:
InputDecorationTheme(
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(
8),
),
2023-10-12 17:30:22 +03:00
),
),
2024-07-09 23:03:40 +03:00
child: ColorPicker(
color: widgetBackgroundColor
.isEmpty
2024-07-10 21:59:36 +03:00
? context
.theme.primaryColor
2024-07-09 23:03:40 +03:00
: HexColor.fromHex(
widgetBackgroundColor),
onChanged: (pickedColor) {
colorBackground =
pickedColor.toHex();
},
),
2023-10-12 17:30:22 +03:00
),
),
2024-07-09 23:03:40 +03:00
IconButton(
icon: const Icon(
2024-08-12 21:03:35 +03:00
IconsaxPlusLinear.tick_square,
2024-07-09 23:03:40 +03:00
),
onPressed: () {
if (colorBackground == null) {
return;
}
weatherController
.updateWidgetBackgroundColor(
colorBackground!);
MyApp.updateAppState(context,
newWidgetBackgroundColor:
colorBackground);
Get.back();
},
2023-10-12 17:30:22 +03:00
),
2024-07-09 23:03:40 +03:00
],
),
2023-10-12 20:48:23 +03:00
),
),
2024-07-09 23:03:40 +03:00
);
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.text_block),
2024-07-09 23:03:40 +03:00
text: 'widgetText'.tr,
info: true,
infoWidget: CircleAvatar(
backgroundColor: context.theme.indicatorColor,
radius: 11,
child: CircleAvatar(
backgroundColor: widgetTextColor.isEmpty
? context.theme.primaryColor
: HexColor.fromHex(widgetTextColor),
radius: 10,
2023-10-12 20:48:23 +03:00
),
),
2024-07-09 23:03:40 +03:00
onPressed: () {
colorText = null;
showDialog(
context: context,
builder: (context) => Dialog(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(
vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'widgetText'.tr,
style: context
.textTheme.titleMedium
?.copyWith(fontSize: 18),
),
2023-10-12 20:48:23 +03:00
),
2024-07-09 23:03:40 +03:00
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(
horizontal: 15),
2024-07-09 23:03:40 +03:00
child: Theme(
data: context.theme.copyWith(
inputDecorationTheme:
InputDecorationTheme(
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(
8),
),
2023-10-12 20:48:23 +03:00
),
),
2024-07-09 23:03:40 +03:00
child: ColorPicker(
color: widgetTextColor.isEmpty
2024-07-10 21:59:36 +03:00
? context
.theme.primaryColor
2024-07-09 23:03:40 +03:00
: HexColor.fromHex(
widgetTextColor),
onChanged: (pickedColor) {
colorText =
pickedColor.toHex();
},
),
2023-10-12 20:48:23 +03:00
),
),
2024-07-09 23:03:40 +03:00
IconButton(
icon: const Icon(
2024-08-12 21:03:35 +03:00
IconsaxPlusLinear.tick_square,
2024-07-09 23:03:40 +03:00
),
onPressed: () {
if (colorText == null) return;
weatherController
.updateWidgetTextColor(
colorText!);
MyApp.updateAppState(context,
newWidgetTextColor:
colorText);
Get.back();
},
2023-10-12 20:48:23 +03:00
),
2024-07-09 23:03:40 +03:00
],
),
2023-10-12 17:30:22 +03:00
),
),
2024-07-09 23:03:40 +03:00
);
},
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
),
);
},
),
2023-10-12 17:30:22 +03:00
);
},
2023-10-12 12:11:20 +05:30
);
},
),
2023-07-15 21:51:32 +03:00
SettingCard(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.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-12 11:36:18 +05:30
infoWidget: _TextInfo(
2023-12-03 16:19:42 +03:00
info: appLanguages.firstWhere(
(element) => (element['locale'] == locale),
2023-10-12 11:36:18 +05:30
orElse: () => appLanguages.first)['name'],
),
2023-07-04 21:22:29 +03:00
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 15),
child: Text(
'language'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
textAlign: TextAlign.center,
2023-07-14 20:19:43 +03:00
),
2023-07-04 21:22:29 +03:00
),
2024-07-09 23:03:40 +03:00
ListView.builder(
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
itemCount: appLanguages.length,
itemBuilder: (context, index) {
return Card(
elevation: 4,
margin: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
child: ListTile(
title: Text(
appLanguages[index]['name'],
style: context.textTheme.labelLarge,
textAlign: TextAlign.center,
),
onTap: () {
MyApp.updateAppState(context,
newLocale: appLanguages[index]
['locale']);
updateLanguage(
appLanguages[index]['locale']);
},
2023-07-04 21:22:29 +03:00
),
2024-07-09 23:03:40 +03:00
);
},
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
);
},
),
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(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.dollar_square),
2023-09-26 21:53:03 +03:00
text: 'support'.tr,
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
2024-07-10 21:59:36 +03:00
padding:
const EdgeInsets.symmetric(vertical: 15),
2024-07-09 23:03:40 +03:00
child: Text(
'support'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2023-09-26 21:53:03 +03:00
),
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.card),
2024-07-09 23:03:40 +03:00
text: 'DonationAlerts',
onPressed: () => urlLauncher(
'https://www.donationalerts.com/r/darkmoonight'),
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.wallet),
2024-07-09 23:03:40 +03:00
text: 'ЮMoney',
onPressed: () => urlLauncher(
'https://yoomoney.ru/to/4100117672775961'),
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
),
);
},
),
2023-09-26 21:53:03 +03:00
);
},
);
},
),
2024-06-08 18:03:59 +03:00
SettingCard(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.link_square),
2024-06-08 18:03:59 +03:00
text: 'groups'.tr,
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
2024-07-09 23:03:40 +03:00
return Padding(
2024-07-10 21:59:36 +03:00
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom),
2024-07-09 23:03:40 +03:00
child: StatefulBuilder(
builder: (BuildContext context, setState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 15),
child: Text(
'groups'.tr,
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2024-06-08 18:03:59 +03:00
),
),
2024-07-09 23:03:40 +03:00
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(LineAwesomeIcons.discord),
2024-07-09 23:03:40 +03:00
text: 'Discord',
onPressed: () async {
2024-07-10 21:59:36 +03:00
final Uri url = Uri.parse(
'https://discord.gg/JMMa9aHh8f');
2024-07-09 23:03:40 +03:00
if (!await launchUrl(url,
mode: LaunchMode.externalApplication)) {
throw Exception('Could not launch $url');
}
},
),
SettingCard(
elevation: 4,
2024-08-12 21:03:35 +03:00
icon: const Icon(LineAwesomeIcons.telegram),
2024-07-09 23:03:40 +03:00
text: 'Telegram',
onPressed: () async {
final Uri url =
Uri.parse('https://t.me/darkmoonightX');
if (!await launchUrl(url,
mode: LaunchMode.externalApplication)) {
throw Exception('Could not launch $url');
}
},
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2024-07-09 23:03:40 +03:00
],
),
);
},
),
2024-06-08 18:03:59 +03:00
);
},
);
},
),
2023-10-10 14:33:26 +05:30
SettingCard(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.document),
2023-10-10 14:33:26 +05:30
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-12 17:30:22 +03:00
SettingCard(
2024-08-12 21:03:35 +03:00
icon: const Icon(IconsaxPlusLinear.hierarchy_square_2),
2023-10-12 17:30:22 +03:00
text: 'version'.tr,
info: true,
infoWidget: _TextInfo(
info: '$appVersion',
),
),
2023-10-10 12:54:55 +03:00
SettingCard(
2024-08-12 21:03:35 +03:00
icon: const Icon(LineAwesomeIcons.github),
2023-10-10 12:54:55 +03:00
text: '${'project'.tr} GitHub',
2023-12-03 16:19:42 +03:00
onPressed: () =>
urlLauncher('https://github.com/darkmoonight/Rain'),
2023-10-10 12:54:55 +03:00
),
2024-06-08 18:03:59 +03:00
Padding(
padding: const EdgeInsets.all(10),
child: GestureDetector(
child: Text(
'openMeteo'.tr,
style: context.textTheme.bodyMedium,
overflow: TextOverflow.visible,
textAlign: TextAlign.center,
),
onTap: () => urlLauncher('https://open-meteo.com/'),
),
),
2024-08-04 11:48:25 +03:00
const Gap(10),
2023-06-17 20:57:57 +03:00
],
),
);
}
}
2023-10-12 11:36:18 +05:30
class _TextInfo extends StatelessWidget {
const _TextInfo({required this.info});
final String info;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(right: 5),
child: Text(
info,
style: context.textTheme.bodyMedium,
overflow: TextOverflow.visible,
),
);
}
}