This commit is contained in:
Javier Suárez Ruiz 2020-03-09 13:21:41 +01:00
Родитель 2cf65c7c16
Коммит 100475d335
77 изменённых файлов: 12811 добавлений и 0 удалений

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

@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".
These files will be deployed with your package and will be accessible using Android's
AssetManager, like this:
public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
InputStream input = Assets.Open ("my_asset.txt");
}
}
Additionally, some Android functions will automatically load asset files:
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");

Двоичные данные
src/RelativeSourcePlayground.Android/Assets/Montserrat-Bold.ttf Normal file

Двоичный файл не отображается.

Двоичные данные
src/RelativeSourcePlayground.Android/Assets/Montserrat-Regular.ttf Normal file

Двоичный файл не отображается.

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

@ -0,0 +1,33 @@
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace RelativeSourcePlayground.Droid
{
[Activity(Label = "RelativeSourcePlayground", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}

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

@ -0,0 +1,6 @@
<?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.companyname.relativesourceplayground">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="RelativeSourcePlayground.Android"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

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

@ -0,0 +1,30 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RelativeSourcePlayground.Android")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RelativeSourcePlayground.Android")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// Add some common permissions, these can be removed if not needed
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]

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

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8CA93138-28D4-424B-9A02-0DEC7A145FA2}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{c9e5eea5-ca05-42a1-839b-61506e0a37df}</TemplateGuid>
<OutputType>Library</OutputType>
<RootNamespace>RelativeSourcePlayground.Droid</RootNamespace>
<AssemblyName>RelativeSourcePlayground.Android</AssemblyName>
<Deterministic>True</Deterministic>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991265" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Tabbar.xml" />
<AndroidResource Include="Resources\layout\Toolbar.xml" />
<AndroidResource Include="Resources\values\styles.xml" />
<AndroidResource Include="Resources\values\colors.xml" />
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon.xml" />
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon_round.xml" />
<AndroidResource Include="Resources\mipmap-hdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-hdpi\launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-mdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-mdpi\launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-xhdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-xhdpi\launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-xxhdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-xxhdpi\launcher_foreground.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
<AndroidResource Include="Resources\drawable\coffee.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\marshmallows.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\plant.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
<AndroidResource Include="Resources\drawable\strawberry.png">
<SubType></SubType>
<Generator></Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\drawable\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RelativeSourcePlayground\RelativeSourcePlayground.csproj">
<Project>{423C1EDC-997A-4DF3-9266-6EC67255F0D1}</Project>
<Name>RelativeSourcePlayground</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\Montserrat-Bold.ttf" />
<AndroidAsset Include="Assets\Montserrat-Regular.ttf" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

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

@ -0,0 +1,50 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.
For example, a sample Android app that contains a user interface layout (main.xml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:
Resources/
drawable-hdpi/
icon.png
drawable-ldpi/
icon.png
drawable-mdpi/
icon.png
layout/
main.xml
values/
strings.xml
In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called
"Resource" that contains the tokens for each one of the resources included. For example,
for the above Resources layout, this is what the Resource class would expose:
public class Resource {
public class drawable {
public const int icon = 0x123;
}
public class layout {
public const int main = 0x456;
}
public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

11449
src/RelativeSourcePlayground.Android/Resources/Resource.designer.cs сгенерированный Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Двоичные данные
src/RelativeSourcePlayground.Android/Resources/drawable/coffee.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.8 MiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.3 MiB

Двоичные данные
src/RelativeSourcePlayground.Android/Resources/drawable/plant.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 MiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.5 MiB

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

@ -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,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/launcher_background" />
<foreground android:drawable="@mipmap/launcher_foreground" />
</adaptive-icon>

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

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/launcher_background" />
<foreground android:drawable="@mipmap/launcher_foreground" />
</adaptive-icon>

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.6 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 11 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.7 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.3 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.9 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 12 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 33 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 19 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 51 KiB

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

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="launcher_background">#FFFFFF</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

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

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.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 https://aka.ms/material-colors -->
<!-- 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>

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

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace RelativeSourcePlayground.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
}

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

@ -0,0 +1,117 @@
{
"images": [
{
"scale": "2x",
"size": "20x20",
"idiom": "iphone",
"filename": "Icon40.png"
},
{
"scale": "3x",
"size": "20x20",
"idiom": "iphone",
"filename": "Icon60.png"
},
{
"scale": "2x",
"size": "29x29",
"idiom": "iphone",
"filename": "Icon58.png"
},
{
"scale": "3x",
"size": "29x29",
"idiom": "iphone",
"filename": "Icon87.png"
},
{
"scale": "2x",
"size": "40x40",
"idiom": "iphone",
"filename": "Icon80.png"
},
{
"scale": "3x",
"size": "40x40",
"idiom": "iphone",
"filename": "Icon120.png"
},
{
"scale": "2x",
"size": "60x60",
"idiom": "iphone",
"filename": "Icon120.png"
},
{
"scale": "3x",
"size": "60x60",
"idiom": "iphone",
"filename": "Icon180.png"
},
{
"scale": "1x",
"size": "20x20",
"idiom": "ipad",
"filename": "Icon20.png"
},
{
"scale": "2x",
"size": "20x20",
"idiom": "ipad",
"filename": "Icon40.png"
},
{
"scale": "1x",
"size": "29x29",
"idiom": "ipad",
"filename": "Icon29.png"
},
{
"scale": "2x",
"size": "29x29",
"idiom": "ipad",
"filename": "Icon58.png"
},
{
"scale": "1x",
"size": "40x40",
"idiom": "ipad",
"filename": "Icon40.png"
},
{
"scale": "2x",
"size": "40x40",
"idiom": "ipad",
"filename": "Icon80.png"
},
{
"scale": "1x",
"size": "76x76",
"idiom": "ipad",
"filename": "Icon76.png"
},
{
"scale": "2x",
"size": "76x76",
"idiom": "ipad",
"filename": "Icon152.png"
},
{
"scale": "2x",
"size": "83.5x83.5",
"idiom": "ipad",
"filename": "Icon167.png"
},
{
"scale": "1x",
"size": "1024x1024",
"idiom": "ios-marketing",
"filename": "Icon1024.png"
}
],
"properties": {},
"info": {
"version": 1,
"author": "xcode"
}
}

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 69 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.7 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.6 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.6 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.1 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 845 B

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.1 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.5 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.3 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.4 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.7 KiB

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

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

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

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>CFBundleDisplayName</key>
<string>RelativeSourcePlayground</string>
<key>CFBundleIdentifier</key>
<string>com.companyname.RelativeSourcePlayground</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
<string>RelativeSourcePlayground</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
</dict>
</plist>

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

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace RelativeSourcePlayground.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
}
}

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

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RelativeSourcePlayground.iOS")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RelativeSourcePlayground.iOS")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

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

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{6143fdea-f3c2-4a09-aafa-6e230626515e}</TemplateGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RelativeSourcePlayground.iOS</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>RelativeSourcePlayground.iOS</AssemblyName>
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<ProvisioningType>automatic</ProvisioningType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchArch>x86_64</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchArch>ARM64</MtouchArch>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>None</MtouchLink>
<MtouchInterpreter>-all</MtouchInterpreter>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchArch>ARM64</MtouchArch>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon1024.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon180.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon167.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon152.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon120.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon87.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon80.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon76.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon60.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon58.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon40.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon29.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon20.png">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991265" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\RelativeSourcePlayground\RelativeSourcePlayground.csproj">
<Project>{423C1EDC-997A-4DF3-9266-6EC67255F0D1}</Project>
<Name>RelativeSourcePlayground</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\marshmallows.png" />
<BundleResource Include="Resources\plant.png" />
<BundleResource Include="Resources\strawberry.png" />
<BundleResource Include="Resources\coffee.png" />
<BundleResource Include="Resources\Montserrat-Bold.ttf" />
<BundleResource Include="Resources\Montserrat-Regular.ttf" />
</ItemGroup>
</Project>

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Default-568h@2x.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 8.7 KiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Default-Portrait.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 10 KiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Default-Portrait@2x.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 34 KiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Default.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.1 KiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Default@2x.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 8.2 KiB

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

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="X5k-f2-b5h">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238" />
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="gAE-YM-kbH">
<objects>
<viewController id="X5k-f2-b5h" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Y8P-hJ-Z43" />
<viewControllerLayoutGuide type="bottom" id="9ZL-r4-8FZ" />
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="yd7-JS-zBw">
<rect key="frame" x="0.0" y="0.0" width="600" height="600" />
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" image="Icon-60.png" translatesAutoresizingMaskIntoConstraints="NO" id="23">
<rect key="frame" x="270" y="270" width="60" height="60" />
<rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0" />
</imageView>
</subviews>
<color key="backgroundColor" red="0.20392156862745098" green="0.59607843137254901" blue="0.85882352941176465" alpha="1" colorSpace="calibratedRGB" />
<constraints>
<constraint firstItem="23" firstAttribute="centerY" secondItem="yd7-JS-zBw" secondAttribute="centerY" priority="1" id="39" />
<constraint firstItem="23" firstAttribute="centerX" secondItem="yd7-JS-zBw" secondAttribute="centerX" priority="1" id="41" />
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="XAI-xm-WK6" userLabel="First Responder" sceneMemberID="firstResponder" />
</objects>
<point key="canvasLocation" x="349" y="339" />
</scene>
</scenes>
<resources>
<image name="Icon-60.png" width="180" height="180" />
</resources>
</document>

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Montserrat-Bold.ttf Normal file

Двоичный файл не отображается.

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/Montserrat-Regular.ttf Normal file

Двоичный файл не отображается.

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/coffee.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.8 MiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/marshmallows.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.3 MiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/plant.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 MiB

Двоичные данные
src/RelativeSourcePlayground.iOS/Resources/strawberry.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.5 MiB

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

@ -0,0 +1,57 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelativeSourcePlayground.Android", "RelativeSourcePlayground.Android\RelativeSourcePlayground.Android.csproj", "{8CA93138-28D4-424B-9A02-0DEC7A145FA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelativeSourcePlayground.iOS", "RelativeSourcePlayground.iOS\RelativeSourcePlayground.iOS.csproj", "{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelativeSourcePlayground", "RelativeSourcePlayground\RelativeSourcePlayground.csproj", "{423C1EDC-997A-4DF3-9266-6EC67255F0D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Release|Any CPU.Build.0 = Release|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Debug|iPhone.Build.0 = Debug|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Release|iPhone.ActiveCfg = Release|Any CPU
{8CA93138-28D4-424B-9A02-0DEC7A145FA2}.Release|iPhone.Build.0 = Release|Any CPU
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Debug|iPhone.ActiveCfg = Debug|iPhone
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Debug|iPhone.Build.0 = Debug|iPhone
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Release|iPhone.ActiveCfg = Release|iPhone
{33DF73F5-5A24-42E8-BF95-30BFC61B3C9C}.Release|iPhone.Build.0 = Release|iPhone
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Release|Any CPU.Build.0 = Release|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Debug|iPhone.Build.0 = Debug|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Release|iPhone.ActiveCfg = Release|Any CPU
{423C1EDC-997A-4DF3-9266-6EC67255F0D1}.Release|iPhone.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

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

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Application
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" x:Class="RelativeSourcePlayground.App">
<Application.Resources>
<ResourceDictionary>
<!-- COLORS -->
<Color x:Key="WhiteColor">#FFFFFF</Color>
<Color x:Key="BlackColor">#000000</Color>
<!-- FONTS -->
<OnPlatform x:Key="MontserratRegular"
x:TypeArguments="x:String"
Android="Montserrat-Regular.ttf#Montserrat"
iOS="Montserrat-Regular" />
<OnPlatform x:Key="MontserratBold"
x:TypeArguments="x:String"
Android="Montserrat-Bold.ttf#Montserrat"
iOS="Montserrat-Bold" />
<!-- STYLES -->
<Style x:Key="DrinkTitleStyle" TargetType="Label">
<Setter Property="TextColor" Value="{StaticResource WhiteColor}" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="{StaticResource MontserratBold}" />
<Setter Property="Margin" Value="12, 0" />
</Style>
<Style x:Key="DrinkDescriptionStyle" TargetType="Label" BasedOn="{StaticResource DrinkTitleStyle}">
<Setter Property="FontSize" Value="10" />
<Setter Property="LineBreakMode" Value="CharacterWrap" />
<Setter Property="FontFamily" Value="{StaticResource MontserratRegular}" />
</Style>
<Style x:Key="BuyButtonStyle" TargetType="Button">
<Setter Property="CornerRadius" Value="12" />
<Setter Property="HeightRequest" Value="40" />
<Setter Property="WidthRequest" Value="150" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="BackgroundColor" Value="{StaticResource WhiteColor}" />
<Setter Property="BorderWidth" Value="1" />
<Setter Property="FontFamily" Value="{StaticResource MontserratRegular}" />
</Style>
<Style x:Key="DrinkPanelStyle" TargetType="Frame">
<Setter Property="CornerRadius" Value="24" />
<Setter Property="HasShadow" Value="True" />
<Setter Property="Margin" Value="6" />
</Style>
<Style x:Key="DrinkImagePanelStyle" TargetType="Grid">
<Setter Property="Margin" Value="6" />
</Style>
<Style x:Key="DrinkImageStyle" TargetType="Image">
<Setter Property="Margin" Value="6" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>

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

@ -0,0 +1,27 @@
using RelativeSourcePlayground.Views;
using Xamarin.Forms;
namespace RelativeSourcePlayground
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MainView());
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
}
protected override void OnResume()
{
}
}
}

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

@ -0,0 +1,3 @@
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

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

@ -0,0 +1,36 @@
using Xamarin.Forms;
namespace RelativeSourcePlayground.Controls
{
public class DrinkCardView : ContentView
{
public static readonly BindableProperty DrinkTitleProperty = BindableProperty.Create(nameof(DrinkTitle), typeof(string), typeof(DrinkCardView), string.Empty);
public static readonly BindableProperty DrinkDescriptionProperty = BindableProperty.Create(nameof(DrinkDescription), typeof(string), typeof(DrinkCardView), string.Empty);
public static readonly BindableProperty DrinkColorProperty = BindableProperty.Create(nameof(DrinkColor), typeof(Color), typeof(DrinkCardView), Color.Default);
public static readonly BindableProperty DrinkImageSourceProperty = BindableProperty.Create(nameof(DrinkImageSource), typeof(ImageSource), typeof(DrinkCardView), default(ImageSource));
public string DrinkTitle
{
get => (string)GetValue(DrinkTitleProperty);
set => SetValue(DrinkTitleProperty, value);
}
public string DrinkDescription
{
get => (string)GetValue(DrinkDescriptionProperty);
set => SetValue(DrinkDescriptionProperty, value);
}
public Color DrinkColor
{
get => (Color)GetValue(DrinkColorProperty);
set => SetValue(DrinkColorProperty, value);
}
public ImageSource DrinkImageSource
{
get => (ImageSource)GetValue(DrinkImageSourceProperty);
set => SetValue(DrinkImageSourceProperty, value);
}
}
}

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

@ -0,0 +1,13 @@
using Xamarin.Forms;
namespace RelativeSourcePlayground.Models
{
public class Drink
{
public string Title { get; set; }
public string Description { get; set; }
public string Image { get; set; }
public double Price { get; set; }
public Color Color { get; set; }
}
}

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

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991265" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
<Folder Include="Models\" />
<Folder Include="ViewModels\" />
<Folder Include="Controls\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\RelativeSourceTemplatedParentView.xaml.cs">
<DependentUpon>RelativeSourceTemplatedParentView.xaml</DependentUpon>
</Compile>
<Compile Update="Views\RelativeSourceFindAncestorView.xaml.cs">
<DependentUpon>RelativeSourceFindAncestorView.xaml</DependentUpon>
</Compile>
<Compile Update="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>

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

@ -0,0 +1,45 @@
using System.Collections.ObjectModel;
using System.Windows.Input;
using RelativeSourcePlayground.Models;
using Xamarin.Forms;
namespace RelativeSourcePlayground.ViewModels
{
public class RelativeSourceViewModel : BindableObject
{
private ObservableCollection<Drink> _drinks;
public RelativeSourceViewModel()
{
LoadDrinks();
}
public ObservableCollection<Drink> Drinks
{
get { return _drinks; }
set
{
_drinks = value;
OnPropertyChanged();
}
}
public ICommand BuyCommand => new Command<Drink>(OnBuy);
void LoadDrinks()
{
Drinks = new ObservableCollection<Drink>()
{
new Drink { Image="coffee.png", Title = "BRAZILIAN COFFEE", Color= Color.Maroon, Price =3.5, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." },
new Drink { Image="marshmallows.png", Title = "HOT CHOCOLATE WITH MARSHMALLOWS", Color= Color.Wheat, Price = 8, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." },
new Drink { Image="plant.png", Title = "MILK WITH MINT", Color= Color.Green, Price = 7.99, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." },
new Drink { Image="strawberry.png", Title = "STRAWBERRY MILK", Color= Color.Red, Price = 6.5, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." }
};
}
void OnBuy(Drink drink)
{
MessagingCenter.Send(this, "dialog", drink);
}
}
}

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

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RelativeSourcePlayground.Views.MainView"
xmlns:views="clr-namespace:RelativeSourcePlayground.Views"
Title="RelativeSource Playground">
<ContentPage.Content>
<Grid
Padding="12">
<TableView
Intent="Menu">
<TableRoot>
<TableSection
Title="Relative Bindings">
<TextCell
Text="Relative bindings to self"
Detail="Define the binding source using Self mode"
Command="{Binding NavigateCommand}"
CommandParameter="{x:Type views:RelativeSourceSelfView}" />
<TextCell
Text="Relative bindings to an ancestor"
Detail="Define the binding source using FindAncestor mode"
Command="{Binding NavigateCommand}"
CommandParameter="{x:Type views:RelativeSourceFindAncestorView}" />
<TextCell
Text="Relative bindings to a templated parent"
Detail="Define the binding source using TemplatedParent mode"
Command="{Binding NavigateCommand}"
CommandParameter="{x:Type views:RelativeSourceTemplatedParentView}" />
</TableSection>
</TableRoot>
</TableView>
</Grid>
</ContentPage.Content>
</ContentPage>

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

@ -0,0 +1,25 @@
using System;
using System.Windows.Input;
using Xamarin.Forms;
namespace RelativeSourcePlayground.Views
{
public partial class MainView : ContentPage
{
public MainView()
{
InitializeComponent();
NavigateCommand = new Command<Type>(
async (Type pageType) =>
{
Page page = (Page)Activator.CreateInstance(pageType);
await Navigation.PushAsync(page);
});
BindingContext = this;
}
public ICommand NavigateCommand { get; private set; }
}
}

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

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodels="clr-namespace:RelativeSourcePlayground.ViewModels"
x:Class="RelativeSourcePlayground.Views.RelativeSourceFindAncestorView"
Title="RelativeSource FindAncestor">
<ContentPage.BindingContext>
<viewmodels:RelativeSourceViewModel />
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout
Padding="12">
<Label
Text="In this example, the button's Command property is bound to the BuyCommand in its parent's view model."/>
<CollectionView
ItemsSource="{Binding Drinks}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Frame
BackgroundColor="{Binding Color}"
Style="{StaticResource DrinkPanelStyle}">
<Grid
HeightRequest="120"
ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label
Grid.Row="0"
Text="{Binding Title}"
Style="{StaticResource DrinkTitleStyle}"/>
<Label
Grid.Row="1"
Text="{Binding Description}"
Style="{StaticResource DrinkDescriptionStyle}" />
</Grid>
<Grid
Grid.Column="1"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Source="{Binding Image}"/>
<Button
Grid.Row="1"
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:RelativeSourceViewModel}}, Path=BuyCommand}"
CommandParameter="{Binding Source={RelativeSource Self}, Path=BindingContext}"
TextColor="{Binding Color}"
BorderColor="{Binding Color}"
Text="{Binding Price, StringFormat='{0:C}'}"
Style="{StaticResource BuyButtonStyle}"/>
</Grid>
</Grid>
</Frame>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

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

@ -0,0 +1,19 @@
using RelativeSourcePlayground.Models;
using RelativeSourcePlayground.ViewModels;
using Xamarin.Forms;
namespace RelativeSourcePlayground.Views
{
public partial class RelativeSourceFindAncestorView : ContentPage
{
public RelativeSourceFindAncestorView()
{
InitializeComponent();
MessagingCenter.Subscribe<RelativeSourceViewModel, Drink>(this, "dialog", async (sender, arg) =>
{
await DisplayAlert("Buy", arg.Title, "OK");
});
}
}
}

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

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RelativeSourcePlayground.Views.RelativeSourceSelfView"
Title="RelativeSource Self"
BindingContext="{Binding Source={RelativeSource Self}, Path=Drink}">
<ContentPage.Content>
<StackLayout
Padding="12">
<Label
Text="In this example, the page's BindingContext is bound to its own Drinks property."/>
<Grid
Margin="24">
<Grid>
<Frame
BackgroundColor="{Binding Color}"
Style="{StaticResource DrinkPanelStyle}">
<Grid
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="48" />
</Grid.RowDefinitions>
<Grid
Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label
Grid.Row="0"
Text="{Binding Title}"
Style="{StaticResource DrinkTitleStyle}"/>
<Label
Grid.Row="1"
Text="{Binding Description}"
Style="{StaticResource DrinkDescriptionStyle}" />
</Grid>
<Grid
Grid.Row="1"
Style="{StaticResource DrinkImagePanelStyle}">
<Image
Source="{Binding Image}"
Style="{StaticResource DrinkImageStyle}"/>
</Grid>
<Grid
Grid.Row="2">
<Button
TextColor="{Binding Color}"
BorderColor="{Binding Color}"
Text="{Binding Price, StringFormat='{0:C}'}"
Style="{StaticResource BuyButtonStyle}"/>
</Grid>
</Grid>
</Frame>
</Grid>
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>

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

@ -0,0 +1,22 @@
using RelativeSourcePlayground.Models;
using Xamarin.Forms;
namespace RelativeSourcePlayground.Views
{
public partial class RelativeSourceSelfView : ContentPage
{
public RelativeSourceSelfView()
{
InitializeComponent();
}
public Drink Drink { get; } = new Drink
{
Image = "coffee.png",
Title = "BRAZILIAN COFFEE",
Color = Color.Maroon,
Price = 3.5,
Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
};
}
}

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

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:RelativeSourcePlayground.Controls"
x:Class="RelativeSourcePlayground.Views.RelativeSourceTemplatedParentView"
Title="RelativeSource TemplatedParent">
<ContentPage.Resources>
<ResourceDictionary>
<ControlTemplate x:Key="DrinkCardViewControlTemplate">
<!--
In this example, the frame's BindingContext is set to the control instance that the template is applied to. Therefore,
the binding expressions resolve against the properties of each DrinkCardView object.
-->
<Grid>
<Frame
BindingContext="{Binding Source={RelativeSource TemplatedParent}}"
BackgroundColor="{Binding DrinkColor}"
Style="{StaticResource DrinkPanelStyle}">
<Grid
HeightRequest="120"
ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label
Grid.Row="0"
Text="{Binding DrinkTitle}"
Style="{StaticResource DrinkTitleStyle}"/>
<Label
Grid.Row="1"
Text="{Binding DrinkDescription}"
Style="{StaticResource DrinkDescriptionStyle}" />
</Grid>
<Grid
Grid.Column="1"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Source="{Binding DrinkImageSource}"/>
</Grid>
</Grid>
</Frame>
</Grid>
</ControlTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView>
<StackLayout
Margin="10">
<Label
Text="In this example, the frame's BindingContext is set to the control instance that the template is applied to. Therefore, the binding expressions resolve against the properties of each DrinkCardView object."/>
<controls:DrinkCardView
DrinkTitle="BRAZILIAN COFFEE"
DrinkDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
DrinkColor="Maroon"
DrinkImageSource="coffee.png"
ControlTemplate="{StaticResource DrinkCardViewControlTemplate}" />
<controls:DrinkCardView
DrinkTitle="HOT CHOCOLATE WITH MARSHMALLOWS"
DrinkDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
DrinkColor="Wheat"
DrinkImageSource="marshmallows.png"
ControlTemplate="{StaticResource DrinkCardViewControlTemplate}" />
<controls:DrinkCardView
DrinkTitle="MILK WITH MINT"
DrinkDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
DrinkColor="Green"
DrinkImageSource="plant.png"
ControlTemplate="{StaticResource DrinkCardViewControlTemplate}" />
<controls:DrinkCardView
DrinkTitle="STRAWBERRY MILK"
DrinkDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
DrinkColor="Red"
DrinkImageSource="strawberry.png"
ControlTemplate="{StaticResource DrinkCardViewControlTemplate}" />
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>

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

@ -0,0 +1,12 @@
using Xamarin.Forms;
namespace RelativeSourcePlayground.Views
{
public partial class RelativeSourceTemplatedParentView : ContentPage
{
public RelativeSourceTemplatedParentView()
{
InitializeComponent();
}
}
}