-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74d2b72
commit a585a95
Showing
8 changed files
with
194 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using EntityViews.Attributes.Input; | ||
|
||
namespace MauiApp1.Input; | ||
|
||
[DisplayControl] | ||
public class CustomDisplayLabel : Border | ||
{ | ||
public CustomDisplayLabel() | ||
{ | ||
BackgroundColor = Colors.Red; | ||
Padding = new Thickness(5); | ||
Content = Label = new Label | ||
{ | ||
TextColor = Colors.White | ||
}; | ||
} | ||
|
||
[ControlProperty] | ||
public Label Label { get; set; } | ||
} | ||
|
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,21 @@ | ||
using EntityViews.Attributes.Input; | ||
|
||
namespace MauiApp1.Input; | ||
|
||
[TextControl] | ||
public class CustomTextInput : Border | ||
{ | ||
public CustomTextInput() | ||
{ | ||
BackgroundColor = Colors.Gray; | ||
Padding = new Thickness(5); | ||
Content = TextInput = new Entry | ||
{ | ||
TextColor = Colors.Black | ||
}; | ||
} | ||
|
||
[ControlProperty] | ||
public Entry TextInput { get; set; } | ||
} | ||
|
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,21 @@ | ||
using EntityViews.Attributes.Input; | ||
|
||
namespace MauiApp1.Input; | ||
|
||
[ValidationControl] | ||
public class CustomValidationLabel : Border | ||
{ | ||
public CustomValidationLabel() | ||
{ | ||
BackgroundColor = Colors.Red; | ||
Padding = new Thickness(5); | ||
Content = Label = new Label | ||
{ | ||
TextColor = Colors.White | ||
}; | ||
} | ||
|
||
[ControlProperty] | ||
public Label Label { get; set; } | ||
} | ||
|
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,27 @@ | ||
namespace EntityViews.Attributes.Input; | ||
|
||
/// <summary> | ||
/// Indicates that the marked class is the display control, the display control is used to display the property name. | ||
/// </summary> | ||
public class DisplayControlAttribute : Attribute | ||
{ } | ||
|
||
/// <summary> | ||
/// Indicates that the marked class is the text control, the text control is where the user enters the property value. | ||
/// </summary> | ||
public class TextControlAttribute : Attribute | ||
{ } | ||
|
||
/// <summary> | ||
/// Indicates that the marked class is the validation control, the validation control is where validation errors are shown. | ||
/// </summary> | ||
public class ValidationControlAttribute : Attribute | ||
{ } | ||
|
||
/// <summary> | ||
/// Indicates that the marked property is the actual control to use. The containing class must be marked with | ||
/// <see cref="DisplayControlAttribute"/>, <see cref="TextControlAttribute"/> or <see cref="ValidationControlAttribute"/>, | ||
/// then the marked property will behave as the main control of the class. | ||
/// </summary> | ||
public class ControlPropertyAttribute : TextControlAttribute | ||
{ } |
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
53 changes: 53 additions & 0 deletions
53
src/EntityViews.SourceGenerators/Templates/MauiControls.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 @@ | ||
namespace EntityViews.SourceGenerators.Templates; | ||
|
||
public static class Controls | ||
{ | ||
public static Control? Display; | ||
public static string GetDisplayClassName() | ||
{ | ||
return Display?.ClassName ?? "Label"; | ||
} | ||
public static string GetDisplayRef(string defaultRefName) | ||
{ | ||
return Display?.TargetProperty is null | ||
? defaultRefName | ||
: $"{defaultRefName}.{Display.TargetProperty}"; | ||
} | ||
|
||
public static Control? TextInput; | ||
public static string GetTextInputClassName() | ||
{ | ||
return TextInput?.ClassName ?? "Entry"; | ||
} | ||
public static string GetTextInputRef(string defaultRefName) | ||
{ | ||
return TextInput?.TargetProperty is null | ||
? defaultRefName | ||
: $"{defaultRefName}.{TextInput.TargetProperty}"; | ||
} | ||
|
||
public static Control? Validation; | ||
public static string GetValidationClassName() | ||
{ | ||
return Validation?.ClassName ?? "Label"; | ||
} | ||
public static string GetValidationRef(string defaultRefName) | ||
{ | ||
return Validation?.TargetProperty is null | ||
? defaultRefName | ||
: $"{defaultRefName}.{Validation.TargetProperty}"; | ||
} | ||
|
||
public class Control(string className, string? propertyName) | ||
{ | ||
public string ClassName { get; } = className; | ||
public string? TargetProperty { get; } = propertyName; | ||
} | ||
|
||
public static void Clear() | ||
{ | ||
Display = null; | ||
TextInput = null; | ||
Validation = null; | ||
} | ||
} |