Kaynağa Gözat

init map and device/bicycle postion on page show, enhanced navigation

master
Flo Smilari 4 yıl önce
ebeveyn
işleme
f22db98e0d

+ 1
- 1
Pages/AccountPage.razor Dosyayı Görüntüle

protected async override void OnInitialized() { protected async override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack); PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack);
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
Account = await GetUserData(); Account = await GetUserData();
if (!string.IsNullOrEmpty(FromRoute) && ReportDataProvider.Report != null) { if (!string.IsNullOrEmpty(FromRoute) && ReportDataProvider.Report != null) {
UserDataProvider.MapUserData(Account, ReportDataProvider.Report); UserDataProvider.MapUserData(Account, ReportDataProvider.Report);
} }
private void Next() { private void Next() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
if ("Found".Equals(FromRoute)) { if ("Found".Equals(FromRoute)) {
UserDataProvider.MapReport(ReportDataProvider.Report, Account); UserDataProvider.MapReport(ReportDataProvider.Report, Account);
NavigationManager.NavigateTo("fundvelo/conclusion_found"); NavigationManager.NavigateTo("fundvelo/conclusion_found");

+ 1
- 1
Pages/CaritasServicesPage.razor Dosyayı Görüntüle

protected override void OnInitialized() { protected override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.Reset(); PageHistoryManager.Reset();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
} }
private void FundVelo_LostFound() { private void FundVelo_LostFound() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
NavigationManager.NavigateTo("fundvelo/lost_found"); NavigationManager.NavigateTo("fundvelo/lost_found");
} }

+ 1
- 1
Pages/Fundvelo/CaritasServiceFundVeloAlternatePickupContactPage.razor Dosyayı Görüntüle

protected override void OnInitialized() { protected override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack); PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack);
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
refreshGUIFromDto(); refreshGUIFromDto();
StateHasChanged(); StateHasChanged();
} }
private void Next() { private void Next() {
updateDtoFromGUI(); updateDtoFromGUI();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
NavigationManager.NavigateTo("fundvelo/account/Found"); NavigationManager.NavigateTo("fundvelo/account/Found");
} }

+ 0
- 1
Pages/Fundvelo/CaritasServiceFundVeloFoundConclusion.razor Dosyayı Görüntüle

