Ejemplo n.º 1
0
        public DialogViewModel(ILocationService locationService, ITravelPanelService travelPanelService,
                               IStartButtonService startButtonService, ITrailService trailService)
        {
            _visible.Raise(true);
            _locationService    = locationService;
            _travelPanelService = travelPanelService;
            _startButtonService = startButtonService;
            _trailService       = trailService;

            var currentLocation = _locationService.CurrentLocation;


            var nearestPoint = _locationService.GetNearestPoint(currentLocation, _trailService.Points);

            if (_locationService.CheckPointIsNear(currentLocation, nearestPoint)) // user and point location
            {
                CanStart          = true;
                TrailStartCommand = new MvxCommand(StartTrail);
                TrailTitle        = "MOŻNA"; // here name of point
                TrailInfo         = "Możesz rozpocząć swoją wędrówkę!";
            }
            else
            {
                var distance = _locationService.GetDistanceBetweenTwoPointsOnMapInMeters(currentLocation, nearestPoint);
                CanStart   = false;
                TrailTitle = "NIE MOŻNA";                                                                                       //some function should be here, but idk how i want to do here
                TrailInfo  = "Najbliższy punkt to " + nearestPoint.Name + " oddalony o " + _locationService.Distance(distance); // name of nearest point
            }
            NearestPointCommand = new MvxCommand(ShowNearestPoint);
        }