Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 60beea8

Browse files
committed
Restyled app.
1 parent 2aad2bf commit 60beea8

File tree

11 files changed

+77
-75
lines changed

11 files changed

+77
-75
lines changed

XAML/ResourceDictionaries/Droid/MainActivity.cs

100755100644
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
using System;
2-
3-
using Android.App;
4-
using Android.Content;
1+
using Android.App;
52
using Android.Content.PM;
6-
using Android.Runtime;
7-
using Android.Views;
8-
using Android.Widget;
93
using Android.OS;
104

115
namespace ResourceDictionaryDemo.Droid
@@ -15,10 +9,11 @@ public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompa
159
{
1610
protected override void OnCreate (Bundle bundle)
1711
{
18-
base.OnCreate (bundle);
12+
TabLayoutResource = Resource.Layout.Tabbar;
13+
ToolbarResource = Resource.Layout.Toolbar;
1914

15+
base.OnCreate (bundle);
2016
global::Xamarin.Forms.Forms.Init (this, bundle);
21-
2217
LoadApplication (new App ());
2318
}
2419
}

XAML/ResourceDictionaries/Droid/Resources/Resource.designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ResourceDictionaryDemo.App">
2+
<Application xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="ResourceDictionaryDemo.App">
35
<Application.Resources>
4-
<ResourceDictionary>
5-
<Color x:Key="PageBackgroundColor">Yellow</Color>
6-
<Color x:Key="HeadingTextColor">Black</Color>
7-
<Color x:Key="NormalTextColor">Blue</Color>
8-
<Style x:Key="LabelPageHeadingStyle" TargetType="Label">
9-
<Setter Property="FontAttributes" Value="Bold" />
10-
<Setter Property="HorizontalOptions" Value="Center" />
11-
<Setter Property="TextColor" Value="{StaticResource HeadingTextColor}" />
12-
</Style>
13-
</ResourceDictionary>
6+
7+
<Thickness x:Key="PageMargin">20</Thickness>
8+
9+
<!-- Colors -->
10+
<Color x:Key="AppBackgroundColor">AliceBlue</Color>
11+
<Color x:Key="NavigationBarColor">#1976D2</Color>
12+
<Color x:Key="NavigationBarTextColor">White</Color>
13+
<Color x:Key="NormalTextColor">Black</Color>
14+
15+
<!-- Implicit styles -->
16+
<Style TargetType="{x:Type NavigationPage}">
17+
<Setter Property="BarBackgroundColor"
18+
Value="{StaticResource NavigationBarColor}" />
19+
<Setter Property="BarTextColor"
20+
Value="{StaticResource NavigationBarTextColor}" />
21+
</Style>
22+
23+
<Style TargetType="{x:Type ContentPage}"
24+
ApplyToDerivedTypes="True">
25+
<Setter Property="BackgroundColor"
26+
Value="{StaticResource AppBackgroundColor}" />
27+
</Style>
28+
1429
</Application.Resources>
1530
</Application>

XAML/ResourceDictionaries/ResourceDictionaryDemo/App.xaml.cs

100755100644
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
using Xamarin.Forms;
2-
using Xamarin.Forms.Xaml;
32

