language version degraded to 9.0

This commit is contained in:
Tsanie Lily 2022-02-25 13:38:42 +08:00
parent 9a6011c3d8
commit e012110b00
32 changed files with 1287 additions and 1262 deletions

View File

@ -3,10 +3,10 @@ using Billing.Themes;
using Xamarin.Essentials;
using Xamarin.Forms;
namespace Billing;
public class App : Application
namespace Billing
{
public class App : Application
{
public static AppTheme CurrentTheme { get; private set; }
public static PlatformCulture CurrentCulture { get; private set; }
@ -58,4 +58,5 @@ public class App : Application
// TODO: status bar
Resources = instance;
}
}
}

View File

@ -1,9 +1,9 @@
using System;
namespace Billing;
internal static class Helper
namespace Billing
{
internal static class Helper
{
public static void Debug(string message)
{
var time = DateTime.Now.ToString("HH:mm:ss.fff");
@ -20,4 +20,5 @@ internal static class Helper
var time = DateTime.Now.ToString("HH:mm:ss.fff");
System.Diagnostics.Debug.Fail($"[{time}] - {category}", message);
}
}
}

View File

@ -36,7 +36,7 @@ namespace Billing.Languages
{
get
{
if (strings?.TryGetValue(key, out string val) == true)
if (strings != null && strings.TryGetValue(key, out string val))
{
return val;
}

View File

@ -1,11 +1,12 @@
using Xamarin.Forms;
namespace Billing;
public partial class MainShell : Shell
namespace Billing
{
public partial class MainShell : Shell
{
public MainShell()
{
InitializeComponent();
}
}
}

View File

@ -1,9 +1,9 @@
using System.Xml.Linq;
namespace Billing.Models;
public class Account : BaseModel
namespace Billing.Models
{
public class Account : BaseModel
{
public int Id { get; set; }
public string Icon { get; set; } = ICON_DEFAULT;
public AccountCategory Category { get; set; }
@ -30,12 +30,13 @@ public class Account : BaseModel
Write(node, nameof(Balance), Balance);
Write(node, nameof(Memo), Memo);
}
}
}
public enum AccountCategory
{
public enum AccountCategory
{
Cash = 0,
CreditCard,
DebitCard,
ElecAccount
}
}

View File

@ -5,17 +5,17 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Billing.Models;
public interface IModel
namespace Billing.Models
{
public interface IModel
{
void OnXmlSerialize(XElement node);
void OnXmlDeserialize(XElement node);
}
}
public abstract class BaseModel : IModel, IDisposable
{
public abstract class BaseModel : IModel, IDisposable
{
protected const string ICON_DEFAULT = "ic_default";
private bool disposed = false;
@ -181,4 +181,5 @@ public abstract class BaseModel : IModel, IDisposable
disposed = true;
}
}
}
}

View File

@ -1,10 +1,10 @@
using System;
using System.Xml.Linq;
namespace Billing.Models;
public class Billing : BaseModel
namespace Billing.Models
{
public class Billing : BaseModel
{
public decimal Amount { get; set; }
public string Name { get; set; }
public int CategoryId { get; set; }
@ -31,4 +31,5 @@ public class Billing : BaseModel
Write(node, nameof(Store), Store);
Write(node, nameof(CreateTime), CreateTime);
}
}
}

View File

@ -1,9 +1,9 @@
using System.Xml.Linq;
namespace Billing.Models;
public class Category : BaseModel
namespace Billing.Models
{
public class Category : BaseModel
{
public int Id { get; set; }
public string Icon { get; set; } = ICON_DEFAULT;
public string Name { get; set; }
@ -31,4 +31,5 @@ public class Category : BaseModel
Write(node, nameof(ParentId), ParentId.Value);
}
}
}
}

View File

@ -1,10 +1,10 @@
using Billing.UI;
using Xamarin.Forms;
namespace Billing.Themes;
public abstract class BaseTheme : ResourceDictionary
namespace Billing.Themes
{
public abstract class BaseTheme : ResourceDictionary
{
public const string CascadiaFontRegular = nameof(CascadiaFontRegular);
public const string CascadiaFontBold = nameof(CascadiaFontBold);
public const string RobotoCondensedFontRegular = nameof(RobotoCondensedFontRegular);
@ -73,4 +73,5 @@ public abstract class BaseTheme : ResourceDictionary
}
});
}
}
}

View File

@ -1,10 +1,9 @@
using Billing.UI;
using Xamarin.Forms;
using Xamarin.Forms;
namespace Billing.Themes;
public class Dark : BaseTheme
namespace Billing.Themes
{
public class Dark : BaseTheme
{
private static Dark _instance;
public static Dark Instance => _instance ??= new Dark();
@ -47,4 +46,5 @@ public class Dark : BaseTheme
}
});
}
}
}