protected async override void OnInitialized() { protected async override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
try { try {
if (ReportDataProvider.ReportRepositoryItem != null) { if (ReportDataProvider.ReportRepositoryItem != null) {
response = await IBicycleRestService.SendFoundReport((FoundReportRepositoryItem)ReportDataProvider.ReportRepositoryItem); response = await IBicycleRestService.SendFoundReport((FoundReportRepositoryItem)ReportDataProvider.ReportRepositoryItem);

+ 11
- 4
Pages/Fundvelo/CaritasServiceFundVeloFoundKeyDataPage.razor Dosyayı Görüntüle

await GetBicycleTypes(); await GetBicycleTypes();
await GetBrands(); await GetBrands();
refreshGUIFromDto(); refreshGUIFromDto();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
OnlineStatusProvider.AddOnlineStatusChangeCallBack(OnOnlineStatusChanged); OnlineStatusProvider.AddOnlineStatusChangeCallBack(OnOnlineStatusChanged);
StateHasChanged(); StateHasChanged();
} }
private async void AfterRenderMap() { private async void AfterRenderMap() {
FoundReport report = ReportDataProvider.GetFoundReport(); FoundReport report = ReportDataProvider.GetFoundReport();
if (report.GeographicInfo.Latitude != 0 && report.GeographicInfo.Longitude != 0) {
MouseEvent mouseEvent = new MouseEvent();
LatLng coordinates;
LatLng devicePosition = await InitializeDeviceMapPosition();
if (report != null && report.GeographicInfo.Latitude != 0 && report.GeographicInfo.Longitude != 0) {
bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider); bicycleGeoPosition.DisplayCity = await GetFormattedAddressZipAndTown(ReportDataProvider);
LatLng coordinates = new LatLng(report.GeographicInfo.Latitude, report.GeographicInfo.Longitude);
MouseEvent mouseEvent = new MouseEvent();
coordinates = new LatLng(report.GeographicInfo.Latitude, report.GeographicInfo.Longitude);
mouseEvent.LatLng = coordinates; mouseEvent.LatLng = coordinates;
await InitializeBicycleMapPosition(); await InitializeBicycleMapPosition();
await AddBicycleMarkerOnClickPosition(mouseEvent); await AddBicycleMarkerOnClickPosition(mouseEvent);
StateHasChanged(); StateHasChanged();
} else { // Set bicycle postion equal to device position
coordinates = new LatLng(devicePosition.Lat, devicePosition.Lng);
mouseEvent.LatLng = coordinates;
await OnMouseMapClicked(mouseEvent);
} }
StateHasChanged();
} }
private Brand getBrand(Brand brand) { private Brand getBrand(Brand brand) {
private void Next() { private void Next() {
updateDtoFromGUI(); updateDtoFromGUI();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
if (abholadresseIsNotContact) { if (abholadresseIsNotContact) {
NavigationManager.NavigateTo("fundvelo/alternate_pickup"); NavigationManager.NavigateTo("fundvelo/alternate_pickup");
} else { } else {

+ 24
- 16
Pages/Fundvelo/CaritasServiceFundVeloFoundKeyDataPage.razor.cs Dosyayı Görüntüle

await this.mapRef.OnClick(async (MouseEvent mouseEvent) => await OnMouseMapClicked(mouseEvent)); await this.mapRef.OnClick(async (MouseEvent mouseEvent) => await OnMouseMapClicked(mouseEvent));
} }
protected async Task InitializeDeviceMapPosition() {
protected async Task<LatLng> InitializeDeviceMapPosition() {
CreateBicycleMarkerOptions(); CreateBicycleMarkerOptions();
await AddEventsToMap(); await AddEventsToMap();
await ShowDeviceGeoLocation();
return await ShowDeviceGeoLocation();
} }
protected async Task InitializeBicycleMapPosition() { protected async Task InitializeBicycleMapPosition() {
this.bicyclePositionMarker = await this.MarkerFactory.CreateAndAddToMap(mouseEvent.LatLng, this.mapRef, this.bicycleMarkerOptions); this.bicyclePositionMarker = await this.MarkerFactory.CreateAndAddToMap(mouseEvent.LatLng, this.mapRef, this.bicycleMarkerOptions);
} }
protected async Task<LatLng> GetDeviceGeoLocation() {
LatLng geoPosition;
BlazorGeolocationPosition position = await this.BlazorGeolocationService.GetPositionAsync();
if (position.ErrorCode != null) {
Toaster.ShowError(I18n.GetString("Error.GeoLocation.Title", position.ErrorCode), I18n.GetString("Error.GeoLocation.Msg", position.ErrorMessage));
geoPosition = new(0, 0);
} else {
geoPosition = new((double)position.Latitude, (double)position.Longitude);
}
return geoPosition;
}
private async void CreateBicycleMarkerOptions() { private async void CreateBicycleMarkerOptions() {
this.bicycleMarkerOptions = new MarkerOptions() { this.bicycleMarkerOptions = new MarkerOptions() {
IconRef = await this.IconFactory.Create(new IconOptions() { IconRef = await this.IconFactory.Create(new IconOptions() {
}; };
} }
private async Task ShowDeviceGeoLocation() {
BlazorGeolocationPosition position = await this.BlazorGeolocationService.GetPositionAsync();
if (position.ErrorCode != null) {
Toaster.ShowError(I18n.GetString("Error.GeoLocation.Title", position.ErrorCode), I18n.GetString("Error.GeoLocation.Msg", position.ErrorMessage));
} else {
LatLng geoPosition = new((double)position.Latitude, (double)position.Longitude);
if (this.devicePositionMarker != null) {
await devicePositionMarker.Remove();
}
this.devicePositionMarker = await this.MarkerFactory.CreateAndAddToMap(geoPosition, this.mapRef);
private async Task<LatLng> ShowDeviceGeoLocation() {
LatLng geoPosition = await GetDeviceGeoLocation();
await this.mapRef.SetZoom(16);
await this.mapRef.SetView(geoPosition);
if (this.devicePositionMarker != null) {
await devicePositionMarker.Remove();
} }
this.devicePositionMarker = await this.MarkerFactory.CreateAndAddToMap(geoPosition, this.mapRef);
await this.mapRef.SetZoom(16);
await this.mapRef.SetView(geoPosition);
return geoPosition;
} }
private async Task ShowBicycleGeoLocation() { private async Task ShowBicycleGeoLocation() {
return String.IsNullOrEmpty(postcode) ? "" : postcode.Split("-", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0]; return String.IsNullOrEmpty(postcode) ? "" : postcode.Split("-", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0];
} }
private async Task OnMouseMapClicked(MouseEvent mouseEvent) {
protected async Task OnMouseMapClicked(MouseEvent mouseEvent) {
await AddBicycleMarkerOnClickPosition(mouseEvent); await AddBicycleMarkerOnClickPosition(mouseEvent);
this.bicycleGeoPosition.Latitude = mouseEvent.LatLng.Lat; this.bicycleGeoPosition.Latitude = mouseEvent.LatLng.Lat;

+ 0
- 1
Pages/Fundvelo/CaritasServiceFundVeloHistoryPage.razor Dosyayı Görüntüle

protected override void OnInitialized() { protected override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
StateHasChanged(); StateHasChanged();
} }

+ 2
- 1
Pages/Fundvelo/CaritasServiceFundVeloLostFoundPage.razor Dosyayı Görüntüle

protected async override void OnInitialized() { protected async override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
ReportDataProvider.Report = null; ReportDataProvider.Report = null;
ReportDataProvider.ReportRepositoryItem = null; ReportDataProvider.ReportRepositoryItem = null;
StateHasChanged(); StateHasChanged();
Report report = new FoundReport(); Report report = new FoundReport();
UserDataProvider.MapReport(report, await UserDataProvider.Get()); UserDataProvider.MapReport(report, await UserDataProvider.Get());
ReportDataProvider.Report = report; ReportDataProvider.Report = report;
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
NavigationManager.NavigateTo("fundvelo/keydata/Found"); NavigationManager.NavigateTo("fundvelo/keydata/Found");
} }
Report report = new MissingReport(); Report report = new MissingReport();
UserDataProvider.MapReport(report, await UserDataProvider.Get()); UserDataProvider.MapReport(report, await UserDataProvider.Get());
ReportDataProvider.Report = report; ReportDataProvider.Report = report;
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
NavigationManager.NavigateTo("fundvelo/keydata/Missing"); NavigationManager.NavigateTo("fundvelo/keydata/Missing");
} }

+ 0
- 1
Pages/Fundvelo/CaritasServiceFundVeloMissingConclusion.razor Dosyayı Görüntüle

protected async override void OnInitialized() { protected async override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
try { try {
if (ReportDataProvider.ReportRepositoryItem != null) { if (ReportDataProvider.ReportRepositoryItem != null) {
response = await IBicycleRestService.SendMissingReport((MissingReportRepositoryItem)ReportDataProvider.ReportRepositoryItem); response = await IBicycleRestService.SendMissingReport((MissingReportRepositoryItem)ReportDataProvider.ReportRepositoryItem);

+ 1
- 1
Pages/Fundvelo/CaritasServiceFundVeloMissingKeyDataPage.razor Dosyayı Görüntüle

await GetBrands(); await GetBrands();
await GetSearchServices(); await GetSearchServices();
refreshGUIFromDto(); refreshGUIFromDto();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
StateHasChanged(); StateHasChanged();
} }
private void Next() { private void Next() {
updateDtoFromGUI(); updateDtoFromGUI();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
NavigationManager.NavigateTo("fundvelo/account/Missing"); NavigationManager.NavigateTo("fundvelo/account/Missing");
} }

+ 0
- 1
Pages/Fundvelo/CaritasServiceFundVeloPendingOverviewPage.razor Dosyayı Görüntüle

protected async override void OnInitialized() { protected async override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
pendingReports.AddRange(await ReportRepositoryService.GetPendingFoundReports()); pendingReports.AddRange(await ReportRepositoryService.GetPendingFoundReports());
pendingReports.AddRange(await ReportRepositoryService.GetPendingMissingReports()); pendingReports.AddRange(await ReportRepositoryService.GetPendingMissingReports());
StateHasChanged(); StateHasChanged();

+ 0
- 1
Pages/InfoPage.razor Dosyayı Görüntüle

protected override void OnInitialized() { protected override void OnInitialized() {
base.OnInitialized(); base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
version = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; version = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
} }

+ 1
- 1
Shared/NavMenu.razor Dosyayı Görüntüle

base.OnInitialized(); base.OnInitialized();
AppState.OnChange += StateHasChanged; AppState.OnChange += StateHasChanged;
NavigationManager.LocationChanged += LocationChanged; NavigationManager.LocationChanged += LocationChanged;
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
locUrl = I18n.GetString(NavigationManager.Uri.Replace(NavigationManager.BaseUri, "")); locUrl = I18n.GetString(NavigationManager.Uri.Replace(NavigationManager.BaseUri, ""));
StateHasChanged(); StateHasChanged();
} }
private void ButtonClicked(int _Index) { private void ButtonClicked(int _Index) {
index = _Index; index = _Index;
navSubMenuOpen = (index == 3 || index == 4); navSubMenuOpen = (index == 3 || index == 4);
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
StateHasChanged(); StateHasChanged();
ButtonClicked(); ButtonClicked();
} }

+ 2
- 3
Shared/Services/PageHistoryManager.cs Dosyayı Görüntüle

public string GetPreviousPage() { public string GetPreviousPage() {
if (CanGoBack()) { if (CanGoBack()) {
// You add a page on initialization, so you need to return the 2nd from the last // You add a page on initialization, so you need to return the 2nd from the last
string previousPage = previousPages.ElementAt(previousPages.Count - 2);
previousPages.RemoveAt(previousPages.Count - 1);
string previousPage = previousPages.ElementAt(previousPages.Count - 1);
previousPages.RemoveAt(previousPages.Count - 1); previousPages.RemoveAt(previousPages.Count - 1);
return previousPage; return previousPage;
} }
} }
public bool CanGoBack() { public bool CanGoBack() {
return previousPages.Count > 1;
return previousPages.Count >= 1;
} }
public async void NavigateBack() { public async void NavigateBack() {

+ 5
- 0
wwwroot/css/app.css Dosyayı Görüntüle

.mdc-nav-item.selected { .mdc-nav-item.selected {
background-color: var(--primary); background-color: var(--primary);
color: #fff !important; color: #fff !important;
}
.mat-drawer {
border-right-width: 0px;
width: var(--mat-drawer-custom-width, 300px);
} }

Loading…
İptal
Kaydet