Pārlūkot izejas kodu

Back navigation and some translations

master
Flo Smilari pirms 4 gadiem
vecāks
revīzija
7744544250

+ 7
- 3
Pages/AccountPage.razor Parādīt failu

@@ -1,8 +1,9 @@
@page "/account"
@page "/account/{FromRoute}"
@page "/fundvelo/account/{FromRoute}"
@inject NavigationManager NavigationManager
@inject UserDataProvider UserDataProvider
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="row no-gutters align-items-start w-100">
@@ -64,6 +65,8 @@
public string FromRoute { get; set; }
protected async override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
await GetUserData();
}
@@ -85,15 +88,16 @@
private void Next() {
if ("Found".Equals(FromRoute)) {
NavigationManager.NavigateTo("conclusion_found/");
NavigationManager.NavigateTo("fundvelo/conclusion_found");
} else {
NavigationManager.NavigateTo("conclusion_missing/");
NavigationManager.NavigateTo("fundvelo/conclusion_missing");
}
}
private void Cancel() {
NavigationManager.NavigateTo("caritas_services");
}
}

+ 8
- 1
Pages/CaritasServiceFundVeloFoundConclusion.razor Parādīt failu

@@ -1,6 +1,7 @@
@page "/conclusion_found"
@page "/fundvelo/conclusion_found"
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="row no-gutters align-items-start justify-content-center w-100">
@@ -26,6 +27,12 @@
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
private void Finished() {
NavigationManager.NavigateTo("caritas_services");
}

+ 13
- 7
Pages/CaritasServiceFundVeloKeyDataPage.razor Parādīt failu

