using Android.Util; using CommunityToolkit.Maui.Alerts; using CommunityToolkit.Maui.Core; using Microsoft.Extensions.Configuration; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Json; using System.Reflection; using System.Text; using System.Threading.Tasks; using WorkFlowCheck.Common.DTO; namespace WorkFlowCheck.MAUI.Helper { public static class SystemHelper { public static string DatabaseName = ""; public static bool Syncronised = false; #if DEBUG public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/"; public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="; #endif #if !DEBUG public static string ApiBaseUrl = $"https://wfcapi.nuvolar.hu/"; public static string ApiKey = $"RUJeLSpSMzVASUdaRCEzUyYxRSE0VyFISFRSJC0zRzhLM1hCSDU="; #endif public async static Task GetAPIInfoAsync() { using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ApiBaseUrl); httpClient.DefaultRequestHeaders.Add("X-Api-Key", ApiKey); string endpoint = $"{ApiBaseUrl}api/System/GetDatabaseAndVersionInfo"; var retVal = new RoleDTO(); try { var response = await httpClient.GetFromJsonAsync>(endpoint); if (response != null) { if (response.IsSuccess) { DatabaseName = response.Data; } } } catch (Exception ex) { //Log.Error(ex.Message); } } } public async static Task ShowSnackBar(string message, string actionButtonTextColor = "#FF0000", string backgroundColor = "#FF0000", string textColor = "#FF0000", int duration = 10, string actionButtonText = "Ok", Func action = null) { var visualOptions = new SnackbarOptions { ActionButtonTextColor = Colors.Yellow, CornerRadius = new CornerRadius(10), Font = Microsoft.Maui.Font.SystemFontOfSize(16), BackgroundColor = Colors.Red, TextColor = Colors.Yellow }; var snackbar = Snackbar.Make( message, duration: TimeSpan.FromSeconds(duration), action: async () => { if (action != null) await action(); }, actionButtonText: actionButtonText, visualOptions: visualOptions ); await snackbar.Show(); } } }