mirror of
https://github.com/darkmoonight/Rain.git
synced 2025-06-28 12:09:57 +00:00
minor fixes
This commit is contained in:
parent
225a5240b2
commit
b160fc8fa4
23 changed files with 199 additions and 137 deletions
|
@ -43,10 +43,8 @@ class _HomePageState extends State<HomePage> 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<HomePage> with TickerProviderStateMixin {
|
|||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: const Icon(
|
||||
Iconsax.location,
|
||||
size: 18,
|
||||
),
|
||||
title: visible
|
||||
? RawAutocomplete<Result>(
|
||||
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<Result>.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<Result> onSelected,
|
||||
Iterable<Result> 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<Result>(
|
||||
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<Result>.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<Result> onSelected,
|
||||
Iterable<Result> 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<HomePage> 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),
|
||||
|
|
|
@ -122,5 +122,7 @@ class BnIn {
|
|||
'shortwaveRadiation': 'সংক্ষেপণ তরঙ্গ প্রকৃতি',
|
||||
'W/m2': 'ডব্লিউ/মিটার বর্গ',
|
||||
'roundDegree': 'ডিগ্রি রাউন্ড করুন',
|
||||
'settings_full': 'সেটিংস',
|
||||
'cities': 'শহর',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -120,5 +120,7 @@ class CsCz {
|
|||
'dewpoint': 'Rosný bod',
|
||||
'shortwaveRadiation': 'Krátká vlnová radiace',
|
||||
'roundDegree': 'Zaokrouhlit stupně',
|
||||
'settings_full': 'Nastavení',
|
||||
'cities': 'Města',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -122,5 +122,7 @@ class DeDe {
|
|||
'dewpoint': 'Taupunkt',
|
||||
'shortwaveRadiation': 'Kurzwellenstrahlung',
|
||||
'roundDegree': 'Grad runden',
|
||||
'settings_full': 'Einstellungen',
|
||||
'cities': 'Städte',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -121,5 +121,7 @@ class EnUs {
|
|||
'shortwaveRadiation': 'Shortwave radiation',
|
||||
'W/m2': 'W/m2',
|
||||
'roundDegree': 'Round degrees',
|
||||
'settings_full': 'Settings',
|
||||
'cities': 'Cities',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -122,5 +122,7 @@ class GaIe {
|
|||
'shortwaveRadiation': 'Fuinneamh Ghearrfhad',
|
||||
'W/m2': 'W/m2',
|
||||
'roundDegree': 'Timpeall na Gráid',
|
||||
'settings_full': 'Socruithe',
|
||||
'cities': 'Cathracha',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -119,5 +119,7 @@ class HiIn {
|
|||
'dewpoint': 'बर्फ़ के बिंदु',
|
||||
'shortwaveRadiation': 'शॉर्टवेव विकिरण',
|
||||
'roundDegree': 'डिग्री गोली मारें',
|
||||
'settings_full': 'सेटिंग्स',
|
||||
'cities': 'शहर',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -122,5 +122,7 @@ class ItIt {
|
|||
'dewpoint': 'Punto di rugiada',
|
||||
'shortwaveRadiation': 'Radiazione a onde corte',
|
||||
'roundDegree': 'Arrotonda i gradi',
|
||||
'settings_full': 'Impostazioni',
|
||||
'cities': 'Città',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -121,5 +121,7 @@ class KaGe {
|
|||
'dewpoint': 'დევპოინტი',
|
||||
'shortwaveRadiation': 'მოკლე ტალღის გამოსხივება',
|
||||
'roundDegree': 'ხარისხი მიჯნურობა',
|
||||
'settings_full': 'პარამეტრები',
|
||||
'cities': 'ქალაქები',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -122,5 +122,7 @@ class NlNl {
|
|||
'dewpoint': 'Dauwpunt',
|
||||
'shortwaveRadiation': 'Korte golfstraling',
|
||||
'roundDegree': 'Rond graden af',
|
||||
'settings_full': 'Instellingen',
|
||||
'cities': 'Steden',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -120,5 +120,7 @@ class PlPl {
|
|||
'dewpoint': 'Punkt rosy',
|
||||
'shortwaveRadiation': 'Promieniowanie krótkofalowe',
|
||||
'roundDegree': 'Zaokrąglaj stopnie',
|
||||
'settings_full': 'Ustawienia',
|
||||
'cities': 'Miasta',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -121,5 +121,7 @@ class RuRu {
|
|||
'shortwaveRadiation': 'Коротковолновое излучение',
|
||||
'W/m2': 'Вт/м2',
|
||||
'roundDegree': 'Округлить градусы',
|
||||
'settings_full': 'Настройки',
|
||||
'cities': 'Города',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -120,5 +120,7 @@ class SkSk {
|
|||
'dewpoint': 'Rosný bod',
|
||||
'shortwaveRadiation': 'Krátka vlnová radiácia',
|
||||
'roundDegree': 'Zaokrúhliť stupne',
|
||||
'settings_full': 'Nastavenia',
|
||||
'cities': 'Mestá',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -120,5 +120,7 @@ class TrTr {
|
|||
'dewpoint': 'Çiğ noktası',
|
||||
'shortwaveRadiation': 'Kısa dalga radyasyonu',
|
||||
'roundDegree': 'Dereceleri yuvarla',
|
||||
'settings_full': 'Ayarlar',
|
||||
'cities': 'Şehirler',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -121,5 +121,7 @@ class UrPk {
|
|||
'shortwaveRadiation': 'چھوٹی موجی شعاع',
|
||||
'W/m2': 'واٹ/میٹر مربع',
|
||||
'roundDegree': 'ڈگری گھیریں',
|
||||
'settings_full': 'ترتیبات',
|
||||
'cities': 'شہر',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -116,5 +116,7 @@ class ZhCh {
|
|||
'dewpoint': '露点',
|
||||
'shortwaveRadiation': '短波辐射',
|
||||
'roundDegree': '四舍五入度数',
|
||||
'settings_full': '设置',
|
||||
'cities': '城市',
|
||||
};
|
||||
}
|
||||
|
|
28
pubspec.lock
28
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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue