Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/UdaraAlwis/XFShellAdvThemeing

Stunning App themes with Xamarin Forms Shell!
https://github.com/UdaraAlwis/XFShellAdvThemeing

shell styles themes xamarin xamarin-forms

Last synced: 30 days ago
JSON representation

Stunning App themes with Xamarin Forms Shell!

Awesome Lists containing this project

README

        

# XFShellAdvThemeing
Stunning App themes with Xamarin Forms Shell!

You probably already know how to in classic Xamarin.Forms, but how about Setting up App Themes in a Xamarin.Forms Shell App?, now that's what this is for. 😉

Check out the blog post: https://theconfuzedsourcecode.wordpress.com/2019/12/26/stunning-app-themes-in-xamarin-forms-shell-projects/

A little sneak peak:
![Android](/screenshots/PreviewStepByStepDemoAndroid.png)

>Here we're using awesome built-in Xamarin.Forms Dynamic Binding, and Styling features to implement a neat App Theming solution.
>An alternative for: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming
>But focused on the awesome new paradigm of Xamarin.Forms Shell!

### In a nutshell:
- Define Theme files with Colors/Fonts/Images/Icons in them
- Create Styles based on the Theme properties using Dynamic Binding
- Bind the UI Elements to the Styles created earlier
- Implement dynamic App Theme selection using MergedDictionaries
- Use XF.Essentials Preferences API to save App Theme preferences

Sample Theme File:
```xaml


#fc0384
#ffb8dd
White

White
#fc0384

#3d0020
#610033
#960050

```

Sample Style:

```xaml

<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}" />
<Setter Property="TextColor" Value="{DynamicResource SecondaryColor}" />
<Setter Property="HeightRequest" Value="45" />
<Setter Property="WidthRequest" Value="190" />

```

Sample UI Element:

```xaml

```

Dynamic App Theme Switching:
```csharp
ICollection mergedDictionaries
= Application.Current.Resources.MergedDictionaries;
...
...
case Theme.Pink:
mergedDictionaries.Add(new PinkTheme());
break;
...
...
```

Saving Theme Preferences:
```csharp
Preferences.Set("CurrentAppTheme", SelectedItem.ToString());
```

Behold the beauty on Android and iOS...
![Android](/screenshots/PreviewCollectionAndroid.png)
![iOS](/screenshots/PreviewCollectioniOS.png)