Add clear cache

This commit is contained in:
Yoshi 2024-08-20 22:19:02 +03:00
parent 27e276a092
commit 88a7bafffb
28 changed files with 234 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

View file

@ -1,9 +1,11 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:gap/gap.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:iconsax_plus/iconsax_plus.dart';
import 'package:latlong2/latlong.dart';
import 'package:rain/app/api/api.dart';
import 'package:rain/app/api/city_api.dart';
import 'package:rain/app/controller/controller.dart';
@ -34,6 +36,17 @@ class _SelectGeolocationState extends State<SelectGeolocation> {
final _controllerCity = TextEditingController();
final _controllerDistrict = TextEditingController();
static const colorFilter = ColorFilter.matrix(<double>[
-0.2, -0.7, -0.08, 0, 255, // Red channel
-0.2, -0.7, -0.08, 0, 255, // Green channel
-0.2, -0.7, -0.08, 0, 255, // Blue channel
0, 0, 0, 1, 0, // Alpha channel
]);
final bool _isDarkMode = Get.theme.brightness == Brightness.dark;
final mapController = MapController();
textTrim(value) {
value.text = value.text.trim();
while (value.text.contains(' ')) {
@ -59,6 +72,19 @@ class _SelectGeolocationState extends State<SelectGeolocation> {
setState(() {});
}
void fillMap(double latitude, double longitude) {
_controllerLat.text = '$latitude';
_controllerLon.text = '$longitude';
setState(() {});
}
Widget _buildMapTileLayer() {
return TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.darkmoonight.rain',
);
}
@override
Widget build(BuildContext context) {
const kTextFieldElevation = 4.0;
@ -103,13 +129,63 @@ class _SelectGeolocationState extends State<SelectGeolocation> {
child: SingleChildScrollView(
child: Column(
children: [
Image.asset(
'assets/icons/Search.png',
scale: 7,
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 5, horizontal: 10),
horizontal: 10),
child: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(20),
),
child: SizedBox(
height: Get.size.height * 0.3,
child: FlutterMap(
mapController: mapController,
options: MapOptions(
backgroundColor:
context.theme.colorScheme.surface,
initialCenter: const LatLng(
55.7522,
37.6156,
),
initialZoom: 3,
cameraConstraint:
CameraConstraint.contain(
bounds: LatLngBounds(
const LatLng(-90, -180),
const LatLng(90, 180),
),
),
onLongPress: (tapPosition, point) =>
fillMap(point.latitude,
point.longitude),
),
children: [
if (_isDarkMode)
ColorFiltered(
colorFilter: colorFilter,
child: _buildMapTileLayer(),
)
else
_buildMapTileLayer(),
RichAttributionWidget(
animationConfig: const ScaleRAWA(),
attributions: [
TextSourceAttribution(
'OpenStreetMap contributors',
onTap: () => weatherController
.urlLauncher(
'https://openstreetmap.org/copyright'),
),
],
),
],
),
),
),
),
Padding(
padding:
const EdgeInsets.fromLTRB(10, 15, 10, 5),
child: Text(
'searchMethod'.tr,
style: context.theme.textTheme.bodyLarge
@ -162,6 +238,7 @@ class _SelectGeolocationState extends State<SelectGeolocation> {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Align(
alignment: Alignment.topCenter,

View file

@ -218,7 +218,7 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
FlutterMap(
mapController: _animatedMapController.mapController,
options: MapOptions(
backgroundColor: context.theme.scaffoldBackgroundColor,
backgroundColor: context.theme.colorScheme.surface,
initialCenter: LatLng(mainLocation.lat!, mainLocation.lon!),
initialZoom: 12,
cameraConstraint: CameraConstraint.contain(
@ -242,9 +242,9 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
if (_isDarkMode)
ColorFiltered(
colorFilter: const ColorFilter.matrix(<double>[
-0.2126, -0.7152, -0.0722, 0, 255, // Red channel
-0.2126, -0.7152, -0.0722, 0, 255, // Green channel
-0.2126, -0.7152, -0.0722, 0, 255, // Blue channel
-0.2, -0.7, -0.08, 0, 255, // Red channel
-0.2, -0.7, -0.08, 0, 255, // Green channel
-0.2, -0.7, -0.08, 0, 255, // Blue channel
0, 0, 0, 1, 0, // Alpha channel
]),
child: _buildMapTileLayer(cacheStore),
@ -320,7 +320,7 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
},
onSelected: (Result selection) {
_animatedMapController.mapController
.move(LatLng(selection.latitude, selection.longitude), 12);
.move(LatLng(selection.latitude, selection.longitude), 14);
_controllerSearch.clear();
_focusNode.unfocus();
},

View file

@ -1,4 +1,5 @@
import 'dart:io';
import 'package:dio_cache_interceptor_file_store/dio_cache_interceptor_file_store.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hsvcolor_picker/flutter_hsvcolor_picker.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
@ -9,6 +10,7 @@ import 'package:iconsax_plus/iconsax_plus.dart';
import 'package:intl/intl.dart';
import 'package:line_awesome_flutter/line_awesome_flutter.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:rain/app/controller/controller.dart';
import 'package:rain/app/data/weather.dart';
import 'package:rain/app/modules/settings/widgets/setting_card.dart';
@ -827,6 +829,49 @@ class _SettingsPageState extends State<SettingsPage> {
);
},
),
SettingCard(
icon: const Icon(IconsaxPlusLinear.trash_square),
text: 'clearCacheStore'.tr,
onPressed: () => showAdaptiveDialog(
context: context,
builder: (context) => AlertDialog.adaptive(
title: Text(
'deletedCacheStore'.tr,
style: context.textTheme.titleLarge,
),
content: Text(
'deletedCacheStoreQuery'.tr,
style: context.textTheme.titleMedium,
),
actions: [
TextButton(
onPressed: () => Get.back(),
child: Text(
'cancel'.tr,
style: context.textTheme.titleMedium?.copyWith(
color: Colors.blueAccent,
),
),
),
TextButton(
onPressed: () async {
final dir = await getTemporaryDirectory();
final cacheStoreFuture = FileCacheStore(
'${dir.path}${Platform.pathSeparator}MapTiles');
cacheStoreFuture.clean();
Get.back();
},
child: Text(
'delete'.tr,
style: context.textTheme.titleMedium?.copyWith(
color: Colors.red,
),
),
),
],
),
),
),
SettingCard(
icon: const Icon(IconsaxPlusLinear.language_square),
text: 'language'.tr,

View file

@ -131,5 +131,9 @@ class BnIn {
'hourlyVariables': 'ঘণ্টায় আবহাওয়ার পরিবর্তনশীল',
'dailyVariables': 'দৈনিক আবহাওয়ার পরিবর্তনশীল',
'largeElement': 'বড় আবহাওয়া ডিসপ্লে',
'map': 'মানচিত্র',
'clearCacheStore': 'ক্যাশ পরিষ্কার করুন',
'deletedCacheStore': 'ক্যাশ পরিষ্কার করা হচ্ছে',
'deletedCacheStoreQuery': 'আপনি কি সত্যিই ক্যাশ পরিষ্কার করতে চান?',
};
}

View file

@ -131,5 +131,9 @@ class CsCz {
'hourlyVariables': 'Hodinové meteorologické proměnné',
'dailyVariables': 'Denní meteorologické proměnné',
'largeElement': 'Velké zobrazení počasí',
'map': 'Mapa',
'clearCacheStore': 'Vymazat mezipaměť',
'deletedCacheStore': 'Čištění mezipaměti',
'deletedCacheStoreQuery': 'Opravdu chcete vymazat mezipaměť?',
};
}

View file

@ -132,5 +132,9 @@ class DaDk {
'hourlyVariables': 'Timevise vejrfaktorer',
'dailyVariables': 'Daglige vejrfaktorer',
'largeElement': 'Stort vejrdisplay',
'map': 'Kort',
'clearCacheStore': 'Ryd cache',
'deletedCacheStore': 'Rydder cache',
'deletedCacheStoreQuery': 'Er du sikker på, at du vil rydde cachen?',
};
}

View file

@ -133,5 +133,10 @@ class DeDe {
'hourlyVariables': 'Stündliche Wettervariablen',
'dailyVariables': 'Tägliche Wettervariablen',
'largeElement': 'Große Wetteranzeige',
'map': 'Karte',
'clearCacheStore': 'Cache leeren',
'deletedCacheStore': 'Cache wird geleert',
'deletedCacheStoreQuery':
'Sind Sie sicher, dass Sie den Cache leeren möchten?',
};
}

View file

@ -133,5 +133,8 @@ class EnUs {
'dailyVariables': 'Daily weather variables',
'largeElement': 'Large weather display',
'map': 'Map',
'clearCacheStore': 'Clear cache',
'deletedCacheStore': 'Clearing the cache',
'deletedCacheStoreQuery': 'Are you sure you want to clear the cache?',
};
}

View file

@ -133,5 +133,10 @@ class EsEs {
'hourlyVariables': 'Variables meteorológicas horarias',
'dailyVariables': 'Variables meteorológicas diarias',
'largeElement': 'Visualización grande del clima',
'map': 'Mapa',
'clearCacheStore': 'Borrar caché',
'deletedCacheStore': 'Borrando caché',
'deletedCacheStoreQuery':
'¿Estás seguro de que quieres borrar el caché?',
};
}

View file

@ -132,5 +132,10 @@ class FaIr {
'hourlyVariables': 'متغیرهای ساعتی هواشناسی',
'dailyVariables': 'متغیرهای روزانه هواشناسی',
'largeElement': 'نمایش هواشناسی بزرگ',
'map': 'نقشه',
'clearCacheStore': 'پاک کردن حافظه نهان',
'deletedCacheStore': 'در حال پاک کردن حافظه نهان',
'deletedCacheStoreQuery':
'آیا مطمئن هستید که می‌خواهید حافظه نهان را پاک کنید؟',
};
}

View file

@ -133,5 +133,9 @@ class FrFr {
'hourlyVariables': 'Variables météorologiques horaires',
'dailyVariables': 'Variables météorologiques quotidiennes',
'largeElement': 'Affichage météo grand format',
'map': 'Carte',
'clearCacheStore': 'Effacer le cache',
'deletedCacheStore': 'Effacement du cache',
'deletedCacheStoreQuery': 'Êtes-vous sûr de vouloir effacer le cache?',
};
}

View file

@ -133,5 +133,10 @@ class GaIe {
'hourlyVariables': 'Athrógacha aimsire uaireanta',
'dailyVariables': 'Athrógacha aimsire laethúla',
'largeElement': 'Taispeáint mór na haimsire',
'map': 'Léarscáil',
'clearCacheStore': 'Glan taisce',
'deletedCacheStore': 'Ag glanadh an taisce',
'deletedCacheStoreQuery':
'An bhfuil tú cinnte gur mian leat an taisce a ghlanadh?',
};
}

