mirror of
https://github.com/darkmoonight/Rain.git
synced 2025-06-28 12:09:57 +00:00
Add markers
This commit is contained in:
parent
6c7da7b28d
commit
8ed047a1aa
10 changed files with 172 additions and 68 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -41,4 +41,6 @@ app.*.map.json
|
|||
# Android Studio will place build artifacts here
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
/android/app/release
|
||||
|
||||
/lib/secret_key.dart
|
|
@ -21,6 +21,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|||
import 'package:timezone/data/latest_all.dart' as tz;
|
||||
import 'package:timezone/standalone.dart' as tz;
|
||||
import 'package:timezone/timezone.dart' as tz;
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:workmanager/workmanager.dart';
|
||||
|
||||
class WeatherController extends GetxController {
|
||||
|
@ -597,4 +598,11 @@ class WeatherController extends GetxController {
|
|||
return !value.contains(false);
|
||||
});
|
||||
}
|
||||
|
||||
void urlLauncher(String uri) async {
|
||||
final Uri url = Uri.parse(uri);
|
||||
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,6 +157,14 @@ class LocationCache {
|
|||
this.city,
|
||||
this.district,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'lat': lat,
|
||||
'lon': lon,
|
||||
'city': city,
|
||||
'district': district,
|
||||
};
|
||||
}
|
||||
|
||||
@collection
|
||||
|
|
|
@ -124,7 +124,7 @@ const SettingsSchema = CollectionSchema(
|
|||
getId: _settingsGetId,
|
||||
getLinks: _settingsGetLinks,
|
||||
attach: _settingsAttach,
|
||||
version: '3.1.7',
|
||||
version: '3.1.8',
|
||||
);
|
||||
|
||||
int _settingsEstimateSize(
|
||||
|
@ -3047,7 +3047,7 @@ const MainWeatherCacheSchema = CollectionSchema(
|
|||
getId: _mainWeatherCacheGetId,
|
||||
getLinks: _mainWeatherCacheGetLinks,
|
||||
attach: _mainWeatherCacheAttach,
|
||||
version: '3.1.7',
|
||||
version: '3.1.8',
|
||||
);
|
||||
|
||||
int _mainWeatherCacheEstimateSize(
|
||||
|
@ -10770,7 +10770,7 @@ const LocationCacheSchema = CollectionSchema(
|
|||
getId: _locationCacheGetId,
|
||||
getLinks: _locationCacheGetLinks,
|
||||
attach: _locationCacheAttach,
|
||||
version: '3.1.7',
|
||||
version: '3.1.8',
|
||||
);
|
||||
|
||||
int _locationCacheEstimateSize(
|
||||
|
@ -11869,7 +11869,7 @@ const WeatherCardSchema = CollectionSchema(
|
|||
getId: _weatherCardGetId,
|
||||
getLinks: _weatherCardGetLinks,
|
||||
attach: _weatherCardAttach,
|
||||
version: '3.1.7',
|
||||
version: '3.1.8',
|
||||
);
|
||||
|
||||
int _weatherCardEstimateSize(
|
||||
|
|
|
@ -9,7 +9,13 @@ import 'package:rain/app/widgets/text_form.dart';
|
|||
import 'package:rain/main.dart';
|
||||
|
||||
class CreateWeatherCard extends StatefulWidget {
|
||||
const CreateWeatherCard({super.key});
|
||||
const CreateWeatherCard({
|
||||
super.key,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
});
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
|
||||
@override
|
||||
State<CreateWeatherCard> createState() => _CreateWeatherCardState();
|
||||
|
@ -21,11 +27,11 @@ class _CreateWeatherCardState extends State<CreateWeatherCard>
|
|||
final formKey = GlobalKey<FormState>();
|
||||
final _focusNode = FocusNode();
|
||||
final weatherController = Get.put(WeatherController());
|
||||
final _controller = TextEditingController();
|
||||
final _controllerLat = TextEditingController();
|
||||
final _controllerLon = TextEditingController();
|
||||
final _controllerCity = TextEditingController();
|
||||
final _controllerDistrict = TextEditingController();
|
||||
late final TextEditingController _controller = TextEditingController();
|
||||
late TextEditingController _controllerLat = TextEditingController();
|
||||
late TextEditingController _controllerLon = TextEditingController();
|
||||
late final TextEditingController _controllerCity = TextEditingController();
|
||||
late final TextEditingController _controllerDistrict = TextEditingController();
|
||||
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> _animation;
|
||||
|
@ -33,6 +39,10 @@ class _CreateWeatherCardState extends State<CreateWeatherCard>
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.latitude != null && widget.longitude != null) {
|
||||
_controllerLat = TextEditingController(text: widget.latitude);
|
||||
_controllerLon = TextEditingController(text: widget.longitude);
|
||||
}
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_animations/flutter_map_animations.dart';
|
||||
import 'package:flutter_map_cache/flutter_map_cache.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:rain/app/controller/controller.dart';
|
||||
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
|
||||
import 'package:dio_cache_interceptor_file_store/dio_cache_interceptor_file_store.dart';
|
||||
import 'package:rain/app/modules/cards/widgets/create_card_weather.dart';
|
||||
import 'package:rain/secret_key.dart';
|
||||
|
||||
class MapWeather extends StatefulWidget {
|
||||
const MapWeather({super.key});
|
||||
|
@ -21,6 +23,7 @@ class MapWeather extends StatefulWidget {
|
|||
class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
||||
late final _animatedMapController = AnimatedMapController(vsync: this);
|
||||
final weatherController = Get.put(WeatherController());
|
||||
bool isDarkMode = Get.theme.brightness == Brightness.dark;
|
||||
|
||||
final Future<CacheStore> _cacheStoreFuture = _getCacheStore();
|
||||
|
||||
|
@ -32,7 +35,10 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mainLocation = weatherController.location;
|
||||
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
// final mainWeather = weatherController.mainWeather;
|
||||
// final weatherCard = WeatherCard.fromJson({}
|
||||
// ..addAll(mainWeather.toJson())
|
||||
// ..addAll(mainLocation.toJson()));
|
||||
|
||||
Widget darkModeTilesContainerBuilder(
|
||||
BuildContext context,
|
||||
|
@ -51,7 +57,8 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
|
||||
Widget openStreetMapTileLayer(CacheStore cacheStore) {
|
||||
return TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
urlTemplate:
|
||||
'https://api.mapbox.com/styles/v1/yoshimok/clzvnt6ae000s01qsh52veh8f/tiles/256/{z}/{x}/{y}@2x?access_token=$accessToken',
|
||||
userAgentPackageName: 'com.darkmoonight.rain',
|
||||
tileProvider: CachedTileProvider(
|
||||
store: cacheStore,
|
||||
|
@ -76,12 +83,104 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
const LatLng(90, 180),
|
||||
),
|
||||
),
|
||||
onLongPress: (tapPosition, point) => showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
enableDrag: false,
|
||||
builder: (BuildContext context) => CreateWeatherCard(
|
||||
latitude: '${point.latitude}',
|
||||
longitude: '${point.longitude}',
|
||||
),
|
||||
),
|
||||
),
|
||||
children: [
|
||||
isDarkMode
|
||||
? darkModeTilesContainerBuilder(
|
||||
context, openStreetMapTileLayer(cacheStore))
|
||||
: openStreetMapTileLayer(cacheStore)
|
||||
: openStreetMapTileLayer(cacheStore),
|
||||
RichAttributionWidget(
|
||||
animationConfig: const ScaleRAWA(),
|
||||
attributions: [
|
||||
TextSourceAttribution(
|
||||
'Mapbox contributors',
|
||||
onTap: () => weatherController
|
||||
.urlLauncher('https://www.mapbox.com/legal/tos'),
|
||||
),
|
||||
],
|
||||
),
|
||||
Obx(
|
||||
() {
|
||||
var weatherCards = weatherController.weatherCards.toList();
|
||||
return MarkerLayer(
|
||||
markers: [
|
||||
Marker(
|
||||
point: LatLng(mainLocation.lat!, mainLocation.lon!),
|
||||
child: GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
context.theme.colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
IconsaxPlusBold.home,
|
||||
color: context
|
||||
.theme.colorScheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
...weatherCards.map(
|
||||
(weatherCardList) => Marker(
|
||||
width: 35,
|
||||
height: 35,
|
||||
point: LatLng(
|
||||
weatherCardList.lat!, weatherCardList.lon!),
|
||||
child: GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: context
|
||||
.theme.colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
IconsaxPlusBold.location,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
// Positioned(
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// bottom: 0,
|
||||
// child: GestureDetector(
|
||||
// onTap: () => Get.to(
|
||||
// () => InfoWeatherCard(
|
||||
// weatherCard: weatherCard,
|
||||
// ),
|
||||
// transition: Transition.downToUp,
|
||||
// ),
|
||||
// child: WeatherCardContainer(
|
||||
// time: mainWeather.time!,
|
||||
// timeDaily: mainWeather.timeDaily!,
|
||||
// timeDay: mainWeather.sunrise!,
|
||||
// timeNight: mainWeather.sunset!,
|
||||
// weather: mainWeather.weathercode!,
|
||||
// degree: mainWeather.temperature2M!,
|
||||
// district: mainLocation.district!,
|
||||
// city: mainLocation.city!,
|
||||
// timezone: mainWeather.timezone!,
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -38,13 +38,6 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
});
|
||||
}
|
||||
|
||||
void urlLauncher(String uri) async {
|
||||
final Uri url = Uri.parse(uri);
|
||||
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
infoVersion();
|
||||
|
@ -933,14 +926,14 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
elevation: 4,
|
||||
icon: const Icon(IconsaxPlusLinear.card),
|
||||
text: 'DonationAlerts',
|
||||
onPressed: () => urlLauncher(
|
||||
onPressed: () => weatherController.urlLauncher(
|
||||
'https://www.donationalerts.com/r/darkmoonight'),
|
||||
),
|
||||
SettingCard(
|
||||
elevation: 4,
|
||||
icon: const Icon(IconsaxPlusLinear.wallet),
|
||||
text: 'ЮMoney',
|
||||
onPressed: () => urlLauncher(
|
||||
onPressed: () => weatherController.urlLauncher(
|
||||
'https://yoomoney.ru/to/4100117672775961'),
|
||||
),
|
||||
const Gap(10),
|
||||
|
@ -1051,8 +1044,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
SettingCard(
|
||||
icon: const Icon(LineAwesomeIcons.github),
|
||||
text: '${'project'.tr} GitHub',
|
||||
onPressed: () =>
|
||||
urlLauncher('https://github.com/darkmoonight/Rain'),
|
||||
onPressed: () => weatherController
|
||||
.urlLauncher('https://github.com/darkmoonight/Rain'),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
|
@ -1063,7 +1056,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
overflow: TextOverflow.visible,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onTap: () => urlLauncher('https://open-meteo.com/'),
|
||||
onTap: () =>
|
||||
weatherController.urlLauncher('https://open-meteo.com/'),
|
||||
),
|
||||
),
|
||||
const Gap(10),
|
||||
|
|
|
@ -132,5 +132,6 @@ class EnUs {
|
|||
'hourlyVariables': 'Hourly weather variables',
|
||||
'dailyVariables': 'Daily weather variables',
|
||||
'largeElement': 'Large weather display',
|
||||
'map': 'Map',
|
||||
};
|
||||
}
|
||||
|
|
52
pubspec.lock
52
pubspec.lock
|
@ -202,10 +202,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||
sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
version: "3.0.5"
|
||||
csslib:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -266,10 +266,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: dio
|
||||
sha256: e17f6b3097b8c51b72c74c9f071a605c47bcc8893839bd66732457a5ebe73714
|
||||
sha256: "0dfb6b6a1979dac1c1245e17cef824d7b452ea29bd33d3467269f9bef3715fb0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.5.0+1"
|
||||
version: "5.6.0"
|
||||
dio_cache_interceptor:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -290,10 +290,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: dio_web_adapter
|
||||
sha256: "36c5b2d79eb17cdae41e974b7a8284fec631651d2a6f39a8a2ff22327e90aeac"
|
||||
sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "2.0.0"
|
||||
dynamic_color:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -412,10 +412,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_map_animations
|
||||
sha256: "826c10a551d9dbb686a8ed9ee8815b974475812c41beb4ce9fe19095fe1c5611"
|
||||
sha256: a2135cd3cf36c07d821efeabb0be31aca380449528af80913c77b158e142eae9
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
version: "0.7.1"
|
||||
flutter_map_cache:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -424,14 +424,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
flutter_map_cancellable_tile_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_map_cancellable_tile_provider
|
||||
sha256: "6a2221be8044bd2abfd6ec1de97483fe03f01c7f8b6c2adb4ba160f60d95699a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
flutter_native_splash:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
@ -686,26 +678,26 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: isar
|
||||
sha256: d06cca880885fe016d20a53847ce8605cde595e38de00a613b086fa8fd900790
|
||||
sha256: e17a9555bc7f22ff26568b8c64d019b4ffa2dc6bd4cb1c8d9b269aefd32e53ad
|
||||
url: "https://pub.isar-community.dev"
|
||||
source: hosted
|
||||
version: "3.1.7"
|
||||
version: "3.1.8"
|
||||
isar_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: isar_flutter_libs
|
||||
sha256: d5036c0cb92b15025301fb7260e7a7557393c855ed2f9903f2b1fbb56f423bc5
|
||||
sha256: "78710781e658ce4bff59b3f38c5b2735e899e627f4e926e1221934e77b95231a"
|
||||
url: "https://pub.isar-community.dev"
|
||||
source: hosted
|
||||
version: "3.1.7"
|
||||
version: "3.1.8"
|
||||
isar_generator:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: isar_generator
|
||||
sha256: c88bcdfc4a6407ff9672364bf62330d0314e88753dd0b442179f2f802a5f2179
|
||||
sha256: "484e73d3b7e81dbd816852fe0b9497333118a9aeb646fd2d349a62cc8980ffe1"
|
||||
url: "https://pub.isar-community.dev"
|
||||
source: hosted
|
||||
version: "3.1.7"
|
||||
version: "3.1.8"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -834,14 +826,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.11.1"
|
||||
material_floating_search_bar_2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: material_floating_search_bar_2
|
||||
sha256: ab0c6d209d9491f98dd4c72f2641d0ba1dd35c87effca1f23d8679bece43add0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1123,10 +1107,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: synchronized
|
||||
sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558"
|
||||
sha256: a824e842b8a054f91a728b783c177c1e4731f6b124f9192468457a8913371255
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.0+1"
|
||||
version: "3.2.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1211,10 +1195,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: "94d8ad05f44c6d4e2ffe5567ab4d741b82d62e3c8e288cc1fcea45965edf47c9"
|
||||
sha256: f0c73347dfcfa5b3db8bc06e1502668265d39c08f310c29bff4e28eea9699f79
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.8"
|
||||
version: "6.3.9"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
12
pubspec.yaml
12
pubspec.yaml
|
@ -15,7 +15,7 @@ dependencies:
|
|||
sdk: flutter
|
||||
get: ^4.6.6
|
||||
gap: ^3.0.1
|
||||
dio: ^5.5.0+1
|
||||
dio: ^5.6.0
|
||||
intl: ^0.19.0
|
||||
shimmer: ^3.0.0
|
||||
latlong2: ^0.9.1
|
||||
|
@ -43,19 +43,17 @@ dependencies:
|
|||
lat_lng_to_timezone: ^0.2.0
|
||||
line_awesome_flutter: ^3.0.1
|
||||
dio_cache_interceptor: ^3.5.0
|
||||
flutter_map_animations: ^0.7.0
|
||||
flutter_map_animations: ^0.7.1
|
||||
flutter_hsvcolor_picker: ^1.5.1
|
||||
scrollable_positioned_list: ^0.3.8
|
||||
flutter_local_notifications: ^17.2.2
|
||||
material_floating_search_bar_2: ^0.5.0
|
||||
internet_connection_checker_plus: ^2.5.1
|
||||
dio_cache_interceptor_file_store: ^1.2.2
|
||||
flutter_map_cancellable_tile_provider: ^3.0.0
|
||||
isar:
|
||||
version: ^3.1.7
|
||||
version: ^3.1.8
|
||||
hosted: https://pub.isar-community.dev/
|
||||
isar_flutter_libs:
|
||||
version: ^3.1.7
|
||||
version: ^3.1.8
|
||||
hosted: https://pub.isar-community.dev/
|
||||
|
||||
# Uncomment this for publishing FLOSS variant
|
||||
|
@ -76,7 +74,7 @@ dev_dependencies:
|
|||
flutter_native_splash: ^2.4.1
|
||||
flutter_launcher_icons: ^0.13.1
|
||||
isar_generator:
|
||||
version: ^3.1.7
|
||||
version: ^3.1.8
|
||||
hosted: https://pub.isar-community.dev/
|
||||
|
||||
flutter_launcher_icons:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue