stylesheets

This commit is contained in:
Kyle Spearrin 2019-03-29 17:54:03 -04:00
parent a1c853d7fc
commit fe52324eea
10 changed files with 92 additions and 34 deletions

View file

@ -3,6 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.App">
<Application.Resources>
</Application.Resources>
</Application>

View file

@ -1,6 +1,8 @@
using Bit.App.Pages;
using System;
using System.Reflection;
using Xamarin.Forms;
using Xamarin.Forms.StyleSheets;
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
@ -11,6 +13,23 @@ namespace Bit.App
public App()
{
InitializeComponent();
// TODO: Load theme?
if(false)
{
#pragma warning disable CS0162 // Unreachable code detected
Resources.Add(
#pragma warning restore CS0162 // Unreachable code detected
StyleSheet.FromAssemblyResource(IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly,
"Bit.App.Css.dark.css"));
}
Resources.Add(
StyleSheet.FromAssemblyResource(IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly,
"Bit.App.Css.styles.css"));
Resources.Add(
StyleSheet.FromAssemblyResource(IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly,
$"Bit.App.Css.{Device.RuntimePlatform.ToLowerInvariant()}.css"));
MainPage = new TabsPage();
}

View file

@ -3,12 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Controls.CipherViewCell"
xmlns:controls="clr-namespace:Bit.App.Controls">
<ViewCell.View>
<StackLayout x:Name="_layout"
Padding="10"
x:DataType="controls:CipherViewCellViewModel">
<StackLayout.BindingContext>
<controls:CipherViewCellViewModel />
</StackLayout.BindingContext>
@ -16,8 +15,7 @@
<Label Text="{Binding Cipher.Name}"
LineBreakMode="NoWrap"
FontSize="16" />
</StackLayout>
</ViewCell.View>
</ViewCell.View>
</ViewCell>

View file

@ -0,0 +1,20 @@
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class FaLabel : Label
{
public FaLabel()
{
switch(Device.RuntimePlatform)
{
case Device.iOS:
FontFamily = "FontAwesome";
break;
case Device.Android:
FontFamily = "FontAwesome.ttf#FontAwesome";
break;
}
}
}
}

3
src/App/Css/android.css Normal file
View file

@ -0,0 +1,3 @@
^Label, ^Entry, ^Editor {
font-size: 16;
}

3
src/App/Css/dark.css Normal file
View file

@ -0,0 +1,3 @@
^contentpage {
background-color: gray;
}

3
src/App/Css/ios.css Normal file
View file

@ -0,0 +1,3 @@
^Label, ^Entry, ^Editor {
font-size: 14;
}

12
src/App/Css/styles.css Normal file
View file

@ -0,0 +1,12 @@
^ContentPage {
background-color: white;
}
StackLayout.list-cell {
padding: 10;
-xf-orientation: horizontal;
}
StackLayout.list-cell > FaLabel {
font-size: 22;
}

View file

@ -21,10 +21,14 @@
<DataTemplate x:Key="folderTemplate"
x:DataType="pages:GroupingsPageListItem">
<ViewCell>
<StackLayout Padding="10">
<StackLayout StyleClass="list-cell">
<controls:FaLabel Text="&#xf07c;"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand" />
<Label Text="{Binding Folder.Name}"
LineBreakMode="NoWrap"
FontSize="16" />
LineBreakMode="TailTruncation"
HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ViewCell>
</DataTemplate>
@ -32,10 +36,14 @@
<DataTemplate x:Key="collectionTemplate"
x:DataType="pages:GroupingsPageListItem">
<ViewCell>
<StackLayout Padding="10">
<StackLayout StyleClass="list-cell">
<controls:FaLabel Text="&#xf1b2;"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand" />
<Label Text="{Binding Collection.Name}"
LineBreakMode="NoWrap"
FontSize="16" />
LineBreakMode="TailTruncation"
HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ViewCell>
</DataTemplate>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Pages.SettingsPage"
xmlns:pages="clr-namespace:Bit.App.Pages"
xmlns:controls="clr-namespace:Bit.App.Controls"
x:DataType="pages:SettingsPageViewModel"
Title="{Binding PageTitle}">
<ContentPage.BindingContext>
@ -12,21 +12,13 @@
<StackLayout>
<!-- Place new controls here -->
<Label
Text="Settings!"
<Label Text="Settings!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Label
Text="&#xf2b9;"
<controls:FaLabel Text="&#xf2b9;"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String"
Android="FontAwesome.ttf#FontAwesome"
iOS="FontAwesome" />
</Label.FontFamily>
</Label>
</controls:FaLabel>
</StackLayout>
</ContentPage>