Add project files.

This commit is contained in:
2025-10-11 08:15:33 +02:00
commit 5d1e7858f2
140 changed files with 7567 additions and 0 deletions

View File

@ -0,0 +1,44 @@
using System.Text.RegularExpressions;
namespace GreadyPoang.Common;
public class DigitsOnlyBehavior : Behavior<Entry?>
{
protected override void OnAttachedTo(Entry? entry)
{
if (entry != null)
{
entry.TextChanged += OnTextChanged;
}
base.OnAttachedTo(entry);
}
protected override void OnDetachingFrom(Entry? entry)
{
if (entry != null)
{
entry.TextChanged -= OnTextChanged;
}
base.OnDetachingFrom(entry);
}
private void OnTextChanged(object? sender, TextChangedEventArgs e)
{
var entry = sender as Entry;
if (entry == null) return;
// Tillåt endast siffror (09)
if (!Regex.IsMatch(e.NewTextValue, @"^\d*$"))
{
entry.Text = e.OldTextValue; // Återställ till tidigare giltigt värde
}
/*
* Vill du tillåta decimaler? Ändra regex till @"^\d*\.?\d*$"
Vill du tillåta negativa tal? Använd @"^-?\d*$"
Vill du visa en varning när användaren skriver fel?
Lägg till en BindableProperty för IsValid och bind den till UI.
*
*/
}
}