Exemplo n.º 1
0
        public DashboardPage()
        {
            AddReloadToolbarIcon();

            this.SetBinding(DashboardPage.MapPinsProperty, nameof(DashboardPageModel.MapPins));

            Device.BeginInvokeOnMainThread(async() =>
            {
                if (await CoordinateHelper.HasGeolocationAccess())
                {
                    CrossGeolocator.Current.PositionChanged += PositionChanged;
                    await InitializeMapCoordinates();
                }
            });

            InitializeNearPartyView();
            InitializeMyPartyView();
            InitializeHistoryPartyView();

            //Main layout
            var mainLayout = new Grid()
            {
                RowSpacing     = 0,
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                Children =
                {
                    new MapWrapper(_headerMap),
                    { _myPartiesContainer,      0, 2 },
                    { _interestingPartieContainer,0, 3 },
                    { _historyContainer,        0, 4 }
                }
            };

            var mainScroll = new ScrollView
            {
                Content     = mainLayout,
                Orientation = ScrollOrientation.Vertical
            };

            Content = mainScroll;
        }
Exemplo n.º 2
0
 private void SetupGeolocator()
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (await CoordinateHelper.HasGeolocationAccess())
         {
             await CrossGeolocator.Current.StartListeningAsync(50, 100);
             CrossGeolocator.Current.PositionChanged += CurrentOnPositionChanged;
         }
     });
 }
Exemplo n.º 3
0
        public MapWrapper(Map map)
        {
            _map          = map;
            HeightRequest = map.HeightRequest;
            // check if maps is avaible on device
            if (Device.OS == TargetPlatform.Android && !App.MapAvailable)
            {
                BackgroundColor = Color.Gray.MultiplyAlpha(0.6);
                Content         = new Label {
                    Text   = AppResources.MapsNotInstalled,
                    Margin = new Thickness(10)
                };
            }
            else
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    var locationAvailable            = await CoordinateHelper.HasGeolocationAccess();
                    var locationPermissionsAvailable = await
                                                       FreshIOC.Container.Resolve <IAlertService>().RequestLocationPermissions();


                    if (locationPermissionsAvailable && CrossGeolocator.Current.IsGeolocationEnabled)
                    {
                        map.IsShowingUser = locationAvailable;
                    }

                    if (locationAvailable)
                    {
                        Content = map;
                    }
                    else
                    {
                        Content = new Label
                        {
                            Text   = AppResources.LocationNotEnabled,
                            Margin = new Thickness(10)
                        };
                    }
                });
            }
        }