basic logic
This commit is contained in:
		@@ -37,7 +37,7 @@
 | 
			
		||||
                    <TapGestureRecognizer Command="{Binding OnDayTapped, Source={x:Reference billingDate}}" CommandParameter="{TemplateBinding BillingDay}"/>
 | 
			
		||||
                </Grid.GestureRecognizers>
 | 
			
		||||
                <Label Style="{StaticResource dateLabel}" Text="{TemplateBinding BillingDay.Text}"
 | 
			
		||||
                       TextColor="{DynamicResource WeekendColor}"
 | 
			
		||||
                       TextColor="{DynamicResource RedColor}"
 | 
			
		||||
                       FontFamily="{TemplateBinding BillingDay.FontFamily}"
 | 
			
		||||
                       Opacity="{TemplateBinding BillingDay.TextOpacity}"/>
 | 
			
		||||
                <StackLayout Grid.Row="1"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
using Billing.Themes;
 | 
			
		||||
using System;
 | 
			
		||||
using Xamarin.Forms;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,3 +21,20 @@ public class TitleDateConverter : IValueConverter
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class MoneyConverter : IValueConverter
 | 
			
		||||
{
 | 
			
		||||
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
    {
 | 
			
		||||
        if (value is decimal d)
 | 
			
		||||
        {
 | 
			
		||||
            return "¥ " + d.ToString("n2", CultureInfo.InvariantCulture);
 | 
			
		||||
        }
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
			
		||||
    {
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Billing.Themes;
 | 
			
		||||
using System;
 | 
			
		||||
using Xamarin.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Billing.UI;
 | 
			
		||||
@@ -29,3 +30,125 @@ public class LongPressButton : Button
 | 
			
		||||
        LongPressed?.Invoke(this, EventArgs.Empty);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class OptionEntry : Entry { }
 | 
			
		||||
 | 
			
		||||
public abstract class OptionCell : ViewCell
 | 
			
		||||
{
 | 
			
		||||
    public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(OptionCell));
 | 
			
		||||
    public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(OptionCell));
 | 
			
		||||
 | 
			
		||||
    public string Title
 | 
			
		||||
    {
 | 
			
		||||
        get => (string)GetValue(TitleProperty);
 | 
			
		||||
        set => SetValue(TitleProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
    public Color BackgroundColor
 | 
			
		||||
    {
 | 
			
		||||
        get => (Color)GetValue(BackgroundColorProperty);
 | 
			
		||||
        set => SetValue(BackgroundColorProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected abstract View Content { get; }
 | 
			
		||||
 | 
			
		||||
    public OptionCell()
 | 
			
		||||
    {
 | 
			
		||||
        View = new Grid
 | 
			
		||||
        {
 | 
			
		||||
            BindingContext = this,
 | 
			
		||||
            Padding = new Thickness(20, 0),
 | 
			
		||||
            ColumnDefinitions =
 | 
			
		||||
            {
 | 
			
		||||
                new ColumnDefinition { Width = new GridLength(.3, GridUnitType.Star) },
 | 
			
		||||
                new ColumnDefinition { Width = new GridLength(.7, GridUnitType.Star) }
 | 
			
		||||
            },
 | 
			
		||||
            Children =
 | 
			
		||||
            {
 | 
			
		||||
                new Label
 | 
			
		||||
                {
 | 
			
		||||
                    LineBreakMode = LineBreakMode.TailTruncation,
 | 
			
		||||
                    VerticalOptions = LayoutOptions.Center
 | 
			
		||||
                }
 | 
			
		||||
                .Binding(Label.TextProperty, nameof(Title))
 | 
			
		||||
                .DynamicResource(Label.TextColorProperty, BaseTheme.TextColor),
 | 
			
		||||
 | 
			
		||||
                Content.GridColumn(1)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        .DynamicResource(VisualElement.BackgroundColorProperty, BaseTheme.OptionTintColor);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class OptionTextCell : OptionCell
 | 
			
		||||
{
 | 
			
		||||
    public static readonly BindableProperty DetailProperty = BindableProperty.Create(nameof(Detail), typeof(string), typeof(OptionTextCell));
 | 
			
		||||
 | 
			
		||||
    public string Detail
 | 
			
		||||
    {
 | 
			
		||||
        get => (string)GetValue(DetailProperty);
 | 
			
		||||
        set => SetValue(DetailProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override View Content => new Label
 | 
			
		||||
    {
 | 
			
		||||
        HorizontalOptions = LayoutOptions.End,
 | 
			
		||||
        VerticalOptions = LayoutOptions.Center
 | 
			
		||||
    }
 | 
			
		||||
    .Binding(Label.TextProperty, nameof(Detail))
 | 
			
		||||
    .DynamicResource(Label.TextColorProperty, BaseTheme.SecondaryTextColor);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class OptionSwitchCell : OptionCell
 | 
			
		||||
{
 | 
			
		||||
    public static readonly BindableProperty IsToggledProperty = BindableProperty.Create(nameof(IsToggled), typeof(bool), typeof(OptionSwitchCell));
 | 
			
		||||
 | 
			
		||||
    public bool IsToggled
 | 
			
		||||
    {
 | 
			
		||||
        get => (bool)GetValue(IsToggledProperty);
 | 
			
		||||
        set => SetValue(IsToggledProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override View Content => new Switch
 | 
			
		||||
    {
 | 
			
		||||
        HorizontalOptions = LayoutOptions.End,
 | 
			
		||||
        VerticalOptions = LayoutOptions.Center
 | 
			
		||||
    }
 | 
			
		||||
    .Binding(Switch.IsToggledProperty, nameof(IsToggled), BindingMode.TwoWay);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class OptionEntryCell : OptionCell
 | 
			
		||||
{
 | 
			
		||||
    public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(OptionEntryCell));
 | 
			
		||||
    public static readonly BindableProperty KeyboardProperty = BindableProperty.Create(nameof(Keyboard), typeof(Keyboard), typeof(OptionEntryCell));
 | 
			
		||||
    public static readonly BindableProperty PlaceholderProperty = BindableProperty.Create(nameof(Placeholder), typeof(string), typeof(OptionEntryCell));
 | 
			
		||||
 | 
			
		||||
    public string Text
 | 
			
		||||
    {
 | 
			
		||||
        get => (string)GetValue(TextProperty);
 | 
			
		||||
        set => SetValue(TextProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
    public Keyboard Keyboard
 | 
			
		||||
    {
 | 
			
		||||
        get => (Keyboard)GetValue(KeyboardProperty);
 | 
			
		||||
        set => SetValue(KeyboardProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
    public string Placeholder
 | 
			
		||||
    {
 | 
			
		||||
        get => (string)GetValue(PlaceholderProperty);
 | 
			
		||||
        set => SetValue(PlaceholderProperty, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override View Content => new OptionEntry
 | 
			
		||||
    {
 | 
			
		||||
        HorizontalOptions = LayoutOptions.Fill,
 | 
			
		||||
        HorizontalTextAlignment = TextAlignment.End,
 | 
			
		||||
        VerticalOptions = LayoutOptions.Center,
 | 
			
		||||
        ReturnType = ReturnType.Next
 | 
			
		||||
    }
 | 
			
		||||
    .Binding(Entry.TextProperty, nameof(Text), BindingMode.TwoWay)
 | 
			
		||||
    .Binding(InputView.KeyboardProperty, nameof(Keyboard))
 | 
			
		||||
    .Binding(Entry.PlaceholderProperty, nameof(Placeholder))
 | 
			
		||||
    .DynamicResource(Entry.TextColorProperty, BaseTheme.TextColor)
 | 
			
		||||
    .DynamicResource(Entry.PlaceholderColorProperty, BaseTheme.SecondaryTextColor)
 | 
			
		||||
    .DynamicResource(VisualElement.BackgroundColorProperty, BaseTheme.OptionTintColor);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								Billing.Shared/UI/CustomEffect.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Billing.Shared/UI/CustomEffect.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
using Xamarin.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Billing.UI;
 | 
			
		||||
 | 
			
		||||
public class ShadowEffect : RoutingEffect
 | 
			
		||||
{
 | 
			
		||||
    public float Radius { get; set; }
 | 
			
		||||
    public Color Color { get; set; }
 | 
			
		||||
    public Size Offect { get; set; }
 | 
			
		||||
    public float Opacity { get; set; }
 | 
			
		||||
 | 
			
		||||
    public ShadowEffect() : base($"Org.Tsanie.{nameof(ShadowEffect)}")
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
namespace Billing.UI;
 | 
			
		||||
using System;
 | 
			
		||||
using Xamarin.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Billing.UI;
 | 
			
		||||
 | 
			
		||||
public static partial class Definition
 | 
			
		||||
{
 | 
			
		||||
@@ -7,3 +10,59 @@ public static partial class Definition
 | 
			
		||||
    public static partial string GetRobotoCondensedRegularFontFamily();
 | 
			
		||||
    public static partial string GetRobotoCondensedBoldFontFamily();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public static class ExtensionHelper
 | 
			
		||||
{
 | 
			
		||||
    public static View Binding(this View view, BindableProperty property, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null)
 | 
			
		||||
    {
 | 
			
		||||
        view.SetBinding(property, path, mode, converter);
 | 
			
		||||
        return view;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static View DynamicResource(this View view, BindableProperty property, string key)
 | 
			
		||||
    {
 | 
			
		||||
        view.SetDynamicResource(property, key);
 | 
			
		||||
        return view;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static View GridColumn(this View view, int column)
 | 
			
		||||
    {
 | 
			
		||||
        Grid.SetColumn(view, column);
 | 
			
		||||
        return view;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static View GridRow(this View view, int row)
 | 
			
		||||
    {
 | 
			
		||||
        Grid.SetRow(view, row);
 | 
			
		||||
        return view;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class Tap : IDisposable
 | 
			
		||||
{
 | 
			
		||||
    private readonly static object sync = new();
 | 
			
		||||
    private static Tap instance;
 | 
			
		||||
 | 
			
		||||
    private bool busy = false;
 | 
			
		||||
 | 
			
		||||
    private Tap() { }
 | 
			
		||||
 | 
			
		||||
    public static bool IsBusy => instance?.busy ?? false;
 | 
			
		||||
 | 
			
		||||
    public static Tap Start()
 | 
			
		||||
    {
 | 
			
		||||
        lock (sync)
 | 
			
		||||
        {
 | 
			
		||||
            (instance ??= new Tap()).busy = true;
 | 
			
		||||
        }
 | 
			
		||||
        return instance;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void Dispose()
 | 
			
		||||
    {
 | 
			
		||||
        lock (sync)
 | 
			
		||||
        {
 | 
			
		||||
            busy = false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user