├── .gitignore
├── CoreSample
├── CoreSample.cs
├── CoreSample.projitems
├── CoreSample.shproj
├── MainPage.cs
├── Page1.cs
├── Page2.cs
├── Page3.cs
└── Page4.cs
├── Droid
├── Assets
│ └── AboutAssets.txt
├── CoreSample.Droid.csproj
├── MainActivity.cs
├── MainApplication.cs
├── Properties
│ ├── AndroidManifest.xml
│ └── AssemblyInfo.cs
├── Resources
│ ├── AboutResources.txt
│ ├── Resource.designer.cs
│ ├── drawable-hdpi
│ │ ├── balloon.jpg
│ │ └── icon.png
│ ├── drawable-xhdpi
│ │ ├── balloon.jpg
│ │ └── icon.png
│ ├── drawable-xxhdpi
│ │ ├── balloon.jpg
│ │ └── icon.png
│ └── drawable
│ │ ├── balloon.jpg
│ │ └── icon.png
└── packages.config
├── LICENSE
├── README.md
├── Resources
├── README.md
├── balloon.jpg
├── resize_images.py
└── resize_images.yml
├── Screenshots
└── Screenshot1.png
├── Uniforms.Misc.Droid
├── Properties
│ └── AssemblyInfo.cs
├── Renderers
│ └── RoundedBoxRenderer.cs
├── Resources
│ ├── AboutResources.txt
│ ├── Resource.designer.cs
│ └── values
│ │ └── Strings.xml
├── Uniforms.Misc.Droid.csproj
├── Utils
│ ├── ImageUtils.cs
│ ├── ScreenUtils.cs
│ └── TextUtils.cs
└── packages.config
├── Uniforms.Misc.iOS
├── Properties
│ └── AssemblyInfo.cs
├── Renderers
│ └── RoundedBoxRenderer.cs
├── Uniforms.Misc.iOS.csproj
├── Utils
│ ├── ImageUtils.cs
│ ├── KeyboardUtils.cs
│ ├── ScreenUtils.cs
│ └── TextUtils.cs
└── packages.config
├── Uniforms.Misc.nuspec
├── Uniforms.Misc.sln
├── Uniforms.Misc
├── Properties
│ └── AssemblyInfo.cs
├── Uniforms.Misc.csproj
├── Utils
│ ├── ImageUtils.cs
│ ├── KeyboardUtils.cs
│ ├── ScreenUtils.cs
│ └── TextUtils.cs
├── Views
│ └── RoundedBox.cs
└── packages.config
├── build.sh
└── iOS
├── AppDelegate.cs
├── CoreSample.iOS.csproj
├── Entitlements.plist
├── Info.plist
├── Main.cs
├── Resources
├── Graphics
│ ├── balloon.jpg
│ ├── balloon@2x.jpg
│ └── balloon@3x.jpg
├── Images.xcassets
│ └── AppIcons.appiconset
│ │ └── Contents.json
└── LaunchScreen.xib
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | # User-specific files
2 | *.suo
3 | *.user
4 | *.sln.docstates
5 | *.DS_Store
6 | *.userprefs
7 | *.jf
8 |
9 | # Restored packages
10 | /packages
11 |
12 | # Build results
13 | .builds
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | x64/
18 | build/
19 | bld/
20 | [Bb]in/
21 | [Oo]bj/
22 |
23 | *_i.c
24 | *_p.c
25 | *_i.h
26 | *.dll
27 | *.ilk
28 | *.mdb
29 | *.meta
30 | *.nupkg
31 | *.obj
32 | *.pch
33 | *.pdb
34 | *.pgc
35 | *.pgd
36 | *.rsp
37 | *.sbr
38 | *.tlb
39 | *.tli
40 | *.tlh
41 | *.tmp
42 | *.tmp_proj
43 | *.log
44 | *.vspscc
45 | *.vssscc
46 | *.pidb
47 | *.svclog
48 | *.scc
49 |
--------------------------------------------------------------------------------
/CoreSample/CoreSample.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 | using Uniforms.Misc;
4 |
5 | namespace CoreSample
6 | {
7 | #if __ANDROID__
8 | using Activity = Android.App.Activity;
9 | using Bundle = Android.OS.Bundle;
10 | #endif
11 |
12 | public class CoreSample : Application
13 | {
14 | //
15 | // Init platform
16 | //
17 |
18 | #if __ANDROID__
19 | public static void InitPlatform(Activity context, Bundle bundle)
20 | #else
21 | public static void InitPlatform()
22 | #endif
23 | {
24 | #if __ANDROID__
25 | Xamarin.Forms.Forms.Init(context, bundle);
26 | Uniforms.Misc.Droid.ScreenUtils.Init ();
27 | Uniforms.Misc.Droid.ImageUtils.Init ();
28 | Uniforms.Misc.Droid.TextUtils.Init ();
29 | #endif
30 |
31 | #if __IOS__
32 | Xamarin.Forms.Forms.Init();
33 | Uniforms.Misc.iOS.ScreenUtils.Init ();
34 | Uniforms.Misc.iOS.ImageUtils.Init ();
35 | Uniforms.Misc.iOS.KeyboardUtils.Init ();
36 | Uniforms.Misc.iOS.TextUtils.Init ();
37 | #endif
38 | }
39 |
40 | //
41 | // Constructor
42 | //
43 |
44 | public CoreSample()
45 | {
46 | MainPage = new MainPage();
47 | }
48 |
49 | //
50 | // Overrides
51 | //
52 |
53 | protected override void OnStart()
54 | {
55 | // Handle when your app starts
56 | }
57 |
58 | protected override void OnSleep()
59 | {
60 | // Handle when your app sleeps
61 | }
62 |
63 | protected override void OnResume()
64 | {
65 | // Handle when your app resumes
66 | }
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/CoreSample/CoreSample.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {2EE45A47-CCB7-4C54-A812-57C4FFCC7409}
7 |
8 |
9 | CoreSample
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/CoreSample/CoreSample.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {2EE45A47-CCB7-4C54-A812-57C4FFCC7409}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CoreSample/MainPage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 |
4 | namespace CoreSample
5 | {
6 | public class MainPage : TabbedPage
7 | {
8 | public MainPage()
9 | {
10 | Title = "Uniforms.Misc";
11 |
12 | Children.Add (new Page1 ());
13 | Children.Add (new Page2 ());
14 | Children.Add (new Page3 ());
15 | Children.Add (new Page4 ());
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CoreSample/Page1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 | using Uniforms.Misc;
4 |
5 | namespace CoreSample
6 | {
7 | public class Page1 : ContentPage
8 | {
9 | public Page1()
10 | {
11 | Title = "Welcome";
12 |
13 | var screenSize = ScreenUtils.ScreenSize;
14 |
15 | var fontSize = 32.0;
16 | var testText = "La-la-la\nHa-ha-ha!";
17 | var textSize = TextUtils.GetTextSize (
18 | testText, screenSize.Width, fontSize);
19 |
20 | Content = new StackLayout {
21 | VerticalOptions = LayoutOptions.Center,
22 | Children = {
23 | new Label {
24 | HorizontalTextAlignment = TextAlignment.Center,
25 | Text = "Welcome to Xamarin Forms!"
26 | },
27 | new Label {
28 | HorizontalTextAlignment = TextAlignment.Center,
29 | Text = String.Format(
30 | "Screen width = {0}\n Screen height = {1}",
31 | screenSize.Width, screenSize.Height)
32 | },
33 | new Label {
34 | HorizontalTextAlignment = TextAlignment.Center,
35 | FontSize = fontSize,
36 | Text = testText
37 | },
38 | new Label {
39 | HorizontalTextAlignment = TextAlignment.Center,
40 | Text = $"(text height = {textSize.Height})"
41 | },
42 | new RoundedBox {
43 | HorizontalOptions = LayoutOptions.Center,
44 | HeightRequest = 50,
45 | WidthRequest = 50,
46 | BackgroundColor = Color.Purple,
47 | CornerRadius = 10,
48 |
49 | ShadowOffset = new Size(0, 2.0),
50 | ShadowOpacity = 0.5,
51 | ShadowRadius = 2.0,
52 | },
53 | }
54 | };
55 | }
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/CoreSample/Page2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 | using Uniforms.Misc;
4 |
5 | namespace CoreSample
6 | {
7 | public class Page2 : ContentPage
8 | {
9 | public Page2()
10 | {
11 | Title = "Images";
12 |
13 | const string imageName = "Graphics/balloon.jpg";
14 | var imageSize = ImageUtils.GetImageSize(imageName);
15 |
16 | Content = new StackLayout {
17 | VerticalOptions = LayoutOptions.Center,
18 | Children = {
19 | new Label {
20 | HorizontalTextAlignment = TextAlignment.Center,
21 | Text = String.Format("Image: {0}", imageName)
22 | },
23 | new Image {
24 | HorizontalOptions = LayoutOptions.Center,
25 | Source = imageName
26 | },
27 | new Label {
28 | HorizontalTextAlignment = TextAlignment.Center,
29 | Text = String.Format("Size: {0} x {1}",
30 | imageSize.Width, imageSize.Height)
31 | },
32 | }
33 | };
34 | }
35 | }
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/CoreSample/Page3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Xamarin.Forms;
4 | using Uniforms.Misc;
5 |
6 | namespace CoreSample
7 | {
8 | using CrossMedia = Plugin.Media.CrossMedia;
9 | using MediaOptions = Plugin.Media.Abstractions.StoreCameraMediaOptions;
10 |
11 | public class Page3 : ContentPage
12 | {
13 | const double resizedImageSize = 300;
14 |
15 | Image takenImage;
16 |
17 | public Page3()
18 | {
19 | Title = "Resize";
20 |
21 | var getPhotoButton = new Button {
22 | Text = "Tap to pick a photo",
23 | HorizontalOptions = LayoutOptions.Center
24 | };
25 | getPhotoButton.Clicked += GetPhotoButtonClicked;
26 |
27 | Content = new StackLayout {
28 | VerticalOptions = LayoutOptions.Center,
29 | Children = {
30 | getPhotoButton,
31 | }
32 | };
33 | }
34 |
35 | async void GetPhotoButtonClicked(object sender, EventArgs e)
36 | {
37 | if (await CrossMedia.Current.Initialize())
38 | {
39 | //if (!CrossMedia.Current.IsCameraAvailable ||
40 | // !CrossMedia.Current.IsTakePhotoSupported)
41 | //{
42 | // await DisplayAlert("Error", "Sorry, can't connect to camera!", "OK");
43 | // return;
44 | //}
45 |
46 | //var options = new MediaOptions {
47 | // Directory = "Temp",
48 | // Name = "photo.jpg"
49 | //};
50 |
51 | if (!CrossMedia.Current.IsPickPhotoSupported) {
52 | await DisplayAlert ("Error", "Sorry, can't pick a photo!", "OK");
53 | return;
54 | }
55 |
56 | var mediaFile = await CrossMedia.Current.PickPhotoAsync ();
57 |
58 | if (mediaFile != null)
59 | {
60 | var layout = Content as StackLayout;
61 |
62 | if (takenImage != null)
63 | {
64 | layout.Children.Remove(takenImage);
65 | }
66 |
67 | var imageSource = ImageSource.FromStream(() => {
68 | var origStream = mediaFile.GetStream();
69 | var resizedStream = GetResizedImageStream(mediaFile.GetStream());
70 | origStream.Dispose();
71 | mediaFile.Dispose();
72 | return resizedStream;
73 | });
74 |
75 | takenImage = new Image {
76 | HorizontalOptions = LayoutOptions.Center,
77 | Source = imageSource
78 | };
79 |
80 | layout.Children.Add(takenImage);
81 | }
82 | }
83 | }
84 |
85 | static Stream GetResizedImageStream(Stream imageStream)
86 | {
87 | return ImageUtils.ResizeImage(
88 | imageStream, resizedImageSize, resizedImageSize);
89 | }
90 | }
91 | }
92 |
93 |
94 |
--------------------------------------------------------------------------------
/CoreSample/Page4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using Xamarin.Forms;
4 | using Uniforms.Misc;
5 |
6 | namespace CoreSample
7 | {
8 | public class Page4 : ContentPage
9 | {
10 | Label label;
11 |
12 | public Page4 ()
13 | {
14 | Title = "Keyboard";
15 |
16 | KeyboardUtils.KeyboardHeightChanged += OnKeyboardHeightChanged;
17 |
18 | label = new Label {
19 | Text = "Keyboard is hidden"
20 | };
21 |
22 | Content = new StackLayout {
23 | VerticalOptions = LayoutOptions.Center,
24 |
25 | Spacing = 10.0,
26 | Padding = 20.0,
27 |
28 | Children = {
29 | new Entry {
30 | Placeholder = "Enter some text...",
31 | },
32 | label
33 | },
34 | };
35 | }
36 |
37 | void OnKeyboardHeightChanged (double height)
38 | {
39 | Debug.WriteLine ($"OnKeyboardHeightChanged: {height}");
40 |
41 | label.Text = $"Keyboard height: {height}";
42 | }
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Droid/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with your package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/Droid/CoreSample.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {246AE70C-B880-4E1D-B6DB-1659A642281E}
8 | Library
9 | CoreSample.Droid
10 | Assets
11 | Resources
12 | Resource
13 | Resources\Resource.designer.cs
14 | True
15 | True
16 | CoreSample.Droid
17 | Properties\AndroidManifest.xml
18 | v6.0
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug
25 | DEBUG;
26 | prompt
27 | 4
28 | None
29 | false
30 |
31 |
32 | full
33 | true
34 | bin\Release
35 | prompt
36 | 4
37 | false
38 | false
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | ..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll
47 |
48 |
49 | ..\packages\Xamarin.Android.Support.v7.CardView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll
50 |
51 |
52 | ..\packages\Xamarin.Android.Support.v7.RecyclerView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.RecyclerView.dll
53 |
54 |
55 | ..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll
56 |
57 |
58 | ..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll
59 |
60 |
61 | ..\packages\Xamarin.Android.Support.v7.AppCompat.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll
62 |
63 |
64 | ..\packages\Xamarin.Android.Support.Design.23.3.0\lib\MonoAndroid43\Xamarin.Android.Support.Design.dll
65 |
66 |
67 | ..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll
68 |
69 |
70 | ..\packages\Plugin.CurrentActivity.1.0.1\lib\MonoAndroid10\Plugin.CurrentActivity.dll
71 |
72 |
73 | ..\packages\Plugin.Permissions.1.1.7\lib\MonoAndroid10\Plugin.Permissions.Abstractions.dll
74 |
75 |
76 | ..\packages\Plugin.Permissions.1.1.7\lib\MonoAndroid10\Plugin.Permissions.dll
77 |
78 |
79 | ..\packages\Xam.Plugin.Media.2.3.0\lib\MonoAndroid10\Plugin.Media.Abstractions.dll
80 |
81 |
82 | ..\packages\Xam.Plugin.Media.2.3.0\lib\MonoAndroid10\Plugin.Media.dll
83 |
84 |
85 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\FormsViewGroup.dll
86 |
87 |
88 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Core.dll
89 |
90 |
91 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll
92 |
93 |
94 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.dll
95 |
96 |
97 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | {97380917-62A3-44F2-8FEF-C92E0B68D317}
131 | Uniforms.Misc
132 |
133 |
134 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}
135 | Uniforms.Misc.Droid
136 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/Droid/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Android.App;
4 | using Android.Content;
5 | using Android.Content.PM;
6 | using Android.Runtime;
7 | using Android.Views;
8 | using Android.Widget;
9 | using Android.OS;
10 |
11 | namespace CoreSample.Droid
12 | {
13 | [Activity(Label = "CoreSample.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
14 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
15 | {
16 | protected override void OnCreate(Bundle savedInstanceState)
17 | {
18 | base.OnCreate(savedInstanceState);
19 |
20 | CoreSample.InitPlatform(this, savedInstanceState);
21 |
22 | LoadApplication(new CoreSample());
23 | }
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/Droid/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Android.App;
4 | using Android.OS;
5 | using Android.Runtime;
6 | using Plugin.CurrentActivity;
7 |
8 | namespace CoreSample.Droid
9 | {
10 | //You can specify additional application information in this attribute
11 | [Application]
12 | public class MainApplication : Application, Application.IActivityLifecycleCallbacks
13 | {
14 | public MainApplication(IntPtr handle, JniHandleOwnership transer)
15 | :base(handle, transer)
16 | {
17 | }
18 |
19 | public override void OnCreate()
20 | {
21 | base.OnCreate();
22 | RegisterActivityLifecycleCallbacks(this);
23 | //A great place to initialize Xamarin.Insights and Dependency Services!
24 | }
25 |
26 | public override void OnTerminate()
27 | {
28 | base.OnTerminate();
29 | UnregisterActivityLifecycleCallbacks(this);
30 | }
31 |
32 | public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
33 | {
34 | CrossCurrentActivity.Current.Activity = activity;
35 | }
36 |
37 | public void OnActivityDestroyed(Activity activity)
38 | {
39 | }
40 |
41 | public void OnActivityPaused(Activity activity)
42 | {
43 | }
44 |
45 | public void OnActivityResumed(Activity activity)
46 | {
47 | CrossCurrentActivity.Current.Activity = activity;
48 | }
49 |
50 | public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
51 | {
52 | }
53 |
54 | public void OnActivityStarted(Activity activity)
55 | {
56 | CrossCurrentActivity.Current.Activity = activity;
57 | }
58 |
59 | public void OnActivityStopped(Activity activity)
60 | {
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/Droid/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using Android.App;
4 |
5 | // Information about this assembly is defined by the following attributes.
6 | // Change them to the values specific to your project.
7 |
8 | [assembly: AssemblyTitle("CoreSample.Droid")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("05Bit")]
12 | [assembly: AssemblyProduct("")]
13 | [assembly: AssemblyCopyright("")]
14 | [assembly: AssemblyTrademark("05Bit")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
19 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
20 |
21 | [assembly: AssemblyVersion("1.0.0")]
22 |
23 | // The following attributes are used to specify the signing key for the assembly,
24 | // if desired. See the Mono documentation for more information about signing.
25 |
26 | //[assembly: AssemblyDelaySign(false)]
27 | //[assembly: AssemblyKeyFile("")]
28 |
29 |
--------------------------------------------------------------------------------
/Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/Droid/Resources/drawable-hdpi/balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable-hdpi/balloon.jpg
--------------------------------------------------------------------------------
/Droid/Resources/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/Droid/Resources/drawable-xhdpi/balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable-xhdpi/balloon.jpg
--------------------------------------------------------------------------------
/Droid/Resources/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/Droid/Resources/drawable-xxhdpi/balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable-xxhdpi/balloon.jpg
--------------------------------------------------------------------------------
/Droid/Resources/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/Droid/Resources/drawable/balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable/balloon.jpg
--------------------------------------------------------------------------------
/Droid/Resources/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Droid/Resources/drawable/icon.png
--------------------------------------------------------------------------------
/Droid/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2016 Alexey Kinev
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Uniforms
2 | ========
3 |
4 | The missing helpers library for awesome [Xamarin Forms](https://www.xamarin.com/forms)!
5 |
6 | Why
7 | ---
8 |
9 | There are [Xamarin-Forms-Labs](https://github.com/XLabs/Xamarin-Forms-Labs) and [Xamarin.Plugins](https://github.com/jamesmontemagno/Xamarin.Plugins) projects and probably some more but still some basic things are just missing out of box.
10 |
11 | So, we'll try to keep simple things simple and fill some gaps. Stay tuned! :)
12 |
13 | Install
14 | -------
15 |
16 | `Uniforms.Misc` package is available via NuGet:
17 | https://www.nuget.org/packages/Uniforms.Misc/
18 |
19 | Alternitavely, you may just clone this repo and references to your projects.
20 |
21 | Usage
22 | -----
23 |
24 | See example in `CoreSample` project:
25 | https://github.com/TheUniforms/Uniforms-Misc/blob/master/CoreSample/CoreSample.cs#L20
26 |
27 |
28 | 1. Init utilities right after `Forms.Init()`:
29 |
30 |
31 | On **Android**:
32 |
33 | ```csharp
34 | Xamarin.Forms.Forms.Init(context, bundle);
35 | Uniforms.Misc.Droid.ScreenUtils.Init ();
36 | Uniforms.Misc.Droid.ImageUtils.Init ();
37 | Uniforms.Misc.Droid.TextUtils.Init ();
38 | ```
39 |
40 | On **iOS**:
41 |
42 | ```csharp
43 | Xamarin.Forms.Forms.Init();
44 | Uniforms.Misc.iOS.ScreenUtils.Init ();
45 | Uniforms.Misc.iOS.ImageUtils.Init ();
46 | Uniforms.Misc.iOS.KeyboardUtils.Init ();
47 | Uniforms.Misc.iOS.TextUtils.Init ();
48 | ```
49 |
50 | 2. Then use `Uniforms.Misc.*` in your cross-platform code!
51 |
52 | Quick reference
53 | ---------------
54 |
55 | Utils interface is provided via static classes:
56 |
57 | - `Uniforms.Misc.ScreenUtils`
58 | - `Uniforms.Misc.ImageUtils`
59 | - `Uniforms.Misc.KeyboardUtils`
60 | - `Uniforms.Misc.TextUtils`
61 |
62 | ## Get screen size
63 |
64 | ```csharp
65 | var screenSize = Uniforms.Misc.ScreenUtils.ScreenSize;
66 | ```
67 |
68 | ## Handle keyboard change events
69 |
70 | ```csharp
71 | Uniforms.Misc.KeyboardUtils.KeyboardHeightChanged += (height) => {
72 | Debug.WriteLine ($"KeyboardHeightChanged: {height}");
73 | };
74 | ```
75 |
76 | ## Get image size by file name
77 |
78 | ```csharp
79 | var imageSize = Uniforms.Misc.ImageUtils.GetImageSize("Graphics/icon.png");
80 | ```
81 |
82 | ## Rounded box view
83 |
84 | ```csharp
85 | var box = new RoundedBox {
86 | HeightRequest = 50,
87 | WidthRequest = 50,
88 | BackgroundColor = Color.Purple,
89 | CornerRadius = 10,
90 | ShadowOffset = new Size(0, 2.0),
91 | ShadowOpacity = 0.5,
92 | ShadowRadius = 2.0,
93 | };
94 | ```
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Resources/README.md:
--------------------------------------------------------------------------------
1 | balloon.jpg
2 | -----------
3 |
4 | From Wikimedia Commons, the free media repository
5 |
6 |
7 | © Tomas Castelazo, www.tomascastelazo.com / Wikimedia Commons / CC-BY-SA-3.0
8 |
--------------------------------------------------------------------------------
/Resources/balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Resources/balloon.jpg
--------------------------------------------------------------------------------
/Resources/resize_images.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Save resized images from source directory to one or
3 | multiple destinations.
4 |
5 | Requirements:
6 |
7 | - Python 2.7+
8 | - YAML parser library
9 | - ImageMagic + Wand or Pillow library
10 |
11 | If you want to use ImageMagic:
12 |
13 | apt-get install libmagickwand-dev
14 | pip install PyYAML Wand
15 |
16 | If you want to use Pillow:
17 |
18 | pip install pillow PyYAML
19 |
20 | """
21 | import os
22 |
23 |
24 | class DirResizer(object):
25 | """Save resized images from `src` to `dst` directory,
26 | applying `scale` and renaming file with `name_format`.
27 |
28 | Arguments:
29 |
30 | src -- source directory
31 | dst -- destination directory
32 | scale -- destination images scale, < 1.0
33 | name_format -- string format for file names,
34 | accepts {name} and {ext} tokens
35 | imagemagic -- use ImageMagic or not (use Pillow then)
36 |
37 | Usage example:
38 |
39 | # Retina resizer: take 3x images and make 2x resizes
40 | resizer = DirResizer('../Resources', '../iOS/Resources',
41 | 2.0/3.0, '{name}@2x.{ext}')
42 | resizer.run()
43 |
44 | """
45 | def __init__(self, src, dst, scale, name_format,
46 | imagemagic=True, nohyphens=False):
47 | self.src = os.path.realpath(src)
48 | self.dst = os.path.realpath(dst)
49 | self.scale = scale
50 | self.name_format = name_format
51 | self.imagemagic = imagemagic
52 | self.nohyphens = nohyphens
53 |
54 | assert dst and (self.dst != self.src),\
55 | "Error, output dir and input dir must be different!"
56 |
57 | def run(self):
58 | try:
59 | os.makedirs(self.dst)
60 | except OSError:
61 | pass
62 |
63 | for item in os.listdir(self.src):
64 | file_path = os.path.join(self.src, item)
65 | name, ext = os.path.splitext(item)
66 |
67 | if not os.path.isfile(file_path):
68 | continue
69 |
70 | if not ext.lower() in ('.png', '.jpg', 'jpeg'):
71 | continue
72 |
73 | out_name = self.name_format.format(name=name,
74 | ext=ext.lstrip('.'))
75 |
76 | if self.nohyphens:
77 | # Android platform does not allow hyphens in resources
78 | # file names!!!
79 | out_name = out_name.replace('-', '_')
80 |
81 | out_file = os.path.join(self.dst, out_name)
82 |
83 | if self.imagemagic:
84 | self.resize_imagemagic(file_path, out_file)
85 | else:
86 | self.resize_pillow(file_path, out_file)
87 |
88 | def resize_imagemagic(self, file_path, out_file):
89 | from wand.image import Image
90 |
91 | with Image(filename=file_path) as im:
92 | im.resize(int(im.size[0] * self.scale + 0.5),
93 | int(im.size[1] * self.scale + 0.5))
94 | # if im.depth != 8:
95 | # print(im.depth)
96 | im.depth = 8
97 | im.save(filename=out_file)
98 |
99 | def resize_pillow(self, file_path, out_file):
100 | from PIL import Image
101 |
102 | im = Image.open(file_path)
103 | size = (int(im.size[0] * self.scale + 0.5),
104 | int(im.size[1] * self.scale + 0.5))
105 | im_resized = im.resize(size, Image.ANTIALIAS)
106 | im_resized.save(out_file, optimize=True)
107 |
108 |
109 | class Resizer(object):
110 | """Bulk resizer.
111 |
112 | Arguments:
113 |
114 | src -- source directory
115 | base -- base image scale at source directory
116 | resizes -- list of dict configs for resizes with keys:
117 | `dst`, `scale`, `name_format`
118 |
119 | Usage example:
120 |
121 | with open('resize_images.yml') as f:
122 | config = yaml.load(f)
123 | resizer = Resizer('../Resources', 3.0, config['resizes'])
124 | resizer.run()
125 |
126 | """
127 | def __init__(self, src, base, resizes, imagemagic=True):
128 | self.src = src
129 | self.base = base
130 | self.resizes = resizes
131 | self.imagemagic = imagemagic
132 |
133 | def run(self):
134 | for x in self.resizes:
135 | resize = x.copy()
136 | resize.update({
137 | 'src': self.src,
138 | 'scale': x['scale'] / self.base,
139 | 'imagemagic': self.imagemagic,
140 | })
141 | resizer = DirResizer(**resize)
142 | resizer.run()
143 |
144 |
145 | if __name__ == '__main__':
146 | import yaml
147 |
148 | with open('resize_images.yml') as f:
149 | config = yaml.load(f)
150 |
151 | print(config)
152 |
153 | resizer = Resizer(config['src'], config['base'], config['resizes'],
154 | imagemagic=config.get('imagemagic', True))
155 | resizer.run()
156 |
--------------------------------------------------------------------------------
/Resources/resize_images.yml:
--------------------------------------------------------------------------------
1 | ---
2 | src: ./
3 | base: 3.0
4 | imagemagic: true
5 |
6 | resizes:
7 | - dst: ../Droid/Resources/drawable
8 | scale: 1.0
9 | name_format: "{name}.{ext}"
10 | nohyphens: true
11 |
12 | - dst: ../Droid/Resources/drawable-hdpi
13 | scale: 1.5
14 | name_format: "{name}.{ext}"
15 | nohyphens: true
16 |
17 | - dst: ../Droid/Resources/drawable-xhdpi
18 | scale: 2.25
19 | name_format: "{name}.{ext}"
20 | nohyphens: true
21 |
22 | - dst: ../Droid/Resources/drawable-xxhdpi
23 | scale: 3.0
24 | name_format: "{name}.{ext}"
25 | nohyphens: true
26 |
27 | - dst: ../iOS/Resources/Graphics
28 | scale: 1.0
29 | name_format: "{name}.{ext}"
30 |
31 | - dst: ../iOS/Resources/Graphics
32 | scale: 2.0
33 | name_format: "{name}@2x.{ext}"
34 |
35 | - dst: ../iOS/Resources/Graphics
36 | scale: 3.0
37 | name_format: "{name}@3x.{ext}"
38 |
--------------------------------------------------------------------------------
/Screenshots/Screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/Screenshots/Screenshot1.png
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("Uniforms.Misc.Droid")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("05Bit")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("")]
13 | [assembly: AssemblyTrademark("05Bit")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.0")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Renderers/RoundedBoxRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using Xamarin.Forms;
4 | using Xamarin.Forms.Platform.Android;
5 | using Android.Graphics;
6 | using Uniforms.Misc;
7 | using Uniforms.Misc.Droid;
8 |
9 | [assembly: ExportRenderer (typeof (RoundedBox), typeof (RoundedBoxRenderer))]
10 |
11 | namespace Uniforms.Misc.Droid
12 | {
13 | public class RoundedBoxRenderer : BoxRenderer
14 | {
15 | protected override void OnElementChanged (ElementChangedEventArgs e)
16 | {
17 | base.OnElementChanged (e);
18 |
19 | SetWillNotDraw (false);
20 |
21 | Invalidate ();
22 | }
23 |
24 | protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
25 | {
26 | base.OnElementPropertyChanged (sender, e);
27 |
28 | if (e.PropertyName == RoundedBox.CornerRadiusProperty.PropertyName) {
29 | Invalidate ();
30 | }
31 | }
32 |
33 | public override void Draw (Canvas canvas)
34 | {
35 | var box = Element as RoundedBox;
36 | var rect = new Rect ();
37 | var paint = new Paint () {
38 | Color = box.BackgroundColor.ToAndroid (),
39 | AntiAlias = true,
40 | };
41 |
42 | GetDrawingRect (rect);
43 |
44 | var radius = (float)(rect.Width () / box.Width * box.CornerRadius);
45 |
46 | canvas.DrawRoundRect (new RectF (rect), radius, radius, paint);
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Uniforms.Misc.Droid
4 |
5 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Uniforms.Misc.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}
8 | Library
9 | Uniforms.Misc.Droid
10 | Assets
11 | Resources
12 | Resource
13 | Resources\Resource.designer.cs
14 | True
15 | Uniforms.Misc.Droid
16 | v6.0
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug
23 | DEBUG;
24 | prompt
25 | 4
26 | None
27 | false
28 |
29 |
30 | true
31 | pdbonly
32 | true
33 | bin\Release
34 | prompt
35 | 4
36 | false
37 | false
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | ..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll
46 |
47 |
48 | ..\packages\Xamarin.Android.Support.v7.CardView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll
49 |
50 |
51 | ..\packages\Xamarin.Android.Support.v7.RecyclerView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.RecyclerView.dll
52 |
53 |
54 | ..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll
55 |
56 |
57 | ..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll
58 |
59 |
60 | ..\packages\Xamarin.Android.Support.v7.AppCompat.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll
61 |
62 |
63 | ..\packages\Xamarin.Android.Support.Design.23.3.0\lib\MonoAndroid43\Xamarin.Android.Support.Design.dll
64 |
65 |
66 | ..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll
67 |
68 |
69 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\FormsViewGroup.dll
70 |
71 |
72 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Core.dll
73 |
74 |
75 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll
76 |
77 |
78 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.dll
79 |
80 |
81 | ..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | {97380917-62A3-44F2-8FEF-C92E0B68D317}
103 | Uniforms.Misc
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Utils/ImageUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Xamarin.Forms;
4 | using Android.Graphics;
5 | using Uniforms.Misc.Droid;
6 |
7 | [assembly: Xamarin.Forms.Dependency(typeof(ImageUtils))]
8 |
9 | namespace Uniforms.Misc.Droid
10 | {
11 | using Path = System.IO.Path;
12 |
13 | public class ImageUtils : IImageUtils
14 | {
15 | public static void Init()
16 | {
17 | Misc.ImageUtils.Init (new ImageUtils ());
18 | }
19 |
20 | #region IImageUtils implementation
21 |
22 | public Xamarin.Forms.Size GetImageSize(string name)
23 | {
24 | var display = Forms.Context.Resources.DisplayMetrics;
25 | var options = new BitmapFactory.Options {
26 | InJustDecodeBounds = true
27 | };
28 | var resId = Forms.Context.Resources.GetIdentifier(
29 | Path.GetFileNameWithoutExtension(name.Replace("-", "_")),
30 | "drawable", Forms.Context.PackageName);
31 |
32 | BitmapFactory.DecodeResource(
33 | Forms.Context.Resources, resId, options);
34 |
35 | return new Size(
36 | Math.Round((double)options.OutWidth / display.Density),
37 | Math.Round((double)options.OutHeight / display.Density));
38 | }
39 |
40 | public Stream ResizeImage(
41 | Stream imageStream,
42 | double width,
43 | double height,
44 | string format = "jpeg",
45 | int quality = 96)
46 | {
47 | // Decode stream
48 | var options = new BitmapFactory.Options {
49 | InJustDecodeBounds = true
50 | };
51 | BitmapFactory.DecodeStream(imageStream, null, options);
52 | imageStream.Seek(0, SeekOrigin.Begin);
53 |
54 | var width0 = options.OutWidth;
55 | var height0 = options.OutHeight;
56 |
57 | // No need to resize
58 | if ((height >= height0) && (width >= width0)) {
59 | return imageStream;
60 | }
61 |
62 | // Calculate scale and sample size
63 | var scale = Math.Min(width / width0, height / height0);
64 | width = width0 * scale;
65 | height = height0 * scale;
66 |
67 | var inSampleSize = 1;
68 | while ((0.5 * height0 > inSampleSize * height) &&
69 | (0.5 * width0 > inSampleSize * width)) {
70 | inSampleSize *= 2;
71 | }
72 |
73 | // Resize
74 | var originalImage = BitmapFactory.DecodeStream(imageStream, null,
75 | new BitmapFactory.Options {
76 | InJustDecodeBounds = false,
77 | InSampleSize = inSampleSize
78 | });
79 | Bitmap resizedImage = Bitmap.CreateScaledBitmap(
80 | originalImage, (int)(width), (int)(height), false);
81 | originalImage.Recycle();
82 |
83 | // Compress
84 | var stream = new MemoryStream();
85 | Bitmap.CompressFormat imageFormat = (format == "png") ?
86 | Bitmap.CompressFormat.Png :
87 | Bitmap.CompressFormat.Jpeg;
88 | resizedImage.Compress(imageFormat, quality, stream);
89 | resizedImage.Recycle();
90 |
91 | // Reset stream and return
92 | stream.Seek(0, SeekOrigin.Begin);
93 | return stream;
94 | }
95 |
96 | #endregion
97 | }
98 | }
99 |
100 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Utils/ScreenUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Uniforms.Misc.Droid;
3 |
4 | namespace Uniforms.Misc.Droid
5 | {
6 | public static class ScreenUtils
7 | {
8 | public static void Init ()
9 | {
10 | var display = Xamarin.Forms.Forms.Context.Resources.DisplayMetrics;
11 | Misc.ScreenUtils.ScreenSize = new Xamarin.Forms.Size (
12 | display.WidthPixels / display.Density,
13 | display.HeightPixels / display.Density
14 | );
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/Utils/TextUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.Widget;
3 | using Android.Util;
4 | using Android.Views;
5 | using Android.Graphics;
6 |
7 | namespace Uniforms.Misc.Droid
8 | {
9 | public class TextUtils : ITextUtils
10 | {
11 | public static void Init ()
12 | {
13 | Misc.TextUtils.Init (new TextUtils ());
14 | }
15 |
16 | static Typeface textTypeface;
17 |
18 | static string createdFontName;
19 |
20 | public Xamarin.Forms.Size GetTextSize (
21 | string text,
22 | double maxWidth,
23 | double fontSize = 0,
24 | string fontName = null)
25 | {
26 | var textView = new TextView (global::Android.App.Application.Context);
27 | textView.Typeface = GetTypeface (fontName);
28 | textView.SetText (text, TextView.BufferType.Normal);
29 | textView.SetTextSize (ComplexUnitType.Px, (float)fontSize);
30 |
31 | int widthMeasureSpec = View.MeasureSpec.MakeMeasureSpec (
32 | (int)maxWidth, MeasureSpecMode.AtMost);
33 |
34 | int heightMeasureSpec = View.MeasureSpec.MakeMeasureSpec (
35 | 0, MeasureSpecMode.Unspecified);
36 |
37 | textView.Measure (widthMeasureSpec, heightMeasureSpec);
38 |
39 | return new Xamarin.Forms.Size (
40 | textView.MeasuredWidth,
41 | textView.MeasuredHeight);
42 | }
43 |
44 | static Typeface GetTypeface (string fontName)
45 | {
46 | if (fontName == null) {
47 | return Typeface.Default;
48 | }
49 |
50 | if (textTypeface == null || fontName != createdFontName) {
51 | textTypeface = Typeface.Create (fontName, TypefaceStyle.Normal);
52 | createdFontName = fontName;
53 | }
54 |
55 | return textTypeface;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Uniforms.Misc.Droid/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("Uniforms.Misc.iOS")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("05Bit")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("")]
13 | [assembly: AssemblyTrademark("05Bit")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Renderers/RoundedBoxRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using Xamarin.Forms;
4 | using Xamarin.Forms.Platform.iOS;
5 | using Uniforms.Misc;
6 | using Uniforms.Misc.iOS;
7 | using CoreGraphics;
8 | using CoreAnimation;
9 | using UIKit;
10 |
11 | [assembly: ExportRenderer (typeof (RoundedBox), typeof (RoundedBoxRenderer))]
12 |
13 | namespace Uniforms.Misc.iOS
14 | {
15 | public class RoundedBoxRenderer : BoxRenderer
16 | {
17 | ///
18 | /// The color layer.
19 | ///
20 | CALayer colorLayer = new CALayer { MasksToBounds = true };
21 |
22 | protected override void OnElementChanged (ElementChangedEventArgs e)
23 | {
24 | base.OnElementChanged (e);
25 |
26 | if (Element != null) {
27 | Layer.MasksToBounds = false;
28 | Layer.BackgroundColor = Color.Transparent.ToCGColor ();
29 | Layer.AddSublayer (colorLayer);
30 | UpdateLayers ();
31 | UpdateColor ();
32 | }
33 | }
34 |
35 | protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
36 | {
37 | base.OnElementPropertyChanged (sender, e);
38 |
39 | if (e.PropertyName == RoundedBox.CornerRadiusProperty.PropertyName ||
40 | e.PropertyName == RoundedBox.ShadowRadiusProperty.PropertyName) {
41 | UpdateLayers ();
42 | } else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) {
43 | UpdateColor ();
44 | }
45 | }
46 |
47 | void UpdateColor ()
48 | {
49 | colorLayer.BackgroundColor = Element.BackgroundColor.ToCGColor ();
50 | }
51 |
52 | void UpdateLayers ()
53 | {
54 | var box = Element as RoundedBox;
55 |
56 | colorLayer.CornerRadius = (float)box.CornerRadius;
57 |
58 | if (box.ShadowRadius > 0) {
59 | Layer.ShadowRadius = (float)box.ShadowRadius;
60 | Layer.ShadowOpacity = (float)box.ShadowOpacity;
61 | Layer.ShadowColor = box.ShadowColor.ToCGColor ();
62 | Layer.ShadowOffset = box.ShadowOffset.ToSizeF ();
63 | } else {
64 | Layer.ShadowOpacity = 0;
65 | }
66 | }
67 |
68 | public override void LayoutSubviews ()
69 | {
70 | base.LayoutSubviews ();
71 |
72 | colorLayer.Frame = Layer.Bounds;
73 |
74 | var box = Element as RoundedBox;
75 | if (Layer.ShadowOpacity > 0) {
76 | Layer.ShadowPath = UIBezierPath.FromRoundedRect (
77 | Layer.Bounds, (float)box.CornerRadius).CGPath;
78 | }
79 | }
80 |
81 | public override void Draw (CGRect rect)
82 | {
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Uniforms.Misc.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}
8 | Library
9 | Uniforms.Misc.iOS
10 | Resources
11 | Uniforms.Misc.iOS
12 |
13 |
14 | true
15 | full
16 | false
17 | bin\Debug
18 | DEBUG;
19 | prompt
20 | 4
21 | false
22 |
23 |
24 | true
25 | pdbonly
26 | true
27 | bin\Release
28 | prompt
29 | 4
30 | false
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | ..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll
39 |
40 |
41 | ..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll
42 |
43 |
44 | ..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll
45 |
46 |
47 | ..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | {97380917-62A3-44F2-8FEF-C92E0B68D317}
66 | Uniforms.Misc
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Utils/ImageUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using UIKit;
4 | using CoreGraphics;
5 | using Foundation;
6 | using Uniforms.Misc.iOS;
7 |
8 | [assembly: Xamarin.Forms.Dependency(typeof(ImageUtils))]
9 |
10 | namespace Uniforms.Misc.iOS
11 | {
12 | public class ImageUtils : IImageUtils
13 | {
14 | ///
15 | /// Initialize platform implementation for image utils.
16 | ///
17 | public static void Init()
18 | {
19 | Misc.ImageUtils.Init (new ImageUtils ());
20 | }
21 |
22 | #region IImageUtils implementation
23 |
24 | public Xamarin.Forms.Size GetImageSize(string name)
25 | {
26 | UIImage image = UIImage.FromFile(name);
27 |
28 | var size = new Xamarin.Forms.Size(
29 | (double)image.Size.Width,
30 | (double)image.Size.Height);
31 |
32 | image.Dispose ();
33 |
34 | return size;
35 | }
36 |
37 | public Stream ResizeImage(
38 | Stream imageStream,
39 | double width,
40 | double height,
41 | string format = "jpeg",
42 | int quality = 96)
43 | {
44 | if (imageStream == null) {
45 | return null;
46 | }
47 |
48 | UIImage image = null;
49 | try {
50 | using (var memoryStream = new MemoryStream ()) {
51 | imageStream.CopyTo (memoryStream);
52 | var data = memoryStream.ToArray ();
53 | image = UIImage.LoadFromData (NSData.FromArray (data));
54 | }
55 | } catch (Exception e) {
56 | Console.WriteLine ($"ResizeImage: {e.Message}");
57 | return null;
58 | }
59 |
60 | // No need to resize if required size is greater than original
61 | var scale = Math.Min (width / image.Size.Width,
62 | height / image.Size.Height);
63 | if (scale > 1.0) {
64 | return imageStream;
65 | }
66 |
67 | width = (float)(scale * image.Size.Width);
68 | height = (float)(scale * image.Size.Height);
69 |
70 | UIGraphics.BeginImageContextWithOptions (
71 | new CGSize (width, height),
72 | opaque: true,
73 | scale: 0);
74 | image.Draw (new CGRect (0, 0, width, height));
75 | var resized = UIGraphics.GetImageFromCurrentImageContext ();
76 | UIGraphics.EndImageContext ();
77 |
78 | var stream = new MemoryStream ();
79 |
80 | var resizeData = ((format == "png") ?
81 | resized.AsPNG ().ToArray () :
82 | resized.AsJPEG ((nfloat)(0.01 * quality)).ToArray ());
83 |
84 | image.Dispose ();
85 | resized.Dispose ();
86 |
87 | stream.Write (resizeData, 0, resizeData.Length);
88 | stream.Seek (0, SeekOrigin.Begin);
89 | return stream;
90 | }
91 |
92 | #endregion
93 | }
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Utils/KeyboardUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using UIKit;
4 | using Foundation;
5 | using Uniforms.Misc.iOS;
6 |
7 | [assembly: Xamarin.Forms.Dependency (typeof (KeyboardUtils))]
8 |
9 | namespace Uniforms.Misc.iOS
10 | {
11 | public class KeyboardUtils : IKeyboardEvents
12 | {
13 | ///
14 | /// Empty method for reference.
15 | ///
16 | public static void Init ()
17 | {
18 | Misc.KeyboardUtils.Init (new KeyboardUtils ());
19 | }
20 |
21 | ///
22 | /// Occurs when keyboard height changed.
23 | ///
24 | public event Action KeyboardHeightChanged;
25 |
26 | public KeyboardUtils ()
27 | {
28 | var windowHeight = UIScreen.MainScreen.Bounds.Height;
29 |
30 | // Show or change frame
31 | NSNotificationCenter.DefaultCenter.AddObserver (
32 | UIKeyboard.WillChangeFrameNotification, (notify) => {
33 | var info = notify.UserInfo;
34 | var value = (NSValue)(info [UIKeyboard.FrameEndUserInfoKey]);
35 | var height = windowHeight - value.RectangleFValue.Y;
36 |
37 | Debug.WriteLine ("KeyboardEvents, height={0}", height);
38 |
39 | KeyboardHeightChanged?.Invoke (height);
40 | });
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Utils/ScreenUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UIKit;
3 | using Uniforms.Misc.iOS;
4 |
5 | namespace Uniforms.Misc.iOS
6 | {
7 | public static class ScreenUtils
8 | {
9 | public static void Init ()
10 | {
11 | Misc.ScreenUtils.ScreenSize = new Xamarin.Forms.Size(
12 | UIScreen.MainScreen.Bounds.Width,
13 | UIScreen.MainScreen.Bounds.Height
14 | );
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/Utils/TextUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Foundation;
4 | using UIKit;
5 | using Xamarin.Forms;
6 |
7 | namespace Uniforms.Misc.iOS
8 | {
9 | public class TextUtils : ITextUtils
10 | {
11 | public static void Init ()
12 | {
13 | Misc.TextUtils.Init (new TextUtils());
14 | }
15 |
16 | public Xamarin.Forms.Size GetTextSize (
17 | string text,
18 | double maxWidth,
19 | double fontSize = 0,
20 | string fontName = null)
21 | {
22 | if (fontSize <= 0) {
23 | fontSize = UIFont.SystemFontSize;
24 | }
25 |
26 | UIFont font = null;
27 | if (string.IsNullOrEmpty (fontName)) {
28 | font = UIFont.SystemFontOfSize ((nfloat)fontSize);
29 | } else {
30 | font = UIFont.FromName (fontName, (nfloat)fontSize);
31 | }
32 |
33 | var attributes = new UIStringAttributes { Font = font };
34 | var boundSize = new SizeF ((float)maxWidth, float.MaxValue);
35 | var options = NSStringDrawingOptions.UsesFontLeading |
36 | NSStringDrawingOptions.UsesLineFragmentOrigin;
37 |
38 | var nsText = new NSString (text);
39 | var resultSize = nsText.GetBoundingRect (
40 | boundSize,
41 | options,
42 | attributes,
43 | null).Size;
44 |
45 | font.Dispose ();
46 | nsText.Dispose ();
47 |
48 | return new Xamarin.Forms.Size (
49 | Math.Ceiling ((double)resultSize.Width),
50 | Math.Ceiling ((double)resultSize.Height));
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Uniforms.Misc.iOS/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Uniforms.Misc.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Uniforms.Misc
5 | 0.9.1
6 | Uniforms.Misc - various helpers for Xamarin.Forms
7 | Alexey Kinëv
8 | Alexey Kinëv
9 | Various helpers to simplify cross-platform development with Xamarin.Forms.
10 |
11 | Available utilities:
12 |
13 | - Get device screen size
14 | - Get image size by path
15 | - The very basic image resize
16 | - Box view with rounded corners + shadow support on iOS
17 | - Keyboard height change events on iOS
18 |
19 | Details and samples are available on the project's website:
20 | https://github.com/TheUniforms/Uniforms-Misc
21 | Various helpers to simplify cross-platform development with Xamarin.Forms: device screen size, get image size, get current locale etc.
22 | https://github.com/TheUniforms/Uniforms-Misc
23 | https://github.com/TheUniforms/Uniforms-Misc/blob/master/LICENSE
24 | false
25 | Beta
26 | Copyright 2016, 05Bit
27 | xamarin, utils, pcl, xamarin.forms, ios
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Uniforms.Misc.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uniforms.Misc", "Uniforms.Misc\Uniforms.Misc.csproj", "{97380917-62A3-44F2-8FEF-C92E0B68D317}"
5 | EndProject
6 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CoreSample", "CoreSample\CoreSample.shproj", "{2EE45A47-CCB7-4C54-A812-57C4FFCC7409}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreSample.iOS", "iOS\CoreSample.iOS.csproj", "{66E28864-F2D3-451D-9936-CAB05827A4B8}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreSample.Droid", "Droid\CoreSample.Droid.csproj", "{246AE70C-B880-4E1D-B6DB-1659A642281E}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uniforms.Misc.iOS", "Uniforms.Misc.iOS\Uniforms.Misc.iOS.csproj", "{D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uniforms.Misc.Droid", "Uniforms.Misc.Droid\Uniforms.Misc.Droid.csproj", "{F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
21 | Release|iPhone = Release|iPhone
22 | Release|iPhoneSimulator = Release|iPhoneSimulator
23 | Debug|iPhone = Debug|iPhone
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
29 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Debug|iPhone.Build.0 = Debug|Any CPU
30 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
31 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
32 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Release|iPhone.ActiveCfg = Release|Any CPU
35 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Release|iPhone.Build.0 = Release|Any CPU
36 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
37 | {246AE70C-B880-4E1D-B6DB-1659A642281E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
38 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
39 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
40 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Debug|iPhone.ActiveCfg = Debug|iPhone
41 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Debug|iPhone.Build.0 = Debug|iPhone
42 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
43 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
44 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Release|Any CPU.ActiveCfg = Release|iPhone
45 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Release|Any CPU.Build.0 = Release|iPhone
46 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Release|iPhone.ActiveCfg = Release|iPhone
47 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Release|iPhone.Build.0 = Release|iPhone
48 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
49 | {66E28864-F2D3-451D-9936-CAB05827A4B8}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
50 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Debug|iPhone.ActiveCfg = Debug|Any CPU
53 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Debug|iPhone.Build.0 = Debug|Any CPU
54 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
55 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
56 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Release|iPhone.ActiveCfg = Release|Any CPU
59 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Release|iPhone.Build.0 = Release|Any CPU
60 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
61 | {97380917-62A3-44F2-8FEF-C92E0B68D317}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
62 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Debug|Any CPU.Build.0 = Debug|Any CPU
64 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Debug|iPhone.ActiveCfg = Debug|Any CPU
65 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Debug|iPhone.Build.0 = Debug|Any CPU
66 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
67 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
68 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Release|Any CPU.ActiveCfg = Release|Any CPU
69 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Release|Any CPU.Build.0 = Release|Any CPU
70 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Release|iPhone.ActiveCfg = Release|Any CPU
71 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Release|iPhone.Build.0 = Release|Any CPU
72 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
73 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
74 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
76 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Debug|iPhone.ActiveCfg = Debug|Any CPU
77 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Debug|iPhone.Build.0 = Debug|Any CPU
78 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
79 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
80 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
81 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Release|Any CPU.Build.0 = Release|Any CPU
82 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Release|iPhone.ActiveCfg = Release|Any CPU
83 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Release|iPhone.Build.0 = Release|Any CPU
84 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
85 | {F03D6B60-AB98-4C16-AA3E-51A57ABBF2CA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
86 | EndGlobalSection
87 | EndGlobal
88 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("Uniforms.Misc")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("05Bit")]
11 | [assembly: AssemblyProduct("")]
12 | [assembly: AssemblyCopyright("")]
13 | [assembly: AssemblyTrademark("05Bit")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
28 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Uniforms.Misc.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {97380917-62A3-44F2-8FEF-C92E0B68D317}
8 | Library
9 | Uniforms.Misc
10 | Uniforms.Misc
11 | v4.5
12 | Profile78
13 |
14 |
15 | true
16 | full
17 | false
18 | bin\Debug
19 | DEBUG;
20 | prompt
21 | 4
22 | false
23 |
24 |
25 | true
26 | pdbonly
27 | true
28 | bin\Release
29 | prompt
30 | 4
31 | false
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | ..\packages\Xamarin.Forms.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll
50 |
51 |
52 | ..\packages\Xamarin.Forms.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll
53 |
54 |
55 | ..\packages\Xamarin.Forms.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Utils/ImageUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Xamarin.Forms;
4 |
5 | namespace Uniforms.Misc
6 | {
7 | public interface IImageUtils
8 | {
9 | Size GetImageSize(string name);
10 |
11 | Stream ResizeImage(
12 | Stream imageData,
13 | double width,
14 | double height,
15 | string format = "jpeg",
16 | int quality = 96);
17 | }
18 |
19 | ///
20 | /// Image utils.
21 | ///
22 | public static class ImageUtils
23 | {
24 | static IImageUtils implementation;
25 |
26 | internal static void Init (IImageUtils platformImplementation)
27 | {
28 | implementation = platformImplementation;
29 | }
30 |
31 | public static Size GetImageSize (string name)
32 | {
33 | return implementation.GetImageSize (name);
34 | }
35 |
36 | public static Stream ResizeImage (
37 | Stream imageData,
38 | double width,
39 | double height,
40 | string format = "jpeg",
41 | int quality = 96)
42 | {
43 | return implementation.ResizeImage (
44 | imageData, width, height, format, quality);
45 | }
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Utils/KeyboardUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Uniforms.Misc
4 | {
5 | public interface IKeyboardEvents
6 | {
7 | ///
8 | /// Occurs when keyboard height changed.
9 | ///
10 | event Action KeyboardHeightChanged;
11 | }
12 |
13 | ///
14 | /// Keyboard utils.
15 | ///
16 | public static class KeyboardUtils
17 | {
18 | public static event Action KeyboardHeightChanged;
19 |
20 | static IKeyboardEvents implementation;
21 |
22 | internal static void Init (IKeyboardEvents platformImplementation)
23 | {
24 | implementation = platformImplementation;
25 |
26 | implementation.KeyboardHeightChanged += (double height) => {
27 | KeyboardHeightChanged?.Invoke (height);
28 | };
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Utils/ScreenUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using Xamarin.Forms;
4 |
5 | [assembly: InternalsVisibleTo ("Uniforms.Misc.iOS")]
6 | [assembly: InternalsVisibleTo ("Uniforms.Misc.Droid")]
7 |
8 | namespace Uniforms.Misc
9 | {
10 | ///
11 | /// Screen utils.
12 | ///
13 | public static class ScreenUtils
14 | {
15 | public static Size ScreenSize { get; internal set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Utils/TextUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 |
4 | namespace Uniforms.Misc
5 | {
6 | public interface ITextUtils
7 | {
8 | Size GetTextSize (
9 | string text,
10 | double maxWidth,
11 | double fontSize = 0,
12 | string fontName = null);
13 | }
14 |
15 | ///
16 | /// Text utils.
17 | ///
18 | public static class TextUtils
19 | {
20 | static ITextUtils implementation;
21 |
22 | ///
23 | /// Init with the specified platform implementation.
24 | ///
25 | internal static void Init (ITextUtils platformImplementation)
26 | {
27 | implementation = platformImplementation;
28 | }
29 |
30 | ///
31 | /// Gets the size of the text.
32 | ///
33 | public static Size GetTextSize (
34 | string text,
35 | double maxWidth,
36 | double fontSize = 0,
37 | string fontName = null)
38 | {
39 | return implementation.GetTextSize (
40 | text, maxWidth, fontSize, fontName);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Uniforms.Misc/Views/RoundedBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 |
4 | namespace Uniforms.Misc
5 | {
6 | public class RoundedBox : BoxView
7 | {
8 | ///
9 | /// The corner radius property.
10 | ///
11 | public static readonly BindableProperty CornerRadiusProperty =
12 | BindableProperty.Create ("CornerRadius", typeof (double), typeof (RoundedBox), 0.0);
13 |
14 | ///
15 | /// The shadow radius property.
16 | ///
17 | public static readonly BindableProperty ShadowRadiusProperty =
18 | BindableProperty.Create ("ShadowRadius", typeof (double), typeof (RoundedBox), 0.0);
19 |
20 | ///
21 | /// Gets or sets the corner radius.
22 | ///
23 | public double CornerRadius {
24 | get { return (double)GetValue (CornerRadiusProperty); }
25 | set { SetValue (CornerRadiusProperty, value); }
26 | }
27 |
28 | ///
29 | /// Gets or sets the shadow radius.
30 | ///
31 | public double ShadowRadius {
32 | get { return (double)GetValue (ShadowRadiusProperty); }
33 | set { SetValue (ShadowRadiusProperty, value); }
34 | }
35 |
36 | ///
37 | /// Gets or sets the shadow opacity.
38 | ///
39 | public double ShadowOpacity { get; set; }
40 |
41 | ///
42 | /// Gets or sets the color of the shadow.
43 | ///
44 | public Color ShadowColor { get; set; } = Color.Black;
45 |
46 | ///
47 | /// Gets or sets the shadow offset.
48 | ///
49 | public Size ShadowOffset { get; set; } = Size.Zero;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Uniforms.Misc/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # build.sh -a build all
4 | # build.sh -n build NuGet
5 | # build.sh -c build component
6 | # build.sh -h print help
7 |
8 | BUILD_TOOL='/Applications/Xamarin Studio.app/Contents/MacOS/mdtool'
9 | NUGET_TOOL=`which nuget`
10 | PROJECT_BASE='Uniforms.Misc'
11 | OUTPUT_DIR='lib'
12 |
13 | build_nuget=false
14 | build_all=false
15 | build_component=false
16 | need_help=false
17 |
18 | #################
19 | # Parse options #
20 | #################
21 |
22 | if [ -z "$1" ] ; then
23 | need_help=true
24 | fi
25 |
26 | # OPTIND=1 # Reset in case getopts has been used previously in the shell.
27 |
28 | while getopts "h?anc" opt; do
29 | case "$opt" in
30 | h|\?)
31 | need_help=true
32 | ;;
33 | a) build_all=true
34 | build_nuget=true
35 | build_component=true
36 | ;;
37 | c) build_nuget=true
38 | build_component=true
39 | ;;
40 | n) build_nuget=true
41 | ;;
42 | esac
43 | done
44 |
45 | shift $((OPTIND-1))
46 |
47 | [ "$1" = "--" ] && shift
48 |
49 | #############
50 | # Show help #
51 | #############
52 |
53 | if [ "$need_help" = true ] ; then
54 | echo "build.sh -a build all"
55 | echo "build.sh -n build NuGet only"
56 | echo "build.sh -h print help"
57 | exit 0
58 | fi
59 |
60 | ##################
61 | # Build solution #
62 | ##################
63 |
64 | if [ "$build_all" = true ] ; then
65 | "$BUILD_TOOL" build -c:"Release"
66 | fi
67 |
68 | #############################
69 | # Build NuGet and component #
70 | #############################
71 |
72 | if [ "$build_nuget" = true ] ; then
73 | mkdir -p $OUTPUT_DIR
74 |
75 | rm -v $OUTPUT_DIR/*.dll* $OUTPUT_DIR/*.nupkg
76 |
77 | cp -v $PROJECT_BASE.Droid/bin/Release/*.dll* $OUTPUT_DIR 2> /dev/null
78 | cp -v $PROJECT_BASE.iOS/bin/Release/*.dll* $OUTPUT_DIR 2> /dev/null
79 | cp -v $PROJECT_BASE/bin/Release/*.dll* $OUTPUT_DIR 2> /dev/null
80 |
81 | "$NUGET_TOOL" pack -OutputDirectory $OUTPUT_DIR
82 |
83 | echo "Use nuget tool to publish the package:"
84 | echo
85 | echo " nuget push $OUTPUT_DIR/$PROJECT_BASE.*.nupkg"
86 | echo
87 | fi
88 |
--------------------------------------------------------------------------------
/iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace CoreSample.iOS
9 | {
10 | [Register("AppDelegate")]
11 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
12 | {
13 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
14 | {
15 | CoreSample.InitPlatform();
16 |
17 | var sharedApp = new CoreSample();
18 |
19 | LoadApplication(sharedApp);
20 |
21 | return base.FinishedLaunching(app, options);
22 | }
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/iOS/CoreSample.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
7 | {66E28864-F2D3-451D-9936-CAB05827A4B8}
8 | Exe
9 | CoreSample.iOS
10 | Resources
11 | CoreSample.iOS
12 |
13 |
14 | true
15 | full
16 | false
17 | bin\iPhoneSimulator\Debug
18 | DEBUG;ENABLE_TEST_CLOUD;
19 | prompt
20 | 4
21 | false
22 | i386
23 | SdkOnly
24 | true
25 | true
26 | true
27 | iPhone Developer
28 | true
29 |
30 |
31 | full
32 | true
33 | bin\iPhone\Release
34 | prompt
35 | 4
36 | false
37 | ARMv7, ARM64
38 | Entitlements.plist
39 | true
40 | true
41 | iPhone Developer
42 | true
43 |
44 |
45 | full
46 | true
47 | bin\iPhoneSimulator\Release
48 | prompt
49 | 4
50 | false
51 | i386
52 | SdkOnly
53 | true
54 | iPhone Developer
55 | true
56 |
57 |
58 | true
59 | full
60 | false
61 | bin\iPhone\Debug
62 | DEBUG;ENABLE_TEST_CLOUD;
63 | prompt
64 | 4
65 | false
66 | ARMv7, ARM64
67 | Entitlements.plist
68 | true
69 | true
70 | true
71 | true
72 | iPhone Developer
73 | true
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | ..\packages\Xamarin.Forms.2.3.1.114\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll
82 |
83 |
84 | ..\packages\Xamarin.Forms.2.3.1.114\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll
85 |
86 |
87 | ..\packages\Xamarin.Forms.2.3.1.114\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll
88 |
89 |
90 | ..\packages\Xamarin.Forms.2.3.1.114\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll
91 |
92 |
93 | ..\packages\Xam.Plugin.Media.2.3.0\lib\Xamarin.iOS10\Plugin.Media.Abstractions.dll
94 |
95 |
96 | ..\packages\Xam.Plugin.Media.2.3.0\lib\Xamarin.iOS10\Plugin.Media.dll
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | {97380917-62A3-44F2-8FEF-C92E0B68D317}
119 | Uniforms.Misc
120 |
121 |
122 | {D13A4CCA-6F79-4D18-9DA0-A37163C0BC55}
123 | Uniforms.Misc.iOS
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | CoreSample
7 | CFBundleIdentifier
8 | com.05bit.Uniforms.Miscsample
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1.0
13 | LSRequiresIPhoneOS
14 |
15 | MinimumOSVersion
16 | 7.0
17 | UIDeviceFamily
18 |
19 | 1
20 | 2
21 |
22 | UILaunchStoryboardName
23 | LaunchScreen
24 | UIRequiredDeviceCapabilities
25 |
26 | armv7
27 |
28 | UISupportedInterfaceOrientations
29 |
30 | UIInterfaceOrientationPortrait
31 | UIInterfaceOrientationLandscapeLeft
32 | UIInterfaceOrientationLandscapeRight
33 |
34 | UISupportedInterfaceOrientations~ipad
35 |
36 | UIInterfaceOrientationPortrait
37 | UIInterfaceOrientationPortraitUpsideDown
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | XSAppIconAssets
42 | Resources/Images.xcassets/AppIcons.appiconset
43 | CFBundleName
44 | CoreSample
45 |
46 |
47 |
--------------------------------------------------------------------------------
/iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace CoreSample.iOS
9 | {
10 | public class Application
11 | {
12 | // This is the main entry point of the application.
13 | static void Main(string[] args)
14 | {
15 | // if you want to use a different Application Delegate class from "AppDelegate"
16 | // you can specify it here.
17 | UIApplication.Main(args, null, "AppDelegate");
18 | }
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/iOS/Resources/Graphics/balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/iOS/Resources/Graphics/balloon.jpg
--------------------------------------------------------------------------------
/iOS/Resources/Graphics/balloon@2x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/iOS/Resources/Graphics/balloon@2x.jpg
--------------------------------------------------------------------------------
/iOS/Resources/Graphics/balloon@3x.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheUniforms/Uniforms-Misc/a7e687de17e08957a649dbe9f8c298b43ed5e35a/iOS/Resources/Graphics/balloon@3x.jpg
--------------------------------------------------------------------------------
/iOS/Resources/Images.xcassets/AppIcons.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "size": "29x29",
5 | "scale": "1x",
6 | "idiom": "iphone"
7 | },
8 | {
9 | "size": "29x29",
10 | "scale": "2x",
11 | "idiom": "iphone"
12 | },
13 | {
14 | "size": "29x29",
15 | "scale": "3x",
16 | "idiom": "iphone"
17 | },
18 | {
19 | "size": "40x40",
20 | "scale": "2x",
21 | "idiom": "iphone"
22 | },
23 | {
24 | "size": "40x40",
25 | "scale": "3x",
26 | "idiom": "iphone"
27 | },
28 | {
29 | "size": "57x57",
30 | "scale": "1x",
31 | "idiom": "iphone"
32 | },
33 | {
34 | "size": "57x57",
35 | "scale": "2x",
36 | "idiom": "iphone"
37 | },
38 | {
39 | "size": "60x60",
40 | "scale": "2x",
41 | "idiom": "iphone"
42 | },
43 | {
44 | "size": "60x60",
45 | "scale": "3x",
46 | "idiom": "iphone"
47 | },
48 | {
49 | "size": "29x29",
50 | "scale": "1x",
51 | "idiom": "ipad"
52 | },
53 | {
54 | "size": "29x29",
55 | "scale": "2x",
56 | "idiom": "ipad"
57 | },
58 | {
59 | "size": "40x40",
60 | "scale": "1x",
61 | "idiom": "ipad"
62 | },
63 | {
64 | "size": "40x40",
65 | "scale": "2x",
66 | "idiom": "ipad"
67 | },
68 | {
69 | "size": "50x50",
70 | "scale": "1x",
71 | "idiom": "ipad"
72 | },
73 | {
74 | "size": "50x50",
75 | "scale": "2x",
76 | "idiom": "ipad"
77 | },
78 | {
79 | "size": "72x72",
80 | "scale": "1x",
81 | "idiom": "ipad"
82 | },
83 | {
84 | "size": "72x72",
85 | "scale": "2x",
86 | "idiom": "ipad"
87 | },
88 | {
89 | "size": "76x76",
90 | "scale": "1x",
91 | "idiom": "ipad"
92 | },
93 | {
94 | "size": "76x76",
95 | "scale": "2x",
96 | "idiom": "ipad"
97 | },
98 | {
99 | "size": "120x120",
100 | "scale": "1x",
101 | "idiom": "car"
102 | }
103 | ],
104 | "info": {
105 | "version": 1,
106 | "author": "xcode"
107 | }
108 | }
--------------------------------------------------------------------------------
/iOS/Resources/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/iOS/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------