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" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.App"> x:Class="Bit.App.App">
<Application.Resources> <Application.Resources>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@ -1,6 +1,8 @@
using Bit.App.Pages; using Bit.App.Pages;
using System; using System;
using System.Reflection;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.StyleSheets;
using Xamarin.Forms.Xaml; using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)] [assembly: XamlCompilation(XamlCompilationOptions.Compile)]
@ -11,6 +13,23 @@ namespace Bit.App
public App() public App()
{ {
InitializeComponent(); 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(); MainPage = new TabsPage();
} }

View File

@ -3,12 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Controls.CipherViewCell" x:Class="Bit.App.Controls.CipherViewCell"
xmlns:controls="clr-namespace:Bit.App.Controls"> xmlns:controls="clr-namespace:Bit.App.Controls">
<ViewCell.View> <ViewCell.View>
<StackLayout x:Name="_layout" <StackLayout x:Name="_layout"
Padding="10" Padding="10"
x:DataType="controls:CipherViewCellViewModel"> x:DataType="controls:CipherViewCellViewModel">
<StackLayout.BindingContext> <StackLayout.BindingContext>
<controls:CipherViewCellViewModel /> <controls:CipherViewCellViewModel />
</StackLayout.BindingContext> </StackLayout.BindingContext>
@ -16,8 +15,7 @@
<Label Text="{Binding Cipher.Name}" <Label Text="{Binding Cipher.Name}"
LineBreakMode="NoWrap" LineBreakMode="NoWrap"
FontSize="16" /> FontSize="16" />
</StackLayout> </StackLayout>
</ViewCell.View>
</ViewCell.View>
</ViewCell> </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" <DataTemplate x:Key="folderTemplate"
x:DataType="pages:GroupingsPageListItem"> x:DataType="pages:GroupingsPageListItem">
<ViewCell> <ViewCell>
<StackLayout Padding="10"> <StackLayout StyleClass="list-cell">
<controls:FaLabel Text="&#xf07c;"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand" />
<Label Text="{Binding Folder.Name}" <Label Text="{Binding Folder.Name}"
LineBreakMode="NoWrap" LineBreakMode="TailTruncation"
FontSize="16" /> HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand" />
</StackLayout> </StackLayout>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>
@ -32,10 +36,14 @@
<DataTemplate x:Key="collectionTemplate" <DataTemplate x:Key="collectionTemplate"
x:DataType="pages:GroupingsPageListItem"> x:DataType="pages:GroupingsPageListItem">
<ViewCell> <ViewCell>
<StackLayout Padding="10"> <StackLayout StyleClass="list-cell">
<controls:FaLabel Text="&#xf1b2;"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand" />
<Label Text="{Binding Collection.Name}" <Label Text="{Binding Collection.Name}"
LineBreakMode="NoWrap" LineBreakMode="TailTruncation"
FontSize="16" /> HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand" />
</StackLayout> </StackLayout>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>

View File

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