Skip to content

Commit

Permalink
Frontend.Maui: fix window size for gtk
Browse files Browse the repository at this point in the history
Initial window size was too thin so we tried to resize
the window once it's created.

Also extracted default window size to a constant in
FrontendHelpers to prevent code duplication.

Co-authored-by: webwarrior <[email protected]>
  • Loading branch information
parhamsaremi and webwarrior-ws committed Dec 12, 2024
1 parent bd47559 commit 201c2c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/GWallet.Frontend.Maui/App.xaml.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace GWallet.Frontend.Maui

open Microsoft.Maui
open Microsoft.Maui.Controls
open Microsoft.Maui.Controls.Xaml

Expand All @@ -9,3 +10,13 @@ type App() as this =

do this.LoadFromXaml typeof<App> |> ignore<App>
do this.MainPage <- (WelcomePage GlobalState) :> Page

#if GTK
override _.CreateWindow(activationState) =
let window = base.CreateWindow(activationState)
window.Created.Add(fun _ ->
let gtkWindow = MauiGtkApplication.Current.MainWindow
gtkWindow.Resize FrontendHelpers.DefaultDesktopWindowSize
)
window
#endif
3 changes: 2 additions & 1 deletion src/GWallet.Frontend.XF.Gtk/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ open Xamarin.Forms.Platform.GTK

open GWallet.Backend
open GWallet.Backend.FSharpUtil.UwpHacks
open GWallet.Frontend.XF

module Main =

Expand Down Expand Up @@ -34,7 +35,7 @@ module Main =
)
else
window.SetApplicationIcon logoFileName
window.SetDefaultSize (500, 1000)
window.SetDefaultSize FrontendHelpers.DefaultDesktopWindowSize
window.Show()
Gtk.Application.Run()
0
Expand Down
1 change: 1 addition & 0 deletions src/GWallet.Frontend.XF/FrontendHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,4 @@ module FrontendHelpers =
let currencyLogoImg = Image(Source = imageSource, IsVisible = true)
currencyLogoImg
#endif
let DefaultDesktopWindowSize = 500, 1000

0 comments on commit 201c2c5

Please sign in to comment.