Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mariusmuntean/simpleimagebutton
A simple ImageButton for Xamarin.Forms
https://github.com/mariusmuntean/simpleimagebutton
image-button imagebutton xamarin-forms
Last synced: 6 days ago
JSON representation
A simple ImageButton for Xamarin.Forms
- Host: GitHub
- URL: https://github.com/mariusmuntean/simpleimagebutton
- Owner: mariusmuntean
- License: mit
- Created: 2018-12-30T13:59:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-27T11:19:42.000Z (almost 6 years ago)
- Last Synced: 2025-01-13T01:37:45.391Z (8 days ago)
- Topics: image-button, imagebutton, xamarin-forms
- Language: C#
- Size: 84.4 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleImageButton
## Intro
A simple ImageButton for Xamarin.Forms## Installation
Grab the NuGet package from: https://www.nuget.org/packages/SimpleImageButton/
(or build it yourself)
1. Install it in your .Net Standard project, where your UI lives.
2. Then install the package in any platform-specific projects that you have.
3. Finally, initialize it. This is necessary in order for the PlatformEffect to get loaded and needs to be done once for each platform.
Init on iOS
In the AppDelegate.cs file, in FinishedLaunching(...) add the following call after Forms.Init() and before LoadApplication(new App()):```csharp
SimpleImageButton.Initializator.Initializator.Init();
```
Init on macOS
In the AppDelegate.cs file, in DidFinishLaunching(...) add the following call after Forms.Init() and before LoadApplication(new App()):```csharp
SimpleImageButton.Initializator.Initializator.Init();
```
Init on Android
In the MainActivity.cs file (or wherever you initialize Xamarin.Forms), in OnCreate(...) add the following call after Forms.Init() and before LoadApplication(new App()):```csharp
SimpleImageButton.Initializator.Initializator.Init();
```
Init on UWP
In the MainPage.xaml.cs.cs file, in the MainPage(...) constructor add the following call before the call to this.InitializeComponent();:```csharp
SimpleImageButton.Initializator.Initializator.Init();
```
Init on Tizen
In your main class, usually the one that inherits from FormsApplication, in the OnCreate() method add a call to Initializator.Init():```csharp
Initializator.Init();
```
### Tizen Note:
Tizen seems to be supported partially. For this reason the button doesn't look quite as nce as on the other platforms. I'll try to compensate as much as possible.Link to limitations: https://developer.tizen.org/development/api-reference/.net-application/current-xamarin.forms-limitations
## Prerequisites to compile the library
Compile on Windows
If you use Windows as your development OS then you're in luck because you can pretty much build everything, without modifying the code.In the Visual Studio Installer ensure that you have the following workloads checked:
* .Net desktop development
* Universal Windows Platform development
* Mobile development with .Net
* .NET Core cross-platform developmentAlso in the Visual Studio Installer, switch to the Individual Components tab and scroll to the bottm. Check the 4 entries for Windows 10 SDK (10.0.16299).
Hint: If you modify the SimpleImageButton.csproj to reference another version of UAP than 10.0.16299 then you would probably need to also come back to the Visual Studio Installer and check that specific version.
That's it!
## Fun fact
I built this for myself, thinking I could whip something together in 10 minutes and make a button out of it using the VisualStateManager.It turned out that Xamarin.Forms' GestureRecognizers are still pretty lame, after so many years, so I had to use PlatformEffects.
This complicated matters quite a lot, as now I had to add platform specific implementations of my Effect (in code you'll find it as TouchAndPressEffect).Because at this point I already decided to share the code as a NuGet package there was the issue that I will have to produce one .Net Standard library(with most of the code) and at least 4 platform-specific libraries (with the PlatformEffects).
SDK Style and Multi-Targeted project to the rescue: long story short this is now a multi-target project, making your life easier and mine significantly more complex. The things I do for you :D
## Here's the sample project showing off the SimpleImageButton
![Sample](Samples/images/SimpleImageButton_SamplesDemo5.gif)