Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v11.x.y enhance window build #13

Merged
merged 7 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ jobs:
if: ${{ inputs.SHOULD_RUN }}
steps:
- uses: actions/checkout@v3
- name: Set default Xamarin SDK versions
run: |
$VM_ASSETS/select-xamarin-sdk-v2.sh --mono=6.12 --android=13.0


- name: Set .netrc
run: |
echo $NETRC >> ~/.netrc
Expand All @@ -26,18 +23,48 @@ jobs:
env:
NETRC : ${{secrets.NETRC}}

- name: Setup .NET Core SDK 7.0.306
- name: Setup .NET Core SDK 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.306'
dotnet-version: '8.0'

- name: Install ios workload
run: |
dotnet workload install ios android maui maui-ios maui-android

- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: '17'

- name: Xcode Select Version
uses: mobiledevops/xcode-select-version-action@v1
with:
xcode-select-version: 15.1

- name: Set MAPBOX_DOWNLOADS_TOKEN
if: contains(${{ inputs.LIB_ARTIFACT }}, 'com.mapbox.maps')
run: |
echo "MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOADS_TOKEN" >> ~/.gradle/gradle.properties
cat ~/.gradle/gradle.properties
shell: bash
env:
MAPBOX_DOWNLOADS_TOKEN : ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}

- name: Create MauiProgram.dev.cs
run: |
cp src/qs/MapboxMauiQs/MauiProgram.dev.cs.example src/qs/MapboxMauiQs/MauiProgram.dev.cs

# - name: Create MapboxMauiQs.props
# run: |
# echo "${{ secrets.PROJECT_PROPS }}" > src/qs/MapboxMauiQs/MapboxMauiQs.props

- name: Build
run: |
sh build.sh
env:
MAPBOX_DOWNLOADS_TOKEN : ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}

- name: Publish NuGet and symbols
id: nuget-push
Expand Down
7 changes: 6 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
dotnet nuget locals -c all
dotnet pack -c Release -t:Clean,Rebuild src/libs/Mapbox.Maui/Mapbox.Maui.csproj --output $PWD/nugets

# Build to trigger gradle process
dotnet build -t:Clean,Rebuild src/qs/MapboxMauiQs/MapboxMauiQs.csproj \
-property:MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOADS_TOKEN

dotnet pack -c Release -t:Clean,Rebuild mapbox-maui.sln --output $PWD/nugets
4 changes: 2 additions & 2 deletions src/libs/Mapbox.Maui/IMapboxView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial interface IMapboxView : IView
{
CameraOptions CameraOptions { get; set; }
MapboxStyle MapboxStyle { get; set; }
Point? MapCenter { get; set; }
IPosition MapCenter { get; set; }
float? MapZoom { get; set; }

OrnamentVisibility ScaleBarVisibility { get; set; }
Expand Down Expand Up @@ -58,7 +58,7 @@ public interface IAnnotationController

public interface IMapFeatureQueryable
{
Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options);
Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options);
}

public class MapTappedEventArgs : EventArgs
Expand Down
5 changes: 4 additions & 1 deletion src/libs/Mapbox.Maui/Mapbox.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Target Name="_CleanAarOutputPath" AfterTargets="_CreateAar" BeforeTargets="_IncludeAarInNuGetPackage">
<Delete Files="$(_AarOutputPath)" />
</Target>

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;</TargetFrameworks>
Expand Down Expand Up @@ -44,7 +47,7 @@
<RepositoryUrl>https://github.com/tuyen-vuduc/mapbox-maui</RepositoryUrl>
<PackageProjectUrl>https://mapbox.tuyen-vuduc.tech</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageVersion>11.3.0-alpha01</PackageVersion>
<PackageVersion>11.3.0-alpha02</PackageVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>tv-mapbox.png</PackageIcon>
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Mapbox.Maui/MapboxView.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public ICommand MapLoadedCommand

public class MapTappedPosition
{
public Point ScreenPosition { get; set; }
public ScreenPosition ScreenPosition { get; set; }

public GeoJSON.Text.Geometry.Point Point { get; set; }
}
Expand Down
12 changes: 6 additions & 6 deletions src/libs/Mapbox.Maui/MapboxView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public CameraOptions CameraOptions