4-
[assembly:XamlCompilation (XamlCompilationOptions.Compile)]
53
namespace ResourceDictionaryDemo
64
{
75
public partial class App : Application
86
{
97
public App ()
108
{
119
InitializeComponent ();
12-
MainPage = new NavigationPage (new HomePage ()) { BarBackgroundColor = (Color)Application.Current.Resources ["PageBackgroundColor"] };
10+
MainPage = new NavigationPage(new HomePage());
1311
}
1412
}
1513
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using Xamarin.Forms.Xaml;
2+
3+
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

XAML/ResourceDictionaries/ResourceDictionaryDemo/HomePage.xaml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
x:Class="ResourceDictionaryDemo.HomePage"
5-
BackgroundColor="{StaticResource PageBackgroundColor}"
65
Title="Home Page">
7-
<StackLayout Margin="0,20,0,0">
8-
<StackLayout.Resources>
9-
<ResourceDictionary>
10-
<Style x:Key="LabelNormalStyle" TargetType="Label">
11-
<Setter Property="TextColor" Value="{StaticResource NormalTextColor}" />
12-
</Style>
13-
<Style x:Key="MediumBoldText" TargetType="Button">
14-
<Setter Property="FontSize" Value="Medium" />
15-
<Setter Property="FontAttributes" Value="Bold" />
16-
</Style>
6+
<StackLayout Margin="{StaticResource PageMargin}">
7+
<StackLayout.Resources>
8+
<!-- Implicit style -->
9+
<Style TargetType="Button">
10+
<Setter Property="FontSize" Value="Medium" />
11+
<Setter Property="BackgroundColor" Value="#1976D2" />
12+
<Setter Property="TextColor" Value="White" />
13+
<Setter Property="CornerRadius" Value="5" />
14+
</Style>
15+
</StackLayout.Resources>
1716

18-
</ResourceDictionary>
19-
</StackLayout.Resources>
20-
<Label Text="ResourceDictionary Demo" Style="{StaticResource LabelPageHeadingStyle}" />
21-
<Label Text="This app demonstrates consuming resources that have been defined in resource dictionaries." Margin="10,20,10,0" Style="{StaticResource LabelNormalStyle}" />
22-
<Button Text="Navigate" Clicked="OnNavigateButtonClicked" TextColor="{StaticResource NormalTextColor}" Margin="0,20,0,0" HorizontalOptions="Center" Style="{StaticResource MediumBoldText}" />
23-
</StackLayout>
17+
<Label Text="This app demonstrates consuming resources that have been defined in resource dictionaries." />
18+
<Button Text="Navigate"
19+
Clicked="OnNavigateButtonClicked" />
20+
</StackLayout>
2421
</ContentPage>
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:ResourceDictionaryDemo" x:Class="ResourceDictionaryDemo.ListDataPage" BackgroundColor="{StaticResource PageBackgroundColor}" Title="List Data Page">
2+
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="ResourceDictionaryDemo.ListDataPage"
5+
Title="List Data Page">
36
<ContentPage.Resources>
4-
<ResourceDictionary>
5-
<ResourceDictionary.MergedDictionaries>
6-
<local:MyResourceDictionary />
7-
</ResourceDictionary.MergedDictionaries>
8-
</ResourceDictionary>
7+
<ResourceDictionary Source="MyResourceDictionary.xaml" />
8+
9+
<!-- Implicit style -->
10+
<Style TargetType="{x:Type ListView}">
11+
<Setter Property="BackgroundColor"
12+
Value="{StaticResource AppBackgroundColor}" />
13+
</Style>
914
</ContentPage.Resources>
10-
<StackLayout Margin="0,20,0,0">
11-
<Label Text="ResourceDictionary Demo" Style="{StaticResource LabelPageHeadingStyle}" />
12-
<ListView x:Name="listView" ItemTemplate="{StaticResource PersonDataTemplate}" Margin="10,20,10,0" BackgroundColor="{StaticResource PageBackgroundColor}" />
13-
</StackLayout>
15+
16+
<ListView x:Name="listView"
17+
Margin="{StaticResource PageMargin}"
18+
ItemTemplate="{StaticResource PersonDataTemplate}" />
1419
</ContentPage>

XAML/ResourceDictionaries/ResourceDictionaryDemo/MyResourceDictionary.xaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ResourceDictionaryDemo.MyResourceDictionary">
2+
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
34
<DataTemplate x:Key="PersonDataTemplate">
45
<ViewCell>
56
<Grid>
@@ -8,9 +9,16 @@
89
<ColumnDefinition Width="0.2*" />
910
<ColumnDefinition Width="0.3*" />
1011
</Grid.ColumnDefinitions>
11-
<Label Text="{Binding Name}" TextColor="{StaticResource NormalTextColor}" FontAttributes="Bold" />
12-
<Label Grid.Column="1" Text="{Binding Age}" TextColor="{StaticResource NormalTextColor}" />
13-
<Label Grid.Column="2" Text="{Binding Location}" TextColor="{StaticResource NormalTextColor}" HorizontalTextAlignment="End" />
12+
<Label Text="{Binding Name}"
13+
TextColor="{StaticResource NormalTextColor}"
14+
FontAttributes="Bold" />
15+
<Label Grid.Column="1"
16+
Text="{Binding Age}"
17+
TextColor="{StaticResource NormalTextColor}" />
18+
<Label Grid.Column="2"
19+
Text="{Binding Location}"
20+
TextColor="{StaticResource NormalTextColor}"
21+
HorizontalTextAlignment="End" />
1422
</Grid>
1523
</ViewCell>
1624
</DataTemplate>

XAML/ResourceDictionaries/ResourceDictionaryDemo/MyResourceDictionary.xaml.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

XAML/ResourceDictionaries/ResourceDictionaryDemo/Person.cs

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
public class Person
44
{
55
public string Name { get; private set; }
6-
76
public int Age { get; private set; }
8-
97
public string Location { get; private set; }
108

119
public Person (string name, int age, string location)

0 commit comments

Comments
 (0)