Skip to content

Commit 1ecea89

Browse files
authored
multi: maplibre android 11.6.+, more tests, fix MapOptions.of(context) / MapOptions.maybeOf(context) (#129)
1 parent 59231f9 commit 1ecea89

21 files changed

+321
-25
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
# run: |
148148
# flutter drive \
149149
# --driver=test_driver/integration_test.dart \
150-
# --target=integration_test/smoke_test.dart \
150+
# --target=integration_test/main.dart \
151151
# -d web-server \
152152
# --release \
153153
# --browser-name=chrome

android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ android {
6565
}
6666

6767
dependencies {
68+
// noinspection GradleDynamicVersion
69+
implementation 'org.maplibre.gl:android-sdk:11.6.+' // JNIGEN
6870
// JNIGEN implementation project(":MapLibreAndroid")
6971
// JNIGEN implementation 'com.google.code.gson:gson:2.11.0'
70-
implementation 'org.maplibre.gl:android-sdk:11.6.0' // JNIGEN
7172
// JNIGEN implementation 'org.maplibre.gl:maplibre-android-gestures:0.0.3'
7273
// JNIGEN implementation 'org.maplibre.gl:android-sdk-geojson:6.0.1'
7374
// JNIGEN implementation 'org.maplibre.gl:android-sdk-turf:6.0.1'

codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ comment:
99

1010
ignore:
1111
- "**/*.g.dart"
12-
- "lib/src/platform/android/jni"
13-
- "example"
12+
- "lib/src/platform/android/jni/**"
13+
- "example/**"

jnigen.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ maven_downloads:
55
preamble: |
66
// Autogenerated by jnigen. DO NOT EDIT!
77
8-
// coverage:ignore-file
98
// ignore_for_file: public_member_api_docs
109
// ignore_for_file: require_trailing_commas
1110
// ignore_for_file: unnecessary_raw_strings
@@ -24,7 +23,7 @@ android_sdk_config:
2423
suspend_fun_to_async: true
2524
output:
2625
dart:
27-
path: 'lib/src/native/jni/'
26+
path: 'lib/src/platform/android/jni/'
2827
source_path:
2928
- 'android/src/main'
3029
classes:

lib/src/annotation/circle_annotation_layer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class CircleAnnotationLayer extends AnnotationLayer<Point> {
4848
'circle-radius': radius,
4949
'circle-color': color.toHexStringNoOpacity(),
5050
'circle-blur': blur,
51-
'circle-opacity': color.opacity,
51+
'circle-opacity': opacity,
5252
'circle-stroke-width': strokeWidth,
5353
'circle-stroke-color': strokeColor.toHexStringNoOpacity(),
54-
'circle-stroke-opacity': strokeColor.opacity,
54+
'circle-stroke-opacity': strokeOpacity,
5555
};
5656

5757
@override

lib/src/annotation/polygon_annotation_layer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PolygonAnnotationLayer extends AnnotationLayer<Polygon> {
2222
@override
2323
Map<String, Object> getPaint() => {
2424
'fill-color': color.toHexStringNoOpacity(),
25-
'fill-opacity': color.opacity,
25+
'fill-opacity': opacity,
2626
'fill-outline-color': outlineColor.toHexStringNoOpacity(),
2727
};
2828

lib/src/annotation/polyline_annotation_layer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PolylineAnnotationLayer extends AnnotationLayer<LineString> {
3535
@override
3636
Map<String, Object> getPaint() => {
3737
'line-color': color.toHexStringNoOpacity(),
38-
'line-opacity': color.opacity,
38+
'line-opacity': opacity,
3939
'line-width': width,
4040
'line-gap-width': gapWidth,
4141
if (dashArray case final List<int> dashArray)

lib/src/map_options.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class MapOptions {
3030

3131
/// Find the [MapOptions] of the closest [MapLibreMap] in the widget tree.
3232
/// Returns null if called outside of the [MapLibreMap.children].
33-
static MapController? maybeOf(BuildContext context) =>
34-
MapLibreInheritedModel.maybeMapControllerOf(context);
33+
static MapOptions? maybeOf(BuildContext context) =>
34+
MapLibreInheritedModel.maybeMapControllerOf(context)?.options;
3535

3636
/// Find the [MapOptions] of the closest [MapLibreMap] in the widget tree.
3737
/// Throws an [StateError] if called outside of the [MapLibreMap.children].
38-
static MapController of(BuildContext context) =>
38+
static MapOptions of(BuildContext context) =>
3939
maybeOf(context) ??
40-
(throw StateError('Unable to find an instance of MapController'));
40+
(throw StateError('Unable to find an instance of MapOptions'));
4141

4242
/// The style URL that should get used. If not set, the default MapLibre style
4343
/// is used (https://demotiles.maplibre.org/style.json).

test/annotation/annotation_manager_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:maplibre/maplibre.dart';
33
import 'package:maplibre/src/annotation/annotation_manager.dart';
44
import 'package:mocktail/mocktail.dart';
55

6-
import '../shared/ui_app.dart';
6+
import '../shared/mocks.dart';
77

88
class MockSource extends Mock implements Source {}
99

test/annotation/models_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ void main() {
2424
expect(o, isNot(equals(o2)));
2525
expect(o.hashCode, equals(o.hashCode));
2626
expect(o.hashCode, isNot(equals(o2.hashCode)));
27+
28+
expect(o.getSourceId(5123), contains(5123.toString()));
29+
expect(o.getLayerId(1532), contains(1532.toString()));
30+
expect(o.getLayout(), isA<Map<String, Object>>());
31+
expect(o.getPaint(), isA<Map<String, Object>>());
2732
});
2833
test('MarkerAnnotationLayer', () {
2934
final o = MarkerAnnotationLayer(
@@ -48,6 +53,11 @@ void main() {
4853
expect(o, isNot(equals(o2)));
4954
expect(o.hashCode, equals(o.hashCode));
5055
expect(o.hashCode, isNot(equals(o2.hashCode)));
56+
57+
expect(o.getSourceId(5123), contains(5123.toString()));
58+
expect(o.getLayerId(1532), contains(1532.toString()));
59+
expect(o.getLayout(), isA<Map<String, Object>>());
60+
expect(o.getPaint(), isA<Map<String, Object>>());
5161
});
5262
test('PolygonAnnotationLayer', () {
5363
final o = PolygonAnnotationLayer(
@@ -74,6 +84,11 @@ void main() {
7484
expect(o, isNot(equals(o2)));
7585
expect(o.hashCode, equals(o.hashCode));
7686
expect(o.hashCode, isNot(equals(o2.hashCode)));
87+
88+
expect(o.getSourceId(5123), contains(5123.toString()));
89+
expect(o.getLayerId(1532), contains(1532.toString()));
90+
expect(o.getLayout(), isA<Map<String, Object>>());
91+
expect(o.getPaint(), isA<Map<String, Object>>());
7792
});
7893
test('PolylineAnnotationLayer', () {
7994
final o = PolylineAnnotationLayer(
@@ -103,6 +118,11 @@ void main() {
103118
expect(o, isNot(equals(o2)));
104119
expect(o.hashCode, equals(o.hashCode));
105120
expect(o.hashCode, isNot(equals(o2.hashCode)));
121+
122+
expect(o.getSourceId(5123), contains(5123.toString()));
123+
expect(o.getLayerId(1532), contains(1532.toString()));
124+
expect(o.getLayout(), isA<Map<String, Object>>());
125+
expect(o.getPaint(), isA<Map<String, Object>>());
106126
});
107127
});
108128
}

0 commit comments

Comments
 (0)