Switch up Font loading

This commit is contained in:
2021-03-27 16:19:11 -05:00
parent 6e52a67726
commit 4c7196c948
14 changed files with 39 additions and 54 deletions
+6 -6
View File
@@ -4,21 +4,21 @@
x:Class="qController.App"> x:Class="qController.App">
<Application.Resources> <Application.Resources>
<!-- Application resource dictionary --> <!-- Application resource dictionary -->
<OnPlatform x:Key="qfont" x:TypeArguments="x:String"> <OnPlatform x:Key="QFontFamily" x:TypeArguments="x:String">
<On Platform="Android" Value="qfont.ttf#qfont" /> <On Platform="Android">qfont.ttf#qfont</On>
<On Platform="iOS" Value="qfont" /> <On Platform="iOS">qfont</On>
</OnPlatform> </OnPlatform>
<OnPlatform x:Key="MaterialFontFamily" x:TypeArguments="x:String"> <OnPlatform x:Key="MaterialFontFamily" x:TypeArguments="x:String">
<On Platform="iOS" Value="Material Design Icons" /> <On Platform="iOS">Material Design Icons</On>
<On Platform="Android" Value="materialdesignicons-webfont.ttf#Material Design Icons" /> <On Platform="Android">materialdesignicons-webfont.ttf#Material Design Icons</On>
</OnPlatform> </OnPlatform>
<Style TargetType="Label" <Style TargetType="Label"
Class="QFont" Class="QFont"
ApplyToDerivedTypes="true"> ApplyToDerivedTypes="true">
<Setter Property="FontFamily" <Setter Property="FontFamily"
Value="{StaticResource qfont}" /> Value="{StaticResource QFontFamily}" />
</Style> </Style>
<Style TargetType="Label" <Style TargetType="Label"
-11
View File
@@ -14,7 +14,6 @@ namespace qController
public static INavigation iNav; public static INavigation iNav;
public static NavigationPage NavigationPage { get; private set; } public static NavigationPage NavigationPage { get; private set; }
public static RootPage rootPage; public static RootPage rootPage;
public static string QFont;
public static DisplayInfo mainDisplayInfo; public static DisplayInfo mainDisplayInfo;
public static double Height; public static double Height;
public static double Width; public static double Width;
@@ -46,16 +45,6 @@ namespace qController
HeightUnit = Height / 100.0; HeightUnit = Height / 100.0;
WidthUnit = Width / 100.0; WidthUnit = Width / 100.0;
switch (Device.RuntimePlatform)
{
case Device.iOS:
QFont = "qfont";
break;
case Device.Android:
QFont = "qfont.ttf#qfont";
break;
}
rootPage = new RootPage(); rootPage = new RootPage();
NavigationPage = new NavigationPage(new QBrowserPage()); NavigationPage = new NavigationPage(new QBrowserPage());
rootPage.Detail = NavigationPage; rootPage.Detail = NavigationPage;
@@ -1,6 +1,6 @@
namespace qController.Helpers namespace qController.Helpers
{ {
static class IconConstants public static class IconConstants
{ {
public const string VectorSquare = "\U000f0001"; public const string VectorSquare = "\U000f0001";
public const string AccessPointNetwork = "\U000f0002"; public const string AccessPointNetwork = "\U000f0002";
@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using qController.Helpers;
namespace qController.QItems namespace qController.QItems
{ {
@@ -18,7 +19,7 @@ namespace qController.QItems
{ {
get get
{ {
return QIcon.GetIconFromType("Group"); return IconConstants.FormatListBulleted;
} }
} }
} }
@@ -10,7 +10,7 @@ namespace qController.UI.Buttons
{ {
Text = QIcon.SLIDERS, Text = QIcon.SLIDERS,
TextColor = Color.Black, TextColor = Color.Black,
FontFamily = App.QFont, FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"],
FontSize = App.HeightUnit * 4, FontSize = App.HeightUnit * 4,
VerticalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand,
@@ -28,7 +28,7 @@ namespace qController.UI.Cells
var icon = new Label(); var icon = new Label();
icon.FontFamily = App.QFont; icon.FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"];
icon.SetBinding(Label.TextProperty, "Icon"); icon.SetBinding(Label.TextProperty, "Icon");
icon.HorizontalTextAlignment = TextAlignment.Center; icon.HorizontalTextAlignment = TextAlignment.Center;
icon.VerticalTextAlignment = TextAlignment.Center; icon.VerticalTextAlignment = TextAlignment.Center;
@@ -1,6 +1,7 @@
using System; using System;
using Xamarin.Forms; using Xamarin.Forms;
using Serilog; using Serilog;
using qController.Helpers;
namespace qController.UI.Cells namespace qController.UI.Cells
{ {
@@ -87,18 +88,18 @@ namespace qController.UI.Cells
connectLabel.HorizontalOptions = LayoutOptions.StartAndExpand; connectLabel.HorizontalOptions = LayoutOptions.StartAndExpand;
connectLabel.VerticalOptions = LayoutOptions.CenterAndExpand; connectLabel.VerticalOptions = LayoutOptions.CenterAndExpand;
connectLabel.Text = QIcon.WIFI; connectLabel.Text = IconConstants.Wifi;
connectLabel.FontSize = App.HeightUnit * 5; connectLabel.FontSize = App.HeightUnit * 5;
connectLabel.TextColor = Color.LimeGreen; connectLabel.TextColor = Color.LimeGreen;
deleteLabel.HorizontalOptions = LayoutOptions.CenterAndExpand; deleteLabel.HorizontalOptions = LayoutOptions.CenterAndExpand;
deleteLabel.VerticalOptions = LayoutOptions.CenterAndExpand; deleteLabel.VerticalOptions = LayoutOptions.CenterAndExpand;
deleteLabel.Text = QIcon.TRASH_EMPTY; deleteLabel.Text = IconConstants.Delete;
deleteLabel.FontSize = App.HeightUnit * 5; deleteLabel.FontSize = App.HeightUnit * 5;
deleteLabel.TextColor = Color.Red; deleteLabel.TextColor = Color.Red;
connectLabel.FontFamily = App.QFont; connectLabel.FontFamily = (OnPlatform<string>)Application.Current.Resources["MaterialFontFamily"];
deleteLabel.FontFamily = App.QFont; deleteLabel.FontFamily = (OnPlatform<string>)Application.Current.Resources["MaterialFontFamily"];
} }
@@ -89,7 +89,7 @@ namespace qController.UI.Cells
type = new Label { type = new Label {
Text = QIcon.SPIN3, Text = QIcon.SPIN3,
FontFamily = App.QFont, FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"],
VerticalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.End, HorizontalTextAlignment = TextAlignment.End,
FontSize = App.HeightUnit * 5 FontSize = App.HeightUnit * 5
+1 -1
View File
@@ -63,7 +63,7 @@ namespace qController.UI
var cueTypeLabel = new Label var cueTypeLabel = new Label
{ {
FontFamily = App.QFont, FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"],
BindingContext = qCueViewModel, BindingContext = qCueViewModel,
HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand,
HorizontalTextAlignment = TextAlignment.Start, HorizontalTextAlignment = TextAlignment.Start,
+4 -3
View File
@@ -1,4 +1,5 @@
using Xamarin.Forms; using qController.Helpers;
using Xamarin.Forms;
namespace qController.UI namespace qController.UI
{ {
@@ -33,14 +34,14 @@ namespace qController.UI
menuButton = new Label menuButton = new Label
{ {
FontFamily = App.QFont, FontFamily = (OnPlatform<string>)Application.Current.Resources["MaterialFontFamily"],
HorizontalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalTextAlignment = TextAlignment.Start, HorizontalTextAlignment = TextAlignment.Start,
VerticalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center,
Padding = 0, Padding = 0,
Margin = new Thickness(10, 0, 0, 0), Margin = new Thickness(10, 0, 0, 0),
Text = QIcon.MENU, Text = IconConstants.Menu,
BackgroundColor = Color.Transparent BackgroundColor = Color.Transparent
}; };
@@ -1,5 +1,7 @@
using Acr.UserDialogs; using Acr.UserDialogs;
using qController.Helpers;
using qController.ViewModels; using qController.ViewModels;
using Serilog;
using Xamarin.Forms; using Xamarin.Forms;
namespace qController.UI namespace qController.UI
@@ -69,7 +71,7 @@ namespace qController.UI
Margin = 0, Margin = 0,
Padding = new Thickness(0,0,15,0), Padding = new Thickness(0,0,15,0),
FontSize = App.HeightUnit * 4, FontSize = App.HeightUnit * 4,
FontFamily = App.QFont FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"]
}; };
type.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor"); type.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor");
type.SetBinding(Label.TextProperty, "type", BindingMode.OneWay); type.SetBinding(Label.TextProperty, "type", BindingMode.OneWay);
@@ -55,7 +55,7 @@ namespace qController.UI
Margin = 0, Margin = 0,
Padding = 0, Padding = 0,
FontSize = App.HeightUnit * 4, FontSize = App.HeightUnit * 4,
FontFamily = App.QFont FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"]
}; };
type.SetBinding(Label.TextProperty, "type", BindingMode.OneWay); type.SetBinding(Label.TextProperty, "type", BindingMode.OneWay);
Children.Add(type, 4, 0); Children.Add(type, 4, 0);
@@ -1,7 +1,4 @@
using System; using QControlKit;
using System.Threading.Tasks;
using QControlKit;
using Xamarin.Forms;
namespace qController.ViewModels namespace qController.ViewModels
{ {
+12 -18
View File
@@ -2,6 +2,7 @@
using Xamarin.Forms; using Xamarin.Forms;
using qController.QItems; using qController.QItems;
using System; using System;
using qController.Helpers;
namespace qController namespace qController
{ {
@@ -21,17 +22,21 @@ namespace qController
{ {
var grid = new Grid { var grid = new Grid {
Padding = 0, Padding = 0,
ColumnSpacing = 0,
ColumnDefinitions = ColumnDefinitions =
{ {
new ColumnDefinition{Width = new GridLength(30)}, new ColumnDefinition{Width = GridLength.Auto},
new ColumnDefinition { Width = GridLength.Star } new ColumnDefinition { Width = GridLength.Star }
} }
}; };
var icon = new Label { var icon = new Label {
FontFamily = App.QFont, FontFamily = (OnPlatform<string>)Application.Current.Resources["MaterialFontFamily"],
HorizontalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center,
VerticalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center,
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Margin = new Thickness(10,0,10,0),
FontSize = App.HeightUnit * 2.75 FontSize = App.HeightUnit * 2.75
}; };
@@ -47,18 +52,6 @@ namespace qController
label.SetBinding(Label.TextProperty, "Title"); label.SetBinding(Label.TextProperty, "Title");
label.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor"); label.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor");
//switch (Device.RuntimePlatform)
//{
// case Device.iOS:
// listView.RowHeight = (int)(App.HeightUnit * 5);
// label.FontSize = App.HeightUnit * 2.75;
// break;
// case Device.Android:
// listView.RowHeight = (int)(App.HeightUnit * 5);
// label.FontSize = App.HeightUnit * 2.75;
// break;
//}
grid.Children.Add(icon); grid.Children.Add(icon);
grid.Children.Add(label, 1, 0); grid.Children.Add(label, 1, 0);
return new ViewCell { View = grid }; return new ViewCell { View = grid };
@@ -81,11 +74,12 @@ namespace qController
items.Add(new MenuPageItem items.Add(new MenuPageItem
{ {
Title = "Disconnect", Title = "Disconnect",
Icon = QIcon.CANCEL, Icon = IconConstants.Close,
Command = "disconnect" Command = "disconnect"
}); });
} }
public void ChangeToWorkspace(QOldWorkspace workspace) public void ChangeToWorkspace(QOldWorkspace workspace)
{ {
for(int i = 0; i < workspace.data.Count; i++) for(int i = 0; i < workspace.data.Count; i++)
@@ -106,19 +100,19 @@ namespace qController
items.Add(new MenuPageItem items.Add(new MenuPageItem
{ {
Title = "Scan Network", Title = "Scan Network",
Icon = "\uE800", Icon = IconConstants.Magnify,
Command = "scan" Command = "scan"
}); });
items.Add(new MenuPageItem items.Add(new MenuPageItem
{ {
Title = "Send Feedback", Title = "Send Feedback",
Icon = QIcon.MAIL, Icon = IconConstants.Email,
Command = "feedback" Command = "feedback"
}); });
items.Add(new MenuPageItem items.Add(new MenuPageItem
{ {
Title = "Support Project", Title = "Support Project",
Icon = QIcon.DOLLAR, Icon = IconConstants.CurrencyUsd,
Command = "support" Command = "support"
}); });
} }