Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit a17bfcb

Browse files
Merge branch 'develop' into guoldev/xctsample_backgroundcolor_issue
2 parents 20ff877 + b7fd3d8 commit a17bfcb

File tree

41 files changed

+953
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+953
-168
lines changed

.github/ISSUE_TEMPLATE/bug-report.md renamed to .github/ISSUE_TEMPLATE/bug_report_template.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
---
22
name: Bug Report
3-
about: Create a report to help us improve
3+
about: Report a bug in the Xamarin Community Toolkit
44
title: "[Bug] "
5-
labels: 'bug, s/unverified'
5+
labels: bug, unverified
66
assignees: ''
77

88
---
99

10+
<!--
11+
Hello, and thanks for your interest in contributing to the Xamarin Community Toolkit!
12+
13+
Please describe the issue below, including detailed steps for reproduction. If we are unable to reproduce the bug we will be unable to fix the issue and may close this Issue.
14+
15+
-->
16+
1017
### Description
1118

19+
<!-- Please provide a detailed description of the issue -->
20+
21+
### Stack Trace
22+
23+
<!-- Please copy/paste the complete stack trace (if applicable) -->
24+
25+
### Link to Reproduction Sample
26+
27+
<!-- Please link to a GitHub Repo or GitHub Page -->
28+
1229
### Steps to Reproduce
1330

1431
1.
@@ -38,7 +55,3 @@ assignees: ''
3855
### Reproduction imagery
3956

4057
<!-- If it is a visual issue, please include imagery (GIF/Screenshots) showing the problem -->
41-
42-
### Reproduction Link
43-
44-
<!-- Please upload or provide a link to a reproduction case -->

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
blank_issues_enabled: false
22
contact_links:
3+
- name: Propose a New Feature for .NET MAUI Toolkit
4+
url: https://github.com/communitytoolkit/maui/discussions/new
5+
about: The Xamarin Community Toolkit is no longer accepting new feature proposals. Going forward, all new features will be added to the .NET MAUI Community Toolkit.
36
- name: DotNetEvolution Discord Server
47
url: https://aka.ms/dotnet-discord
58
about: Please ask and answer questions here in the #xamarin-community-toolkit channel.

.github/ISSUE_TEMPLATE/feature-request.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/new-api-spec.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,24 @@
22
Hey there friend! First of all, thank you so much for this PR!
33
Some things that you should be aware of before opening this amazing PR❣
44
5-
1. Please check if you are targeting the correct branch, we work on two branches and you should target the:
6-
**main**: If you are fixing a bug and this bug doesn't change our public APIs
7-
**develop**: If you are fixing a bug that introduces an API change, for example when you are implementing a new feature.
8-
If you are not sure what branch target, ping one of the team directly or ask in the PR/issue and we will get back to you ASAP!
5+
1. Before doing a lot of work, please check if there's an open issue for this chang, If not, please open an issue first so we can discuss upfront.
96
10-
2. Before doing a lot of work, please check if there's an open issue for this chang, If not, please open an issue first so we can discuss upfront.
7+
2. Please ensure this is a PR for a Bug Fix. The Xamarin Community Toolkit is no longer accepting New Features. Going forward, all New Features are being add to the .NET MAUI Community Toolkit: https://github.com/communitytoolkit/maui
8+
9+
3. Please ensure you are targeting the correct branch, `main`
1110
1211
Also make sure you've read our Contribution guide here: https://github.com/xamarin/XamarinCommunityToolkit/blob/pj/update-pr-template/CONTRIBUTING.md
1312
-->
1413

15-
### Description of Change ###
14+
### Description of Bug ###
1615

17-
<!-- Describe your changes here. -->
16+
<!-- Describe your changes here that fix the bug. -->
1817

19-
### Bugs Fixed ###
18+
### Issues Fixed ###
2019
<!-- Provide links to issues here. Ensure that a GitHub issue was created for your feature or bug fix before sending PR. -->
2120

2221
- Fixes #
2322

24-
### API Changes ###
25-
26-
<!-- List all API changes here (or just put None), example:
27-
28-
Added:
29-
30-
- `string Class.Property { get; set; }`
31-
- `void Class.Method();`
32-
33-
Changed:
34-
35-
- `object Cell.OldPropertyName` => `object Cell.NewPropertyName`
36-
37-
If there is an entirely new API, then you can use a more verbose style:
38-
39-
```csharp
40-
public static class NewClass {
41-
public static int SomeProperty { get; set; }
42-
public static void SomeMethod(string value);
43-
}
44-
``` -->
45-
4623
### Behavioral Changes ###
4724

4825
<!-- Describe any non-bug related behavioral changes that may change how users app behaves when upgrading to this version of the codebase. -->