@@ -1,6 +1,7 @@
@page "/keydata/{FromRoute}"
@page "/fundvelo/keydata/{FromRoute}"
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="row no-gutters align-items-center justify-content-center w-100" style="padding-top:1em">
@@ -112,10 +113,15 @@
public string FromRoute { get; set; }
string value;
ColorItem selectedColor;
private ColorItem selectedColor;
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
private void Next() {
NavigationManager.NavigateTo("account/" + @FromRoute);
NavigationManager.NavigateTo("fundvelo/account/" + @FromRoute);
}
private void Cancel() {
@@ -123,13 +129,13 @@
}
ColorItem[] colorItems = new[] {
private ColorItem[] colorItems = new[] {
new ColorItem(3, "Blue","0,0,255"),
new ColorItem(14, "Brown", "165,42,42"),
new ColorItem(4, "Yellow", "255, 255, 0"),
};
class ColorItem {
private class ColorItem {
public int Index { get; }
public string Name { get; }
public string RGB { get; }
@@ -141,11 +147,11 @@
}
}
string getAddressLbl() {
private string getAddressLbl() {
return i18n.GetString("Address") + " (" + getPlaceLbl() + ")";
}
string getPlaceLbl() {
private string getPlaceLbl() {
return @FromRoute == "Found" ? i18n.GetString("PlaceOfDiscovery") : i18n.GetString("PlaceOfLoss");
}

+ 9
- 3
Pages/CaritasServiceFundVeloLostFoundPage.razor Parādīt failu

@@ -1,5 +1,6 @@
@page "/lost_found"
@page "/fundvelo/lost_found"
@inject NavigationManager NavigationManager
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="row no-gutters align-items-center w-100">
@@ -35,11 +36,16 @@
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
private void Found() {
NavigationManager.NavigateTo("keydata/Found");
NavigationManager.NavigateTo("fundvelo/keydata/Found");
}
private void Missing() {
NavigationManager.NavigateTo("keydata/Missing");
NavigationManager.NavigateTo("fundvelo/keydata/Missing");
}
}

+ 7
- 1
Pages/CaritasServiceFundVeloMissingConclusion.razor Parādīt failu

@@ -1,6 +1,7 @@
@page "/conclusion_missing"
@page "/fundvelo/conclusion_missing"
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="row no-gutters align-items-start justify-content-center w-100">
@@ -19,6 +20,11 @@
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
private void Finished() {
NavigationManager.NavigateTo("caritas_services");
}

+ 10
- 4
Pages/CaritasServicesPage.razor Parādīt failu

@@ -1,6 +1,6 @@
@page "/caritas_services"
@inject NavigationManager NavigationManager
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="row no-gutters align-items-center w-100">
@@ -24,7 +24,7 @@
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-2-phone mat-layout-grid-cell-span-3-tablet mat-layout-grid-cell-span-4-desktop">
<MatCard class="demo-mat-card">
<MatCardContent>
<MatCardMedia Square="true" ImageUrl="./images/batch_fundvelo.png" @onclick="Next"></MatCardMedia>
<MatCardMedia Square="true" ImageUrl="./images/batch_fundvelo.png" @onclick="FundVelo_LostFound"></MatCardMedia>
</MatCardContent>
</MatCard>
</div>
@@ -36,8 +36,14 @@
@code {
private void Next() {
NavigationManager.NavigateTo("lost_found");
protected override void OnInitialized() {
PageHistoryManager.Reset();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
private void FundVelo_LostFound() {
NavigationManager.NavigateTo("fundvelo/lost_found");
}
}

+ 9
- 1
Pages/IndexPage.razor Parādīt failu

@@ -2,6 +2,8 @@
@inject NavigationManager NavigationManager;
@inject AppState AppState;
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
<div class="row h-100 justify-content-center">
<div class="row d-flex align-items-center justify-content-center px-4 w-100">
@@ -21,7 +23,13 @@
@code {
void ButtonClicked() {
protected override void OnInitialized() {
PageHistoryManager.Reset();
base.OnInitialized();
}
private void ButtonClicked() {
NavigationManager.NavigateTo("./caritas_services");
AppState.LoggedIn = true;
}

+ 7
- 1
Pages/InfoPage.razor Parādīt failu

@@ -1,6 +1,7 @@
@page "/info"
@inject NavigationManager NavigationManager;
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
<div class="row px-3 h-100">
<div class="text-center w-100">
@@ -34,7 +35,7 @@
</tr>
<tr>
<td class="text-right">
<img src="./images/integrate_logo.png" style="max-width:200px"/>
<img src="./images/integrate_logo.png" style="max-width:200px" />
</td>
</tr>
<tr>
@@ -54,6 +55,11 @@
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
private void ShowCaritasWebpage() {
NavigationManager.NavigateTo("http://www.caritas.ch");
}

+ 3
- 2
Program.cs Parādīt failu

@@ -16,10 +16,11 @@ namespace CaritasPWA {
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddMatBlazor();
builder.Services.AddSingleton<AppState>();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped<UserDataProvider>();
builder.Services.AddSingleton<AppState>();
builder.Services.AddSingleton<PageHistoryManager>();
builder.Services.AddLocalization();
await builder.Build().RunAsync();

+ 50
- 24
Shared/NavMenu.razor Parādīt failu

@@ -1,19 +1,25 @@
@inject AppState AppState;
@inject NavigationManager NavigationManager;
@inject IStringLocalizer<Resources> i18n
@inject IJSRuntime jsRuntime;
@inject PageHistoryManager PageHistoryManager;
@implements IDisposable;
@if (handleAppBarContainer()) {
@if (HandleAppBarContainer()) {
<div class="sidebar">
<MatAppBarContainer>
<MatAppBar Fixed="true">
<MatAppBarRow>
<MatAppBarSection>
<MatIconButton Icon="menu" OnClick="@((e) => ButtonClicked())"></MatIconButton>
<MatAppBarTitle>CaritasPWA</MatAppBarTitle>
@if (PageHistoryManager.CanGoBack()) {
<MatIconButton Icon="keyboard_backspace" OnClick="@((e) => ButtonBackClicked())" Disabled="@BackButtonDisabled()"></MatIconButton>
}
<MatAppBarTitle Style="padding-left:0px; font-size:90%; font-weight:500">@LocationUrl</MatAppBarTitle>
</MatAppBarSection>
<MatAppBarSection Align="@MatAppBarSectionAlign.End">
<NavLink class="text-white" href="http://www.caritas.ch" Align="@MatAppBarSectionAlign.End" Style="padding-right:1em">About</NavLink>
<MatAppBarSection align="@MatAppBarSectionAlign.End" Style="max-width:min-content">
<NavLink target="_blank" class="text-white small" href="https://www.caritas.ch" align="@MatAppBarSectionAlign.End" style="padding-right:1em">@i18n["Learnmore"]</NavLink>
</MatAppBarSection>
</MatAppBarRow>
</MatAppBar>
@@ -56,38 +62,53 @@
}
@code
{
bool Opened = false;
@code {
static int Index = 1;
private bool Opened = false;
void ButtonClicked() {
Opened = !Opened;
}
private static int Index = 1;
void ButtonClicked(int _Index) {
Index = _Index;
ButtonClicked();
if (_Index == 4) {
AppState.LoggedIn = false;
private string locUrl;
private string LocationUrl {
get => locUrl;
set {
locUrl = value;
StateHasChanged();
}
}
public void Dispose() {
AppState.OnChange -= StateHasChanged;
NavigationManager.LocationChanged -= LocationChanged;
}
protected override void OnInitialized() {
AppState.OnChange += StateHasChanged;
NavigationManager.LocationChanged += LocationChanged;
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
}
public void Dispose() {
AppState.OnChange -= StateHasChanged;
NavigationManager.LocationChanged -= LocationChanged;
private void ButtonClicked() {
Opened = !Opened;
}
private void ButtonClicked(int _Index) {
Index = _Index;
ButtonClicked();
if (_Index == 4) {
AppState.LoggedIn = false;
}
}
private void ButtonBackClicked() {
NavigationManager.NavigateTo(PageHistoryManager.GetPreviousPage());
}
void LocationChanged(object sender, LocationChangedEventArgs e) {
if (isInServicesUrl(e)) {
private void LocationChanged(object sender, LocationChangedEventArgs e) {
locUrl = i18n.GetString(e.Location.Replace(NavigationManager.BaseUri, ""));
if (IsInServicesUrl(e)) {
Index = 1;
} else if (e.Location.Contains("account")) {
Index = 2;
@@ -96,14 +117,15 @@
} else {
Index = 4;
}
StateHasChanged();
}
bool isInServicesUrl(LocationChangedEventArgs e) {
private bool IsInServicesUrl(LocationChangedEventArgs e) {
return (e.Location.Contains("caritas_services") || e.Location.Contains("lost_found") || e.Location.Contains("keydata")
|| e.Location.Contains("account/") || e.Location.Contains("conclusion_"));
}
bool handleAppBarContainer() {
private bool HandleAppBarContainer() {
string uri = NavigationManager.Uri;
string baseUri = NavigationManager.BaseUri;
string delta = uri.Replace(baseUri, "");
@@ -123,4 +145,8 @@
}
}
}
private bool BackButtonDisabled() {
return !PageHistoryManager.CanGoBack();
}
}

+ 40
- 0
Shared/PageHistoryManager.cs Parādīt failu

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CaritasPWA.Shared {
public class PageHistoryManager {
private List<string> previousPages;
public PageHistoryManager() {
previousPages = new List<string>();
}
public void Reset() {
previousPages.Clear();
}
public void AddPageToHistory(string pageName) {
previousPages.Add(pageName);
}
public string GetPreviousPage() {
if (CanGoBack()) {
// 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);
previousPages.RemoveAt(previousPages.Count - 1);
return previousPage;
}
// Can't go back because you didn't navigate enough
return previousPages.FirstOrDefault();
}
public bool CanGoBack() {
return previousPages.Count > 1;
}
}
}

+ 72
- 0
Shared/ResourceFiles/Resources.Designer.cs Parādīt failu

@@ -105,6 +105,15 @@ namespace CaritasPWA.Shared.ResourceFiles {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Caritas Services ähnelt.
/// </summary>
public static string caritas_services {
get {
return ResourceManager.GetString("caritas_services", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Caritas Services ähnelt.
/// </summary>
@@ -222,6 +231,69 @@ namespace CaritasPWA.Shared.ResourceFiles {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle &gt; Found &gt; Founder data ähnelt.
/// </summary>
public static string fundvelo_account_Found {
get {
return ResourceManager.GetString("fundvelo/account/Found", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle &gt; Missing &gt; Reporter data ähnelt.
/// </summary>
public static string fundvelo_account_Missing {
get {
return ResourceManager.GetString("fundvelo/account/Missing", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle &gt; Found &gt; Confirmation ähnelt.
/// </summary>
public static string fundvelo_conclusion_found {
get {
return ResourceManager.GetString("fundvelo/conclusion_found", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle &gt; Missing &gt; Confirmation ähnelt.
/// </summary>
public static string fundvelo_conclusion_missing {
get {
return ResourceManager.GetString("fundvelo/conclusion_missing", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle &gt; Found &gt;Data ähnelt.
/// </summary>
public static string fundvelo_keydata_Found {
get {
return ResourceManager.GetString("fundvelo/keydata/Found", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle &gt; Missing &gt;Data ähnelt.
/// </summary>
public static string fundvelo_keydata_Missing {
get {
return ResourceManager.GetString("fundvelo/keydata/Missing", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bicycle ähnelt.
/// </summary>
public static string fundvelo_lost_found {
get {
return ResourceManager.GetString("fundvelo/lost_found", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Info ähnelt.
/// </summary>

+ 24
- 0
Shared/ResourceFiles/Resources.de.resx Parādīt failu

@@ -135,6 +135,9 @@
<data name="CaritasServices" xml:space="preserve">
<value>Caritas Dienste</value>
</data>
<data name="caritas_services" xml:space="preserve">
<value>Caritas Dienste</value>
</data>
<data name="City" xml:space="preserve">
<value>Ort</value>
</data>
@@ -171,6 +174,27 @@
<data name="FoundBike" xml:space="preserve">
<value>Gefundenes Velo</value>
</data>
<data name="fundvelo/account/Found" xml:space="preserve">
<value>Fundvelo &gt; Gefunden &gt; Finderdaten</value>
</data>
<data name="fundvelo/account/Missing" xml:space="preserve">
<value>Fundvelo &gt; Vermisst &gt; Melderdaten</value>
</data>
<data name="fundvelo/conclusion_found" xml:space="preserve">
<value>Fundvelo &gt; Gefunden &gt; Bestätigung</value>
</data>
<data name="fundvelo/conclusion_missing" xml:space="preserve">
<value>Fundvelo &gt; Vermisst &gt; Bestätigung</value>
</data>
<data name="fundvelo/keydata/Found" xml:space="preserve">
<value>Fundvelo &gt; Gefunden &gt; Daten</value>
</data>
<data name="fundvelo/keydata/Missing" xml:space="preserve">
<value>Fundvelo &gt; Vermisst &gt; Daten</value>
</data>
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Fundvelo</value>
</data>
<data name="Info" xml:space="preserve">
<value>Info</value>
</data>

+ 24
- 0
Shared/ResourceFiles/Resources.fr.resx Parādīt failu

@@ -135,6 +135,9 @@
<data name="CaritasServices" xml:space="preserve">
<value>Services Caritas</value>
</data>
<data name="caritas_services" xml:space="preserve">
<value>Services Caritas</value>
</data>
<data name="City" xml:space="preserve">
<value>Ville</value>
</data>
@@ -171,6 +174,27 @@
<data name="FoundBike" xml:space="preserve">
<value>Velo trouvè</value>
</data>
<data name="fundvelo/account/Found" xml:space="preserve">
<value>Velo &gt;Trouvé &gt; Data trouver</value>
</data>
<data name="fundvelo/account/Missing" xml:space="preserve">
<value>Velo &gt;Perdue &gt; Data trouver</value>
</data>
<data name="fundvelo/conclusion_found" xml:space="preserve">
<value>Velo &gt;Trouvé &gt; Confirmation</value>
</data>
<data name="fundvelo/conclusion_missing" xml:space="preserve">
<value>Velo &gt;Perdue &gt; Data trouver</value>
</data>
<data name="fundvelo/keydata/Found" xml:space="preserve">
<value>Velo &gt;Trouvé &gt; Data</value>
</data>
<data name="fundvelo/keydata/Missing" xml:space="preserve">
<value>Velo &gt;Perdue &gt; Data</value>
</data>
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Velo</value>
</data>
<data name="Info" xml:space="preserve">
<value>Information</value>
</data>

+ 25
- 1
Shared/ResourceFiles/Resources.it.resx Parādīt failu

@@ -135,6 +135,9 @@
<data name="CaritasServices" xml:space="preserve">
<value>Servizi Caritas</value>
</data>
<data name="caritas_services" xml:space="preserve">
<value>Servizi Caritas</value>
</data>
<data name="City" xml:space="preserve">
<value>Città</value>
</data>
@@ -171,6 +174,27 @@
<data name="FoundBike" xml:space="preserve">
<value>Bicicletta trovata</value>
</data>
<data name="fundvelo/account/Found" xml:space="preserve">
<value>Bicicletta &gt; Trovata &gt; Dati trovatore</value>
</data>
<data name="fundvelo/account/Missing" xml:space="preserve">
<value>Bicicletta &gt; Perduta &gt; Dati richiedente</value>
</data>
<data name="fundvelo/conclusion_found" xml:space="preserve">
<value>Bicicletta &gt; Trovata &gt; Conferma</value>
</data>
<data name="fundvelo/conclusion_missing" xml:space="preserve">
<value>Bicicletta &gt; Perduta &gt; Conferma</value>
</data>
<data name="fundvelo/keydata/Found" xml:space="preserve">
<value>Bicicletta &gt; Trovata &gt; Dati</value>
</data>
<data name="fundvelo/keydata/Missing" xml:space="preserve">
<value>Bicicletta &gt; Perduta &gt; Dati</value>
</data>
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Bicicletta</value>
</data>
<data name="Info" xml:space="preserve">
<value>Informazione</value>
</data>
@@ -181,7 +205,7 @@
<value>Latitudine</value>
</data>
<data name="Learnmore" xml:space="preserve">
<value>Per saperne di più</value>
<value>Saperne di più</value>
</data>
<data name="Login" xml:space="preserve">
<value>Avanti!</value>

+ 24
- 0
Shared/ResourceFiles/Resources.resx Parādīt failu

@@ -135,6 +135,9 @@
<data name="CaritasServices" xml:space="preserve">
<value>Caritas Services</value>
</data>
<data name="caritas_services" xml:space="preserve">
<value>Caritas Services</value>
</data>
<data name="City" xml:space="preserve">
<value>City</value>
</data>
@@ -171,6 +174,27 @@
<data name="FoundBike" xml:space="preserve">
<value>Found Bike</value>
</data>
<data name="fundvelo/account/Found" xml:space="preserve">
<value>Bicycle &gt; Found &gt; Founder data</value>
</data>
<data name="fundvelo/account/Missing" xml:space="preserve">
<value>Bicycle &gt; Missing &gt; Reporter data</value>
</data>
<data name="fundvelo/conclusion_found" xml:space="preserve">
<value>Bicycle &gt; Found &gt; Confirmation</value>
</data>
<data name="fundvelo/conclusion_missing" xml:space="preserve">
<value>Bicycle &gt; Missing &gt; Confirmation</value>
</data>
<data name="fundvelo/keydata/Found" xml:space="preserve">
<value>Bicycle &gt; Found &gt;Data</value>
</data>
<data name="fundvelo/keydata/Missing" xml:space="preserve">
<value>Bicycle &gt; Missing &gt;Data</value>
</data>
<data name="fundvelo/lost_found" xml:space="preserve">
<value>Bicycle</value>
</data>
<data name="Info" xml:space="preserve">
<value>Info</value>
</data>

Notiek ielāde…
Atcelt
Saglabāt