From da07dc23c7706bf419aeffd1d43824f2d870e2e7 Mon Sep 17 00:00:00 2001 From: Yoshi Date: Mon, 12 Feb 2024 19:04:42 +0300 Subject: [PATCH] Add advanced search settings --- lib/app/modules/geolocation.dart | 25 ++++++++++++++++++++++--- lib/app/modules/home.dart | 13 ++++++++++--- lib/app/modules/onboarding.dart | 3 ++- lib/main.dart | 2 +- pubspec.lock | 8 ++++---- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/app/modules/geolocation.dart b/lib/app/modules/geolocation.dart index c419bcb..e81f624 100644 --- a/lib/app/modules/geolocation.dart +++ b/lib/app/modules/geolocation.dart @@ -12,7 +12,11 @@ import 'package:rain/app/widgets/text_form.dart'; import 'package:rain/main.dart'; class SelectGeolocation extends StatefulWidget { - const SelectGeolocation({super.key}); + const SelectGeolocation({ + super.key, + required this.isStart, + }); + final bool isStart; @override State createState() => _SelectGeolocationState(); @@ -63,6 +67,19 @@ class _SelectGeolocationState extends State { resizeToAvoidBottomInset: true, appBar: AppBar( centerTitle: true, + leading: widget.isStart + ? null + : IconButton( + onPressed: () { + Get.back(); + }, + icon: const Icon( + Iconsax.arrow_left_1, + size: 20, + ), + splashColor: Colors.transparent, + highlightColor: Colors.transparent, + ), automaticallyImplyLeading: false, title: Text( 'searchCity'.tr, @@ -359,8 +376,10 @@ class _SelectGeolocationState extends State { _controllerDistrict.text, _controllerCity.text, ); - Get.off(() => const HomePage(), - transition: Transition.downToUp); + widget.isStart + ? Get.off(() => const HomePage(), + transition: Transition.downToUp) + : Get.back(); } catch (error) { Future.error(error); } diff --git a/lib/app/modules/home.dart b/lib/app/modules/home.dart index 8e7bf13..e0deaed 100644 --- a/lib/app/modules/home.dart +++ b/lib/app/modules/home.dart @@ -8,6 +8,7 @@ import 'package:rain/app/controller/controller.dart'; import 'package:rain/app/data/weather.dart'; import 'package:rain/app/modules/cards/view/list_weather_card.dart'; import 'package:rain/app/modules/cards/widgets/create_card_weather.dart'; +import 'package:rain/app/modules/geolocation.dart'; import 'package:rain/app/modules/main/view/weather.dart'; import 'package:rain/app/modules/settings/view/settings.dart'; import 'package:rain/app/services/utils.dart'; @@ -81,9 +82,15 @@ class _HomePageState extends State with TickerProviderStateMixin { centerTitle: true, automaticallyImplyLeading: false, leading: switch (tabIndex) { - 0 => const Icon( - Iconsax.global_search, - size: 18, + 0 => IconButton( + onPressed: () { + Get.to(() => const SelectGeolocation(isStart: false), + transition: Transition.downToUp); + }, + icon: const Icon( + Iconsax.global_search, + size: 18, + ), ), int() => null, }, diff --git a/lib/app/modules/onboarding.dart b/lib/app/modules/onboarding.dart index 7bacd40..8140584 100644 --- a/lib/app/modules/onboarding.dart +++ b/lib/app/modules/onboarding.dart @@ -31,7 +31,8 @@ class _OnBordingState extends State { void onBoardHome() { settings.onboard = true; isar.writeTxnSync(() => isar.settings.putSync(settings)); - Get.off(() => const SelectGeolocation(), transition: Transition.downToUp); + Get.off(() => const SelectGeolocation(isStart: true), + transition: Transition.downToUp); } @override diff --git a/lib/main.dart b/lib/main.dart index fc2d21e..670a3d6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -316,7 +316,7 @@ class _MyAppState extends State { (locationCache.district == null) || (locationCache.lat == null) || (locationCache.lon == null) - ? const SelectGeolocation() + ? const SelectGeolocation(isStart: true) : const HomePage() : const OnBording(), ); diff --git a/pubspec.lock b/pubspec.lock index 3243ed5..642fa91 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -441,10 +441,10 @@ packages: dependency: "direct main" description: name: geolocator - sha256: e946395fc608842bb2f6c914807e9183f86f3cb787f6b8f832753e5251036f02 + sha256: f4efb8d3c4cdcad2e226af9661eb1a0dd38c71a9494b22526f9da80ab79520e5 url: "https://pub.dev" source: hosted - version: "10.1.0" + version: "10.1.1" geolocator_android: dependency: transitive description: @@ -457,10 +457,10 @@ packages: dependency: transitive description: name: geolocator_apple - sha256: "79babf44b692ec5e789d322dc736ef71586056e8e6828f747c9e005456b248bf" + sha256: "2f2d4ee16c4df269e93c0e382be075cc01d5db6703c3196e4af20a634fe49ef4" url: "https://pub.dev" source: hosted - version: "2.3.5" + version: "2.3.6" geolocator_platform_interface: dependency: transitive description: