fix/refactor: IOS тоже члены общества!!! Не полноценные пока что но все-же. Теперь при нажатии по кнопке входа bottom sheet с условиями открывается сам.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@@ -26,10 +28,13 @@ Future<void> openLocationOnMap(
|
||||
double? zoom,
|
||||
}) async {
|
||||
final z = (zoom ?? 15).round();
|
||||
final geo = Uri.parse('geo:$latitude,$longitude?z=$z');
|
||||
if (await canLaunchUrl(geo)) {
|
||||
final ok = await launchUrl(geo, mode: LaunchMode.externalApplication);
|
||||
if (ok) return;
|
||||
for (final uri in _nativeMapUris(latitude, longitude, z)) {
|
||||
try {
|
||||
if (!await canLaunchUrl(uri)) continue;
|
||||
if (await launchUrl(uri, mode: LaunchMode.externalApplication)) return;
|
||||
} catch (_) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
await openExternalUrl(
|
||||
@@ -37,3 +42,16 @@ Future<void> openLocationOnMap(
|
||||
'https://yandex.ru/maps/?pt=$longitude,$latitude&z=$z&l=map',
|
||||
);
|
||||
}
|
||||
|
||||
List<Uri> _nativeMapUris(double latitude, double longitude, int zoom) {
|
||||
if (Platform.isIOS) {
|
||||
return [
|
||||
Uri.parse(
|
||||
'yandexmaps://maps.yandex.ru/'
|
||||
'?ll=$longitude,$latitude&z=$zoom&pt=$longitude,$latitude',
|
||||
),
|
||||
Uri.parse('maps://?ll=$latitude,$longitude&q=$latitude,$longitude'),
|
||||
];
|
||||
}
|
||||
return [Uri.parse('geo:$latitude,$longitude?z=$zoom')];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Rect shareOriginOf(BuildContext? context) {
|
||||
final box = context?.findRenderObject() as RenderBox?;
|
||||
if (box != null && box.hasSize && box.attached) {
|
||||
final rect = box.localToGlobal(Offset.zero) & box.size;
|
||||
if (!rect.isEmpty) return rect;
|
||||
}
|
||||
final view = WidgetsBinding.instance.platformDispatcher.views.first;
|
||||
final size = view.physicalSize / view.devicePixelRatio;
|
||||
return Rect.fromCenter(
|
||||
center: Offset(size.width / 2, size.height / 2),
|
||||
width: 1,
|
||||
height: 1,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user