-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
adriano
committed
Dec 7, 2023
1 parent
0a09118
commit c79bb40
Showing
69 changed files
with
4,042 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:qr2web" | ||
x:Class="qr2web.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
| ||
namespace qr2web | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MainPage = new AppShell(); | ||
} | ||
|
||
public static async void InsertCode(string code) | ||
{ | ||
ShellNavigationQueryParameters param = []; | ||
param.Add("code", code); | ||
await Shell.Current.Navigation.PopAsync(true); | ||
|
||
if(Shell.Current.CurrentPage is MainPage page) | ||
{ | ||
page.InsertBarcode(code); | ||
} | ||
} | ||
|
||
protected override Window CreateWindow(IActivationState? activationState) | ||
{ | ||
var window = base.CreateWindow(activationState); | ||
|
||
int newWidth = Preferences.Get("window_w", 450); | ||
int newHeight = (int)Preferences.Get("window_h", 800); | ||
int newX = Preferences.Get("window_x", (int)Microsoft.Maui.Devices.DeviceDisplay.MainDisplayInfo.Width / 2 - 225); | ||
int newY = Preferences.Get("window_y", (int)Microsoft.Maui.Devices.DeviceDisplay.MainDisplayInfo.Height / 2 - 400); | ||
|
||
window.Width = newWidth; | ||
window.Height = newHeight; | ||
window.X = newX; | ||
window.Y = newY; | ||
|
||
window.Destroying += (s, e) => | ||
{ | ||
if (s is Window w) | ||
{ | ||
if (w.Width != newWidth) Preferences.Set("window_w", (int)w.Width); | ||
if (w.Height != newHeight) Preferences.Set("window_h", (int)w.Height); | ||
if (w.X != newX) Preferences.Set("window_x", (int)w.X); | ||
if (w.Y != newY) Preferences.Set("window_y", (int)w.Y); | ||
} | ||
}; | ||
|
||
window.Deactivated += (s, e) => | ||
{ | ||
if (Shell.Current.CurrentPage is MainPage page) | ||
{ | ||
//page.SaveState(); | ||
} | ||
}; | ||
|
||
window.Resumed += (s, e) => | ||
{ | ||
if (Shell.Current.CurrentPage is MainPage page) | ||
{ | ||
//page.RestoreState(); | ||
} | ||
}; | ||
|
||
return window; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="qr2web.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:qr2web" | ||
xmlns:strings="clr-namespace:qr2web.Resources.Strings" | ||
Shell.FlyoutBehavior="Flyout" | ||
FlyoutBackgroundColor="{AppThemeBinding Light=LightSteelBlue, Dark=SteelBlue}" | ||
Shell.BackgroundColor="{AppThemeBinding Light=LightSteelBlue, Dark=Black}" | ||
Navigated="Shell_Navigated" | ||
Title="QR2Web"> | ||
|
||
<Shell.TitleView> | ||
<Grid ColumnDefinitions="auto,*,auto" Background="{AppThemeBinding Light=LightSteelBlue, Dark=Black}"> | ||
<Label Text="QR2Web" FontSize="Medium" VerticalTextAlignment="Center" Padding="20,0" TextColor="{AppThemeBinding Light=DarkBlue, Dark=LightSteelBlue}"></Label> | ||
<HorizontalStackLayout Grid.Column="2" VerticalOptions="Center" Padding="20,0" x:Name="scanIcon" IsVisible="False"> | ||
<ImageButton Source="scanqr.png" Aspect="AspectFit" BackgroundColor="Transparent" Clicked="ScanButton_Clicked" /> | ||
</HorizontalStackLayout> | ||
</Grid> | ||
</Shell.TitleView> | ||
|
||
<Shell.FlyoutHeader> | ||
<Grid HeightRequest="128" HorizontalOptions="FillAndExpand" Background="Black"> | ||
<Image Source="logo128.png" HorizontalOptions="End" /> | ||
<Label Text="QR2Web" TextColor="LightSteelBlue" VerticalOptions="Center" FontSize="Large" /> | ||
</Grid> | ||
</Shell.FlyoutHeader> | ||
|
||
<ShellContent Title="App" ContentTemplate="{DataTemplate local:MainPage}" Route="MainPage"> | ||
</ShellContent> | ||
|
||
<!-- | ||
<FlyoutItem Title="Home Page" FlyoutIcon="scanp.png" IsVisible="False"> | ||
<Tab> | ||
<ShellContent ContentTemplate="{DataTemplate local:MainPage}" /> | ||
</Tab> | ||
</FlyoutItem> | ||
--> | ||
|
||
<MenuItem Text="{Static strings:AppResources.MenuHome}" IconImageSource="scanp.png" Clicked="Home_Clicked" /> | ||
|
||
<MenuItem Text="{Static strings:AppResources.MenuRefresh}" IconImageSource="scanr.png" Clicked="Refresh_Clicked" /> | ||
|
||
<MenuItem Text="{Static strings:AppResources.MenuOptions}" IconImageSource="scanc.png" Clicked="Options_Clicked" /> | ||
|
||
<MenuItem Text="{Static strings:AppResources.MenuHelp}" IconImageSource="help.png" Clicked="Help_Clicked" /> | ||
|
||
<MenuItem Text="{Static strings:AppResources.MenuAbout}" IconImageSource="about.png" Clicked="About_Clicked" /> | ||
|
||
<Shell.FlyoutFooter> | ||
<VerticalStackLayout Padding="10"> | ||
<Label Text="GitHub Project" /> | ||
<Label Text="© Adriano Petrucci - 2023" /> | ||
</VerticalStackLayout> | ||
</Shell.FlyoutFooter> | ||
|
||
</Shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
namespace qr2web | ||
{ | ||
public partial class AppShell : Shell | ||
{ | ||
private static ScanPage? scanPage = null; | ||
|
||
public static Location? MyLocation { get; private set; } = null; | ||
|
||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
|
||
Routing.RegisterRoute("MainPage", typeof(MainPage)); | ||
Routing.RegisterRoute("OptionsPage", typeof(OptionsPage)); | ||
Routing.RegisterRoute("ScanPage", typeof(ScanPage)); | ||
|
||
Task.Run(() => | ||
scanPage = new ScanPage()); | ||
} | ||
|
||
private void ScanButton_Clicked(object sender, EventArgs e) | ||
{ | ||
OpenScanPage(); | ||
//Shell.Current.Navigation.PushAsync(scanPage); | ||
} | ||
|
||
private void Options_Clicked(object sender, EventArgs e) | ||
{ | ||
Shell.Current.Navigation.PushAsync(new OptionsPage()); | ||
} | ||
|
||
private void Refresh_Clicked(object sender, EventArgs e) | ||
{ | ||
if(Current.CurrentPage is MainPage page) | ||
{ | ||
page.RefreshPage(); | ||
Shell.Current.FlyoutIsPresented = false; | ||
} | ||
} | ||
|
||
private void Home_Clicked(object sender, EventArgs e) | ||
{ | ||
if (Current.CurrentPage is MainPage page) | ||
{ | ||
page.GoTo(Options.HomePage); | ||
Shell.Current.FlyoutIsPresented = false; | ||
} | ||
} | ||
|
||
private void Help_Clicked(object sender, EventArgs e) | ||
{ | ||
if (Current.CurrentPage is MainPage page) | ||
{ | ||
page.GoTo("https://adrianotiger.github.io/qr2web/help.html"); | ||
Shell.Current.FlyoutIsPresented = false; | ||
} | ||
} | ||
|
||
private void About_Clicked(object sender, EventArgs e) | ||
{ | ||
if (Current.CurrentPage is MainPage page) | ||
{ | ||
int appVer = AppInfo.Current.Version.Major * 10 + AppInfo.Current.Version.Minor; | ||
page.GoTo("https://adrianotiger.github.io/qr2web/info.html?version=" + appVer); | ||
Shell.Current.FlyoutIsPresented = false; | ||
} | ||
} | ||
|
||
private void Shell_Navigated(object sender, ShellNavigatedEventArgs e) | ||
{ | ||
string currentUrl = e.Current.Location.OriginalString; | ||
var prevUrl = e.Previous?.Location; | ||
if(prevUrl != null) | ||
{ | ||
if (prevUrl.OriginalString.Contains("ScanPage")) | ||
{ | ||
Task.Run(async () => | ||
{ | ||
scanPage = null; | ||
await Task.Delay(500); | ||
scanPage = new ScanPage(); | ||
}); | ||
} | ||
} | ||
if (Options.ShowScanbutton) | ||
scanIcon.IsVisible = currentUrl.EndsWith("MainPage"); | ||
else | ||
scanIcon.IsVisible = false; | ||
} | ||
|
||
public static async void OpenScanPage() | ||
{ | ||
if (scanPage != null) | ||
{ | ||
await Shell.Current.Navigation.PushAsync(scanPage); | ||
if (Options.ForwardLocation) | ||
{ | ||
try | ||
{ | ||
MyLocation = await Geolocation.GetLastKnownLocationAsync(); | ||
if (MyLocation == null) | ||
{ | ||
await Geolocation.GetLocationAsync(new GeolocationRequest { DesiredAccuracy = GeolocationAccuracy.Medium, RequestFullAccuracy = false, Timeout = TimeSpan.FromSeconds(3) }); | ||
} | ||
} | ||
catch { } | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
Shell.NavBarIsVisible="True" | ||
Shell.NavBarHasShadow="True" | ||
x:Class="qr2web.MainPage"> | ||
<Grid> | ||
<WebView | ||
Navigated="WebView_Navigated" | ||
Navigating="WebView_Navigating" | ||
x:Name="webView"> | ||
<WebView.Source> | ||
<HtmlWebViewSource> | ||
<HtmlWebViewSource.Html> | ||
<![CDATA[ | ||
<html> | ||
<body style='background-color:black;color:white;'> | ||
<h1>Qr2Web</h1> | ||
<p>Loading...</p> | ||
</body> | ||
</html> | ||
]]> | ||
</HtmlWebViewSource.Html> | ||
</HtmlWebViewSource> | ||
</WebView.Source> | ||
</WebView> | ||
<ProgressBar VerticalOptions="Start" Progress="0" IsVisible="False" x:Name="progressBar" /> | ||
</Grid> | ||
</ContentPage> |
Oops, something went wrong.