diff --git a/src/DodoSSH.Client.Android/Views/PhoneShell.axaml.cs b/src/DodoSSH.Client.Android/Views/PhoneShell.axaml.cs index d355493..fa804c9 100644 --- a/src/DodoSSH.Client.Android/Views/PhoneShell.axaml.cs +++ b/src/DodoSSH.Client.Android/Views/PhoneShell.axaml.cs @@ -17,6 +17,17 @@ internal sealed partial class PhoneShell : UserControl { private MainWindowViewModel? shell; + /// + /// Everything the phone draws, which is the element the software keyboard is kept off. + /// + /// + /// Looked up rather than read off the field the name generator declares for x:Name, and + /// TerminalScreen does the same for the same reason: that field is assigned by the generated + /// InitializeComponent, and no view on this head calls it — they load their XAML directly. Using + /// it compiles and is null at run time, which on this control means a crash before the first frame. + /// + private readonly Panel body; + /// The software keyboard, while this control is attached. Null on a platform without one. private IInputPane? keyboard; @@ -37,10 +48,12 @@ internal sealed partial class PhoneShell : UserControl { AvaloniaXamlLoader.Load(this); - // Subscribed once, for the life of the control, rather than in OnAttachedToVisualTree: Body is this - // control's own child and cannot outlive it, and re-subscribing on every attach is how a handler - // ends up registered twice. - Body.SizeChanged += OnBodyResized; + body = this.FindControl("Body")!; + + // Subscribed once, for the life of the control, rather than in OnAttachedToVisualTree: the panel is + // this control's own child and cannot outlive it, and re-subscribing on every attach is how a + // handler ends up registered twice. + body.SizeChanged += OnBodyResized; DataContextChanged += (_, _) => { @@ -208,9 +221,9 @@ internal sealed partial class PhoneShell : UserControl { var inset = double.IsFinite(occluded) ? Math.Max(occluded, 0) : 0; - if (Math.Abs(Body.Margin.Bottom - inset) > 0.5) + if (Math.Abs(body.Margin.Bottom - inset) > 0.5) { - Body.Margin = new Thickness(0, 0, 0, inset); + body.Margin = new Thickness(0, 0, 0, inset); } }