Skip to content

Commit

Permalink
Add start search city
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonavichus committed Feb 11, 2024
1 parent b160fc8 commit f77d09d
Show file tree
Hide file tree
Showing 25 changed files with 471 additions and 5 deletions.
Binary file added assets/icons/Search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions lib/app/controller/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,37 @@ class WeatherController extends GetxController {
await readCache();
}

Future<Map> getCurrentLocationSearch() async {
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
double lat, lon;
String city, district;

if (!isOnline) {
showSnackBar(content: 'no_inter'.tr);
}

if (!serviceEnabled) {
showSnackBar(
content: 'no_location'.tr,
onPressed: () => Geolocator.openLocationSettings(),
);
}

Position position = await determinePosition();
List<Placemark> placemarks =
await placemarkFromCoordinates(position.latitude, position.longitude);
Placemark place = placemarks[0];

lat = position.latitude;
lon = position.longitude;
city = '${place.administrativeArea}';
district = '${place.locality}';

Map location = {'lat': lat, 'lon': lon, 'city': city, 'district': district};

return location;
}

Future<void> getLocation(double latitude, double longitude, String district,
String locality) async {
if (!isOnline) {
Expand Down
386 changes: 386 additions & 0 deletions lib/app/modules/geolocation.dart

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/app/modules/onboarding.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:rain/app/data/weather.dart';
import 'package:rain/app/modules/home.dart';
import 'package:rain/app/modules/geolocation.dart';
import 'package:rain/app/widgets/button.dart';
import 'package:rain/main.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -31,7 +31,7 @@ class _OnBordingState extends State<OnBording> {
void onBoardHome() {
settings.onboard = true;
isar.writeTxnSync(() => isar.settings.putSync(settings));
Get.off(() => const HomePage(), transition: Transition.downToUp);
Get.off(() => const SelectGeolocation(), transition: Transition.downToUp);
}

@override
Expand Down
13 changes: 12 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:home_widget/home_widget.dart';
import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';
import 'package:rain/app/controller/controller.dart';
import 'package:rain/app/modules/geolocation.dart';
import 'package:rain/app/modules/home.dart';
import 'package:rain/app/modules/onboarding.dart';
import 'package:rain/theme/theme.dart';
Expand All @@ -26,6 +27,7 @@ import 'translation/translation.dart';

late Isar isar;
late Settings settings;
late LocationCache locationCache;
bool isOnline = false;

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
Expand Down Expand Up @@ -131,6 +133,8 @@ Future<void> isarInit() async {
WeatherCardSchema,
], directory: (await getApplicationSupportDirectory()).path);
settings = isar.settings.where().findFirstSync() ?? Settings();
locationCache =
isar.locationCaches.where().findFirstSync() ?? LocationCache();

if (settings.language == null) {
settings.language = '${Get.deviceLocale}';
Expand Down Expand Up @@ -307,7 +311,14 @@ class _MyAppState extends State<MyApp> {
supportedLocales:
appLanguages.map((e) => e['locale'] as Locale).toList(),
debugShowCheckedModeBanner: false,
home: settings.onboard ? const HomePage() : const OnBording(),
home: settings.onboard
? (locationCache.city == null) ||
(locationCache.district == null) ||
(locationCache.lat == null) ||
(locationCache.lon == null)
? const SelectGeolocation()
: const HomePage()
: const OnBording(),
);
},
);
Expand Down
2 changes: 2 additions & 0 deletions lib/translation/cs_cz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ class CsCz {
'roundDegree': 'Zaokrouhlit stupně',
'settings_full': 'Nastavení',
'cities': 'Města',
'searchMethod': 'Použijte hledání nebo geolokaci',
'done': 'Hotovo',
};
}
2 changes: 2 additions & 0 deletions lib/translation/de_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class DeDe {
'roundDegree': 'Grad runden',
'settings_full': 'Einstellungen',
'cities': 'Städte',
'searchMethod': 'Verwenden Sie die Suche oder die Geolokalisierung',
'done': 'Fertig',
};
}
2 changes: 2 additions & 0 deletions lib/translation/en_us.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@ class EnUs {
'roundDegree': 'Round degrees',
'settings_full': 'Settings',
'cities': 'Cities',
'searchMethod': 'Use search or geolocation',
'done': 'Done',
};
}
2 changes: 2 additions & 0 deletions lib/translation/es_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class EsEs {
'roundDegree': 'Redondear grados',
'settings_full': 'Configuración',
'cities': 'Ciudades',
'searchMethod': 'Usa la búsqueda o la geolocalización',
'done': 'Hecho',
};
}
2 changes: 2 additions & 0 deletions lib/translation/fr_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class FrFr {
'roundDegree': 'Arrondir les degrés',
'settings_full': 'Paramètres',
'cities': 'Villes',
'searchMethod': 'Utilisez la recherche ou la géolocalisation',
'done': 'Terminé',
};
}
2 changes: 2 additions & 0 deletions lib/translation/ga_ie.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class GaIe {
'roundDegree': 'Timpeall na Gráid',
'settings_full': 'Socruithe',
'cities': 'Cathracha',
'searchMethod': 'Úsáid ceangal nó geolocáid',
'done': 'Críochnaithe',
};
}
2 changes: 2 additions & 0 deletions lib/translation/hi_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@ class HiIn {
'roundDegree': 'डिग्री गोली मारें',
'settings_full': 'सेटिंग्स',
'cities': 'शहर',
'searchMethod': 'खोज या स्थानगति का उपयोग करें',
'done': 'किया',
};
}
2 changes: 2 additions & 0 deletions lib/translation/hu_hu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class HuHu {
'roundDegree': 'Fokok Kerekítése',
'settings_full': 'Beállítások',
'cities': 'Városok',
'searchMethod': 'Használja a keresést vagy a földrajzi helyet',
'done': 'Kész',
};
}
2 changes: 2 additions & 0 deletions lib/translation/it_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class ItIt {
'roundDegree': 'Arrotonda i gradi',
'settings_full': 'Impostazioni',
'cities': 'Città',
'searchMethod': 'Utilizza la ricerca o la geolocalizzazione',
'done': 'Fatto',
};
}
2 changes: 2 additions & 0 deletions lib/translation/ka_ge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@ class KaGe {
'roundDegree': 'ხარისხი მიჯნურობა',
'settings_full': 'პარამეტრები',
'cities': 'ქალაქები',
'searchMethod': 'გამოიყენეთ ძებნა ან გეოლოკაცია',
'done': 'დასრულებულია',
};
}
2 changes: 2 additions & 0 deletions lib/translation/nl_nl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,7 @@ class NlNl {
'roundDegree': 'Rond graden af',
'settings_full': 'Instellingen',
'cities': 'Steden',
'searchMethod': 'Gebruik zoeken of geolocatie',
'done': 'Klaar',
};
}
2 changes: 2 additions & 0 deletions lib/translation/pl_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ class PlPl {
'roundDegree': 'Zaokrąglaj stopnie',
'settings_full': 'Ustawienia',
'cities': 'Miasta',
'searchMethod': 'Użyj wyszukiwania lub geolokalizacji',
'done': 'Gotowe',
};
}
2 changes: 2 additions & 0 deletions lib/translation/pt_br.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@ class PtBr {
'roundDegree': 'Arredondar graus',
'settings_full': 'Configurações',
'cities': 'Cidades',
'searchMethod': 'Use a pesquisa ou a geolocalização',
'done': 'Concluído',
};
}
2 changes: 2 additions & 0 deletions lib/translation/ro_ro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ class RoRo {
'roundDegree': 'Rotunjire grade',
'settings_full': 'Setări',
'cities': 'Orașe',
'searchMethod': 'Folosiți căutarea sau geolocația',
'done': 'Gata',
};
}
2 changes: 2 additions & 0 deletions lib/translation/ru_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@ class RuRu {
'roundDegree': 'Округлить градусы',
'settings_full': 'Настройки',
'cities': 'Города',
'searchMethod': 'Воспользуйтесь поиском или геолокацией',
'done': 'Готово',
};
}
2 changes: 2 additions & 0 deletions lib/translation/sk_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ class SkSk {
'roundDegree': 'Zaokrúhliť stupne',
'settings_full': 'Nastavenia',
'cities': 'Mestá',
'searchMethod': 'Použite vyhľadávanie alebo geolokáciu',
'done': 'Hotovo',
};
}
2 changes: 2 additions & 0 deletions lib/translation/tr_tr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ class TrTr {
'roundDegree': 'Dereceleri yuvarla',
'settings_full': 'Ayarlar',
'cities': 'Şehirler',
'searchMethod': 'Arama veya konum belirleme kullanın',
'done': 'Tamam',
};
}
2 changes: 2 additions & 0 deletions lib/translation/ur_pk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@ class UrPk {
'roundDegree': 'ڈگری گھیریں',
'settings_full': 'ترتیبات',
'cities': 'شہر',
'searchMethod': 'تلاش یا جغرافیائی مقام استعمال کریں',
'done': 'ہوگیا',
};
}
2 changes: 2 additions & 0 deletions lib/translation/zh_ch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,7 @@ class ZhCh {
'roundDegree': '四舍五入度数',
'settings_full': '设置',
'cities': '城市',
'searchMethod': '使用搜索或地理定位',
'done': '完成',
};
}
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ packages:
dependency: transitive
description:
name: image
sha256: "49a0d4b0c12402853d3f227fe7c315601b238d126aa4caa5dbb2dcf99421aa4a"
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
url: "https://pub.dev"
source: hosted
version: "4.1.6"
version: "4.1.7"
intl:
dependency: "direct main"
description:
Expand Down

0 comments on commit f77d09d

Please sign in to comment.