View file

@ -130,5 +130,9 @@ class HiIn {
'hourlyVariables': 'घंटेवार मौसम चर',
'dailyVariables': 'दैनिक मौसम चर',
'largeElement': 'बड़े मौसम का प्रदर्शन',
'map': 'मानचित्र',
'clearCacheStore': 'कैश साफ़ करें',
'deletedCacheStore': 'कैश साफ़ हो रहा है',
'deletedCacheStoreQuery': 'क्या आप वाकई कैश साफ़ करना चाहते हैं?',
};
}

View file

@ -133,5 +133,9 @@ class HuHu {
'hourlyVariables': 'Óránkénti időjárási változók',
'dailyVariables': 'Napi időjárási változók',
'largeElement': 'Nagy méretű időjárás megjelenítése',
'map': 'Térkép',
'clearCacheStore': 'Gyorsítótár törlése',
'deletedCacheStore': 'Gyorsítótár törlése folyamatban',
'deletedCacheStoreQuery': 'Biztosan törölni szeretné a gyorsítótárat?',
};
}

View file

@ -133,5 +133,9 @@ class ItIt {
'hourlyVariables': 'Variabili meteorologiche orarie',
'dailyVariables': 'Variabili meteorologiche giornaliere',
'largeElement': 'Visualizzazione grande elemento meteo',
'map': 'Mappa',
'clearCacheStore': 'Cancella cache',
'deletedCacheStore': 'Cancellazione della cache',
'deletedCacheStoreQuery': 'Sei sicuro di voler cancellare la cache?',
};
}

