Skip to content

Instantly share code, notes, and snippets.

Avatar
🤷‍♂️
Developing tings.

Steven Thewissen sthewissen

🤷‍♂️
Developing tings.
View GitHub Profile
View AndroidManifest.xml
<application android:label="MVP"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
...
</application>
View ic_launcher.xml
<?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 Feb 22, 2021
MyDatePickerRenderer.cs
View 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 Jan 12, 2021
ExtendedTabbedPageRenderer
View ExtendedTabbedPageRenderer.cs
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;
View 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>
View App.xaml.cs
public App()
{
InitializeComponent();
// Set the theme that the user has picked.
Current.UserAppTheme = (OSAppTheme)Preferences.Get(Settings.AppTheme, Settings.AppThemeDefault);
}
View ThemePickerViewModel.cs
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; }
@sthewissen
sthewissen / AppTheme.cs
Created Dec 16, 2020
Getting/setting app theme
View AppTheme.cs
// Get the current theme
OSAppTheme currentTheme = Application.Current.RequestedTheme;
// Set the current theme.
Application.Current.UserAppTheme = OSAppTheme.Dark;
View AppThemeBinding.xaml
<ContentPage>
<StackLayout Margin="20">
<Label Text="This text is green in light mode, and red in dark mode."
TextColor="{AppThemeBinding Light=Green, Dark=Red}" />
<Image Source="{AppThemeBinding Light=lightlogo.png, Dark=darklogo.png}" />
</StackLayout>
</ContentPage>
@sthewissen
sthewissen / TouchEff.xaml
Created Nov 20, 2020
A sample using basic TouchEffect properties
View TouchEff.xaml
<Grid touch:TouchEff.PressedBackgroundColor="{StaticResource light_blue}"
touch:TouchEff.RegularBackgroundColor="{StaticResource white}"
touch:TouchEff.Command="{Binding OpenThemePickerCommand}">
...
</Grid>