MauiCompatSteps.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,79 @@ foreach (var child in children)
600600
```
601601
602602
- [ ] TextSwitcherRenderer.android.cs
603+
604+
### 9. Add MauiColorExtensions Classes
605+
606+
In .NET MAUI the `Color` object has been changed from a `struct` to an `object`. Because of that, we now need to be aware of passing `null` values on methods that have to do with colors. For instance, the `ToAndroid()` and `ToUIColor()` extension methods that take a .NET MAUI `Color` and convert it into a native platform color. There are multiple ways to solve this, but we chose to overload these extension methods with our own. This method checks if the incoming color is `null`, if it is, we replace the color with `Colors.Transparent` and pass it to the extension method and return its value.
607+
608+
This way we didn't need to edit all the lines with this extension method individually.
609+
610+
#### 9.1 Create `MauiColorExtensions.android.cs`
611+
The code looks like underneath.
612+
613+
```cs
614+
using AColor = Android.Graphics.Color;
615+
616+
namespace Xamarin.CommunityToolkit.MauiCompat
617+
{
618+
public static partial class MauiColorExtensions
619+
{
620+
public static AColor ToAndroid(this Microsoft.Maui.Graphics.Color self)
621+
{
622+
var colorToConvert = self;
623+
624+
if (colorToConvert == null)
625+
{
626+
colorToConvert = Microsoft.Maui.Graphics.Colors.Transparent;
627+
}
628+
629+
return Microsoft.Maui.Controls.Compatibility.Platform.Android.ColorExtensions.ToAndroid(colorToConvert);
630+
}
631+
}
632+
}
633+
```
634+
635+
#### 9.2 Create `MauiColorExtensions.ios.cs`
636+
The code looks like underneath.
637+
638+
```cs
639+
using iColor = UIKit.UIColor;
640+
641+
namespace Xamarin.CommunityToolkit.MauiCompat
642+
{
643+
public static partial class MauiColorExtensions
644+
{
645+
public static iColor ToUIColor(this Microsoft.Maui.Graphics.Color self)
646+
{
647+
var colorToConvert = self;
648+
649+
if (colorToConvert == null)
650+
{
651+
colorToConvert = Microsoft.Maui.Graphics.Colors.Transparent;
652+
}
653+
654+
return Microsoft.Maui.Controls.Compatibility.Platform.iOS.ColorExtensions.ToUIColor(colorToConvert);
655+
}
656+
}
657+
}
658+
659+
```
660+
661+
#### 9.3 Add `using` Statement to Files Which Reference Original Extension Methods
662+
Now in each file that references the `ToAndroid()` and `ToUIColor()` methods we need to add the `using Xamarin.CommunityToolkit.MauiCompat;` line to make sure that it uses _our_ extension method. There is one catch: you have to declare this using **inside** the namespace declaration so that it will prefer _our_ extension method over the .NET MAUI one. In example:
663+
664+
```cs
665+
// ... Rest omitted for brevity
666+
using Microsoft.Maui.Controls.Compatibility;
667+
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
668+
// ... Rest omitted for brevity
669+
670+
[assembly: ExportRenderer(typeof(DrawingView), typeof(DrawingViewRenderer))]
671+
672+
namespace Xamarin.CommunityToolkit.UI.Views
673+
{
674+
// Make sure this using is here!
675+
using Xamarin.CommunityToolkit.MauiCompat;
676+
677+
public class DrawingViewRenderer : ViewRenderer<DrawingView, View> { }
678+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<pages:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
5+
xmlns:vm="clr-namespace:Xamarin.CommunityToolkit.Sample.ViewModels.Animations"
6+
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Animations.AnimationPage"
7+
x:DataType="{x:Null}">
8+
<pages:BasePage.BindingContext>
9+
<vm:AnimationViewModel />
10+
</pages:BasePage.BindingContext>
11+
12+
<Grid RowDefinitions="*,*">
13+
<Label Text="Select an animation below and then tap start."
14+
HorizontalTextAlignment="Center"
15+
x:Name="Lab"/>
16+
17+
<StackLayout Grid.Row="1">
18+
<Picker ItemsSource="{Binding Animations}"
19+
SelectedItem="{Binding SelectedAnimation}"
20+
ItemDisplayBinding="{Binding Name}"/>
21+
22+
<Button Text="Start"
23+
Command="{Binding StartAnimationCommand}"
24+
CommandParameter="{x:Reference Name=Lab}"/>
25+
26+
<Button Text="Stop"
27+
Command="{Binding StopAnimationCommand}"/>
28+
</StackLayout>
29+
30+
31+
</Grid>
32+
</pages:BasePage>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Xamarin.CommunityToolkit.Sample.Pages.Animations
2+
{
3+
public partial class AnimationPage : BasePage
4+
{
5+
public AnimationPage()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

samples/XCT.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
<Label Text="This sample demonstrates how to use ViewTappedAnimationBehaviour applying it in different UI elements."
1717
Padding="10,10,10,50"/>
1818

19+
<Button Text="Tada"
20+
FontSize="40"
21+
FontAttributes="Bold"
22+
TextColor="#2D1767"
23+
BackgroundColor="#F8E3C8">
24+
<Button.Behaviors>
25+
<xct:AnimationBehavior EventName="Clicked">
26+
<xct:AnimationBehavior.AnimationType>
27+
<xct:TadaAnimation Easing="{x:Static Easing.Linear}"
28+
IsRepeated="True"
29+
Duration="1000"/>
30+
</xct:AnimationBehavior.AnimationType>
31+
</xct:AnimationBehavior>
32+
</Button.Behaviors>
33+
</Button>
34+
1935
<Button Text="Testing Fade Animation"
2036
TextColor="HotPink">
2137
<Button.Behaviors>

samples/XCT.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
public partial class AnimationBehaviorPage : BasePage
44
{
55
public AnimationBehaviorPage() => InitializeComponent();
6-
}
6+
}
77
}

0 commit comments

Comments
 (0)