Skip to content

Instantly share code, notes, and snippets.

View sthewissen's full-sized avatar
🤷‍♂️
Developing tings.

Steven Thewissen sthewissen

🤷‍♂️
Developing tings.
View GitHub Profile
public class MyButton : View, IMyButton
{
}
public interface IMyButton : IView
{
public string Text { get; }
public Color TextColor { get; }
void Completed();
}
@sthewissen
sthewissen / NativeView.cs
Created January 17, 2022 10:15
Grab a native view from MAUI
#if __ANDROID__
ViewHandler.ViewMapper[nameof(IView.BackgroundColor)] = (handler, view) =>
(handler.NativeView as AView).SetBackgroundColor(Android.Graphics.Color.Green);
var textView = crossPlatformLabel.Handler.NativeView as TextView;
#endif
<application android:label="MVP"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
...
</application>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/mvp_logo"/>
</adaptive-icon>
@sthewissen
sthewissen / MyDatePickerRenderer.cs
Last active February 22, 2021 14:11
MyDatePickerRenderer.cs
[assembly: ExportRenderer(typeof(DatePicker), typeof(MyDatePickerRenderer))]
namespace MyProject.iOS.Renderers
{
public class MyDatePickerRenderer : DatePickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
{
base.OnElementChanged(e);
if (e.NewElement != null && Control != null)
@sthewissen
sthewissen / ExtendedTabbedPageRenderer.cs
Last active January 12, 2021 15:51
ExtendedTabbedPageRenderer
using Android.Content;
using Android.Graphics;
using Android.Widget;
using Google.Android.Material.BottomNavigation;
using Google.Android.Material.Internal;
using MyProject.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms.Platform.Android.AppCompat;
@sthewissen
sthewissen / dimens.xml
Created January 12, 2021 14:22
Dimens.xml
<?xml version="1.0" encoding="UTF-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen name="design_bottom_navigation_text_size" tools:override="true">14sp</dimen>
<dimen name="design_bottom_navigation_active_text_size" tools:override="true">14sp</dimen>
<dimen name="design_bottom_navigation_icon_size">20dp</dimen>
<dimen name="design_bottom_navigation_height">60dp</dimen>
</resources>
@sthewissen
sthewissen / App.xaml.cs
Created December 16, 2020 12:21
App.xaml.cs
public App()
{
InitializeComponent();
// Set the theme that the user has picked.
Current.UserAppTheme = (OSAppTheme)Preferences.Get(Settings.AppTheme, Settings.AppThemeDefault);
}
@sthewissen
sthewissen / ThemePickerViewModel.cs
Created December 16, 2020 12:16
ThemePickerViewModel
public class ThemePickerViewModel
{
public IList<AppThemeViewModel> AppThemes { get; set; } = new List<AppThemeViewModel> {
new AppThemeViewModel() { Key = (int)OSAppTheme.Unspecified },
new AppThemeViewModel() { Key = (int)OSAppTheme.Light },
new AppThemeViewModel() { Key = (int)OSAppTheme.Dark }
};
public ICommand SetAppThemeCommand { get; set; }