瀏覽代碼

got rid of Twer, progress circle on image loading

master
Flo Smilari 4 年之前
父節點
當前提交
6d3e7e902c

+ 0
- 1
CaritasPWA.csproj 查看文件

<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.7" /> <PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.7" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" /> <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.1.0.21158" /> <PackageReference Include="Tewr.Blazor.FileReader" Version="3.1.0.21158" />
<PackageReference Include="Tewr.Blazor.FileReader.Wasm" Version="0.11.19128" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

+ 1
- 0
CaritasPWA.csproj.user 查看文件

</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ActiveDebugProfile>CaritasPWA</ActiveDebugProfile> <ActiveDebugProfile>CaritasPWA</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>D:\Work\Caritas\CaritasPWA\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

+ 1
- 1
Pages/AccountPage.razor 查看文件

<div class="row no-gutters align-items-start w-100"> <div class="row no-gutters align-items-start w-100">
<div class="row no-gutters align-items-center w-100" style="padding-top:2em"> <div class="row no-gutters align-items-center w-100" style="padding-top:2em">
<div class="col-12"> <div class="col-12">
<MatSelect Class="w-100" Label="@i18n["Salutation"]" Outlined="true" @bind-Value="@Account.Salutation">
<MatSelect Class="w-100" Label="@i18n["Salutation"]" Outlined="true" @bind-Value="@Account.Salutation" Style="margin-bottom: 0.5rem">
<MatOptionString Value="sir">@i18n["Man"]</MatOptionString> <MatOptionString Value="sir">@i18n["Man"]</MatOptionString>
<MatOptionString Value="madam">@i18n["Woman"]</MatOptionString> <MatOptionString Value="madam">@i18n["Woman"]</MatOptionString>
</MatSelect> </MatSelect>

+ 49
- 32
Pages/CaritasServiceFundVeloKeyDataPage.razor 查看文件