View file

@ -132,5 +132,10 @@ class KaGe {
'hourlyVariables': 'საათობრივი ამინდის ცვლადები',
'dailyVariables': 'ყოველდღიური ამინდის ცვლადები',
'largeElement': 'გადიდი ამინდის გამოჩენა',
'map': 'რუკა',
'clearCacheStore': 'ქეშის გასუფთავება',
'deletedCacheStore': 'ქეშის გასუფთავება მიმდინარეობს',
'deletedCacheStoreQuery':
'დარწმუნებული ხართ, რომ გსურთ ქეშის გასუფთავება?',
};
}

View file

@ -128,5 +128,9 @@ class KoKr {
'hourlyVariables': '시간별 날씨 변수',
'dailyVariables': '일별 날씨 변수',
'largeElement': '큰 날씨 표시',
'map': '지도',
'clearCacheStore': '캐시 지우기',
'deletedCacheStore': '캐시 삭제 중',
'deletedCacheStoreQuery': '캐시를 정말로 지우시겠습니까?',
};
}

View file

@ -133,5 +133,9 @@ class NlNl {
'hourlyVariables': 'Uurlijkse weervariabelen',
'dailyVariables': 'Dagelijkse weervariabelen',
'largeElement': 'Groot weerbericht weergeven',
'map': 'Kaart',
'clearCacheStore': 'Cache wissen',
'deletedCacheStore': 'Cache wissen',
'deletedCacheStoreQuery': 'Weet je zeker dat je de cache wilt wissen?',
};
}

