This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Name Generation for Identical View Class Names (#93)
* fix: Name Generation for Identical View Class Names * nit: Formatting
- Loading branch information
1 parent
138be17
commit 88b52d8
Showing
16 changed files
with
173 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:Avalonia.NameGenerator.Sandbox.Controls" | ||
x:Class="Avalonia.NameGenerator.Sandbox.Controls.SignUpView"> | ||
<StackPanel> | ||
<controls:CustomTextBox Margin="0 10 0 0" | ||
x:Name="UserNameTextBox" | ||
Watermark="Please, enter user name..." | ||
UseFloatingWatermark="True" /> | ||
<TextBlock x:Name="UserNameValidation" | ||
Foreground="Red" | ||
FontSize="12" /> | ||
<TextBox Margin="0 10 0 0" | ||
x:Name="PasswordTextBox" | ||
Watermark="Please, enter your password..." | ||
UseFloatingWatermark="True" | ||
PasswordChar="*" /> | ||
<TextBlock x:Name="PasswordValidation" | ||
Foreground="Red" | ||
FontSize="12" /> | ||
<TextBox Margin="0 10 0 0" | ||
x:Name="ConfirmPasswordTextBox" | ||
Watermark="Please, confirm the password..." | ||
UseFloatingWatermark="True" | ||
PasswordChar="*" /> | ||
<TextBlock x:Name="ConfirmPasswordValidation" | ||
TextWrapping="Wrap" | ||
Foreground="Red" | ||
FontSize="12" /> | ||
<Button Margin="0 10 0 5" | ||
Content="Sign up" | ||
x:Name="SignUpButton" /> | ||
<TextBlock x:Name="CompoundValidation" | ||
TextWrapping="Wrap" | ||
Foreground="Red" | ||
FontSize="12" /> | ||
</StackPanel> | ||
</UserControl> |
53 changes: 53 additions & 0 deletions
53
src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Reactive.Disposables; | ||
using Avalonia.NameGenerator.Sandbox.ViewModels; | ||
using Avalonia.ReactiveUI; | ||
using ReactiveUI; | ||
using ReactiveUI.Validation.Extensions; | ||
using ReactiveUI.Validation.Formatters; | ||
|
||
namespace Avalonia.NameGenerator.Sandbox.Controls; | ||
|
||
/// <summary> | ||
/// This is a sample view class with typed x:Name references generated using | ||
/// .NET 5 source generators. The class has to be partial because x:Name | ||
/// references are living in a separate partial class file. See also: | ||
/// https://devblogs.microsoft.com/dotnet/new-c-source-generator-samples/ | ||
/// </summary> | ||
public partial class SignUpView : ReactiveUserControl<SignUpViewModel> | ||
{ | ||
public SignUpView() | ||
{ | ||
// The InitializeComponent method is also generated automatically | ||
// and lives in the autogenerated part of the partial class. | ||
InitializeComponent(); | ||
this.WhenActivated(disposables => | ||
{ | ||
this.Bind(ViewModel, x => x.UserName, x => x.UserNameTextBox.Text) | ||
.DisposeWith(disposables); | ||
this.Bind(ViewModel, x => x.Password, x => x.PasswordTextBox.Text) | ||
.DisposeWith(disposables); | ||
this.Bind(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordTextBox.Text) | ||
.DisposeWith(disposables); | ||
this.BindCommand(ViewModel, x => x.SignUp, x => x.SignUpButton) | ||
.DisposeWith(disposables); | ||
this.BindValidation(ViewModel, x => x.UserName, x => x.UserNameValidation.Text) | ||
.DisposeWith(disposables); | ||
this.BindValidation(ViewModel, x => x.Password, x => x.PasswordValidation.Text) | ||
.DisposeWith(disposables); | ||
this.BindValidation(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordValidation.Text) | ||
.DisposeWith(disposables); | ||
var newLineFormatter = new SingleLineFormatter(Environment.NewLine); | ||
this.BindValidation(ViewModel, x => x.CompoundValidation.Text, newLineFormatter) | ||
.DisposeWith(disposables); | ||
// The references to text boxes below are also auto generated. | ||
// Use Ctrl+Click in order to view the generated sources. | ||
UserNameTextBox.Text = "Joseph!"; | ||
PasswordTextBox.Text = "1234"; | ||
ConfirmPasswordTextBox.Text = "1234"; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.