@inject MasterDataService MasterDataService @inject MasterDataService MasterDataService
@inject IMatToaster Toaster @inject IMatToaster Toaster
@*@using Tewr.Blazor.FileReader
@inject IFileReaderService fileReaderService;*@
<div class="row px-3 h-100"> <div class="row px-3 h-100">
<div class="row no-gutters align-items-center justify-content-center w-100" style="padding-top:1em"> <div class="row no-gutters align-items-center justify-content-center w-100" style="padding-top:1em">
<div class="mat-layout-grid-inner"> <div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-1 justify-content-center" style="text-align: center"> <div class="mat-layout-grid-cell mat-layout-grid-cell-span-1 justify-content-center" style="text-align: center">
<div> <div>
<InputFile class="inputFile" id="camera" type="file" name="camera" accept="image/*" capture="user" OnChange="@OnFileSelection" />
<InputFile class="inputFile" id="camera" type="file" name="camera" accept="image/*" capture="environment" OnChange="@OnGatheringPicture" />
<MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default"> <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default">
<label for="camera"> <label for="camera">
<svg xmlns="http://www.w3.org/2000/svg" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000"> <svg xmlns="http://www.w3.org/2000/svg" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000">
</MatRipple> </MatRipple>
</div> </div>
<div style="margin-top:1rem"> <div style="margin-top:1rem">
@*<input @ref="inputTypeFileElement" id="file" type="file" name="file" accept="image/x-png,image/jpeg,image/gif" class="inputFile" @onchange="ReadFile" />*@
<InputFile id="file" type="file" name="file" accept="image/x-png,image/jpeg,image/gif" class="inputFile" OnChange="@OnFileSelection" />
@* <input @ref="inputTypeFileElement" class="inputFile" id="file" type="file" name="file" accept="image/x-png,image/jpeg,image/gif" @onchange="ReadFile" />*@
<InputFile class="inputFile" id="file" type="file" name="file" accept="image/x-png,image/jpeg,image/gif" OnChange="@OnGatheringPicture" />
<MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default"> <MatRipple class="inputfile-mat-ripple" Color="@MatRippleColor.Default">
<label for="file"> <label for="file">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000"> <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" width="48px" height="48px" viewBox="0 0 24 24" fill="#000000">
</div> </div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-3"> <div class="mat-layout-grid-cell mat-layout-grid-cell-span-3">
<div> <div>
<MatCard Class="demo-mat-card">
<MatCard Id="bikePic" Class="fv-mat-card">
<MatCardContent> <MatCardContent>
<MatCardMedia Square="true" Class="" ImageUrl="@imgUrl" />
<MatCardMedia Square="true" Class="" ImageUrl="@imgUrl">
@if (loading) {
<MatProgressCircle Indeterminate="true" Size="MatProgressCircleSize.Medium" />
}
</MatCardMedia>
</MatCardContent> </MatCardContent>
</MatCard> </MatCard>
</div> </div>
</div> </div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-3"> <div class="mat-layout-grid-cell mat-layout-grid-cell-span-3">
<div> <div>
<MatCard Class="demo-mat-card">
<MatCard Id="OSM" Class="fv-mat-card">
<MatCardContent> <MatCardContent>
<MatCardMedia Square="true" Class="" /> <MatCardMedia Square="true" Class="" />
</MatCardContent> </MatCardContent>
[Parameter(CaptureUnmatchedValues = true)] [Parameter(CaptureUnmatchedValues = true)]
public IDictionary<string, object> Attributes { get; set; } public IDictionary<string, object> Attributes { get; set; }
private static int MAX_FILE_SIZE = 4000000;
private static long MAX_FILE_SIZE = 3145728; //3MB
private ColorItem selectedColor; private ColorItem selectedColor;
private BicycleType selectedBcType; private BicycleType selectedBcType;
private ElementReference inputTypeFileElement;
private string imgUrl = string.Empty; private string imgUrl = string.Empty;
private Boolean loading = false;
protected async override void OnInitialized() { protected async override void OnInitialized() {
Console.WriteLine("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name); Console.WriteLine("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name);
Console.WriteLine("Current language is {0}.", CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToUpper()); Console.WriteLine("Current language is {0}.", CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToUpper());
return @FromRoute == "Found" ? i18n.GetString("PlaceOfDiscovery") : i18n.GetString("PlaceOfLoss"); return @FromRoute == "Found" ? i18n.GetString("PlaceOfDiscovery") : i18n.GetString("PlaceOfLoss");
} }
private async Task OnFileSelection(InputFileChangeEventArgs e) {
private async Task OnGatheringPicture(InputFileChangeEventArgs e) {
IBrowserFile imgFile = e.File; IBrowserFile imgFile = e.File;
var buffers = new byte[imgFile.Size]; var buffers = new byte[imgFile.Size];
try { try {
imgUrl = string.Empty;
loading = true;
StateHasChanged();
await imgFile.OpenReadStream(MAX_FILE_SIZE).ReadAsync(buffers); await imgFile.OpenReadStream(MAX_FILE_SIZE).ReadAsync(buffers);
string imageType = imgFile.ContentType; string imageType = imgFile.ContentType;
imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffers)}"; imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffers)}";
} catch (IOException ex) { } catch (IOException ex) {
Console.WriteLine("Ex.Meesage is: {0}.", ex.Message); Console.WriteLine("Ex.Meesage is: {0}.", ex.Message);
Show(MatToastType.Danger, i18n.GetString("Error.PhotoOrPictureToBig.Title"), i18n.GetString("Error.PhotoOrPictureToBig.Msg", MAX_FILE_SIZE / 1000));
Show(MatToastType.Danger, i18n.GetString("Error.PhotoOrPictureToBig.Title"), i18n.GetString("Error.PhotoOrPictureToBig.Msg", MAX_FILE_SIZE / (1024 * 1024)));
} finally {
loading = false;
StateHasChanged();
} }
} }
//public async Task ReadFile() {
// foreach (var file in await fileReaderService.CreateReference(inputTypeFileElement).EnumerateFilesAsync()) {
// IFileInfo fileInfo = await file.ReadFileInfoAsync();
public void Show(MatToastType type, string title, string message, string icon = "") {
Toaster.Add(message, type, title, icon);
}
// if (fileInfo.Size > MAX_FILE_SIZE) {
//*******
// Show(MatToastType.Danger, i18n.GetString("Error.PhotoOrPictureToBig.Title"), i18n.GetString("Error.PhotoOrPictureToBig.Msg", MAX_FILE_SIZE / (1024*1024)));
//private ElementReference inputTypeFileElement;
// } else {
// imgUrl = string.Empty;
// loading = true;
// StateHasChanged();
//public async Task ReadFile() {
// foreach (var file in await fileReaderService.CreateReference(inputTypeFileElement).EnumerateFilesAsync()) {
// IFileInfo fileInfo = await file.ReadFileInfoAsync();
// byte[] buffer = new byte[fileInfo.Size];
// using (MemoryStream memoryStream = await file.CreateMemoryStreamAsync(4096)) {
// int bytesRead = 0;
// int offset = 0;
// do {
// bytesRead = memoryStream.Read(buffer, offset, 4096);
// offset = offset + bytesRead;
// } while (bytesRead < 4096);
// string imageType = fileInfo.Type;
// imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffer)}";
// byte[] buffer = new byte[fileInfo.Size];
// await using (Stream stream = await file.OpenReadAsync()) {
// buffer = new Byte[stream.Length];
// await stream.ReadAsync(buffer);
// }
// using (MemoryStream memoryStream = await file.CreateMemoryStreamAsync(4096)) {
// memoryStream.Read(buffer);
// string imageType = fileInfo.Type;
// loading = false;
// imgUrl = $"data:{imageType};base64,{Convert.ToBase64String(buffer)}";
// StateHasChanged();
// }
// } // }
// } // }
//} //}
public void Show(MatToastType type, string title, string message, string icon = "") {
Toaster.Add(message, type, title, icon);
}
} }

+ 1
- 1
Shared/ResourceFiles/Resources.de.resx 查看文件

<value>Entwickelt durch</value> <value>Entwickelt durch</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve">
<value>Die Grösse des gewählten Bildes oder Fotos darf {0:d} KB nicht überschreiten!</value>
<value>Die Grösse des gewählten Bildes oder Fotos darf {0:d} MB nicht überschreiten!</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>Bilddatei zu gross!</value> <value>Bilddatei zu gross!</value>

+ 1
- 1
Shared/ResourceFiles/Resources.fr.resx 查看文件

<value>Développé par</value> <value>Développé par</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve">
<value>La taille de l'image sélectionnée ou de la photo prise dépasse la taille maximale autorisée de {0:d} KB.</value>
<value>La taille de l'image sélectionnée ou de la photo prise dépasse la taille maximale autorisée de {0:d} MB.</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>La taille de la photo est trop grande!</value> <value>La taille de la photo est trop grande!</value>

+ 1
- 1
Shared/ResourceFiles/Resources.it.resx 查看文件

<value>Sviluppata da</value> <value>Sviluppata da</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve">
<value>La dimensione dell'immagine selezionata o della foto scattata supera la dimensione massima consentita di {0:d} KB.</value>
<value>La dimensione dell'immagine selezionata o della foto scattata supera la dimensione massima consentita di {0:d} MB.</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>Dimensione dell'immagine troppo grande!</value> <value>Dimensione dell'immagine troppo grande!</value>

+ 1
- 1
Shared/ResourceFiles/Resources.resx 查看文件

<value>Developed by</value> <value>Developed by</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Msg" xml:space="preserve">
<value>The size of the selected picture or taken photo exceeds the max. allowed size of {0:d} KB.</value>
<value>The size of the selected picture or taken photo exceeds the max. allowed size of {0:d} MB.</value>
</data> </data>
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve"> <data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>Size of picture to big!</value> <value>Size of picture to big!</value>

+ 1
- 2
_Imports.razor 查看文件

@using CaritasPWA.Shared @using CaritasPWA.Shared
@using CaritasPWA.Shared.ResourceFiles @using CaritasPWA.Shared.ResourceFiles
@using MatBlazor @using MatBlazor
@using BlazorAnimate
@using Tewr.Blazor.FileReader
@using BlazorAnimate

+ 10
- 1
wwwroot/css/app.css 查看文件

background-color: var(--primary); background-color: var(--primary);
} }
.demo-mat-card {
.fv-mat-card {
border-radius:20px; border-radius:20px;
} }
white-space: normal; white-space: normal;
line-height: inherit; line-height: inherit;
} }
div.mat-card-media div.mdc-circular-progress {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

Loading…
取消
儲存