View file

@ -131,5 +131,10 @@ class PlPl {
'hourlyVariables': 'Godzinowe zmienne pogodowe',
'dailyVariables': 'Dzienne zmienne pogodowe',
'largeElement': 'Duże wyświetlanie pogody',
'map': 'Mapa',
'clearCacheStore': 'Wyczyść pamięć podręczną',
'deletedCacheStore': 'Czyszczenie pamięci podręcznej',
'deletedCacheStoreQuery':
'Czy na pewno chcesz wyczyścić pamięć podręczną?',
};
}

View file

@ -132,5 +132,9 @@ class PtBr {
'hourlyVariables': 'Variáveis meteorológicas horárias',
'dailyVariables': 'Variáveis meteorológicas diárias',
'largeElement': 'Exibição grande do clima',
'map': 'Mapa',
'clearCacheStore': 'Limpar cache',
'deletedCacheStore': 'Limpando cache',
'deletedCacheStoreQuery': 'Tem certeza de que deseja limpar o cache?',
};
}

View file

@ -131,5 +131,9 @@ class RoRo {
'hourlyVariables': 'Variabile meteorologice orare',
'dailyVariables': 'Variabile meteorologice zilnice',
'largeElement': 'Afișare mare a vremii',
'map': 'Hartă',
'clearCacheStore': 'Șterge cache-ul',
'deletedCacheStore': 'Ștergerea cache-ului',
'deletedCacheStoreQuery': 'Ești sigur că vrei să ștergi cache-ul?',
};
}

View file

@ -133,5 +133,8 @@ class RuRu {
'dailyVariables': 'Ежедневные погодные условия',
'largeElement': 'Отображение погоды большим элементом',
'map': 'Карта',
'clearCacheStore': 'Очистить кэш',
'deletedCacheStore': 'Очистка кэша',
'deletedCacheStoreQuery': 'Вы уверены, что хотите очистить кэш?',
};
}

View file

@ -131,5 +131,10 @@ class SkSk {
'hourlyVariables': 'Hodinové meteorologické premenné',
'dailyVariables': 'Denné meteorologické premenné',
'largeElement': 'Veľké zobrazenie počasia',
'map': 'Mapa',
'clearCacheStore': 'Vymazať vyrovnávaciu pamäť',
'deletedCacheStore': 'Vymazávanie vyrovnávacej pamäte',
'deletedCacheStoreQuery':
'Ste si istí, že chcete vymazať vyrovnávaciu pamäť?',
};
}

View file

@ -131,5 +131,10 @@ class TrTr {
'hourlyVariables': 'Saatlik hava değişkenleri',
'dailyVariables': 'Günlük hava değişkenleri',
'largeElement': 'Büyük hava durumu gösterimi',
'map': 'Harita',
'clearCacheStore': 'Önbelleği temizle',
'deletedCacheStore': 'Önbellek temizleniyor',
'deletedCacheStoreQuery':
'Önbelleği temizlemek istediğinizden emin misiniz?',
};
}

View file

@ -132,5 +132,9 @@ class UrPk {
'hourlyVariables': 'ہر گھنٹے کے موسمی متغیرات',
'dailyVariables': 'روزانہ کے موسمی متغیرات',
'largeElement': 'بڑے موسم کا ڈسپلے',
'map': 'نقشہ',
'clearCacheStore': 'کیچ صاف کریں',
'deletedCacheStore': 'کیچ صاف کی جارہی ہے',
'deletedCacheStoreQuery': 'کیا آپ واقعی کیچ صاف کرنا چاہتے ہیں؟',
};
}

View file

@ -127,5 +127,9 @@ class ZhCh {
'hourlyVariables': '每小时天气变量',
'dailyVariables': '每日天气变量',
'largeElement': '大天气显示',
'map': '地图',
'clearCacheStore': '清除缓存',
'deletedCacheStore': '正在清除缓存',
'deletedCacheStoreQuery': '您确定要清除缓存吗?',
};
}

View file

@ -128,5 +128,9 @@ class ZhTw {
'hourlyVariables': '每小時天氣變量',
'dailyVariables': '每日天氣變量',
'largeElement': '大型天氣顯示',
'map': '地圖',
'clearCacheStore': '清除快取',
'deletedCacheStore': '正在清除快取',
'deletedCacheStoreQuery': '您確定要清除快取嗎?',
};
}