Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
37b8579
SnackBar/Toast
VladislavAntonyuk Jul 29, 2021
c17bf53
Fix DisplaySnackBarAsync Task never completes if another SnackBar app…
VladislavAntonyuk Oct 6, 2021
916fc58
Add samples
VladislavAntonyuk Oct 6, 2021
3a79cd1
Update src/CommunityToolkit.Maui/Views/Snackbar/Options/SnackBarActio…
VladislavAntonyuk Oct 16, 2021
9c2ade3
Apply suggestions from code review
VladislavAntonyuk Oct 16, 2021
ce72c10
Base Toast and Snackbar
VladislavAntonyuk Nov 21, 2021
4d60e6e
Remove toast, update sample, remove ios
VladislavAntonyuk Nov 21, 2021
c2a6a38
Add border, padding, fix tests, call events
VladislavAntonyuk Nov 21, 2021
8d6f126
remove base popup, fix anchor view
VladislavAntonyuk Nov 23, 2021
ca8c147
rebase on main, ios, macos snackbar
VladislavAntonyuk Nov 23, 2021
db3dd8b
implement ITextStyle
VladislavAntonyuk Nov 23, 2021
6eb2206
styles for ios/macos
VladislavAntonyuk Nov 24, 2021
2347e57
documentation
VladislavAntonyuk Nov 24, 2021
90079ac
Merge branch 'main' into vantonyuk/snackbar
VladislavAntonyuk Nov 24, 2021
c32e466
set android action button font
VladislavAntonyuk Nov 24, 2021
8c5eec7
Fix font
VladislavAntonyuk Nov 24, 2021
38ace05
base tests
VladislavAntonyuk Nov 25, 2021
8126f31
Add tests, IPlatformPopupExtensions
VladislavAntonyuk Nov 25, 2021
aaf38a5
Remove unused tasks from pipeline
VladislavAntonyuk Nov 25, 2021
a221d06
Add Windows
VladislavAntonyuk Nov 26, 2021
c6589f5
fix styles
VladislavAntonyuk Nov 26, 2021
040479c
Add padding, fix ios font size
VladislavAntonyuk Nov 26, 2021
8ee1d85
Unsubscribe from events
VladislavAntonyuk Nov 26, 2021
b68f68c
Minor code style tweaks
VladislavAntonyuk Nov 26, 2021
c508b2d
Update azure-pipelines.yml
TheCodeTraveler Nov 26, 2021
dcac25c
Update CommunityToolkit.Maui.Sample.csproj
TheCodeTraveler Nov 26, 2021
db35efc
`dotnet format`
TheCodeTraveler Nov 26, 2021
9d1b36f
Implement `IDisposable` Per .NET Guidelines
TheCodeTraveler Nov 26, 2021
4e33ffa
`dotnet format`
TheCodeTraveler Nov 26, 2021
022ffdd
`SnackBar` -> `Snackbar`
TheCodeTraveler Nov 26, 2021
84899c9
`SnackBar` -> `Snackbar`, Windows
TheCodeTraveler Nov 26, 2021
7a51152
Update Snackbar Architecture
TheCodeTraveler Nov 27, 2021
259016c
`dotnet format`
TheCodeTraveler Nov 27, 2021
451b385
Refactor Snackbar Namespace to Alert`
TheCodeTraveler Nov 27, 2021
e22d151
Update SnackBar.shared.cs
TheCodeTraveler Nov 27, 2021
688d8d1
Fix CR comments
VladislavAntonyuk Nov 27, 2021
4af19e6
Fix behavior on Windows and ios
VladislavAntonyuk Nov 27, 2021
7024408
Add tests
VladislavAntonyuk Nov 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ csharp_style_namespace_declarations = file_scoped:error
dotnet_diagnostic.CS4014.severity = error

# Remove explicit default access modifiers
dotnet_style_require_accessibility_modifiers = omit_if_default:error
dotnet_style_require_accessibility_modifiers = omit_if_default:error

# CA1063: Implement IDisposable Correctly
dotnet_diagnostic.CA1063.severity = error
27 changes: 9 additions & 18 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ jobs:
pool:
vmImage: windows-latest
steps:
# .NET 5.0 is required for maui-check
- task: UseDotNet@2
displayName: 'Install .NET 5.0 SDK'
inputs:
version: '5.0.x'
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
Expand Down Expand Up @@ -77,7 +72,7 @@ jobs:
- powershell: |
$prNumber = $env:System_PullRequest_PullRequestNumber
$commitId = "$($env:System_PullRequest_SourceCommitId)".Substring(0, 7)
$fullVersionString = "$(CurrentSemanticVersionBase)-build.$prNumber+$commitId"
$fullVersionString = "$(CurrentSemanticVersionBase)-build-$prNumber.$(Build.BuildId)+$commitId"
Write-Host("GitHub PR = $prNumber, Commit = $commitId");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$fullVersionString")
Write-Host "##vso[build.updatebuildnumber]$fullVersionString"
Expand All @@ -96,15 +91,13 @@ jobs:
inputs:
script: 'dotnet build $(PathToCommunityToolkitCsproj) -c Release'
- task: CmdLine@2
displayName: 'Build Community Toolkit Sample'
displayName: 'Run Unit Tests'
inputs:
script: 'dotnet build $(PathToCommunityToolkitSampleCsproj) -c Release'
script: 'dotnet test $(PathToCommunityToolkitUnitTestCsproj) -c Release'
- task: CmdLine@2
displayName: 'Run Unit Tests'
displayName: 'Build Community Toolkit Sample'
inputs:
script: |
dotnet build $(PathToCommunityToolkitUnitTestCsproj) -c Release
dotnet test $(PathToCommunityToolkitUnitTestCsproj) -c Release
script: 'dotnet build $(PathToCommunityToolkitSampleCsproj) -c Release'
- task: CmdLine@2
displayName: Pack Community Toolkit NuGets
inputs:
Expand Down Expand Up @@ -163,15 +156,13 @@ jobs:
inputs:
script: 'dotnet build $(PathToCommunityToolkitCsproj) -c Release'
- task: CmdLine@2
displayName: 'Build Community Toolkit Sample'
displayName: 'Run Unit Tests'
inputs:
script: 'dotnet build $(PathToCommunityToolkitSampleCsproj) -c Release'
script: 'dotnet test $(PathToCommunityToolkitUnitTestCsproj) -c Release'
- task: CmdLine@2
displayName: 'Run Unit Tests'
displayName: 'Build Community Toolkit Sample'
inputs:
script: |
dotnet build $(PathToCommunityToolkitUnitTestCsproj) -c Release
dotnet test $(PathToCommunityToolkitUnitTestCsproj) -c Release
script: 'dotnet build $(PathToCommunityToolkitSampleCsproj) -c Release'
- task: CmdLine@2
displayName: 'Pack CommunityToolkit NuGets'
inputs:
Expand Down
3 changes: 2 additions & 1 deletion samples/CommunityToolkit.Maui.Sample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Maui.Sampl
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3ED2C978-9DDB-48FE-8C5A-521B254F18A3}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\azure-pipelines.yml = ..\azure-pipelines.yml
..\Directory.Build.props = ..\Directory.Build.props
..\global.json = ..\global.json
..\.editorconfig = ..\.editorconfig
EndProjectSection
EndProject
Global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.0.3" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="1.0.0-pre2" />
</ItemGroup>

Expand All @@ -67,4 +67,8 @@
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-android'))">
Comment thread
TheCodeTraveler marked this conversation as resolved.
<RuntimeIdentifiers>android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CommunityToolkit.Maui.Sample.ViewModels.Alerts;

namespace CommunityToolkit.Maui.Sample.Pages.Alerts;

public class AlertsGalleryPage : BaseGalleryPage<AlertsGalleryViewModel>
{
public AlertsGalleryPage() : base("Alerts")
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
xmlns:converters="clr-namespace:CommunityToolkit.Maui.Converters;assembly=CommunityToolkit.Maui"
x:Class="CommunityToolkit.Maui.Sample.Pages.Alerts.SnackbarPage">

<pages:BasePage.Resources>
<ResourceDictionary>
<converters:ColorToColorForTextConverter x:Key="ColorToColorForTextConverter"/>
</ResourceDictionary>
</pages:BasePage.Resources>

<VerticalStackLayout Spacing="12">

<Label Text="The Snackbar is a timed alert that appears at the bottom of the screen by default. It is dismissed after a configurable duration of time. Snackbar is fully customizable and can be anchored to any IView."
LineBreakMode = "WordWrap" />

<Label Text="Windows uses toast notifications to display snackbar. Make sure you switched off Focus Assist."
IsVisible="false">
<Label.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean">
<On Platform="UWP" Value="true" />
</OnPlatform>
</Label.IsVisible>
</Label>

<Button Clicked="DisplayDefaultSnackbarButtonClicked"
Text="Display Default Snackbar"/>

<Button x:Name="DisplayCustomSnackbarButton"
Clicked="DisplayCustomSnackbarButtonClicked"
TextColor="{Binding Source={RelativeSource Self}, Path=BackgroundColor, Converter={StaticResource ColorToColorForTextConverter}}"/>

</VerticalStackLayout>

</pages:BasePage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using CommunityToolkit.Maui.Alerts.Snackbar;
using CommunityToolkit.Maui.Extensions;
using Microsoft.Maui;
using Microsoft.Maui.Graphics;

namespace CommunityToolkit.Maui.Sample.Pages.Alerts;

public partial class SnackbarPage : BasePage
{
const string _displayCustomSnackbarText = "Display a Custom Snackbar, Anchored to this Button";
const string _dismissCustomSnackbarText = "Dismiss Custom Snackbar";
readonly IReadOnlyList<Color> _colors = typeof(Colors)
.GetFields(BindingFlags.Static | BindingFlags.Public)
.ToDictionary(c => c.Name, c => (Color)(c.GetValue(null) ?? throw new InvalidOperationException()))
.Values.ToList();

ISnackbar? _customSnackbar;

public SnackbarPage()
{
InitializeComponent();

DisplayCustomSnackbarButton ??= new();
DisplayCustomSnackbarButton.Text = _displayCustomSnackbarText;
}

async void DisplayDefaultSnackbarButtonClicked(object? sender, EventArgs args) =>
await this.DisplaySnackbar("This is a Snackbar.\nIt will disappear in 3 seconds.\nOr click OK to dismiss immediately");

async void DisplayCustomSnackbarButtonClicked(object? sender, EventArgs args)
{
if (DisplayCustomSnackbarButton.Text is _displayCustomSnackbarText)
{
var options = new SnackbarOptions
{
BackgroundColor = Colors.Red,
TextColor = Colors.Green,
ActionButtonTextColor = Colors.Yellow,
CornerRadius = new CornerRadius(10),
Font = Font.SystemFontOfSize(14),
};

_customSnackbar = Snackbar.Make(
"This is a customized Snackbar",
async () =>
{
await DisplayCustomSnackbarButton.BackgroundColorTo(_colors[new Random().Next(_colors.Count)], length: 500);
DisplayCustomSnackbarButton.Text = _displayCustomSnackbarText;
},
"Change Button Color",
TimeSpan.FromSeconds(30),
options,
DisplayCustomSnackbarButton);

await _customSnackbar.Show();

DisplayCustomSnackbarButton.Text = _dismissCustomSnackbarText;
}
else if (DisplayCustomSnackbarButton.Text is _dismissCustomSnackbarText)
{
if (_customSnackbar is not null)
await _customSnackbar.Dismiss();

DisplayCustomSnackbarButton.Text = _displayCustomSnackbarText;
}
else
{
throw new NotImplementedException($"{nameof(DisplayCustomSnackbarButton)}.{nameof(ITextButton.Text)} Not Recognized");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
using Microsoft.Maui;

namespace CommunityToolkit.Maui.Sample;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
public class MainActivity : MauiAppCompatActivity
{
// https://github.com/dotnet/maui/pull/3345
Comment thread
VladislavAntonyuk marked this conversation as resolved.
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
Microsoft.Maui.Essentials.Platform.Init(this, savedInstanceState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
IgnorableNamespaces="uap rescap desktop4">

<Identity
Name="E71AB0A7-18D7-47F1-8F52-55C91EAFA3E8"
Expand All @@ -27,7 +28,7 @@
</Resources>

<Applications>
<Application Id="App"
<Application Id="App" desktop4:SupportsMultipleInstances="false"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using CommunityToolkit.Maui.Sample.Models;
using CommunityToolkit.Maui.Sample.Pages.Alerts;

namespace CommunityToolkit.Maui.Sample.ViewModels.Alerts;

public class AlertsGalleryViewModel : BaseGalleryViewModel
{
protected override IEnumerable<SectionModel> CreateItems() => new[]
{
new SectionModel(typeof(SnackbarPage), "Snackbar", "Show Snackbar Alert")
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using CommunityToolkit.Maui.Sample.Pages.Behaviors;
using CommunityToolkit.Maui.Sample.Pages.Converters;
using CommunityToolkit.Maui.Sample.Pages.Extensions;
using CommunityToolkit.Maui.Sample.Pages.Alerts;
using Microsoft.Maui.Graphics;

namespace CommunityToolkit.Maui.Sample.ViewModels;
Expand All @@ -19,5 +20,8 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]

new SectionModel(typeof(ExtensionsGalleryPage), "Extensions", Color.FromArgb("#00EA56"),
"Extenions lets you add methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type."),

new SectionModel(typeof(AlertsGalleryPage), "Alerts", Color.FromArgb("#EF6950"),
"Alerts allow you display alerts to your user"),
};
}
Loading