From 17bc9ed1904c0d73d9b81f0136be7bf39fe15a2b Mon Sep 17 00:00:00 2001 From: DaPi Date: Sun, 15 Sep 2024 23:51:32 +0200 Subject: [PATCH] Play Console and others --- Jugenddienst Stunden/App.xaml.cs | 44 +++++- Jugenddienst Stunden/AppShell.xaml | 12 +- .../Jugenddienst Stunden.csproj | 37 ++++- Jugenddienst Stunden/MauiProgram.cs | 5 + Jugenddienst Stunden/Models/Stunde.cs | 32 ++++- .../Platforms/Windows/App.xaml.cs | 7 +- .../Resources/Images/icon_security.png | Bin 0 -> 5166 bytes .../Resources/Images/icon_security_ios.png | Bin 0 -> 3031 bytes Jugenddienst Stunden/Types/DayTime.cs | 19 +++ Jugenddienst Stunden/Types/Hours.cs | 2 + .../ViewModels/StundeViewModel.cs | 52 +++++++ .../ViewModels/StundenViewModel.cs | 54 ++++---- Jugenddienst Stunden/Views/StundePage.xaml | 18 +++ Jugenddienst Stunden/Views/StundePage.xaml.cs | 9 ++ Jugenddienst Stunden/Views/StundenPage.xaml | 128 +++++++++++------- .../Views/StundenPage.xaml.cs | 4 + paket_icon.png | Bin 0 -> 5983 bytes 17 files changed, 325 insertions(+), 98 deletions(-) create mode 100644 Jugenddienst Stunden/Resources/Images/icon_security.png create mode 100644 Jugenddienst Stunden/Resources/Images/icon_security_ios.png create mode 100644 Jugenddienst Stunden/Types/DayTime.cs create mode 100644 Jugenddienst Stunden/ViewModels/StundeViewModel.cs create mode 100644 Jugenddienst Stunden/Views/StundePage.xaml create mode 100644 Jugenddienst Stunden/Views/StundePage.xaml.cs create mode 100644 paket_icon.png diff --git a/Jugenddienst Stunden/App.xaml.cs b/Jugenddienst Stunden/App.xaml.cs index 92a98c0..2dd72ac 100644 --- a/Jugenddienst Stunden/App.xaml.cs +++ b/Jugenddienst Stunden/App.xaml.cs @@ -1,5 +1,4 @@ -//using AndroidX.Browser.Trusted; - + namespace Jugenddienst_Stunden { public partial class App : Application { public App() { @@ -7,11 +6,42 @@ namespace Jugenddienst_Stunden { MainPage = new AppShell(); - //Models.Auth.Main(new string[] { "http://hours.dauni.mine.nu:81/appapi", "OTI6Y1JVUS9RTG1jMTZUbnN2c2JZRm5yRDNiUTZz" }); //Angelika - //Models.Auth.Main(new string[] { "http://hours.dauni.mine.nu:81/appapi", "Njc6cjltcVJ1SmtITUtFZ3llUVpJcWJzc2NDejVZ" }); //Dario - - //Models.Auth.Main(new string[] { "http://hours.dauni.mine.nu:81/appapi?hours", "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk=" }); //Christine - } + + + //protected override Window CreateWindow(IActivationState activationState) => + //new Window(new AppShell()) { + // Width = 500, + // Height = 900 + //}; + + + // protected override Window CreateWindow(IActivationState activationState) { + // Window window = base.CreateWindow(activationState); + // window.Activated += Window_Activated; + // return window; + // } + + // private async void Window_Activated(object sender, EventArgs e) { + //#if WINDOWS + // const int DefaultWidth = 500; + // const int DefaultHeight = 900; + + // var window = sender as Window; + + // // change window size. + // window.Width = DefaultWidth; + // window.Height = DefaultHeight; + + // // give it some time to complete window resizing task. + // await window.Dispatcher.DispatchAsync(() => { }); + + // var disp = DeviceDisplay.Current.MainDisplayInfo; + + // // move to screen center + // //window.X = (disp.Width / disp.Density - window.Width) / 2; + // //window.Y = (disp.Height / disp.Density - window.Height) / 2; + //#endif + // } } } diff --git a/Jugenddienst Stunden/AppShell.xaml b/Jugenddienst Stunden/AppShell.xaml index bf1a733..ed27028 100644 --- a/Jugenddienst Stunden/AppShell.xaml +++ b/Jugenddienst Stunden/AppShell.xaml @@ -7,20 +7,20 @@ Shell.FlyoutBehavior="Disabled"> + + - - + Icon="{OnPlatform 'icon_security.png', iOS='icon_security_ios.png', MacCatalyst='icon_security_ios.png'}" /> \ No newline at end of file diff --git a/Jugenddienst Stunden/Jugenddienst Stunden.csproj b/Jugenddienst Stunden/Jugenddienst Stunden.csproj index fb0a0de..60fa632 100644 --- a/Jugenddienst Stunden/Jugenddienst Stunden.csproj +++ b/Jugenddienst Stunden/Jugenddienst Stunden.csproj @@ -1,7 +1,7 @@  - net8.0-ios;net8.0-maccatalyst;net8.0-android34.0 + net8.0-maccatalyst;net8.0-android34.0 @@ -31,20 +31,32 @@ 11.0 13.1 - 29.0 + 27.0 10.0.17763.0 10.0.17763.0 6.5 + True + paket_icon.png + de + + + + + True + + + + True + + + + True $(TargetFrameworks);net8.0-windows10.0.26100.0 - - False - - @@ -63,6 +75,13 @@ + + + True + \ + + + @@ -79,6 +98,9 @@ LoginPage.xaml + + StundePage.xaml + @@ -88,6 +110,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/Jugenddienst Stunden/MauiProgram.cs b/Jugenddienst Stunden/MauiProgram.cs index 64d4da6..fab291b 100644 --- a/Jugenddienst Stunden/MauiProgram.cs +++ b/Jugenddienst Stunden/MauiProgram.cs @@ -1,5 +1,6 @@ //using BarcodeScanning; using Microsoft.Extensions.Logging; +using Microsoft.Maui.LifecycleEvents; using ZXing.Net.Maui.Controls; @@ -15,11 +16,15 @@ namespace Jugenddienst_Stunden { }) .UseBarcodeReader(); + + #if DEBUG builder.Logging.AddDebug(); #endif return builder.Build(); } + + } } diff --git a/Jugenddienst Stunden/Models/Stunde.cs b/Jugenddienst Stunden/Models/Stunde.cs index 3b785a1..a18fa81 100644 --- a/Jugenddienst Stunden/Models/Stunde.cs +++ b/Jugenddienst Stunden/Models/Stunde.cs @@ -11,6 +11,8 @@ namespace Jugenddienst_Stunden.Models { internal class Stunde : ObservableObject { + + //Default-Werte zum Testen //Katharina @@ -29,6 +31,7 @@ namespace Jugenddienst_Stunden.Models //private static readonly string requestUrl = $"{BaseAddress}/appapi?hours"; public DateTime Date { get; set; } + private static Hours Hours { get; set; } @@ -38,9 +41,11 @@ namespace Jugenddienst_Stunden.Models //apiKey = "MTAyfEJZZnB1L3VwcnhoVms0dDlLZENPZWtUVy85b3xodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //name = "Kathi"; //surname = "Wegi"; + //apiKey = "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //name = "Chri"; //surname = "Fe"; + //apiKey = "MTI3fDEyYURVdHVZVWRaZk91eDlNcjZDUFlTdmdkNHxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //name = "Ju"; //surname = "Ze"; @@ -49,6 +54,10 @@ namespace Jugenddienst_Stunden.Models //name = "Le"; //surname = "Ma"; + //apiKey = "OXxpM0lQcXcySUp0S3hHbzFSb3VqdStwRXlDQmd8aHR0cHM6Ly9ob3Vycy5waWRhLmluZm8vYXBwYXBp"; + //name = "Eli"; + //surname = "Gap"; + //Preferences.Default.Set("apiKey", apiKey); //Preferences.Default.Set("name", name); @@ -65,7 +74,7 @@ namespace Jugenddienst_Stunden.Models var tokendata = new TokenData(apiKey); //string data = await Auth.GetApiDataWithAuthAsync(requestUrl, apiKey); - string data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?hours&month=8", tokendata.apiKey); + string data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?hours&month="+DateTime.Today.Month, tokendata.apiKey); if (data == null) { throw new Exception("Keine Daten erhalten"); @@ -112,10 +121,31 @@ namespace Jugenddienst_Stunden.Models } + Hours = hours; + return hours; + } + + public static DayTime LoadEntry(int id) { + + DayTime hours = Hours.daytime.Find(x => x.id == id); + return hours; } + public static Stunde Load(string filename) { + filename = System.IO.Path.Combine(FileSystem.AppDataDirectory, filename); + + if (!File.Exists(filename)) + throw new FileNotFoundException("Unable to find file on local storage.", filename); + + return + new() { + //Filename = Path.GetFileName(filename), + //Text = File.ReadAllText(filename), + Date = File.GetLastWriteTime(filename) + }; + } } } diff --git a/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs b/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs index a7e1346..441d1a0 100644 --- a/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs +++ b/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs @@ -1,4 +1,6 @@ -using Microsoft.UI.Xaml; +using Microsoft.Maui.LifecycleEvents; +using Microsoft.UI.Xaml; + // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -17,6 +19,9 @@ namespace Jugenddienst_Stunden.WinUI { } protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + + } + } diff --git a/Jugenddienst Stunden/Resources/Images/icon_security.png b/Jugenddienst Stunden/Resources/Images/icon_security.png new file mode 100644 index 0000000000000000000000000000000000000000..f9a8616e9520d08fc3a619aa51227ed16443aa49 GIT binary patch literal 5166 zcma)AXIN8Nw+_AcmZ64#C^aFVKp?bG0z(sNG75$?LQ5c_gM=VOx&=W51(6~sf(TNS zG9XeML6Ig!6r>8m2!a&(f-|Gv+_`g~`{R_o-*>OQ*1OkQ=XuU~2RlnXZb@zc0KjL3 zGIL}+-48BKcE(+|%!C;LU>zkoxl!G0ZQvM^zXlph^1^9^`I8wq0AOGgMn+?Naa52O zjzA1RfIl|1fI&no0_=L!7HUgI;=GBdh#=gF2sU{eLvD~k5Ec)2G_&|~F=K=P zdsC@oI0OnHql5< z{$J<^$Uo?0ZxWS6@h1I?L*LL-o`(wVgCI;o6#TsFo@e28Tj_uo-EAMN`rLAO3;ba0g--&d<$^=#LAa zFb)_2*89WQ5Afu_fJl-bDd+?vuNjVMeskd9Jm6OTXadfah^2aexAkM*1{Xm1pTL1Q ze!&OX z;%I3KvNA^=)6_e5OdY17`7P~12H%najv`VRXA*u;34hkY30&YGqd!W+kN6D&fxe{z z9E~{$0|6!nk+8uS9QNDBjHQ2|6cU~qiVnh=5Exm20Gr_PL`J~jAVz%=2?4ku5DWxk z6z|c$uL||XF)aT3$wU714suYMf4OG>`9}Z--w6Lz%Zzn@%rSZdquD^dcN@mwd%wa3 zFq%{lqZ=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>YPKY0@`+W9`cD5p@Qm(iyAb9d}w#<|s-cnr{dAeA%LZ5cQK5 zhwqJy5xYm#3KCP-7j;=S$(O`NN{vHUdD~7J*XWY_QkcDRPtiD|J+T-~{^Q$o(1wGwtd(|xf literal 0 HcmV?d00001 diff --git a/Jugenddienst Stunden/Resources/Images/icon_security_ios.png b/Jugenddienst Stunden/Resources/Images/icon_security_ios.png new file mode 100644 index 0000000000000000000000000000000000000000..830f0a25af4209ea4407f25fcb9c3a801651f6ac GIT binary patch literal 3031 zcma)8dpwl+8lUzMhFV)Tw=T0|m1NAtB__jSMx&Y<42Bfb%saf9nRm<##wBVbcjZ#M z8?A_tAyRfkD;rAE6-6Cow$jD1bR8}ByrY)wbUL5&$2;@>e&6r&{GR9gd!A<|jlOyP z0;CBNfj}(qq>{biZwvLKJsx-blqK;kgyGXc%QpBTbg(`f%Y3qJp&M8pzG6fDFCQ9sJ$ue`;K7$Jc52E
    kQ+m0NdOX>fFsyq zaE=(fEd!4y+Tw`>+!`E#h{MgX;j-YcB&`33uU4B#2c-ayNe20VKn!0n32pn{*&G<~ z8PFZ#K_VZxuHnG&GXbdYgXqa;g#!K{M-n#cYi@rNAPD_WKrIe0Qe9oX0uYvyFz1Uo zhmp{03E00K6YyW5+1n+~LPe*O*Ij)SVL2h_xe62r%2}E=#lhhWubTD{)t7QR`vS1 zcgzN}HXm3$srZp4LzwAp2=?Hpj7oz2dOBBFJi1o@O=J2M%NW}}&ja6P`1cet_IqY# zEYHh9LvQ|sf?un~=#6J@eVKJ~-}s>Jn{BGqMjf})Sd)dae`(g(^iF26ji&U^(R-cN zKN#58Rd8a-KU1ofJ&E-*3oQM%zpZ-Qq4|jW-9?gnd)Q_7>MuKoZqXmiJ$W`c$^A** z%bMO`@M!4py3^+a7*DL+q$&rSHAwc0-PQe}o)yEwX8#*ffS=&%S%jgWrPqzo!d`p1~z_O>pS z>DID78G2!x(W|y{#RA>hUjiuRWrG*q_)aYzFQ|Qj`PJm-5Xk_;jF*&$`?9KT;o4&V zdSuO4MGYpJR;}&b$SdFJt{n1@&oXyy`UN-V5w ziBmsi7ZEyMcW95Sj+#!aGbz_j{N-yGH8lx0(322l;WvrD#VtG5thq|Ly*bIBGP<;Kmq}I10!5H& zqPQ2k(UWQZt}A<>^@-1T;(DheoaW@G3grHby;Jhq_~i!V2Xg&UhJUN4ir{`JsPNEF zO+&kKWZAtp0{;l{^={zi`>}RYUDvMl9t)CR(H|pl%Z9-_sZ-Cb9Hg1phQ1rKX3a(1LF9?Ph>2r0|b8!RznrPMWTAhiBQAT`Za|iIdRnCL@Q*NaA-4}F3xW>*-oOyTk@Z=QvbhHJ_ zQJ5uMV;vQ<$0!TtemQ|Divi~V6YYI@VHWSF7MPvrf-{}QXDydD+@bSlw|wTt`yd@sp+1mU`8A z>G4bKW6yXc#sS9fj6(xki-@B`B!!)yV{Wuzvfp6YpA10S5Bq zC9S%|kX4gMpE;q5WaX*pjAzP*Qo@zQ4nR3JSz+%H*P>vYNJ-MX`{T`!ARD9O$Lb7( zKT{PkitWbrltiy`Je?+2l&1*P*tF(jtrL^*g7nxiW3V#famnJrkaO z!K{N5B~e)Y_1#_rFGkSK*TZs_EB#)_d2KOeW!vixmYrMCO`FQgRX&>jk{sYfH7dT> z;!#NP*uYz<3mkeu9k{V6f_^ROSy$1E#xe`^X_JEXYJssSL*aqZOsgnFM>+f6lmFBk zvXJ#--O~w&O0>40&GrL%PZd73#gVcItp2>%V>r6c6Z0DW+VrYy total; + public TimeOnly end_print; + } +} diff --git a/Jugenddienst Stunden/Types/Hours.cs b/Jugenddienst Stunden/Types/Hours.cs index 4a4759c..87d0d4a 100644 --- a/Jugenddienst Stunden/Types/Hours.cs +++ b/Jugenddienst Stunden/Types/Hours.cs @@ -21,6 +21,7 @@ namespace Jugenddienst_Stunden.Types //[JsonConverter(typeof(JsonSingleOrEmptyArrayConverter))] //public Dictionary zeit_total_daily; public List zeit_total_daily_api; + public List daytime; //public List wochensumme; public string overtime_month; public string overtime; @@ -37,5 +38,6 @@ namespace Jugenddienst_Stunden.Types public DateTime Date; public DateTime MinDate; public DateTime MaxDate; + } } diff --git a/Jugenddienst Stunden/ViewModels/StundeViewModel.cs b/Jugenddienst Stunden/ViewModels/StundeViewModel.cs new file mode 100644 index 0000000..6d06d3d --- /dev/null +++ b/Jugenddienst Stunden/ViewModels/StundeViewModel.cs @@ -0,0 +1,52 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace Jugenddienst_Stunden.ViewModels { + internal class StundeViewModel : ObservableObject, IQueryAttributable { + + public int id { get; set; } + + private Types.DayTime _stunde; + public string Description { + get => _stunde.description; + set { + if (_stunde.description != value) { + _stunde.description = value; + OnPropertyChanged(); + } + } + } + + public int Identifier => (int)_stunde.id; + + public ICommand SaveCommand { get; private set; } + public ICommand DeleteCommand { get; private set; } + + + + //private async Task Save() { + // _stunde.Date = DateTime.Now; + // _stunde.Save(); + // await Shell.Current.GoToAsync($"..?saved={_stunde.Filename}"); + //} + + //private async Task Delete() { + // _stunde.Delete(); + // await Shell.Current.GoToAsync($"..?deleted={_stunde.Filename}"); + //} + + async void IQueryAttributable.ApplyQueryAttributes(IDictionary query) { + if (query.ContainsKey("load")) { + DateTime heute = DateTime.Now; + //_stunde = await Models.Stunde.LoadDay(heute); + //_stunde = await Models.Stunde.LoadData(); + //RefreshProperties(); + } + } + } +} diff --git a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs index 745ee17..7771331 100644 --- a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs +++ b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs @@ -15,23 +15,18 @@ namespace Jugenddienst_Stunden.ViewModels { public string Surname => AppInfo.VersionString; public string MoreInfoUrl => "https://aka.ms/maui"; public string Message => "Hier werden deine geleisteten Arbeitsstunden aufgelistet"; + public string LoadOverview => "Lade Summen für " + DateTime.Today.ToString("MMMM"); + public static DateTime GetDay = DateTime.Today; + public string ShowDay => "Zeit an Tag " + GetDay.ToString("ddd d. MMM") + ": "; + + public int id { get; set; } + public ICommand SelectEntryCommand { get; } + public ICommand LoadDataCommand { get; private set; } public object Stunden { get; } - public static int GetDay = DateTime.Today.Day; - public string ShowDay => "Zeit an Tag " + GetDay + ": "; + - - /* Nicht gemergte Änderung aus Projekt "Jugenddienst Stunden (net8.0-ios)" - Vor: - private Models.Hours _hour; - public Models.Hours Hours { - get => _hour; - Nach: - private Hours _hour; - public Hours Hours { - get => _hour; - */ private Types.Hours _hour; public Types.Hours Hours { get => _hour; @@ -52,6 +47,10 @@ namespace Jugenddienst_Stunden.ViewModels { get => _hour.overtime_month; } + public List DayTimes { + get => _hour.daytime; + } + public DateTime MinimumDate { //get => _hour.MinDate; //get => DateTime.Today.AddDays(-21); @@ -69,12 +68,13 @@ namespace Jugenddienst_Stunden.ViewModels { set { if (dateToday != value) { dateToday = value; - GetDay = dateToday.Day; + GetDay = value; OnPropertyChanged(); _ = LoadDay(value); // Use discard operator to explicitly ignore the returned Task - //RefreshProperties(); + //RefreshProperties(); OnPropertyChanged(nameof(TimeDay)); OnPropertyChanged(nameof(ShowDay)); + OnPropertyChanged(nameof(DayTimes)); } } } @@ -83,9 +83,6 @@ namespace Jugenddienst_Stunden.ViewModels { get => _hour.Date; } - //public Dictionary ZeitTotalDaily { - // get => _hour.zeit_total_daily; - //} public List ZeitTotalDaily { get => _hour.zeit_total_daily_api; @@ -133,20 +130,24 @@ namespace Jugenddienst_Stunden.ViewModels { _hour = new Types.Hours(); LoadDataCommand = new AsyncRelayCommand(LoadData); + SelectEntryCommand = new AsyncRelayCommand(SelectEntryAsync); + } - //protected void OnPropertyChanged(string propertyName) { - // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - //} + private async Task SelectEntryAsync(ViewModels.StundeViewModel entry) { + if (entry != null) + await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.id}"); + } + + - //public async Task LoadData() => - // await Models.Stunde.LoadData(); public event EventHandler AlertEvent; public async Task LoadData() { try { _hour = await Models.Stunde.LoadData(); + RefreshProperties(); } catch (Exception e) { AlertEvent?.Invoke(this, e.Message); } @@ -156,8 +157,11 @@ namespace Jugenddienst_Stunden.ViewModels { try { _hour = await Models.Stunde.LoadDay(date); if (_hour.zeit_total_daily_api != null) { - TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay).ToList() ?? new List { new TimeDay { Day = GetDay, Hours = 0 } }; - RefreshProperties(); + TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay.Day).ToList() ?? new List { new TimeDay { Day = GetDay.Day, Hours = 0 } }; + //RefreshProperties(); + OnPropertyChanged(nameof(ShowDay)); + OnPropertyChanged(nameof(TimeDay)); + OnPropertyChanged(nameof(DayTimes)); } } catch (Exception e) { AlertEvent?.Invoke(this, e.Message); diff --git a/Jugenddienst Stunden/Views/StundePage.xaml b/Jugenddienst Stunden/Views/StundePage.xaml new file mode 100644 index 0000000..afcfbbc --- /dev/null +++ b/Jugenddienst Stunden/Views/StundePage.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Jugenddienst Stunden/Views/StundePage.xaml.cs b/Jugenddienst Stunden/Views/StundePage.xaml.cs new file mode 100644 index 0000000..047715e --- /dev/null +++ b/Jugenddienst Stunden/Views/StundePage.xaml.cs @@ -0,0 +1,9 @@ +namespace Jugenddienst_Stunden.Views; + +public partial class StundePage : ContentPage +{ + public StundePage() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Jugenddienst Stunden/Views/StundenPage.xaml b/Jugenddienst Stunden/Views/StundenPage.xaml index 8f9d519..0df6ee0 100644 --- a/Jugenddienst Stunden/Views/StundenPage.xaml +++ b/Jugenddienst Stunden/Views/StundenPage.xaml @@ -8,73 +8,97 @@ + + + - +