From e6190f9d7563e0f52b0fcd14a649c538e7bf41f1 Mon Sep 17 00:00:00 2001 From: Guilherme Galambas Date: Mon, 8 Jul 2024 16:12:50 +0100 Subject: [PATCH 1/3] snapshot to screenshot --- packages/atlas/CHANGELOG.md | 5 +++ packages/atlas/lib/atlas.dart | 2 +- packages/atlas/lib/src/atlas_controller.dart | 33 +++++++------------ .../{viewport_options.dart => viewpoint.dart} | 6 ++-- packages/atlas/pubspec.yaml | 2 +- 5 files changed, 21 insertions(+), 27 deletions(-) rename packages/atlas/lib/src/{viewport_options.dart => viewpoint.dart} (95%) diff --git a/packages/atlas/CHANGELOG.md b/packages/atlas/CHANGELOG.md index 9e2f44f..370de02 100644 --- a/packages/atlas/CHANGELOG.md +++ b/packages/atlas/CHANGELOG.md @@ -1,5 +1,10 @@ # atlas +## v3.0.0 (2024-06-01) + +- Merged `getScreenShot` and `takeSnapshot` methods of the `AtlasController` +- Renamed `ViewportOptions` to `Viewpoint` + ## v2.0.0 (2024-06-01) - Added support for `Snapshots` diff --git a/packages/atlas/lib/atlas.dart b/packages/atlas/lib/atlas.dart index c159767..ca0e0eb 100644 --- a/packages/atlas/lib/atlas.dart +++ b/packages/atlas/lib/atlas.dart @@ -32,4 +32,4 @@ export 'src/provider.dart'; export 'src/rectangle_2d.dart'; export 'src/screen_coordinate.dart'; export 'src/track_playback.dart'; -export 'src/viewport_options.dart'; +export 'src/viewpoint.dart'; diff --git a/packages/atlas/lib/src/atlas_controller.dart b/packages/atlas/lib/src/atlas_controller.dart index a630522..2574a2f 100644 --- a/packages/atlas/lib/src/atlas_controller.dart +++ b/packages/atlas/lib/src/atlas_controller.dart @@ -31,15 +31,18 @@ abstract class AtlasController { Future getVisibleArea(); /// Return a [Uint8List] to the screenshot of the specified range of the current screen - /// - /// [x] and [y] are the starting coordinates relative to the upper left corner [0, 0] - /// [width] is the width to be intercepted - /// [height] is the height to be intercepted Future getScreenShot({ - int x, - int y, - int width, - int height, + required BuildContext context, + required Size size, + required Viewpoint viewpoint, + MapType mapType = MapType.normal, + bool showUserLocation = false, + Set markers = const {}, + Set polylines = const {}, + Set callouts = const {}, + Set circles = const {}, + Heatmap? heatmap, + bool traffic = false, }); /// Updates the map's logo bottom padding @@ -68,18 +71,4 @@ abstract class AtlasController { /// Set the compass bearing of the map /// [bearing] is the value that the bearing will become Future setBearing(double bearing); - - Future takeSnapshot({ - required BuildContext context, - required Size size, - required ViewportOptions viewportOptions, - MapType mapType = MapType.normal, - bool showUserLocation = false, - Set markers = const {}, - Set polylines = const {}, - Set callouts = const {}, - Set circles = const {}, - Heatmap? heatmap, - bool traffic = false, - }); } diff --git a/packages/atlas/lib/src/viewport_options.dart b/packages/atlas/lib/src/viewpoint.dart similarity index 95% rename from packages/atlas/lib/src/viewport_options.dart rename to packages/atlas/lib/src/viewpoint.dart index 22ce1f7..62670f9 100644 --- a/packages/atlas/lib/src/viewport_options.dart +++ b/packages/atlas/lib/src/viewpoint.dart @@ -6,8 +6,8 @@ import 'package:flutter/widgets.dart'; /// /// Anchor and center points are mutually exclusive, with preference for the /// center point when both are set. -class ViewportOptions { - ViewportOptions({ +class Viewpoint { + Viewpoint({ this.center, this.padding, this.anchor, @@ -41,7 +41,7 @@ class ViewportOptions { bool operator ==(Object other) { if (identical(this, other)) return true; if (other.runtimeType != runtimeType) return false; - if (other is ViewportOptions) { + if (other is Viewpoint) { return center == other.center && padding == other.padding && anchor == other.anchor && diff --git a/packages/atlas/pubspec.yaml b/packages/atlas/pubspec.yaml index 53468f6..1036f89 100644 --- a/packages/atlas/pubspec.yaml +++ b/packages/atlas/pubspec.yaml @@ -1,6 +1,6 @@ name: atlas description: An extensible map abstraction for Flutter with support for multiple map providers -version: 2.0.0 +version: 3.0.0 repository: https://github.com/bmw-tech/atlas issue_tracker: https://github.com/bmw-tech/atlas/issues homepage: https://bmw-tech.github.io/atlas From dd366ad882a7d3e86e141418ad33a233b4a567f0 Mon Sep 17 00:00:00 2001 From: Guilherme Galambas Date: Mon, 8 Jul 2024 16:56:34 +0100 Subject: [PATCH 2/3] added screenshot options --- packages/atlas/lib/atlas.dart | 2 +- packages/atlas/lib/src/atlas_controller.dart | 13 +++-------- .../src/screen_shot/screen_shot_options.dart | 23 +++++++++++++++++++ .../lib/src/{ => screen_shot}/viewpoint.dart | 0 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 packages/atlas/lib/src/screen_shot/screen_shot_options.dart rename packages/atlas/lib/src/{ => screen_shot}/viewpoint.dart (100%) diff --git a/packages/atlas/lib/atlas.dart b/packages/atlas/lib/atlas.dart index ca0e0eb..b71d645 100644 --- a/packages/atlas/lib/atlas.dart +++ b/packages/atlas/lib/atlas.dart @@ -31,5 +31,5 @@ export 'src/polyline.dart'; export 'src/provider.dart'; export 'src/rectangle_2d.dart'; export 'src/screen_coordinate.dart'; +export 'src/screen_shot/viewpoint.dart'; export 'src/track_playback.dart'; -export 'src/viewpoint.dart'; diff --git a/packages/atlas/lib/src/atlas_controller.dart b/packages/atlas/lib/src/atlas_controller.dart index 2574a2f..552e2a8 100644 --- a/packages/atlas/lib/src/atlas_controller.dart +++ b/packages/atlas/lib/src/atlas_controller.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:atlas/atlas.dart'; +import 'package:atlas/src/screen_shot/screen_shot_options.dart'; import 'package:flutter/widgets.dart'; /// `AtlasController` allows developers to manipulate `Atlas` after the map has been initialized. @@ -32,17 +33,9 @@ abstract class AtlasController { /// Return a [Uint8List] to the screenshot of the specified range of the current screen Future getScreenShot({ - required BuildContext context, - required Size size, required Viewpoint viewpoint, - MapType mapType = MapType.normal, - bool showUserLocation = false, - Set markers = const {}, - Set polylines = const {}, - Set callouts = const {}, - Set circles = const {}, - Heatmap? heatmap, - bool traffic = false, + required Size size, + ScreenShotOptions? options, }); /// Updates the map's logo bottom padding diff --git a/packages/atlas/lib/src/screen_shot/screen_shot_options.dart b/packages/atlas/lib/src/screen_shot/screen_shot_options.dart new file mode 100644 index 0000000..84d6643 --- /dev/null +++ b/packages/atlas/lib/src/screen_shot/screen_shot_options.dart @@ -0,0 +1,23 @@ +import 'package:atlas/atlas.dart'; + +class ScreenShotOptions { + final MapType mapType; + final bool showUserLocation; + final Set markers; + final Set polylines; + final Set callouts; + final Set circles; + final Heatmap? heatmap; + final bool traffic; + + ScreenShotOptions({ + this.mapType = MapType.normal, + this.showUserLocation = false, + this.markers = const {}, + this.polylines = const {}, + this.callouts = const {}, + this.circles = const {}, + this.heatmap, + this.traffic = false, + }); +} diff --git a/packages/atlas/lib/src/viewpoint.dart b/packages/atlas/lib/src/screen_shot/viewpoint.dart similarity index 100% rename from packages/atlas/lib/src/viewpoint.dart rename to packages/atlas/lib/src/screen_shot/viewpoint.dart From b9dae16f6d5e8cd94c7e812cbe9e8fe3ac5135e6 Mon Sep 17 00:00:00 2001 From: Guilherme Galambas Date: Mon, 8 Jul 2024 16:57:46 +0100 Subject: [PATCH 3/3] fixed import --- packages/atlas/lib/atlas.dart | 1 + packages/atlas/lib/src/atlas_controller.dart | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/atlas/lib/atlas.dart b/packages/atlas/lib/atlas.dart index b71d645..ddca988 100644 --- a/packages/atlas/lib/atlas.dart +++ b/packages/atlas/lib/atlas.dart @@ -31,5 +31,6 @@ export 'src/polyline.dart'; export 'src/provider.dart'; export 'src/rectangle_2d.dart'; export 'src/screen_coordinate.dart'; +export 'src/screen_shot/screen_shot_options.dart'; export 'src/screen_shot/viewpoint.dart'; export 'src/track_playback.dart'; diff --git a/packages/atlas/lib/src/atlas_controller.dart b/packages/atlas/lib/src/atlas_controller.dart index 552e2a8..fcbee07 100644 --- a/packages/atlas/lib/src/atlas_controller.dart +++ b/packages/atlas/lib/src/atlas_controller.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:atlas/atlas.dart'; -import 'package:atlas/src/screen_shot/screen_shot_options.dart'; import 'package:flutter/widgets.dart'; /// `AtlasController` allows developers to manipulate `Atlas` after the map has been initialized.