View File

@ -1,10 +1,9 @@
using Billing.UI;
using Xamarin.Forms;
using Xamarin.Forms;
namespace Billing.Themes;
public class Light : BaseTheme
namespace Billing.Themes
{
public class Light : BaseTheme
{
private static Light _instance;
public static Light Instance => _instance ??= new Light();
@ -47,4 +46,5 @@ public class Light : BaseTheme
}
});
}
}
}

View File

@ -1,10 +1,10 @@
using System;
using Xamarin.Forms;
namespace Billing.UI;
public partial class BillingDate : ContentView
namespace Billing.UI
{
public partial class BillingDate : ContentView
{
#region UI Properties
private static readonly BindableProperty SundayProperty = BindableProperty.Create(nameof(Sunday), typeof(BillingDay), typeof(BillingDate));
@ -188,20 +188,20 @@ public partial class BillingDate : ContentView
OnSelectedDatePropertyChanged(this, null, SelectedDate);
}
}
}
}
public class DateEventArgs : EventArgs
{
public class DateEventArgs : EventArgs
{
public DateTime Date { get; }
public DateEventArgs(DateTime date)
{
Date = date;
}
}
}
public class BillingDayView : ContentView
{
public class BillingDayView : ContentView
{
public static readonly BindableProperty BillingDayProperty = BindableProperty.Create(nameof(BillingDay), typeof(BillingDay), typeof(BillingDayView));
public static readonly BindableProperty CommandProperty = BindableProperty.Create(nameof(Command), typeof(Command), typeof(BillingDayView));
@ -215,10 +215,10 @@ public class BillingDayView : ContentView
get => (Command)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
}
}
public class BillingDay : BindableObject
{
public class BillingDay : BindableObject
{
private static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime), typeof(BillingDay), propertyChanged: OnDatePropertyChanged);
private static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(BillingDay));
private static readonly BindableProperty FontFamilyProperty = BindableProperty.Create(nameof(FontFamily), typeof(string), typeof(BillingDay), defaultValue: Definition.GetCascadiaRegularFontFamily());
@ -286,4 +286,5 @@ public class BillingDay : BindableObject
SetValue(TextOpacityProperty, .4);
}
}
}
}

View File

@ -1,12 +1,13 @@
using Billing.Themes;
using Xamarin.Forms;
namespace Billing.UI;
public abstract class BillingPage : ContentPage
namespace Billing.UI
{
public abstract class BillingPage : ContentPage
{
public BillingPage()
{
SetDynamicResource(BackgroundColorProperty, BaseTheme.WindowBackgroundColor);
}
}
}

View File

@ -3,10 +3,10 @@ using System;
using System.Globalization;
using Xamarin.Forms;
namespace Billing.UI;
public class TitleDateConverter : IValueConverter
namespace Billing.UI
{
public class TitleDateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is DateTime date)
@ -20,10 +20,10 @@ public class TitleDateConverter : IValueConverter
{
return value;
}
}
}
public class MoneyConverter : IValueConverter
{
public class MoneyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is decimal d)
@ -37,4 +37,5 @@ public class MoneyConverter : IValueConverter
{
return value;
}
}
}

View File

@ -2,10 +2,10 @@
using System;
using Xamarin.Forms;
namespace Billing.UI;
public class TintImage : Image
namespace Billing.UI
{
public class TintImage : Image
{
public static readonly BindableProperty PrimaryColorProperty = BindableProperty.Create(nameof(PrimaryColor), typeof(Color?), typeof(TintImage));
public Color? PrimaryColor
@ -13,10 +13,10 @@ public class TintImage : Image
get => (Color?)GetValue(PrimaryColorProperty);
set => SetValue(PrimaryColorProperty, value);
}
}
}
public class LongPressButton : Button
{
public class LongPressButton : Button
{
public event EventHandler LongPressed;
public LongPressButton()
@ -29,12 +29,12 @@ public class LongPressButton : Button
{
LongPressed?.Invoke(this, EventArgs.Empty);
}
}
}
public class OptionEntry : Entry { }
public class OptionEntry : Entry { }
public abstract class OptionCell : ViewCell
{
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));
@ -77,10 +77,10 @@ public abstract class OptionCell : ViewCell
}
.DynamicResource(VisualElement.BackgroundColorProperty, BaseTheme.OptionTintColor);
}
}
}
public class OptionTextCell : OptionCell
{
public class OptionTextCell : OptionCell
{
public static readonly BindableProperty DetailProperty = BindableProperty.Create(nameof(Detail), typeof(string), typeof(OptionTextCell));
public string Detail
@ -96,10 +96,10 @@ public class OptionTextCell : OptionCell
}
.Binding(Label.TextProperty, nameof(Detail))
.DynamicResource(Label.TextColorProperty, BaseTheme.SecondaryTextColor);
}
}
public class OptionSwitchCell : OptionCell
{
public class OptionSwitchCell : OptionCell
{
public static readonly BindableProperty IsToggledProperty = BindableProperty.Create(nameof(IsToggled), typeof(bool), typeof(OptionSwitchCell));
public bool IsToggled
@ -114,10 +114,10 @@ public class OptionSwitchCell : OptionCell
VerticalOptions = LayoutOptions.Center
}
.Binding(Switch.IsToggledProperty, nameof(IsToggled), BindingMode.TwoWay);
}
}
public class OptionEntryCell : OptionCell
{
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));
@ -151,4 +151,5 @@ public class OptionEntryCell : OptionCell
.DynamicResource(Entry.TextColorProperty, BaseTheme.TextColor)
.DynamicResource(Entry.PlaceholderColorProperty, BaseTheme.SecondaryTextColor)
.DynamicResource(VisualElement.BackgroundColorProperty, BaseTheme.OptionTintColor);
}
}

