This commit is contained in:
Tsanie 2022-03-17 13:19:45 +08:00
parent cac4735bc4
commit b46b150f6a
11 changed files with 40 additions and 59 deletions

View File

@ -31,9 +31,8 @@ namespace Billing.Themes
protected void InitResources() protected void InitResources()
{ {
var regularFontFamily = Definition.GetRegularFontFamily(); Add(FontSemiBold, Definition.SemiBoldFontFamily);
Add(FontSemiBold, Definition.GetSemiBoldFontFamily()); Add(FontBold, Definition.BoldFontFamily);
Add(FontBold, Definition.GetBoldFontFamily());
Add(PrimaryColor, PrimaryMauiColor); Add(PrimaryColor, PrimaryMauiColor);
Add(SecondaryColor, SecondaryMauiColor); Add(SecondaryColor, SecondaryMauiColor);
@ -45,7 +44,7 @@ namespace Billing.Themes
{ {
new Setter { Property = Label.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Label)) }, new Setter { Property = Label.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Label)) },
new Setter { Property = Label.TextColorProperty, Value = PrimaryMauiColor }, new Setter { Property = Label.TextColorProperty, Value = PrimaryMauiColor },
new Setter { Property = Label.FontFamilyProperty, Value = regularFontFamily } new Setter { Property = Label.FontFamilyProperty, Value = Definition.RegularFontFamily }
} }
}); });
Add(new Style(typeof(OptionEntry)) Add(new Style(typeof(OptionEntry))
@ -53,7 +52,7 @@ namespace Billing.Themes
Setters = Setters =
{ {
new Setter { Property = Entry.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Entry)) }, new Setter { Property = Entry.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Entry)) },
new Setter { Property = Entry.FontFamilyProperty, Value = regularFontFamily } new Setter { Property = Entry.FontFamilyProperty, Value = Definition.RegularFontFamily }
} }
}); });
Add(new Style(typeof(OptionEditor)) Add(new Style(typeof(OptionEditor))
@ -61,7 +60,7 @@ namespace Billing.Themes
Setters = Setters =
{ {
new Setter { Property = Editor.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Editor)) }, new Setter { Property = Editor.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Editor)) },
new Setter { Property = Editor.FontFamilyProperty, Value = regularFontFamily } new Setter { Property = Editor.FontFamilyProperty, Value = Definition.RegularFontFamily }
} }
}); });
Add(new Style(typeof(OptionDatePicker)) Add(new Style(typeof(OptionDatePicker))
@ -69,7 +68,7 @@ namespace Billing.Themes
Setters = Setters =
{ {
new Setter { Property = DatePicker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(DatePicker)) }, new Setter { Property = DatePicker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(DatePicker)) },
new Setter { Property = DatePicker.FontFamilyProperty, Value = regularFontFamily } new Setter { Property = DatePicker.FontFamilyProperty, Value = Definition.RegularFontFamily }
} }
}); });
Add(new Style(typeof(OptionTimePicker)) Add(new Style(typeof(OptionTimePicker))
@ -77,7 +76,7 @@ namespace Billing.Themes
Setters = Setters =
{ {
new Setter { Property = TimePicker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(TimePicker)) }, new Setter { Property = TimePicker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(TimePicker)) },
new Setter { Property = TimePicker.FontFamilyProperty, Value = regularFontFamily } new Setter { Property = TimePicker.FontFamilyProperty, Value = Definition.RegularFontFamily }
} }
}); });
Add(new Style(typeof(OptionPicker)) Add(new Style(typeof(OptionPicker))
@ -85,7 +84,7 @@ namespace Billing.Themes
Setters = Setters =
{ {
new Setter { Property = Picker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(TimePicker)) }, new Setter { Property = Picker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(TimePicker)) },
new Setter { Property = Picker.FontFamilyProperty, Value = regularFontFamily } new Setter { Property = Picker.FontFamilyProperty, Value = Definition.RegularFontFamily }
} }
}); });
Add(new Style(typeof(TintImage)) Add(new Style(typeof(TintImage))

View File

@ -230,7 +230,7 @@ namespace Billing.UI
{ {
public static readonly BindableProperty DateProperty = Helper.Create<DateTime, BillingDay>(nameof(Date), propertyChanged: OnDatePropertyChanged); public static readonly BindableProperty DateProperty = Helper.Create<DateTime, BillingDay>(nameof(Date), propertyChanged: OnDatePropertyChanged);
public static readonly BindableProperty TextProperty = Helper.Create<string, BillingDay>(nameof(Text)); public static readonly BindableProperty TextProperty = Helper.Create<string, BillingDay>(nameof(Text));
public static readonly BindableProperty FontFamilyProperty = Helper.Create<string, BillingDay>(nameof(FontFamily), defaultValue: Definition.GetRegularFontFamily()); public static readonly BindableProperty FontFamilyProperty = Helper.Create<string, BillingDay>(nameof(FontFamily), defaultValue: Definition.RegularFontFamily);
public static readonly BindableProperty IsSelectedProperty = Helper.Create<bool, BillingDay>(nameof(IsSelected), defaultValue: false); public static readonly BindableProperty IsSelectedProperty = Helper.Create<bool, BillingDay>(nameof(IsSelected), defaultValue: false);
public static readonly BindableProperty OpacityProperty = Helper.Create<double, BillingDay>(nameof(Opacity), defaultValue: 1.0); public static readonly BindableProperty OpacityProperty = Helper.Create<double, BillingDay>(nameof(Opacity), defaultValue: 1.0);
public static readonly BindableProperty TextOpacityProperty = Helper.Create<double, BillingDay>(nameof(TextOpacity), defaultValue: 1.0); public static readonly BindableProperty TextOpacityProperty = Helper.Create<double, BillingDay>(nameof(TextOpacity), defaultValue: 1.0);
@ -273,11 +273,11 @@ namespace Billing.UI
if (Helper.IsSameDay(date, selected)) if (Helper.IsSameDay(date, selected))
{ {
IsSelected = true; IsSelected = true;
SetValue(FontFamilyProperty, Definition.GetBoldFontFamily()); SetValue(FontFamilyProperty, Definition.BoldFontFamily);
} }
else else
{ {
SetValue(FontFamilyProperty, Definition.GetRegularFontFamily()); SetValue(FontFamilyProperty, Definition.RegularFontFamily);
} }
if (date.Year == selected.Year && date.Month == selected.Month) if (date.Year == selected.Year && date.Month == selected.Month)
{ {

View File

@ -211,7 +211,7 @@ namespace Billing.UI
} }
return new FontImageSource return new FontImageSource
{ {
FontFamily = Definition.GetBrandsFontFamily(), FontFamily = Definition.BrandsFontFamily,
Size = 20, Size = 20,
Glyph = glyph, Glyph = glyph,
Color = Color.Black Color = Color.Black

View File

@ -10,12 +10,6 @@ namespace Billing.UI
public const string PrimaryColorKey = "PrimaryColor"; public const string PrimaryColorKey = "PrimaryColor";
public const string DefaultIcon = "ic_default"; public const string DefaultIcon = "ic_default";
public const long TransparentColor = 0x00ffffffL; public const long TransparentColor = 0x00ffffffL;
public static partial (string main, long build) GetVersion();
public static partial string GetRegularFontFamily();
public static partial string GetSemiBoldFontFamily();
public static partial string GetBoldFontFamily();
public static partial string GetBrandsFontFamily();
} }
public static class ExtensionHelper public static class ExtensionHelper

View File

@ -32,13 +32,8 @@
VerticalOptions="Center" LongCommand="{Binding TitleLongPressed}"> VerticalOptions="Center" LongCommand="{Binding TitleLongPressed}">
<Label Text="{Binding SelectedDate, Converter={StaticResource titleDateConverter}}" <Label Text="{Binding SelectedDate, Converter={StaticResource titleDateConverter}}"
TextColor="{DynamicResource PrimaryColor}" TextColor="{DynamicResource PrimaryColor}"
FontSize="{OnPlatform Android=20, iOS=18}"> FontFamily="{x:Static ui:Definition.SemiBoldFontFamily}"
<Label.FontFamily> FontSize="{OnPlatform Android=20, iOS=18}"/>
<OnPlatform x:TypeArguments="x:String"
Android="OpenSans-SemiBold.ttf#OpenSans-SemiBold"
iOS="OpenSans-Bold"/>
</Label.FontFamily>
</Label>
</ui:LongPressGrid> </ui:LongPressGrid>
<ui:TintImageButton Source="calendar.png" WidthRequest="20" HeightRequest="20" <ui:TintImageButton Source="calendar.png" WidthRequest="20" HeightRequest="20"
VerticalOptions="Center" HorizontalOptions="Start" VerticalOptions="Center" HorizontalOptions="Start"

View File

@ -114,6 +114,16 @@ namespace Billing.Views
private void OnTitleDateLongPressed() private void OnTitleDateLongPressed()
{ {
billingDate.SetDateTime(DateTime.Today); billingDate.SetDateTime(DateTime.Today);
try
{
HapticFeedback.Perform();
}
catch (FeatureNotSupportedException) { }
catch (Exception ex)
{
Helper.Error("haptic.feedback", ex);
}
} }
private async void OnEditBilling(object o) private async void OnEditBilling(object o)

View File

@ -13,23 +13,20 @@
Shell.TabBarIsVisible="True"> Shell.TabBarIsVisible="True">
<Shell.TitleView> <Shell.TitleView>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center" <StackLayout Orientation="Horizontal" Spacing="10">
Orientation="Horizontal" Spacing="10">
<ui:TintImageButton Source="left.png" WidthRequest="20" HeightRequest="20" <ui:TintImageButton Source="left.png" WidthRequest="20" HeightRequest="20"
VerticalOptions="Center" HorizontalOptions="Start" VerticalOptions="Center" HorizontalOptions="Start"
Command="{Binding LeftCommand}"/> Command="{Binding LeftCommand}"/>
<Label Text="{Binding Title}" <Label Text="{Binding Title}"
TextColor="{DynamicResource PrimaryColor}" TextColor="{DynamicResource PrimaryColor}"
FontSize="{OnPlatform Android=20, iOS=18}" FontSize="{OnPlatform Android=20, iOS=18}"
Padding="10, 0"> FontFamily="{x:Static ui:Definition.SemiBoldFontFamily}"
VerticalOptions="Center"
HorizontalOptions="FillAndExpand"
HorizontalTextAlignment="Center">
<Label.GestureRecognizers> <Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding FilterCommand}"/> <TapGestureRecognizer Command="{Binding FilterCommand}"/>
</Label.GestureRecognizers> </Label.GestureRecognizers>
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String"
Android="OpenSans-SemiBold.ttf#OpenSans-SemiBold"
iOS="OpenSans-Bold"/>
</Label.FontFamily>
</Label> </Label>
<ui:TintImageButton Source="right.png" WidthRequest="20" HeightRequest="20" <ui:TintImageButton Source="right.png" WidthRequest="20" HeightRequest="20"
VerticalOptions="Center" HorizontalOptions="End" VerticalOptions="Center" HorizontalOptions="End"

View File

@ -35,7 +35,8 @@ namespace Billing.Views
ShareLogsCommand = new Command(OnShareLogsCommand); ShareLogsCommand = new Command(OnShareLogsCommand);
InitializeComponent(); InitializeComponent();
var (main, build) = Definition.GetVersion(); var main = AppInfo.VersionString;
var build = AppInfo.BuildString;
SetValue(VersionProperty, $"{main} ({build})"); SetValue(VersionProperty, $"{main} ({build})");
} }

View File

@ -2,20 +2,9 @@
{ {
public static partial class Definition public static partial class Definition
{ {
public static partial (string main, long build) GetVersion() public const string RegularFontFamily = "OpenSans-Regular.ttf#OpenSans-Regular";
{ public const string SemiBoldFontFamily = "OpenSans-SemiBold.ttf#OpenSans-SemiBold";
var context = Android.App.Application.Context; public const string BoldFontFamily = "OpenSans-Bold.ttf#OpenSans-Bold";
var manager = context.PackageManager; public const string BrandsFontFamily = "fa-brands-400.ttf#FontAwesome6Brands-Regular";
var info = manager.GetPackageInfo(context.PackageName, 0);
string version = info.VersionName;
long build = info.LongVersionCode;
return (version, build);
}
public static partial string GetRegularFontFamily() => "OpenSans-Regular.ttf#OpenSans-Regular";
public static partial string GetSemiBoldFontFamily() => "OpenSans-SemiBold.ttf#OpenSans-SemiBold";
public static partial string GetBoldFontFamily() => "OpenSans-Bold.ttf#OpenSans-Bold";
public static partial string GetBrandsFontFamily() => "fa-brands-400.ttf#FontAwesome6Brands-Regular";
} }
} }

View File

@ -14,7 +14,7 @@ namespace Billing.Droid
{ {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.2.0.155")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource public partial class Resource
{ {

View File

@ -2,13 +2,9 @@
{ {
public static partial class Definition public static partial class Definition
{ {
public static partial (string main, long build) GetVersion() => ( public const string RegularFontFamily = "OpenSans-Regular";
Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString(), public const string SemiBoldFontFamily = "OpenSans-SemiBold";
int.Parse(Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString()) public const string BoldFontFamily = "OpenSans-Bold";
); public const string BrandsFontFamily = "FontAwesome6Brands-Regular";
public static partial string GetRegularFontFamily() => "OpenSans-Regular";
public static partial string GetSemiBoldFontFamily() => "OpenSans-SemiBold";
public static partial string GetBoldFontFamily() => "OpenSans-Bold";
public static partial string GetBrandsFontFamily() => "FontAwesome6Brands-Regular";
} }
} }