public static readonly BindableProperty MapCenterProperty = BindableProperty.Create(
nameof(MapCenter),
typeof(Point?),
typeof(IPosition),
typeof(MapboxView),
default(Point?)
default(IPosition)
);
public Point? MapCenter
public IPosition MapCenter
{
get => CameraOptions.Center;
set => CameraOptions = CameraOptions with
Expand All @@ -149,11 +149,11 @@ public Thickness? MapPadding

public static readonly BindableProperty MapAnchorProperty = BindableProperty.Create(
nameof(MapAnchor),
typeof(Point?),
typeof(ScreenPosition?),
typeof(MapboxView),
default(Point?)
default(ScreenPosition?)
);
public Point? MapAnchor
public ScreenPosition? MapAnchor
{
get => CameraOptions.Anchor;
set => CameraOptions = CameraOptions with
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Mapbox.Maui/Models/CameraOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public record struct CameraOptions
{
public Point? Center { get; set; }
public IPosition Center { get; set; }
public Thickness? Padding { get; set; }
public Point? Anchor { get; set; }
public ScreenPosition? Anchor { get; set; }
public float? Zoom { get; set; }
public float? Bearing { get; set; }
public float? Pitch { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ public static MapboxMapsCameraOptions ToNative(this CameraOptions cameraOptions)
{
var cameraOptionsBuilder = new MapboxMapsCameraOptions.Builder();

if (cameraOptions.Center.HasValue)
if (cameraOptions.Center is not null)
{
cameraOptionsBuilder.Center(
Com.Mapbox.Geojson.Point.FromLngLat(
cameraOptions.Center.Value.Y,
cameraOptions.Center.Value.X
cameraOptions.Center.Longitude,
cameraOptions.Center.Latitude
));
}

Expand Down Expand Up @@ -345,7 +345,7 @@ public static MapboxMapsCameraOptions ToNative(this CameraOptions cameraOptions)
));
}

if (cameraOptions.Anchor.HasValue)
if (cameraOptions.Anchor is not null)
{
cameraOptionsBuilder.Anchor(new ScreenCoordinate(
cameraOptions.Anchor.Value.X,
Expand Down
11 changes: 5 additions & 6 deletions src/libs/Mapbox.Maui/Platforms/Android/GeometryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ internal static MapTappedPosition ToMapTappedPosition(this Com.Mapbox.Geojson.Po
{
return new MapTappedPosition
{
ScreenPosition = new Point(
ScreenPosition = new ScreenPosition(
screenCoordinate.GetX().PixelToPoint(),
screenCoordinate.GetY().PixelToPoint()),
Point = new GeoJSON.Text.Geometry.Point(
new GeoJSON.Text.Geometry.Position(
point.Latitude(),
point.Longitude(),
point.HasAltitude ? point.Altitude() : null
new Position(
screenCoordinate.GetX().PixelToPoint(),
screenCoordinate.GetY().PixelToPoint(),
point.HasAltitude ? point.Altitude() : null)
)
)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@

partial class MapboxViewHandler : IMapFeatureQueryable
{
public Task<IEnumerable<XQueriedFeature>> QueryRenderedFeaturesWith(Point point, XRenderedQueryOptions options)
public Task<IEnumerable<XQueriedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, XRenderedQueryOptions options)
{
var mapView = PlatformView.GetMapView();
if (mapView == null) return Task.FromResult(
Array.Empty<XQueriedFeature>() as IEnumerable<XQueriedFeature>
);

var tcs = new TaskCompletionSource<IEnumerable<XQueriedFeature>>();
var pixel = mapView.MapboxMap.PixelForCoordinate(
Com.Mapbox.Geojson.Point.FromLngLat(point.Y, point.X)
);
_ = mapView.MapboxMap.QueryRenderedFeatures(
new RenderedQueryGeometry(
new ScreenBox(
new ScreenCoordinate(pixel.GetX() - 25.0, pixel.GetY() - 25.0),
new ScreenCoordinate(pixel.GetX() + 25.0, pixel.GetY() + 25.0)
new ScreenCoordinate(point.X - 25.0, point.Y - 25.0),
new ScreenCoordinate(point.X + 25.0, point.Y + 25.0)
)
),
options.ToPlatform(),
Expand Down
8 changes: 5 additions & 3 deletions src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ public static IList<MBMMapDebugOptions> ToNative(this IEnumerable<DebugOption> o

public static TMBCameraOptions ToNative(this CameraOptions cameraOptions)
{
CLLocationCoordinate2D center = cameraOptions.Center.HasValue
? new CLLocationCoordinate2D(cameraOptions.Center.Value.X, cameraOptions.Center.Value.Y)
CLLocationCoordinate2D center = cameraOptions.Center is not null
? new CLLocationCoordinate2D(
cameraOptions.Center.Latitude,
cameraOptions.Center.Longitude)
: new CLLocationCoordinate2D(0, 0);
UIKit.UIEdgeInsets padding = cameraOptions.Padding.HasValue
? new UIKit.UIEdgeInsets(
Expand All @@ -276,7 +278,7 @@ public static TMBCameraOptions ToNative(this CameraOptions cameraOptions)
(float)cameraOptions.Padding.Value.Bottom,
(float)cameraOptions.Padding.Value.Right)
: UIKit.UIEdgeInsets.Zero;
var anchor = cameraOptions.Anchor.HasValue
var anchor = cameraOptions.Anchor is not null
? new CoreGraphics.CGPoint(
cameraOptions.Anchor.Value.X,
cameraOptions.Anchor.Value.Y
Expand Down
7 changes: 2 additions & 5 deletions src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using CoreGraphics;
using CoreLocation;
using Foundation;
using GeoJSON.Text.Feature;
using GeoJSON.Text.Geometry;
using MapboxCommon;
using MapboxCoreMaps;
using MapboxMapsObjC;

namespace MapboxMaui;
Expand All @@ -15,12 +12,12 @@ internal static MapTappedPosition ToMapTappedPosition(this CLLocationCoordinate2
{
return new MapTappedPosition
{
ScreenPosition = new Microsoft.Maui.Graphics.Point(
ScreenPosition = new ScreenPosition(
screenCoordinate.X,
screenCoordinate.Y
),
Point = new GeoJSON.Text.Geometry.Point(
new GeoJSON.Text.Geometry.Position(
new Position(
coords.Latitude,
coords.Longitude
)
Expand Down
6 changes: 4 additions & 2 deletions src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
using MapboxMaui.Query;
using MapboxMapsObjC;
using Foundation;
using CoreGraphics;

partial class MapboxViewHandler : IMapFeatureQueryable
{
public Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options)
public Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options)
{
var mapView = PlatformView.MapView;
if (mapView == null) return Task.FromResult(
Expand All @@ -15,7 +16,8 @@ public Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(Point

var tcs = new TaskCompletionSource<IEnumerable<QueriedRenderedFeature>>();

_ = mapView.MapboxMap().QueryRenderedFeaturesWithPoint(point, options.ToPlatform(), (features, error) => {
var xpoint = new CGPoint(point.X, point.Y);
_ = mapView.MapboxMap().QueryRenderedFeaturesWithPoint(xpoint, options.ToPlatform(), (features, error) => {
if (error != null) {
tcs.TrySetException(new NSErrorException(error));
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
global using System;
global using System.Text.Json;
global using System.Text.Json;
global using GeoJSON.Text;
global using GeoJSON.Text.Feature;
global using GeoJSON.Text.Geometry;
global using Point = Microsoft.Maui.Graphics.Point;
global using MapboxMaui;
global using MapboxMaui.Expressions;
global using MapboxMaui.Styles;
global using MapboxMaui.Offline;
global using MapboxMaui.Annotations;
global using iOSPage = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page;
global using iOSPage = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page;
global using ScreenPosition = Microsoft.Maui.Graphics.Point;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ApplyQueryAttributes(IDictionary<string, object> query)

private void Map_MapReady(object sender, EventArgs e)
{
var centerLocation = new Point(55.70651, 12.554729);
var centerLocation = new Position(55.70651, 12.554729);
var cameraOptions = new CameraOptions
{
Center = centerLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void Map_StyleLoaded(object sender, EventArgs e)
private void Map_MapReady(object sender, EventArgs e)
{
// Do any additional setup after loading the view.
var center = new Point(55.665957, 12.550343);
var center = new Position(55.665957, 12.550343);
var cameraOptions = new CameraOptions {
Center = center,
Zoom = 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static class Constants
MapboxView map;
IExampleInfo info;

private Point currentPosition = new Point(64.900932, -18.167040);
private IPosition currentPosition = new Position(64.900932, -18.167040);

public AnimatedMarkerExample()
{
Expand Down Expand Up @@ -66,9 +66,7 @@ private void Map_MapLoaded(object sender, EventArgs e)

// Create a GeoJSON data source.
var feature = new Feature(
new GeoJSON.Text.Geometry.Point(
new Position(currentPosition.X, currentPosition.Y)
)
new GeoJSON.Text.Geometry.Point(currentPosition)
);
var source = new GeoJSONSource(Constants.sourceId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mb="clr-namespace:MapboxMaui;assembly=Mapbox.Maui"
xmlns:mb="clr-namespace:MapboxMaui"
x:Class="MapboxMauiQs.BasicMapExample"
Title="BasicMapExample">
<mb:MapboxView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private void Map_MapReady(object sender, EventArgs e)
map.MapboxStyle = MapboxStyle.STANDARD;
map.CameraOptions = new CameraOptions
{
Center = new Point(21.028511, 105.804817),
Center = new Position(21.028511, 105.804817),
Zoom = 9,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void Map_StyleLoaded(object sender, EventArgs e)
layer,
};

var center = new Point(40.7135, -74.0066);
var center = new Position(40.7135, -74.0066);
var cameraOptions = new CameraOptions
{
Center = center,
Expand Down
Loading
Loading