View File

@ -1,9 +1,9 @@
using Xamarin.Forms;
namespace Billing.UI;
public class ShadowEffect : RoutingEffect
namespace Billing.UI
{
public class ShadowEffect : RoutingEffect
{
public float Radius { get; set; }
public Color Color { get; set; }
public Size Offect { get; set; }
@ -12,4 +12,5 @@ public class ShadowEffect : RoutingEffect
public ShadowEffect() : base($"Org.Tsanie.{nameof(ShadowEffect)}")
{
}
}
}

View File

@ -1,18 +1,18 @@
using System;
using Xamarin.Forms;
namespace Billing.UI;
public static partial class Definition
namespace Billing.UI
{
public static partial class Definition
{
public static partial string GetCascadiaRegularFontFamily();
public static partial string GetCascadiaBoldFontFamily();
public static partial string GetRobotoCondensedRegularFontFamily();
public static partial string GetRobotoCondensedBoldFontFamily();
}
}
public static class ExtensionHelper
{
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);
@ -36,10 +36,10 @@ public static class ExtensionHelper
Grid.SetRow(view, row);
return view;
}
}
}
public class Tap : IDisposable
{
public class Tap : IDisposable
{
private readonly static object sync = new();
private static Tap instance;
@ -65,4 +65,5 @@ public class Tap : IDisposable
busy = false;
}
}
}
}

View File

@ -1,11 +1,10 @@
using Billing.UI;
using System;
using Xamarin.Forms;
namespace Billing.Views;
public partial class AccountPage : BillingPage
namespace Billing.Views
{
public partial class AccountPage : BillingPage
{
private static readonly BindableProperty BalanceProperty = BindableProperty.Create(nameof(Balance), typeof(decimal), typeof(AccountPage));
private static readonly BindableProperty AssetProperty = BindableProperty.Create(nameof(Asset), typeof(decimal), typeof(AccountPage));
private static readonly BindableProperty LiabilityProperty = BindableProperty.Create(nameof(Liability), typeof(decimal), typeof(AccountPage));
@ -41,4 +40,5 @@ public partial class AccountPage : BillingPage
{
Helper.Debug(e.Account.ToString());
}
}
}

View File

@ -3,10 +3,10 @@ using Billing.UI;
using System;
using Xamarin.Forms;
namespace Billing.Views;
public partial class AddAccountPage : BillingPage
namespace Billing.Views
{
public partial class AddAccountPage : BillingPage
{
private static readonly BindableProperty AccountNameProperty = BindableProperty.Create(nameof(AccountName), typeof(string), typeof(AddAccountPage));
private static readonly BindableProperty AccountIconProperty = BindableProperty.Create(nameof(AccountIcon), typeof(string), typeof(AddAccountPage));
private static readonly BindableProperty CategoryProperty = BindableProperty.Create(nameof(Category), typeof(string), typeof(AddAccountPage));
@ -78,9 +78,10 @@ public partial class AddAccountPage : BillingPage
}
});
}
}
}
public class AccountEventArgs : EventArgs
{
public class AccountEventArgs : EventArgs
{
public Account Account { get; set; }
}
}

View File

@ -1,11 +1,12 @@
using Billing.UI;
namespace Billing.Views;
public partial class AddBillPage : BillingPage
namespace Billing.Views
{
public partial class AddBillPage : BillingPage
{
public AddBillPage()
{
InitializeComponent();
}
}
}

View File

