Made the samples look nicer and more modern

This commit is contained in:
Matthew Leibowitz 2016-06-09 06:49:58 +02:00
Родитель f1af81508a
Коммит 8dc0cc3f16
13 изменённых файлов: 209 добавлений и 62 удалений

Просмотреть файл

@ -904,6 +904,15 @@ Task ("Default")
.IsDependentOn ("externals")
.IsDependentOn ("libs");
Task ("Everything")
.IsDependentOn ("externals")
.IsDependentOn ("libs")
.IsDependentOn ("docs")
.IsDependentOn ("nuget")
.IsDependentOn ("component")
.IsDependentOn ("tests")
.IsDependentOn ("samples");
////////////////////////////////////////////////////////////////////////////////////////////////////
// CI - the master target to build everything
////////////////////////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -1,21 +1,19 @@
using System;
using Android.App;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.IO;
namespace Skia.Forms.Demo.Droid
{
[Activity (Label = "Skia.Forms.Demo.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
[Activity (Label = "Skia.Forms.Demo.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate (Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
// set up resource paths
string fontName = "content-font.ttf";
string fontPath = Path.Combine (CacheDir.AbsolutePath, fontName);

Просмотреть файл

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.skia_forms_demo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.skia_forms_demo" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<application android:label="Skia.Forms.Demo">
</application>
</manifest>
<application android:label="SkiaSharp for Xamarin.Forms" android:icon="@drawable/icon"></application>
</manifest>

Просмотреть файл

@ -2591,6 +2591,9 @@ namespace Skia.Forms.Demo.Droid
// aapt resource value: 0x7f070013
public const int showTitle = 2131165203;
// aapt resource value: 0x7f070098
public const int sliding_tabs = 2131165336;
// aapt resource value: 0x7f07006c
public const int snackbar_action = 2131165292;
@ -2645,6 +2648,9 @@ namespace Skia.Forms.Demo.Droid
// aapt resource value: 0x7f070048
public const int title_template = 2131165256;
// aapt resource value: 0x7f070099
public const int toolbar = 2131165337;
// aapt resource value: 0x7f070032
public const int top = 2131165234;
@ -2912,6 +2918,12 @@ namespace Skia.Forms.Demo.Droid
// aapt resource value: 0x7f030036
public const int support_simple_spinner_dropdown_item = 2130903094;
// aapt resource value: 0x7f030037
public const int Tabbar = 2130903095;
// aapt resource value: 0x7f030038
public const int Toolbar = 2130903096;
static Layout()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
@ -3067,6 +3079,9 @@ namespace Skia.Forms.Demo.Droid
// aapt resource value: 0x7f0a015a
public const int Animation_Design_BottomSheetDialog = 2131362138;
// aapt resource value: 0x7f0a0174
public const int AppCompatDialogStyle = 2131362164;
// aapt resource value: 0x7f0a00a5
public const int Base_AlertDialog_AppCompat = 2131361957;
@ -3508,6 +3523,12 @@ namespace Skia.Forms.Demo.Droid
// aapt resource value: 0x7f0a001a
public const int CardView_Light = 2131361818;
// aapt resource value: 0x7f0a0172
public const int MyTheme = 2131362162;
// aapt resource value: 0x7f0a0173
public const int MyTheme_Base = 2131362163;
// aapt resource value: 0x7f0a0032
public const int Platform_AppCompat = 2131361842;

Просмотреть файл

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:tabIndicatorColor="@android:color/white" app:tabGravity="fill" app:tabMode="fixed" />

Просмотреть файл

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Просмотреть файл

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>

Просмотреть файл

@ -20,7 +20,7 @@
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
@ -29,6 +29,12 @@
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<ConsolePause>false</ConsolePause>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
<BundleAssemblies>False</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<Debugger>Xamarin</Debugger>
<AndroidEnableMultiDex>False</AndroidEnableMultiDex>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
@ -120,11 +126,10 @@
<None Include="Properties\AndroidManifest.xml" />
<None Include="Assets\AboutAssets.txt" />
<None Include="packages.config" />
<AndroidResource Include="Resources\layout\Tabbar.axml" />
<AndroidResource Include="Resources\layout\Toolbar.axml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\layout\" />
<Folder Include="Resources\values\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<AndroidResource Include="Resources\drawable\icon.png" />
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
@ -136,6 +141,9 @@
<Link>Assets\content-font.ttf</Link>
</AndroidAsset>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\styles.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

Просмотреть файл

@ -1,52 +1,134 @@
using System;
using System.Linq;
using Xamarin.Forms;
using SkiaSharp;
namespace Skia.Forms.Demo
{
public class App : Application
{
public App ()
{
ListView listView;
var listPage = new ContentPage {
Content = listView = new ListView (),
Title = "Skia Demo",
};
public class App : Application
{
public static readonly Color XamarinBlue = Color.FromHex("3498db");
public static readonly Color XamarinGreen = Color.FromHex("77d065");
public static readonly Color XamarinPurple = Color.FromHex("b455b6");
public static readonly Color XamarinDark = Color.FromHex("2c3e50");
NavigationPage navPage;
MainPage = navPage = new NavigationPage (listPage) {
BarBackgroundColor = new Xamarin.Forms.Color (0x34/255.0, 0x98/255.0, 0xdb/255.0),
BarTextColor = Xamarin.Forms.Color.White,
};
public App()
{
var items =
Device.OS == TargetPlatform.iOS ? Demos.SamplesForPlatform(Demos.Platform.iOS) :
Device.OS == TargetPlatform.Android ? Demos.SamplesForPlatform(Demos.Platform.Android) :
Device.OS == TargetPlatform.Windows ? Demos.SamplesForPlatform(Demos.Platform.UWP) :
Demos.SamplesForPlatform(Demos.Platform.All);
listView.ItemsSource = Demos.SamplesForPlatform (Demos.Platform.iOS | Demos.Platform.Android);
var masterDetail = new MasterDetailPage
{
IsGestureEnabled = true,
MasterBehavior = MasterBehavior.Popover
};
var detailPage = new DetailsPage(items.First());
var navPage = new NavigationPage(detailPage)
{
BarBackgroundColor = XamarinBlue,
BarTextColor = Color.White,
};
var masterPage = new MasterPage(items, demo =>
{
masterDetail.IsPresented = false;
detailPage.SetDemo(demo);
navPage.Title = demo;
});
listView.ItemSelected += (sender, e) => {
if (e.SelectedItem == null) return;
listView.SelectedItem = null;
masterDetail.Master = masterPage;
masterDetail.Detail = navPage;
navPage.PushAsync (new ContentPage {
Content = new SkiaView (SkiaSharp.Demos.GetSample (e.SelectedItem.ToString ())),
});
};
}
MainPage = masterDetail;
}
protected override void OnStart ()
{
// Handle when your app starts
}
public class DetailsPage : ContentPage
{
public DetailsPage(string demo)
{
SetDemo(demo);
}
protected override void OnSleep ()
{
// Handle when your app sleeps
}
public void SetDemo(string demo)
{
Title = demo;
Content = new SkiaView(Demos.GetSample(demo));
}
}
protected override void OnResume ()
{
// Handle when your app resumes
}
}
public class MasterPage : ContentPage
{
private readonly ListView listView;
private readonly Action<string> showDemo;
public MasterPage(string[] items, Action<string> showDemo)
{
this.showDemo = showDemo;
Title = "SkiaSharp";
BackgroundColor = Color.FromHex("EEEEEE");
// a nice header
var header = new ContentView
{
BackgroundColor = XamarinDark,
Padding = new Thickness(12, 72, 12, 12),
Margin = 0,
Content = new Label
{
Text = Title,
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
TextColor = Color.White
},
};
var spacer = new BoxView
{
Color = XamarinBlue,
HorizontalOptions = LayoutOptions.Fill,
Margin = 0,
HeightRequest = 3
};
// the contents of the menu
listView = new ListView()
{
ItemsSource = items,
};
listView.ItemSelected += OnItemSelected;
// UWP specific for more spacing there
if (Device.OS == TargetPlatform.Windows)
{
listView.RowHeight = 30;
listView.Margin = new Thickness(12, 6);
header.Padding = new Thickness(12, 36, 12, 12);
}
// put it all together
Content = new StackLayout
{
Children = { header, spacer, listView },
Padding = 0,
Spacing = 0
};
}
private void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
// deselect the menu item
if (e.SelectedItem == null)
{
return;
}
listView.SelectedItem = null;
// display the selected demo
showDemo(e.SelectedItem.ToString());
}
}
}
}

Просмотреть файл

@ -3,8 +3,8 @@
<Identity Name="f736c883-f105-4d30-a719-4bf328872f5e" Publisher="CN=Xamarin" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="f736c883-f105-4d30-a719-4bf328872f5e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>FPCL.WIndows</DisplayName>
<PublisherDisplayName>joaqu</PublisherDisplayName>
<DisplayName>SkiaSharp for Xamarin.Forms</DisplayName>
<PublisherDisplayName>Xamarin</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="FPCL.WIndows.App">
<uap:VisualElements DisplayName="FPCL.WIndows" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="FPCL.WIndows" BackgroundColor="transparent">
<uap:VisualElements DisplayName="SkiaSharp for Xamarin.Forms" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="FPCL.WIndows" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />

Просмотреть файл

@ -24,8 +24,7 @@ namespace Skia.Forms.Demo.iOS
SkiaSharp.Demos.WorkingDirectory = dir;
SkiaSharp.Demos.OpenFileDelegate = path =>
{
var nav = Xamarin.Forms.Platform.iOS.Platform.GetRenderer (Xamarin.Forms.Application.Current.MainPage) as UINavigationController;
var vc = nav.VisibleViewController;
var vc = Xamarin.Forms.Platform.iOS.Platform.GetRenderer(Xamarin.Forms.Application.Current.MainPage) as UIViewController;
var resourceToOpen = NSUrl.FromFilename (Path.Combine (dir, path));
var controller = UIDocumentInteractionController.FromUrl (resourceToOpen);
if (!controller.PresentOpenInMenu (vc.View.Bounds, vc.View, true))

Просмотреть файл

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>Skia.Forms.Demo</string>
<string>SkiaSharp for Xamarin.Forms</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.skia-forms-demo</string>
<key>CFBundleShortVersionString</key>

Просмотреть файл

@ -11,14 +11,14 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480" />
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 billholmes" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines"
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copyright (c) 2016 Xamarin" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21" />
<fontDescription key="fontDescription" type="system" pointSize="17" />
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Skia.Forms.Demo.iOS" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SkiaSharp for Xamarin.Forms" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43" />
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />