1using CommunityToolkit.Maui.Core.Platform;
 
    2using CommunityToolkit.Mvvm.Messaging;
 
    3using Microsoft.Maui.Controls.PlatformConfiguration;
 
    4using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
 
   11        private readonly List<Label> innerLabels;
 
   18            this.InitializeComponent();
 
   21            this.ContentPageModel = ViewModel;
 
   32            this.InnerCodeEntry.Text = 
string.Empty;
 
   38            await base.OnAppearingAsync();
 
   40            WeakReferenceMessenger.Default.Register<
KeyboardSizeMessage>(
this, this.HandleKeyboardSizeMessage);
 
   48            await base.OnDisappearingAsync();
 
   53            await this.Dispatcher.DispatchAsync(() =>
 
   56                if (DeviceInfo.Platform == DevicePlatform.iOS)
 
   58                    Thickness SafeInsets = this.On<iOS>().SafeAreaInsets();
 
   59                    Bottom = SafeInsets.Bottom;
 
   60                    Thickness Margin = new(0, 0, 0, Message.KeyboardSize - Bottom);
 
   61                    this.TheMainGrid.Margin = Margin;
 
   68        private async 
void InnerCodeEntry_TextChanged(
object? Sender, TextChangedEventArgs e)
 
   70            string NewText = e.NewTextValue;
 
   71            int NewLength = NewText.Length;
 
   73            bool IsValid = (NewLength <= this.innerLabels.Count) || NewText.ToCharArray().All(ch => !
"0123456789".Contains(ch));
 
   77                this.InnerCodeEntry.Text = e.OldTextValue;
 
   81            for (
int i = 0; i < this.innerLabels.Count; i++)
 
   85                    this.innerLabels[i].Text = NewText[i..(i + 1)];
 
   86                    VisualStateManager.GoToState(this.innerLabels[i], VisualStateManager.CommonStates.Normal);
 
   90                    this.innerLabels[i].Text = 
"0\u2060"; 
 
   91                    VisualStateManager.GoToState(this.innerLabels[i], VisualStateManager.CommonStates.Disabled);
 
   95            if (NewLength == this.innerLabels.Count)
 
   96                await this.InnerCodeEntry.HideKeyboardAsync();
 
   99        private void TapGestureRecognizer_Tapped(
object sender, TappedEventArgs e)
 
  101            this.InnerCodeEntry.Focus();
 
Base class that references services in the app.
 
static IUiService UiService
Service serializing and managing UI-related tasks.
 
VerifyCodePage()
Creates a new instance of the VerifyCodePage class.
 
override async Task OnDisappearingAsync()
 
override async Task OnAppearingAsync()
 
The view model to bind to when verifying a code.
 
class KeyboardSizeMessage(float KeyboardSize)
Keyboard size change message