@ -2,10 +2,10 @@ using Billing.UI;
using System;
using Xamarin.Forms;
namespace Billing.Views;
public partial class BillPage : BillingPage
namespace Billing.Views
{
public partial class BillPage : BillingPage
{
private static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(nameof(SelectedDate), typeof(DateTime), typeof(BillPage));
public DateTime SelectedDate
@ -41,4 +41,5 @@ public partial class BillPage : BillingPage
{
await Navigation.PushAsync(new AddBillPage());
}
}
}

View File

@ -1,11 +1,12 @@
using Billing.UI;
namespace Billing.Views;
public partial class SettingPage : BillingPage
namespace Billing.Views
{
public partial class SettingPage : BillingPage
{
public SettingPage()
{
InitializeComponent();
}
}
}

View File

@ -16,14 +16,13 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<LangVersion>10.0</LangVersion>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -65,8 +64,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2337" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="Definition.cs" />

View File

@ -1,14 +1,14 @@
using Foundation;
using UIKit;
namespace Billing.iOS;
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register(nameof(AppDelegate))]
public partial class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
namespace Billing.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register(nameof(AppDelegate))]
public partial class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
@ -23,4 +23,5 @@ public partial class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDe
return base.FinishedLaunching(app, options);
}
}
}

View File

@ -15,7 +15,7 @@
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<ProvisioningType>automatic</ProvisioningType>
<LangVersion>10.0</LangVersion>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
@ -138,8 +138,8 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2337" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.1" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\bars.png" />

View File

@ -1,9 +1,10 @@
namespace Billing.UI;
public static partial class Definition
namespace Billing.UI
{
public static partial class Definition
{
public static partial string GetCascadiaRegularFontFamily() => "CascadiaCode-Regular";
public static partial string GetCascadiaBoldFontFamily() => "CascadiaCode-Bold";
public static partial string GetRobotoCondensedRegularFontFamily() => "RobotoCondensed-Regular";
public static partial string GetRobotoCondensedBoldFontFamily() => "RobotoCondensed-Bold";
}
}

View File

@ -7,10 +7,10 @@ using Xamarin.Forms.Platform.iOS;
[assembly: ResolutionGroupName("Org.Tsanie")]
[assembly: ExportEffect(typeof(ShadowEffectPlatform), nameof(ShadowEffect))]
namespace Billing.iOS.Effects;
public class ShadowEffectPlatform : PlatformEffect
namespace Billing.iOS.Effects
{
public class ShadowEffectPlatform : PlatformEffect
{
protected override void OnAttached()
{
try
@ -40,4 +40,5 @@ public class ShadowEffectPlatform : PlatformEffect
layer.ShadowOpacity = 0;
}
}
}
}

View File

@ -1,9 +1,9 @@
using UIKit;
namespace Billing.iOS;
public class Application
namespace Billing.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
@ -11,4 +11,5 @@ public class Application
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}

View File

@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Threading;
namespace Billing.Languages;
public partial class PlatformCulture
namespace Billing.Languages
{
public partial class PlatformCulture
{
public partial string GetNamespace()
{
return typeof(AppDelegate).Namespace;
@ -72,4 +72,5 @@ public partial class PlatformCulture
Helper.Debug($"iOS Language: {iOSLanguage}, .NET Language/Locale: {netLanguage}");
return netLanguage;
}
}
}

View File

@ -5,10 +5,10 @@ using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(LongPressButton), typeof(LongPressButtonRenderer))]
namespace Billing.iOS.Renderers;
public class LongPressButtonRenderer : ButtonRenderer
namespace Billing.iOS.Renderers
{
public class LongPressButtonRenderer : ButtonRenderer
{
private UILongPressGestureRecognizer longGesture;
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
@ -40,4 +40,5 @@ public class LongPressButtonRenderer : ButtonRenderer
button.TriggerLongPress();
}
}
}
}

View File

@ -5,10 +5,10 @@ using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(OptionEntry), typeof(OptionEntryRenderer))]
namespace Billing.iOS.Renderers;
public class OptionEntryRenderer : EntryRenderer
namespace Billing.iOS.Renderers
{
public class OptionEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
@ -19,4 +19,5 @@ public class OptionEntryRenderer : EntryRenderer
control.BorderStyle = UITextBorderStyle.None;
}
}
}
}

View File

@ -5,10 +5,10 @@ using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(TintImage), typeof(TintImageRenderer))]
namespace Billing.iOS.Renderers;
public class TintImageRenderer : ImageRenderer
namespace Billing.iOS.Renderers
{
public class TintImageRenderer : ImageRenderer
{
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
@ -28,4 +28,5 @@ public class TintImageRenderer : ImageRenderer
Control.TintColor = image.PrimaryColor?.ToUIColor();
}
}
}
}