minor fix

This commit is contained in:
Yoshi 2023-10-12 16:30:28 +03:00
parent 232178f6d1
commit 321338a826
9 changed files with 271 additions and 135 deletions

View file

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
@ -53,7 +52,8 @@ class WeatherController extends GetxController {
@override
void onInit() {
weatherCards.assignAll(isar.weatherCards.where().sortByIndex().findAllSync());
weatherCards
.assignAll(isar.weatherCards.where().sortByIndex().findAllSync());
super.onInit();
}
@ -69,9 +69,11 @@ class WeatherController extends GetxController {
}
if (permission == LocationPermission.deniedForever) {
return Future.error('Location permissions are permanently denied, we cannot request permissions.');
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
return await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
return await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high);
}
Future<void> setLocation() async {
@ -79,8 +81,10 @@ class WeatherController extends GetxController {
await getCurrentLocation();
} else {
if ((isar.locationCaches.where().findAllSync()).isNotEmpty) {
LocationCache locationCity = (isar.locationCaches.where().findFirstSync())!;
await getLocation(locationCity.lat!, locationCity.lon!, locationCity.district!, locationCity.city!);
LocationCache locationCity =
(isar.locationCaches.where().findFirstSync())!;
await getLocation(locationCity.lat!, locationCity.lon!,
locationCity.district!, locationCity.city!);
}
}
}
@ -109,7 +113,8 @@ class WeatherController extends GetxController {
}
Position position = await determinePosition();
List<Placemark> placemarks = await placemarkFromCoordinates(position.latitude, position.longitude);
List<Placemark> placemarks =
await placemarkFromCoordinates(position.latitude, position.longitude);
Placemark place = placemarks[0];
_latitude.value = position.latitude;
@ -117,7 +122,8 @@ class WeatherController extends GetxController {
_district.value = '${place.administrativeArea}';
_city.value = '${place.locality}';
_mainWeather.value = await WeatherAPI().getWeatherData(_latitude.value, _longitude.value);
_mainWeather.value =
await WeatherAPI().getWeatherData(_latitude.value, _longitude.value);
notificationCheck();
@ -125,7 +131,8 @@ class WeatherController extends GetxController {
await readCache();
}
Future<void> getLocation(double latitude, double longitude, String district, String locality) async {
Future<void> getLocation(double latitude, double longitude, String district,
String locality) async {
if (!isOnline) {
showSnackBar(content: 'no_inter'.tr);
await readCache();
@ -142,7 +149,8 @@ class WeatherController extends GetxController {
_district.value = district;
_city.value = locality;
_mainWeather.value = await WeatherAPI().getWeatherData(_latitude.value, _longitude.value);
_mainWeather.value =
await WeatherAPI().getWeatherData(_latitude.value, _longitude.value);
notificationCheck();
@ -162,8 +170,10 @@ class WeatherController extends GetxController {
_mainWeather.value = mainWeatherCache;
_location.value = locationCache;
hourOfDay.value = getTime(_mainWeather.value.time!, _mainWeather.value.timezone!);
dayOfNow.value = getDay(_mainWeather.value.timeDaily!, _mainWeather.value.timezone!);
hourOfDay.value =
getTime(_mainWeather.value.time!, _mainWeather.value.timezone!);
dayOfNow.value =
getDay(_mainWeather.value.timeDaily!, _mainWeather.value.timezone!);
if (Platform.isAndroid) {
Workmanager().registerPeriodicTask(
@ -194,8 +204,10 @@ class WeatherController extends GetxController {
);
isar.writeTxnSync(() {
final mainWeatherCachesIsEmpty = (isar.mainWeatherCaches.where().findAllSync()).isEmpty;
final locationCachesIsEmpty = (isar.locationCaches.where().findAllSync()).isEmpty;
final mainWeatherCachesIsEmpty =
(isar.mainWeatherCaches.where().findAllSync()).isEmpty;
final locationCachesIsEmpty =
(isar.locationCaches.where().findAllSync()).isEmpty;
if (mainWeatherCachesIsEmpty) {
isar.mainWeatherCaches.putSync(_mainWeather.value);
@ -213,7 +225,10 @@ class WeatherController extends GetxController {
}
isar.writeTxnSync(() {
isar.mainWeatherCaches.filter().timestampLessThan(cacheExpiry).deleteAllSync();
isar.mainWeatherCaches
.filter()
.timestampLessThan(cacheExpiry)
.deleteAllSync();
});
if ((isar.mainWeatherCaches.where().findAllSync()).isEmpty) {
await flutterLocalNotificationsPlugin.cancelAll();
@ -240,14 +255,16 @@ class WeatherController extends GetxController {
}
// Card Weather
Future<void> addCardWeather(double latitude, double longitude, String city, String district) async {
Future<void> addCardWeather(
double latitude, double longitude, String city, String district) async {
if (!isOnline) {
showSnackBar(content: 'no_inter'.tr);
return;
}
String tz = tzmap.latLngToTimezoneString(latitude, longitude);
_weatherCard.value = await WeatherAPI().getWeatherCard(latitude, longitude, city, district, tz);
_weatherCard.value = await WeatherAPI()
.getWeatherCard(latitude, longitude, city, district, tz);
isar.writeTxnSync(() {
weatherCards.add(_weatherCard.value);
isar.weatherCards.putSync(_weatherCard.value);
@ -257,15 +274,19 @@ class WeatherController extends GetxController {
Future<void> updateCacheCard(bool refresh) async {
List<WeatherCard> weatherCard = refresh
? isar.weatherCards.where().sortByIndex().findAllSync()
: isar.weatherCards.filter().timestampLessThan(cacheExpiry).sortByIndex().findAllSync();
: isar.weatherCards
.filter()
.timestampLessThan(cacheExpiry)
.sortByIndex()
.findAllSync();
if (!isOnline || weatherCard.isEmpty) {
return;
}
for (var oldCard in weatherCard) {
var updatedCard = await WeatherAPI()
.getWeatherCard(oldCard.lat, oldCard.lon, oldCard.city!, oldCard.district!, oldCard.timezone!);
var updatedCard = await WeatherAPI().getWeatherCard(oldCard.lat,
oldCard.lon, oldCard.city!, oldCard.district!, oldCard.timezone!);
isar.writeTxnSync(() {
oldCard
..time = updatedCard.time
@ -290,7 +311,8 @@ class WeatherController extends GetxController {
..sunrise = updatedCard.sunrise
..sunset = updatedCard.sunset
..precipitationSum = updatedCard.precipitationSum
..precipitationProbabilityMax = updatedCard.precipitationProbabilityMax
..precipitationProbabilityMax =
updatedCard.precipitationProbabilityMax
..windspeed10MMax = updatedCard.windspeed10MMax
..windgusts10MMax = updatedCard.windgusts10MMax
..uvIndexMax = updatedCard.uvIndexMax
@ -367,8 +389,10 @@ class WeatherController extends GetxController {
int getTime(List<String> time, String timezone) {
int getTime = 0;
for (var i = 0; i < time.length; i++) {
if (tz.TZDateTime.now(tz.getLocation(timezone)).hour == DateTime.parse(time[i]).hour &&
tz.TZDateTime.now(tz.getLocation(timezone)).day == DateTime.parse(time[i]).day) {
if (tz.TZDateTime.now(tz.getLocation(timezone)).hour ==
DateTime.parse(time[i]).hour &&
tz.TZDateTime.now(tz.getLocation(timezone)).day ==
DateTime.parse(time[i]).day) {
getTime = i;
}
}
@ -415,7 +439,9 @@ class WeatherController extends GetxController {
for (var i = 0; i < mainWeatherCache.time!.length; i += timeRange) {
DateTime notificationTime = DateTime.parse(mainWeatherCache.time![i]);
if (notificationTime.isAfter(now) && notificationTime.hour >= startHour && notificationTime.hour <= endHour) {
if (notificationTime.isAfter(now) &&
notificationTime.hour >= startHour &&
notificationTime.hour <= endHour) {
for (var j = 0; j < mainWeatherCache.timeDaily!.length; j++) {
if (mainWeatherCache.timeDaily![j].day == notificationTime.day) {
NotificationShow().showNotification(
@ -461,14 +487,11 @@ class WeatherController extends GetxController {
}
Future<bool> updateWidgetBackgroundColor(String color) async {
print(settings.widgetBackgroundColor);
settings.widgetBackgroundColor = color;
isar.writeTxnSync(() {
isar.settings.putSync(settings);
});
print(settings.widgetBackgroundColor);
return Future.wait<bool?>([
HomeWidget.saveWidgetData(
'background_color',

View file

@ -80,7 +80,8 @@ class _WeatherPageState extends State<WeatherPage> {
child: SizedBox(
height: 136,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
child: ScrollablePositionedList.separated(
key: const PageStorageKey(0),
physics: const AlwaysScrollableScrollPhysics(),
@ -92,7 +93,8 @@ class _WeatherPageState extends State<WeatherPage> {
);
},
scrollDirection: Axis.horizontal,
itemScrollController: weatherController.itemScrollController,
itemScrollController:
weatherController.itemScrollController,
itemCount: mainWeather.time!.length,
itemBuilder: (ctx, i) {
final i24 = (i / 24).floor();
@ -110,8 +112,10 @@ class _WeatherPageState extends State<WeatherPage> {
vertical: 5,
),
decoration: BoxDecoration(
color:
i == hourOfDay ? context.theme.colorScheme.primaryContainer : Colors.transparent,
color: i == hourOfDay
? context
.theme.colorScheme.primaryContainer
: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(20),
),

View file

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
@ -13,10 +12,9 @@ import 'package:rain/app/data/weather.dart';
import 'package:rain/app/modules/settings/widgets/setting_card.dart';
import 'package:rain/main.dart';
import 'package:rain/theme/theme_controller.dart';
import 'package:rain/utils/color_converter.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../../utils/color_converter.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@ -95,13 +93,18 @@ class _SettingsPageState extends State<SettingsPage> {
text: 'theme'.tr,
dropdown: true,
dropdownName: settings.theme?.tr,
dropdownList: <String>['system'.tr, 'dark'.tr, 'light'.tr],
dropdownList: <String>[
'system'.tr,
'dark'.tr,
'light'.tr
],
dropdownCange: (String? newValue) {
ThemeMode themeMode = newValue?.tr == 'system'.tr
? ThemeMode.system
: newValue?.tr == 'dark'.tr
? ThemeMode.dark
: ThemeMode.light;
ThemeMode themeMode =
newValue?.tr == 'system'.tr
? ThemeMode.system
: newValue?.tr == 'dark'.tr
? ThemeMode.dark
: ThemeMode.light;
String theme = newValue?.tr == 'system'.tr
? 'system'
: newValue?.tr == 'dark'.tr
@ -120,7 +123,8 @@ class _SettingsPageState extends State<SettingsPage> {
value: settings.amoledTheme,
onChange: (value) {
themeController.saveOledTheme(value);
MyApp.updateAppState(context, newAmoledTheme: value);
MyApp.updateAppState(context,
newAmoledTheme: value);
},
),
SettingCard(
@ -131,7 +135,8 @@ class _SettingsPageState extends State<SettingsPage> {
value: settings.materialColor,
onChange: (value) {
themeController.saveMaterialTheme(value);
MyApp.updateAppState(context, newMaterialColor: value);
MyApp.updateAppState(context,
newMaterialColor: value);
},
),
const SizedBox(height: 10),
@ -175,7 +180,8 @@ class _SettingsPageState extends State<SettingsPage> {
value: settings.location,
onChange: (value) async {
if (value) {
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
bool serviceEnabled = await Geolocator
.isLocationServiceEnabled();
if (!serviceEnabled) {
if (!mounted) return;
await showAdaptiveDialog(
@ -186,21 +192,31 @@ class _SettingsPageState extends State<SettingsPage> {
'location'.tr,
style: context.textTheme.titleLarge,
),
content: Text('no_location'.tr, style: context.textTheme.titleMedium),
content: Text('no_location'.tr,
style: context
.textTheme.titleMedium),
actions: [
TextButton(
onPressed: () => Get.back(result: false),
onPressed: () =>
Get.back(result: false),
child: Text('cancel'.tr,
style: context.theme.textTheme.titleMedium
?.copyWith(color: Colors.blueAccent))),
style: context.theme
.textTheme.titleMedium
?.copyWith(
color: Colors
.blueAccent))),
TextButton(
onPressed: () {
Geolocator.openLocationSettings();
Geolocator
.openLocationSettings();
Get.back(result: true);
},
child: Text('settings'.tr,
style: context.theme.textTheme.titleMedium
?.copyWith(color: Colors.green))),
style: context.theme
.textTheme.titleMedium
?.copyWith(
color:
Colors.green))),
],
);
},
@ -224,15 +240,19 @@ class _SettingsPageState extends State<SettingsPage> {
switcher: true,
value: settings.notifications,
onChange: (value) async {
final resultExact = await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
?.requestExactAlarmsPermission();
final resultExact =
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestExactAlarmsPermission();
final result = Platform.isIOS
? await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<IOSFlutterLocalNotificationsPlugin>()
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions()
: await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestNotificationsPermission();
if (result != null && resultExact != null) {
isar.writeTxnSync(() {
@ -240,7 +260,8 @@ class _SettingsPageState extends State<SettingsPage> {
isar.settings.putSync(settings);
});
if (value) {
weatherController.notlification(weatherController.mainWeather);
weatherController.notlification(
weatherController.mainWeather);
} else {
flutterLocalNotificationsPlugin.cancelAll();
}
@ -266,10 +287,12 @@ class _SettingsPageState extends State<SettingsPage> {
settings.timeRange = int.parse(newValue!);
isar.settings.putSync(settings);
});
MyApp.updateAppState(context, newTimeRange: int.parse(newValue!));
MyApp.updateAppState(context,
newTimeRange: int.parse(newValue!));
if (settings.notifications) {
flutterLocalNotificationsPlugin.cancelAll();
weatherController.notlification(weatherController.mainWeather);
weatherController.notlification(
weatherController.mainWeather);
}
},
),
@ -281,19 +304,28 @@ class _SettingsPageState extends State<SettingsPage> {
infoSettings: true,
infoWidget: _TextInfo(
info: settings.timeformat == '12'
? DateFormat.jm().format(
DateFormat.Hm().parse(weatherController.timeConvert(timeStart).format(context)))
? DateFormat.jm().format(DateFormat.Hm()
.parse(weatherController
.timeConvert(timeStart)
.format(context)))
: DateFormat.Hm().format(DateFormat.Hm()
.parse(weatherController.timeConvert(timeStart).format(context))),
.parse(weatherController
.timeConvert(timeStart)
.format(context))),
),
onPressed: () async {
final TimeOfDay? timeStartPicker = await showTimePicker(
final TimeOfDay? timeStartPicker =
await showTimePicker(
context: context,
initialTime: weatherController.timeConvert(timeStart),
initialTime:
weatherController.timeConvert(timeStart),
builder: (context, child) {
final Widget mediaQueryWrapper = MediaQuery(
data: MediaQuery.of(context).copyWith(
alwaysUse24HourFormat: settings.timeformat == '12' ? false : true,
alwaysUse24HourFormat:
settings.timeformat == '12'
? false
: true,
),
child: child!,
);
@ -302,14 +334,18 @@ class _SettingsPageState extends State<SettingsPage> {
);
if (timeStartPicker != null) {
isar.writeTxnSync(() {
settings.timeStart = timeStartPicker.format(context);
settings.timeStart =
timeStartPicker.format(context);
isar.settings.putSync(settings);
});
if (!mounted) return;
MyApp.updateAppState(context, newTimeStart: timeStartPicker.format(context));
MyApp.updateAppState(context,
newTimeStart:
timeStartPicker.format(context));
if (settings.notifications) {
flutterLocalNotificationsPlugin.cancelAll();
weatherController.notlification(weatherController.mainWeather);
weatherController.notlification(
weatherController.mainWeather);
}
}
},
@ -322,19 +358,28 @@ class _SettingsPageState extends State<SettingsPage> {
infoSettings: true,
infoWidget: _TextInfo(
info: settings.timeformat == '12'
? DateFormat.jm().format(
DateFormat.Hm().parse(weatherController.timeConvert(timeEnd).format(context)))
: DateFormat.Hm().format(
DateFormat.Hm().parse(weatherController.timeConvert(timeEnd).format(context))),
? DateFormat.jm().format(DateFormat.Hm()
.parse(weatherController
.timeConvert(timeEnd)
.format(context)))
: DateFormat.Hm().format(DateFormat.Hm()
.parse(weatherController
.timeConvert(timeEnd)
.format(context))),
),
onPressed: () async {
final TimeOfDay? timeEndPicker = await showTimePicker(
final TimeOfDay? timeEndPicker =
await showTimePicker(
context: context,
initialTime: weatherController.timeConvert(timeEnd),
initialTime:
weatherController.timeConvert(timeEnd),
builder: (context, child) {
final Widget mediaQueryWrapper = MediaQuery(
data: MediaQuery.of(context).copyWith(
alwaysUse24HourFormat: settings.timeformat == '12' ? false : true,
alwaysUse24HourFormat:
settings.timeformat == '12'
? false
: true,
),
child: child!,
);
@ -343,14 +388,18 @@ class _SettingsPageState extends State<SettingsPage> {
);
if (timeEndPicker != null) {
isar.writeTxnSync(() {
settings.timeEnd = timeEndPicker.format(context);
settings.timeEnd =
timeEndPicker.format(context);
isar.settings.putSync(settings);
});
if (!mounted) return;
MyApp.updateAppState(context, newTimeEnd: timeEndPicker.format(context));
MyApp.updateAppState(context,
newTimeEnd:
timeEndPicker.format(context));
if (settings.notifications) {
flutterLocalNotificationsPlugin.cancelAll();
weatherController.notlification(weatherController.mainWeather);
weatherController.notlification(
weatherController.mainWeather);
}
}
},
@ -394,10 +443,15 @@ class _SettingsPageState extends State<SettingsPage> {
text: 'degrees'.tr,
dropdown: true,
dropdownName: settings.degrees.tr,
dropdownList: <String>['celsius'.tr, 'fahrenheit'.tr],
dropdownList: <String>[
'celsius'.tr,
'fahrenheit'.tr
],
dropdownCange: (String? newValue) async {
isar.writeTxnSync(() {
settings.degrees = newValue == 'celsius'.tr ? 'celsius' : 'fahrenheit';
settings.degrees = newValue == 'celsius'.tr
? 'celsius'
: 'fahrenheit';
isar.settings.putSync(settings);
});
await weatherController.deleteAll(false);
@ -412,10 +466,16 @@ class _SettingsPageState extends State<SettingsPage> {
text: 'measurements'.tr,
dropdown: true,
dropdownName: settings.measurements.tr,
dropdownList: <String>['metric'.tr, 'imperial'.tr],
dropdownList: <String>[
'metric'.tr,
'imperial'.tr
],
dropdownCange: (String? newValue) async {
isar.writeTxnSync(() {
settings.measurements = newValue == 'metric'.tr ? 'metric' : 'imperial';
settings.measurements =
newValue == 'metric'.tr
? 'metric'
: 'imperial';
isar.settings.putSync(settings);
});
await weatherController.deleteAll(false);
@ -433,7 +493,8 @@ class _SettingsPageState extends State<SettingsPage> {
dropdownList: <String>['12'.tr, '24'.tr],
dropdownCange: (String? newValue) {
isar.writeTxnSync(() {
settings.timeformat = newValue == '12'.tr ? '12' : '24';
settings.timeformat =
newValue == '12'.tr ? '12' : '24';
isar.settings.putSync(settings);
});
setState(() {});
@ -451,7 +512,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
SettingCard(
icon: const Icon(Iconsax.bubble),
text: 'Widget',
text: 'widget'.tr,
info: true,
infoWidget: CircleAvatar(
backgroundColor: context.theme.indicatorColor,
@ -474,31 +535,34 @@ class _SettingsPageState extends State<SettingsPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(12.0),
padding: const EdgeInsets.all(12),
child: Text(
'Widget Background',
style: context.textTheme.titleLarge,
'widgetBackground'.tr,
style: context.textTheme.titleMedium,
),
),
Theme(
data: context.theme.copyWith(
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Theme(
data: context.theme.copyWith(
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
),
child: ColorPicker(
pickerColor: widgetBackgroundColor.isEmpty
? context.theme.primaryColor
: HexColor.fromHex(widgetBackgroundColor),
onColorChanged: (pickedColor) {
color = pickedColor.toHex();
},
hexInputBar: true,
labelTypes: const [],
pickerAreaHeightPercent: 0.7,
pickerAreaBorderRadius: BorderRadius.circular(20),
child: ColorPicker(
pickerColor: widgetBackgroundColor.isEmpty
? context.theme.primaryColor
: HexColor.fromHex(widgetBackgroundColor),
onColorChanged: (pickedColor) {
color = pickedColor.toHex();
},
hexInputBar: true,
labelTypes: const [],
pickerAreaHeightPercent: 0.7,
pickerAreaBorderRadius: BorderRadius.circular(20),
),
),
),
IconButton(
@ -507,10 +571,11 @@ class _SettingsPageState extends State<SettingsPage> {
),
onPressed: () {
if (color != null) {
weatherController.updateWidgetBackgroundColor(color!);
weatherController
.updateWidgetBackgroundColor(color!);
}
setState(() {});
Navigator.of(context).pop();
Get.back();
},
),
],
@ -526,7 +591,8 @@ class _SettingsPageState extends State<SettingsPage> {
info: true,
infoSettings: true,
infoWidget: _TextInfo(
info: appLanguages.firstWhere((element) => (element['locale'] == locale),
info: appLanguages.firstWhere(
(element) => (element['locale'] == locale),
orElse: () => appLanguages.first)['name'],
),
onPressed: () {
@ -554,7 +620,8 @@ class _SettingsPageState extends State<SettingsPage> {
itemBuilder: (context, index) {
return Card(
elevation: 4,
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
margin: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
child: ListTile(
title: Text(
appLanguages[index]['name'],
@ -562,8 +629,11 @@ class _SettingsPageState extends State<SettingsPage> {
textAlign: TextAlign.center,
),
onTap: () {
MyApp.updateAppState(context, newLocale: appLanguages[index]['locale']);
updateLanguage(appLanguages[index]['locale']);
MyApp.updateAppState(context,
newLocale: appLanguages[index]
['locale']);
updateLanguage(
appLanguages[index]['locale']);
},
),
);
@ -605,13 +675,15 @@ class _SettingsPageState extends State<SettingsPage> {
elevation: 4,
icon: const Icon(Iconsax.card),
text: 'DonationAlerts',
onPressed: () => urlLauncher('https://www.donationalerts.com/r/yoshimok'),
onPressed: () => urlLauncher(
'https://www.donationalerts.com/r/yoshimok'),
),
SettingCard(
elevation: 4,
icon: const Icon(Iconsax.wallet),
text: 'ЮMoney',
onPressed: () => urlLauncher('https://yoomoney.ru/to/4100117672775961'),
onPressed: () => urlLauncher(
'https://yoomoney.ru/to/4100117672775961'),
),
const SizedBox(height: 10),
],
@ -642,7 +714,8 @@ class _SettingsPageState extends State<SettingsPage> {
margin: const EdgeInsets.symmetric(vertical: 5),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
image: DecorationImage(image: AssetImage('assets/icons/icon.png'))),
image: DecorationImage(
image: AssetImage('assets/icons/icon.png'))),
),
applicationName: 'Rain',
applicationVersion: appVersion,
@ -656,7 +729,8 @@ class _SettingsPageState extends State<SettingsPage> {
scale: 20,
),
text: '${'project'.tr} GitHub',
onPressed: () => urlLauncher('https://github.com/DarkMooNight/Rain'),
onPressed: () =>
urlLauncher('https://github.com/DarkMooNight/Rain'),
),
],
),

View file

@ -63,7 +63,8 @@ class SettingCard extends StatelessWidget {
? DropdownButton<String>(
underline: Container(),
value: dropdownName,
items: dropdownList!.map<DropdownMenuItem<String>>((String value) {
items: dropdownList!
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),

View file

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/foundation.dart';
@ -30,7 +29,8 @@ late Isar isar;
late Settings settings;
bool isOnline = false;
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
bool amoledTheme = false;
bool materialColor = false;
@ -72,7 +72,8 @@ void main() async {
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
result == ConnectivityResult.none ? isOnline = false : isOnline = true;
});
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(systemNavigationBarColor: Colors.black));
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(systemNavigationBarColor: Colors.black));
if (Platform.isAndroid) {
Workmanager().initialize(callbackDispatcher, isInDebugMode: kDebugMode);
await setOptimalDisplayMode();
@ -87,7 +88,8 @@ void main() async {
await isarInit();
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
const DarwinInitializationSettings initializationSettingsDarwin = DarwinInitializationSettings();
const DarwinInitializationSettings initializationSettingsDarwin =
DarwinInitializationSettings();
const LinuxInitializationSettings initializationSettingsLinux =
LinuxInitializationSettings(defaultActionName: 'Rain');
const InitializationSettings initializationSettings = InitializationSettings(
@ -103,10 +105,13 @@ Future<void> setOptimalDisplayMode() async {
final List<DisplayMode> supported = await FlutterDisplayMode.supported;
final DisplayMode active = await FlutterDisplayMode.active;
final List<DisplayMode> sameResolution = supported
.where((DisplayMode m) => m.width == active.width && m.height == active.height)
.where((DisplayMode m) =>
m.width == active.width && m.height == active.height)
.toList()
..sort((DisplayMode a, DisplayMode b) => b.refreshRate.compareTo(a.refreshRate));
final DisplayMode mostOptimalMode = sameResolution.isNotEmpty ? sameResolution.first : active;
..sort((DisplayMode a, DisplayMode b) =>
b.refreshRate.compareTo(a.refreshRate));
final DisplayMode mostOptimalMode =
sameResolution.isNotEmpty ? sameResolution.first : active;
await FlutterDisplayMode.setPreferredMode(mostOptimalMode);
}
@ -119,9 +124,6 @@ Future<void> isarInit() async {
], directory: (await getApplicationSupportDirectory()).path);
settings = isar.settings.where().findFirstSync() ?? Settings();
print(settings.theme);
print(settings.widgetBackgroundColor);
if (settings.language == null) {
settings.language = '${Get.deviceLocale}';
isar.writeTxnSync(() => isar.settings.putSync(settings));
@ -214,7 +216,8 @@ class _MyAppState extends State<MyApp> {
void initState() {
amoledTheme = settings.amoledTheme;
materialColor = settings.materialColor;
locale = Locale(settings.language!.substring(0, 2), settings.language!.substring(3));
locale = Locale(
settings.language!.substring(0, 2), settings.language!.substring(3));
timeRange = settings.timeRange ?? 1;
timeStart = settings.timeStart ?? '09:00';
timeEnd = settings.timeEnd ?? '21:00';
@ -228,8 +231,10 @@ class _MyAppState extends State<MyApp> {
Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (lightColorScheme, darkColorScheme) {
final lightMaterialTheme = lightTheme(lightColorScheme?.surface, lightColorScheme);
final darkMaterialTheme = darkTheme(darkColorScheme?.surface, darkColorScheme);
final lightMaterialTheme =
lightTheme(lightColorScheme?.surface, lightColorScheme);
final darkMaterialTheme =
darkTheme(darkColorScheme?.surface, darkColorScheme);
final darkMaterialThemeOled = darkTheme(oledColor, darkColorScheme);
return GetMaterialApp(
@ -258,7 +263,8 @@ class _MyAppState extends State<MyApp> {
translations: Translation(),
locale: locale,
fallbackLocale: const Locale('en', 'US'),
supportedLocales: appLanguages.map((e) => e['locale'] as Locale).toList(),
supportedLocales:
appLanguages.map((e) => e['locale'] as Locale).toList(),
debugShowCheckedModeBanner: false,
home: settings.onboard ? const HomePage() : const OnboardingPage(),
);

View file

@ -112,6 +112,8 @@ class Translation extends Translations {
'dark': 'Тёмная',
'light': 'Светлая',
'license': 'Лицензии',
'widget': 'Виджет',
'widgetBackground': 'Фон виджета',
},
'en_US': {
'start': 'Get Started',
@ -222,6 +224,8 @@ class Translation extends Translations {
'dark': 'Dark',
'light': 'Light',
'license': 'Licenses',
'widget': 'Widget',
'widgetBackground': 'Widget background',
},
'fr_FR': {
'start': 'Démarrer',
@ -333,6 +337,8 @@ class Translation extends Translations {
'dark': 'Sombre',
'light': 'Clair',
'license': 'Licences',
'widget': 'Widget',
'widgetBackground': 'Fond du widget',
},
'it_IT': {
'start': 'Clicca per iniziare',
@ -444,6 +450,8 @@ class Translation extends Translations {
'dark': 'Scuro',
'light': 'Chiaro',
'license': 'Licenze',
'widget': 'Widget',
'widgetBackground': 'Sfondo del widget',
},
'de_DE': {
'start': 'Los gehts',
@ -555,6 +563,8 @@ class Translation extends Translations {
'dark': 'Dunkel',
'light': 'Hell',
'license': 'Lizenzen',
'widget': 'Widget',
'widgetBackground': 'Widget-Hintergrund',
},
'tr_TR': {
'start': 'Başlat',
@ -665,6 +675,8 @@ class Translation extends Translations {
'dark': 'Karanlık',
'light': 'Aydınlık',
'license': 'Lisanslar',
'widget': 'Araç',
'widgetBackground': 'Araç Arka Planı',
},
'pt_BR': {
'start': 'Iniciar',
@ -775,6 +787,8 @@ class Translation extends Translations {
'dark': 'Escuro',
'light': 'Claro',
'license': 'Licenças',
'widget': 'Widget',
'widgetBackground': 'Fundo do widget',
},
'es_ES': {
'start': 'Empezar',
@ -886,6 +900,8 @@ class Translation extends Translations {
'dark': 'Oscuro',
'light': 'Claro',
'license': 'Licencias',
'widget': 'Widget',
'widgetBackground': 'Fondo del widget',
},
'sk_SK': {
'start': 'Začať',
@ -996,6 +1012,8 @@ class Translation extends Translations {
'dark': 'Tmavá',
'light': 'Svetlá',
'license': 'Licencie',
'widget': 'Widget',
'widgetBackground': 'Pozadie widgetu',
},
'nl_NL': {
'start': 'Beginnen',
@ -1107,8 +1125,10 @@ class Translation extends Translations {
'dark': 'Donker',
'light': 'Licht',
'license': 'Licenties',
'widget': 'Widget',
'widgetBackground': 'Widget-achtergrond',
},
"hi_IN": {
'hi_IN': {
'start': 'शुरू करें',
'description':
'मौसम ऐप जो किसी भी स्थान के लिए वास्तविक समय पूर्वानुमान, आवारा, दैनिक और साप्ताहिक पूर्वानुमान प्रदान करता है।',
@ -1215,6 +1235,8 @@ class Translation extends Translations {
'dark': 'डार्क',
'light': 'लाइट',
'license': 'लाइसेंस',
'widget': 'विजेट',
'widgetBackground': 'विजेट का पृष्ठभूमि',
},
'ro_RO': {
'start': 'Începe',
@ -1324,6 +1346,8 @@ class Translation extends Translations {
'dark': 'Întunecat',
'light': 'Luminos',
'license': 'Licențe',
'widget': 'Widget',
'widgetBackground': 'Fundal widget',
},
'zh_CN': {
'start': '开始',
@ -1431,6 +1455,8 @@ class Translation extends Translations {
'dark': '',
'light': '',
'license': '许可证',
'widget': '小部件',
'widgetBackground': '小部件背景',
},
'pl_PL': {
'start': 'Rozpocznij',
@ -1540,6 +1566,8 @@ class Translation extends Translations {
'dark': 'Ciemny',
'light': 'Jasny',
'license': 'Licencje',
'widget': 'Widget',
'widgetBackground': 'Tło widżetu',
},
};
}

View file

@ -22,7 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterTimezonePlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}

View file

@ -21,10 +21,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: ca12e6c9ac022f33fd89128e7007fb5e97ab6e814d4fa05dd8d4f2db1e3c69cb
sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03"
url: "https://pub.dev"
source: hosted
version: "3.4.5"
version: "3.4.6"
args:
dependency: transitive
description:
@ -681,10 +681,10 @@ packages:
dependency: "direct main"
description:
name: package_info_plus
sha256: "0351aaba3b267c4962ed73058a5f62a84de7e39670a20e2916a6baff2ffcfbe5"
sha256: "6ff267fcd9d48cb61c8df74a82680e8b82e940231bb5f68356672fde0397334a"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
version: "4.1.0"
package_info_plus_platform_interface:
dependency: transitive
description:

View file

@ -31,7 +31,7 @@ dependencies:
dynamic_color: ^1.6.7
path_provider: ^2.1.1
flutter_timezone: ^1.0.7
package_info_plus: ^5.0.0
package_info_plus: ^4.1.0
connectivity_plus: ^5.0.0
isar_flutter_libs: ^3.1.0+1
flutter_displaymode: ^0.6.0