1

Exploring Christmas UI in .NET MAUI

 1 year ago
source link: https://askxammy.com/exploring-christmas-ui-in-net-maui/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

.Net MAUI, UI

Exploring Christmas UI in .NET MAUI

Leomaris Reyes / 29 December, 2022
ChristmasMainImage.png

Merry Christmas! 🎄 I hope you are very well on these dates and you are happy with yours! 💓 It’s a time where we usually set goals for the next year with the aim of continuing to grow every day! And to contribute to your goals of practicing XAML, I have brought you this article as my last gift of the year, we will be exploring a Christmas UI by Anton Mishin obtained from Dribbble.

In addition to using XAML, in this article we will learn about the following topics:

➖ XAML Styles

➖ Adding external Fonts

➖ Adaptation to light and dark mode

➖Shadows


Let’s start!

Let’s divide the original design into blocks

For a better understanding, I divided the original design into blocks, which are listed in the order in which we will be reproducing each one:

Screen-Shot-2022-12-28-at-1.46.31-PM.png



Screen-Shot-2022-12-28-at-1.49.56-PM.png

Both screens have the same visual elements, so I’ll explain them simultaneously in each block. We’ll start by creating the WalkingStickPage.xaml page which is composed by the following elements:

➖ BackgroundColor: It will have a background color that accommodates light and dark modes (this’s why you’ll see the AppThemeBinding markup extension). This time the light mode will have a white background color while the dark mode will have a dark green one. Add it to your Contentpage as follows:

📋 If you want to know more information about handling light and dark modes in your apps, I recommend the article “Handling Light and Dark Mode With .NET MAUI”.

    • Did you notice that the dark green color is added as a StaticResource?  This helps us to have the color in a single source, so maintenance will be easier because we only have to change it once. Go to Resources ➡ Styles ➡ Colors.xaml and add the following:

➖ Main layout: We’ll use the VerticalStackLayout as the main layout and add its properties in a style. Let’s start by creating the style:

📋 If you want to know more information about VerticalStackLayout, I recommend the article “Horizontal & VerticalStackLayout in .NET MAUI”.

Now, let’s add the layout and the main image to our .xaml:

Let’s see the results for both light and dark mode!

Screen-Shot-2022-12-28-at-3.20.29-PM.png

Also, let’s take the opportunity to create the other page (SantaClaus.xaml), this will benefit from the styles and resources created above (don’t forget to add the BackgroundColor to your Contentpage). We just have to add the following code:

Screen-Shot-2022-12-28-at-3.19.18-PM.png





Screen-Shot-2022-12-28-at-2.43.45-PM.png

This block contains a Title and a Description. At this point we’ll be focusing on implementing styles and we’ll be also adding external Fonts, as you can see below:

  • Styles for Title and Description
  • Adding external Fonts

We’ll add the fonts: Dutch-Bold for the Title and Antebas for the Description.

💡Tip: If you don’t know the name of the font that your UI has, I recommend WhatTheFont, uploading a screenshot of your UI, this site will indicate the name of the font and other similar ones.

📋 For more information on how to add external fonts I recommend the article “Adding Fonts in .NET MAUI”.

Let’s add them to the WalkingStickPage.xaml page: Add your labels with the new fonts and styles!

Screen-Shot-2022-12-28-at-3.22.42-PM.png

Let’s continue with the SantaClausPage.xaml page

Screen-Shot-2022-12-28-at-3.22.54-PM.png

Screen-Shot-2022-12-28-at-3.25.08-PM.png

Finally, we have a circular button with a shadow behind it!

Let’s start creating the Button style

Add the Button with Shadow

📋 If you want to know more information about Shadows, I recommend the article  “Adding Shadows with .NET MAUI”

This code is exactly the same for both WalkingStickPage.xaml and SantaClausPage.xaml, so I won’t add another block of code. Let’s see the results of both:

  • WalkingStickPage.xaml
Screen-Shot-2022-12-28-at-3.34.32-PM.png
  • SantaClausPage.xaml
Screen-Shot-2022-12-28-at-3.38.12-PM.png



And done!! ? In a few minutes we have practiced different interesting topics by replicating this Christmas UI! I hope you liked it! 💚💕

Tagged .NetMaui, AskXammy, Replicating UI, UI


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK