balance binding
This commit is contained in:
parent
4d69bea70b
commit
283acf7d35
@ -19,7 +19,7 @@ namespace Billing.UI
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static View HorizontalOptions(this View view, LayoutOptions options)
|
||||
public static T HorizontalOptions<T>(this T view, LayoutOptions options) where T : View
|
||||
{
|
||||
if (view != null)
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace Billing.UI
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View VerticalOptions(this View view, LayoutOptions options)
|
||||
public static T VerticalOptions<T>(this T view, LayoutOptions options) where T : View
|
||||
{
|
||||
if (view != null)
|
||||
{
|
||||
@ -37,41 +37,41 @@ namespace Billing.UI
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View DynamicResource(this View view, BindableProperty property, string key)
|
||||
public static T Margin<T>(this T view, Thickness margin) where T : View
|
||||
{
|
||||
view.Margin = margin;
|
||||
return view;
|
||||
}
|
||||
|
||||
public static T DynamicResource<T>(this T view, BindableProperty property, string key) where T : Element
|
||||
{
|
||||
view.SetDynamicResource(property, key);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View GridColumn(this View view, int column)
|
||||
public static T GridColumn<T>(this T view, int column) where T : BindableObject
|
||||
{
|
||||
Grid.SetColumn(view, column);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View GridRow(this View view, int row)
|
||||
public static T GridRow<T>(this T view, int row) where T : BindableObject
|
||||
{
|
||||
Grid.SetRow(view, row);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View GridColumnSpan(this View view, int columnSpan)
|
||||
public static T GridColumnSpan<T>(this T view, int columnSpan) where T : BindableObject
|
||||
{
|
||||
Grid.SetColumnSpan(view, columnSpan);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View GridRowSpan(this View view, int rowSpan)
|
||||
public static T GridRowSpan<T>(this T view, int rowSpan) where T : BindableObject
|
||||
{
|
||||
Grid.SetRowSpan(view, rowSpan);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View Margin(this View view, Thickness margin)
|
||||
{
|
||||
view.Margin = margin;
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
public class Tap : IDisposable
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Billing.Themes;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Billing.UI
|
||||
@ -269,19 +270,34 @@ namespace Billing.UI
|
||||
set => SetValue(PlaceholderProperty, value);
|
||||
}
|
||||
|
||||
protected override View Content => new OptionEntry
|
||||
public event EventHandler<FocusEventArgs> Unfocused;
|
||||
|
||||
protected override View Content
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.Fill,
|
||||
HorizontalTextAlignment = TextAlignment.End,
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
ReturnType = ReturnType.Next
|
||||
get
|
||||
{
|
||||
var 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);
|
||||
content.Unfocused += Content_Unfocused;
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
private void Content_Unfocused(object sender, FocusEventArgs e)
|
||||
{
|
||||
Unfocused?.Invoke(sender, e);
|
||||
}
|
||||
.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);
|
||||
}
|
||||
|
||||
public class OptionEditorCell : OptionVerticalCell
|
||||
|
@ -39,8 +39,9 @@
|
||||
<OnPlatform x:TypeArguments="x:String" Android=" "/>
|
||||
</TableSection.Title>
|
||||
<ui:OptionEntryCell Title="{r:Text Balance}" Height="44" Icon="sackdollar.png"
|
||||
Text="{Binding Balance, Mode=TwoWay, Converter={StaticResource moneyConverter}}"
|
||||
Keyboard="Numeric" Placeholder="{r:Text BalancePlaceholder}"/>
|
||||
Text="{Binding Balance, Converter={StaticResource moneyConverter}}"
|
||||
Keyboard="Numeric" Placeholder="{r:Text BalancePlaceholder}"
|
||||
Unfocused="Balance_Unfocused"/>
|
||||
<ui:OptionTextCell Title="{r:Text Currency}" Height="44" Icon="dollar.png"
|
||||
Detail="{r:Text CNY}"/>
|
||||
</TableSection>
|
||||
|
@ -69,6 +69,16 @@ namespace Billing.Views
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Balance_Unfocused(object sender, FocusEventArgs e)
|
||||
{
|
||||
if (sender is OptionEntry entry && decimal.TryParse(entry.Text, out decimal d))
|
||||
{
|
||||
var converter = (MoneyConverter)Resources["moneyConverter"];
|
||||
entry.Text = converter.Convert(d, null, null, null)?.ToString();
|
||||
//Balance = d;
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnCheckAccount()
|
||||
{
|
||||
if (Tap.IsBusy)
|
||||
|
10
Billing.sln
10
Billing.sln
@ -9,7 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Billing.iOS", "Billing\Bill
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Billing.Shared", "Billing.Shared\Billing.Shared.shproj", "{6AC75D01-70D6-4A07-8685-BC52AFD97A7A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Svg2Png", "Svg2Png\Svg2Png.csproj", "{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Svg2Png", "Svg2Png\Svg2Png.csproj", "{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
@ -62,10 +62,10 @@ Global
|
||||
{5C4F1C35-6F66-4063-9605-A9F37FCABBA8}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{5C4F1C35-6F66-4063-9605-A9F37FCABBA8}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
{5C4F1C35-6F66-4063-9605-A9F37FCABBA8}.Release|iPhoneSimulator.Deploy.0 = Release|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|iPhone.ActiveCfg = Debug|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|iPhone.Build.0 = Debug|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{43BB5B21-61E0-42BB-ADF1-DBCD662E61E1}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
|
||||
|
@ -14,7 +14,7 @@ namespace Billing.Droid
|
||||
{
|
||||
|
||||
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.2.0.155")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user