diff --git a/lib/app/modules/home.dart b/lib/app/modules/home.dart index bc5b627..8e7bf13 100644 --- a/lib/app/modules/home.dart +++ b/lib/app/modules/home.dart @@ -43,10 +43,8 @@ class _HomePageState extends State with TickerProviderStateMixin { vsync: this, ); tabController.animation?.addListener(() { - setState(() { - int value = (tabController.animation!.value).round(); - if (value != tabIndex) setState(() => tabIndex = value); - }); + int value = (tabController.animation!.value).round(); + if (value != tabIndex) setState(() => tabIndex = value); }); tabController.addListener(() { setState(() { @@ -82,123 +80,147 @@ class _HomePageState extends State with TickerProviderStateMixin { appBar: AppBar( centerTitle: true, automaticallyImplyLeading: false, - leading: const Icon( - Iconsax.location, - size: 18, - ), - title: visible - ? RawAutocomplete( - focusNode: _focusNode, - textEditingController: _controller, - fieldViewBuilder: (_, __, ___, ____) { - return TextField( - controller: _controller, - focusNode: _focusNode, - style: labelLarge?.copyWith(fontSize: 16), - decoration: InputDecoration( - hintText: 'search'.tr, - ), - ); - }, - optionsBuilder: (TextEditingValue textEditingValue) { - if (textEditingValue.text.isEmpty) { - return const Iterable.empty(); - } - return WeatherAPI() - .getCity(textEditingValue.text, locale); - }, - onSelected: (Result selection) async { - await weatherController.deleteAll(true); - await weatherController.getLocation( - double.parse('${selection.latitude}'), - double.parse('${selection.longitude}'), - selection.admin1, - selection.name, - ); - visible = false; - _controller.clear(); - _focusNode.unfocus(); - setState(() {}); - }, - displayStringForOption: (Result option) => - '${option.name}, ${option.admin1}', - optionsViewBuilder: (BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options) { - return Align( - alignment: Alignment.topLeft, - child: Material( - borderRadius: BorderRadius.circular(20), - elevation: 4.0, - child: SizedBox( - width: 250, - child: ListView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final Result option = options.elementAt(index); - return InkWell( - onTap: () => onSelected(option), - child: ListTile( - title: Text( - '${option.name}, ${option.admin1}', - style: labelLarge, - ), - ), - ); - }, - ), - ), - ), - ); - }, - ) - : Obx( - () { - final location = weatherController.location; - final city = location.city; - final district = location.district; - return Text( - weatherController.isLoading.isFalse - ? district!.isEmpty - ? '$city' - : city!.isEmpty - ? district - : city == district - ? city - : '$city' ', $district' - : settings.location - ? 'search'.tr - : (isar.locationCaches.where().findAllSync()) - .isNotEmpty - ? 'loading'.tr - : 'searchCity'.tr, - style: textTheme.titleMedium?.copyWith( - fontWeight: FontWeight.w600, - fontSize: 18, - ), - ); - }, - ), - actions: [ - IconButton( - onPressed: () { - if (visible) { - _controller.clear(); - _focusNode.unfocus(); - visible = false; - } else { - visible = true; - } - setState(() {}); - }, - icon: Icon( - visible ? Icons.close : Iconsax.search_normal_1, + leading: switch (tabIndex) { + 0 => const Icon( + Iconsax.global_search, size: 18, ), - ), - ], + int() => null, + }, + title: switch (tabIndex) { + 0 => visible + ? RawAutocomplete( + focusNode: _focusNode, + textEditingController: _controller, + fieldViewBuilder: (_, __, ___, ____) { + return TextField( + controller: _controller, + focusNode: _focusNode, + style: labelLarge?.copyWith(fontSize: 16), + decoration: InputDecoration( + hintText: 'search'.tr, + ), + ); + }, + optionsBuilder: (TextEditingValue textEditingValue) { + if (textEditingValue.text.isEmpty) { + return const Iterable.empty(); + } + return WeatherAPI() + .getCity(textEditingValue.text, locale); + }, + onSelected: (Result selection) async { + await weatherController.deleteAll(true); + await weatherController.getLocation( + double.parse('${selection.latitude}'), + double.parse('${selection.longitude}'), + selection.admin1, + selection.name, + ); + visible = false; + _controller.clear(); + _focusNode.unfocus(); + setState(() {}); + }, + displayStringForOption: (Result option) => + '${option.name}, ${option.admin1}', + optionsViewBuilder: (BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options) { + return Align( + alignment: Alignment.topLeft, + child: Material( + borderRadius: BorderRadius.circular(20), + elevation: 4.0, + child: SizedBox( + width: 250, + child: ListView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final Result option = + options.elementAt(index); + return InkWell( + onTap: () => onSelected(option), + child: ListTile( + title: Text( + '${option.name}, ${option.admin1}', + style: labelLarge, + ), + ), + ); + }, + ), + ), + ), + ); + }, + ) + : Obx( + () { + final location = weatherController.location; + final city = location.city; + final district = location.district; + return Text( + weatherController.isLoading.isFalse + ? district!.isEmpty + ? '$city' + : city!.isEmpty + ? district + : city == district + ? city + : '$city' ', $district' + : settings.location + ? 'search'.tr + : (isar.locationCaches.where().findAllSync()) + .isNotEmpty + ? 'loading'.tr + : 'searchCity'.tr, + style: textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ); + }, + ), + 1 => Text( + 'cities'.tr, + style: textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + 2 => Text( + 'settings_full'.tr, + style: textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + int() => null, + }, + actions: switch (tabIndex) { + 0 => [ + IconButton( + onPressed: () { + if (visible) { + _controller.clear(); + _focusNode.unfocus(); + visible = false; + } else { + visible = true; + } + setState(() {}); + }, + icon: Icon( + visible ? Icons.close : Iconsax.search_normal_1, + size: 18, + ), + ) + ], + int() => null, + }, ), body: SafeArea( child: TabBarView( @@ -218,7 +240,7 @@ class _HomePageState extends State with TickerProviderStateMixin { NavigationDestination( icon: const Icon(Iconsax.map_1), selectedIcon: const Icon(Iconsax.map5), - label: 'city'.tr, + label: 'cities'.tr, ), NavigationDestination( icon: const Icon(Iconsax.category), diff --git a/lib/translation/bn_in.dart b/lib/translation/bn_in.dart index c5ac048..d99a8e1 100644 --- a/lib/translation/bn_in.dart +++ b/lib/translation/bn_in.dart @@ -122,5 +122,7 @@ class BnIn { 'shortwaveRadiation': 'সংক্ষেপণ তরঙ্গ প্রকৃতি', 'W/m2': 'ডব্লিউ/মিটার বর্গ', 'roundDegree': 'ডিগ্রি রাউন্ড করুন', + 'settings_full': 'সেটিংস', + 'cities': 'শহর', }; } diff --git a/lib/translation/cs_cz.dart b/lib/translation/cs_cz.dart index 85d2151..19f24f2 100644 --- a/lib/translation/cs_cz.dart +++ b/lib/translation/cs_cz.dart @@ -120,5 +120,7 @@ class CsCz { 'dewpoint': 'Rosný bod', 'shortwaveRadiation': 'Krátká vlnová radiace', 'roundDegree': 'Zaokrouhlit stupně', + 'settings_full': 'Nastavení', + 'cities': 'Města', }; } diff --git a/lib/translation/de_de.dart b/lib/translation/de_de.dart index 86fad15..5d09bb7 100644 --- a/lib/translation/de_de.dart +++ b/lib/translation/de_de.dart @@ -122,5 +122,7 @@ class DeDe { 'dewpoint': 'Taupunkt', 'shortwaveRadiation': 'Kurzwellenstrahlung', 'roundDegree': 'Grad runden', + 'settings_full': 'Einstellungen', + 'cities': 'Städte', }; } diff --git a/lib/translation/en_us.dart b/lib/translation/en_us.dart index fd4d9b0..6c58e70 100644 --- a/lib/translation/en_us.dart +++ b/lib/translation/en_us.dart @@ -121,5 +121,7 @@ class EnUs { 'shortwaveRadiation': 'Shortwave radiation', 'W/m2': 'W/m2', 'roundDegree': 'Round degrees', + 'settings_full': 'Settings', + 'cities': 'Cities', }; } diff --git a/lib/translation/es_es.dart b/lib/translation/es_es.dart index 36fe8e2..ee7fdf2 100644 --- a/lib/translation/es_es.dart +++ b/lib/translation/es_es.dart @@ -122,5 +122,7 @@ class EsEs { 'dewpoint': 'Punto de rocío', 'shortwaveRadiation': 'Radiación de onda corta', 'roundDegree': 'Redondear grados', + 'settings_full': 'Configuración', + 'cities': 'Ciudades', }; } diff --git a/lib/translation/fr_fr.dart b/lib/translation/fr_fr.dart index f35773e..c375864 100644 --- a/lib/translation/fr_fr.dart +++ b/lib/translation/fr_fr.dart @@ -122,5 +122,7 @@ class FrFr { 'dewpoint': 'Point de rosée', 'shortwaveRadiation': 'Rayonnement à ondes courtes', 'roundDegree': 'Arrondir les degrés', + 'settings_full': 'Paramètres', + 'cities': 'Villes', }; } diff --git a/lib/translation/ga_ie.dart b/lib/translation/ga_ie.dart index 36258c9..db0113b 100644 --- a/lib/translation/ga_ie.dart +++ b/lib/translation/ga_ie.dart @@ -122,5 +122,7 @@ class GaIe { 'shortwaveRadiation': 'Fuinneamh Ghearrfhad', 'W/m2': 'W/m2', 'roundDegree': 'Timpeall na Gráid', + 'settings_full': 'Socruithe', + 'cities': 'Cathracha', }; } diff --git a/lib/translation/hi_in.dart b/lib/translation/hi_in.dart index 1a25f88..6a4f3a7 100644 --- a/lib/translation/hi_in.dart +++ b/lib/translation/hi_in.dart @@ -119,5 +119,7 @@ class HiIn { 'dewpoint': 'बर्फ़ के बिंदु', 'shortwaveRadiation': 'शॉर्टवेव विकिरण', 'roundDegree': 'डिग्री गोली मारें', + 'settings_full': 'सेटिंग्स', + 'cities': 'शहर', }; } diff --git a/lib/translation/hu_hu.dart b/lib/translation/hu_hu.dart index 15268ee..5de9483 100644 --- a/lib/translation/hu_hu.dart +++ b/lib/translation/hu_hu.dart @@ -122,5 +122,7 @@ class HuHu { 'shortwaveRadiation': 'Rövidhullámú sugárzás', 'W/m2': 'W/m2', 'roundDegree': 'Fokok Kerekítése', + 'settings_full': 'Beállítások', + 'cities': 'Városok', }; } diff --git a/lib/translation/it_it.dart b/lib/translation/it_it.dart index de4e978..1a3e16e 100644 --- a/lib/translation/it_it.dart +++ b/lib/translation/it_it.dart @@ -122,5 +122,7 @@ class ItIt { 'dewpoint': 'Punto di rugiada', 'shortwaveRadiation': 'Radiazione a onde corte', 'roundDegree': 'Arrotonda i gradi', + 'settings_full': 'Impostazioni', + 'cities': 'Città', }; } diff --git a/lib/translation/ka_ge.dart b/lib/translation/ka_ge.dart index d1e385b..627f88a 100644 --- a/lib/translation/ka_ge.dart +++ b/lib/translation/ka_ge.dart @@ -121,5 +121,7 @@ class KaGe { 'dewpoint': 'დევპოინტი', 'shortwaveRadiation': 'მოკლე ტალღის გამოსხივება', 'roundDegree': 'ხარისხი მიჯნურობა', + 'settings_full': 'პარამეტრები', + 'cities': 'ქალაქები', }; } diff --git a/lib/translation/nl_nl.dart b/lib/translation/nl_nl.dart index 724f66c..500d858 100644 --- a/lib/translation/nl_nl.dart +++ b/lib/translation/nl_nl.dart @@ -122,5 +122,7 @@ class NlNl { 'dewpoint': 'Dauwpunt', 'shortwaveRadiation': 'Korte golfstraling', 'roundDegree': 'Rond graden af', + 'settings_full': 'Instellingen', + 'cities': 'Steden', }; } diff --git a/lib/translation/pl_pl.dart b/lib/translation/pl_pl.dart index adc3412..9a438d4 100644 --- a/lib/translation/pl_pl.dart +++ b/lib/translation/pl_pl.dart @@ -120,5 +120,7 @@ class PlPl { 'dewpoint': 'Punkt rosy', 'shortwaveRadiation': 'Promieniowanie krótkofalowe', 'roundDegree': 'Zaokrąglaj stopnie', + 'settings_full': 'Ustawienia', + 'cities': 'Miasta', }; } diff --git a/lib/translation/pt_br.dart b/lib/translation/pt_br.dart index 8951e0e..613f6ad 100644 --- a/lib/translation/pt_br.dart +++ b/lib/translation/pt_br.dart @@ -121,5 +121,7 @@ class PtBr { 'dewpoint': 'Ponto de orvalho', 'shortwaveRadiation': 'Radiação de ondas curtas', 'roundDegree': 'Arredondar graus', + 'settings_full': 'Configurações', + 'cities': 'Cidades', }; } diff --git a/lib/translation/ro_ro.dart b/lib/translation/ro_ro.dart index 6358c7d..a50a59b 100644 --- a/lib/translation/ro_ro.dart +++ b/lib/translation/ro_ro.dart @@ -120,5 +120,7 @@ class RoRo { 'dewpoint': 'Punct de rouă', 'shortwaveRadiation': 'Radiație cu unde scurte', 'roundDegree': 'Rotunjire grade', + 'settings_full': 'Setări', + 'cities': 'Orașe', }; } diff --git a/lib/translation/ru_ru.dart b/lib/translation/ru_ru.dart index b118ef0..72b05b8 100644 --- a/lib/translation/ru_ru.dart +++ b/lib/translation/ru_ru.dart @@ -121,5 +121,7 @@ class RuRu { 'shortwaveRadiation': 'Коротковолновое излучение', 'W/m2': 'Вт/м2', 'roundDegree': 'Округлить градусы', + 'settings_full': 'Настройки', + 'cities': 'Города', }; } diff --git a/lib/translation/sk_sk.dart b/lib/translation/sk_sk.dart index cf45037..3fd960b 100644 --- a/lib/translation/sk_sk.dart +++ b/lib/translation/sk_sk.dart @@ -120,5 +120,7 @@ class SkSk { 'dewpoint': 'Rosný bod', 'shortwaveRadiation': 'Krátka vlnová radiácia', 'roundDegree': 'Zaokrúhliť stupne', + 'settings_full': 'Nastavenia', + 'cities': 'Mestá', }; } diff --git a/lib/translation/tr_tr.dart b/lib/translation/tr_tr.dart index 505299f..742ef17 100644 --- a/lib/translation/tr_tr.dart +++ b/lib/translation/tr_tr.dart @@ -120,5 +120,7 @@ class TrTr { 'dewpoint': 'Çiğ noktası', 'shortwaveRadiation': 'Kısa dalga radyasyonu', 'roundDegree': 'Dereceleri yuvarla', + 'settings_full': 'Ayarlar', + 'cities': 'Şehirler', }; } diff --git a/lib/translation/ur_pk.dart b/lib/translation/ur_pk.dart index bcdd660..7dee321 100644 --- a/lib/translation/ur_pk.dart +++ b/lib/translation/ur_pk.dart @@ -121,5 +121,7 @@ class UrPk { 'shortwaveRadiation': 'چھوٹی موجی شعاع', 'W/m2': 'واٹ/میٹر مربع', 'roundDegree': 'ڈگری گھیریں', + 'settings_full': 'ترتیبات', + 'cities': 'شہر', }; } diff --git a/lib/translation/zh_ch.dart b/lib/translation/zh_ch.dart index 043624b..5660e00 100644 --- a/lib/translation/zh_ch.dart +++ b/lib/translation/zh_ch.dart @@ -116,5 +116,7 @@ class ZhCh { 'dewpoint': '露点', 'shortwaveRadiation': '短波辐射', 'roundDegree': '四舍五入度数', + 'settings_full': '设置', + 'cities': '城市', }; } diff --git a/pubspec.lock b/pubspec.lock index 394a457..6c32a38 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -101,10 +101,10 @@ packages: dependency: transitive description: name: build_runner_core - sha256: c9e32d21dd6626b5c163d48b037ce906bbe428bc23ab77bcd77bb21e593b6185 + sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799" url: "https://pub.dev" source: hosted - version: "7.2.11" + version: "7.3.0" built_collection: dependency: transitive description: @@ -359,10 +359,10 @@ packages: dependency: "direct dev" description: name: flutter_native_splash - sha256: "9cdb5d9665dab5d098dc50feab74301c2c228cd02ca25c9b546ab572cebcd6af" + sha256: "558f10070f03ee71f850a78f7136ab239a67636a294a44a06b6b7345178edb1e" url: "https://pub.dev" source: hosted - version: "2.3.9" + version: "2.3.10" flutter_test: dependency: "direct dev" description: flutter @@ -385,10 +385,10 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "6c5031daae12c7072b3a87eff98983076434b4889ef2a44384d0cae3f82372ba" + sha256: "57247f692f35f068cae297549a46a9a097100685c6780fe67177503eea5ed4e5" url: "https://pub.dev" source: hosted - version: "2.4.6" + version: "2.4.7" freezed_annotation: dependency: "direct main" description: @@ -449,10 +449,10 @@ packages: dependency: transitive description: name: geolocator_android - sha256: "30ff8fa384ab6d35965aecc15dfc980e5ebc5f823352c1adfc87dc3d000e8e24" + sha256: "136f1c97e1903366393bda514c5d9e98843418baea52899aa45edae9af8a5cd6" url: "https://pub.dev" source: hosted - version: "4.5.0" + version: "4.5.2" geolocator_apple: dependency: transitive description: @@ -465,18 +465,18 @@ packages: dependency: transitive description: name: geolocator_platform_interface - sha256: "6c8d494d6948757c56720b778af742f6973f31fca1f702a7539b8917e4a2468a" + sha256: "3b95ecdc36462c47dbc535dcfedea774d03ccd1f3c9864e0a02ad088eeff4508" url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "4.2.1" geolocator_web: dependency: transitive description: name: geolocator_web - sha256: "59083f7e0871b78299918d92bf930a14377f711d2d1156c558cd5ebae6c20d58" + sha256: "102e7da05b48ca6bf0a5bda0010f886b171d1a08059f01bfe02addd0175ebece" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.1" geolocator_windows: dependency: transitive description: @@ -569,10 +569,10 @@ packages: dependency: transitive description: name: image - sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d" + sha256: "49a0d4b0c12402853d3f227fe7c315601b238d126aa4caa5dbb2dcf99421aa4a" url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "4.1.6" intl: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 4baa5b8..260e69f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Weather application publish_to: "none" -version: 1.2.9+32 +version: 1.3.0+33 environment: sdk: ">=3.2.6 <4.0.0" @@ -53,12 +53,12 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - freezed: ^2.4.6 + freezed: ^2.4.7 build_runner: ^2.4.8 flutter_lints: ^3.0.1 isar_generator: ^3.1.0+1 json_serializable: ^6.7.1 - flutter_native_splash: ^2.3.9 + flutter_native_splash: ^2.3.10 flutter_launcher_icons: ^0.13.1 flutter_icons: