Skip to content

Commit 11c64dc

Browse files
committed
Adress feedback
1 parent 2aaea47 commit 11c64dc

9 files changed

+19
-39
lines changed

CommunityToolkit.Labs.Core.SourceGenerators/Attributes/ToolkitSampleBoolOptionAttribute.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ public sealed class ToolkitSampleBoolOptionAttribute : ToolkitSampleOptionBaseAt
2020
/// <param name="bindingName">The name of the generated property, which you can bind to in XAML.</param>
2121
/// <param name="defaultState">The initial value for the bound property.</param>
2222
/// <param name="title">A title to display on top of this option.</param>
23-
public ToolkitSampleBoolOptionAttribute(string bindingName, string label, bool defaultState, string? title = null)
24-
: base(bindingName, defaultState, title)
23+
public ToolkitSampleBoolOptionAttribute(string bindingName, bool defaultState)
24+
: base(bindingName, null)
2525
{
26-
Label = label;
26+
2727
}
2828

2929
/// <summary>
3030
/// The source generator-friendly type name used for casting.
3131
/// </summary>
3232
internal override string TypeName { get; } = "bool";
33-
34-
/// <summary>
35-
/// A label to display along the boolean option.
36-
/// </summary>
37-
public string Label { get; }
3833
}

CommunityToolkit.Labs.Core.SourceGenerators/Attributes/ToolkitSampleMultiChoiceOptionAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public sealed class ToolkitSampleMultiChoiceOptionAttribute : ToolkitSampleOptio
2121
/// <param name="bindingName">The name of the generated property, which you can bind to in XAML.</param>
2222
/// <param name="choices">A list of the choices to display to the user. Can be literal values, or labeled values. Use a " : " separator (single colon surrounded by at least 1 whitespace) to separate a label from a value.</param>
2323
/// <param name="title">A title to display on top of this option.</param>
24-
public ToolkitSampleMultiChoiceOptionAttribute(string bindingName, string? title = null, params string[] choices)
25-
: base(bindingName, null, title)
24+
public ToolkitSampleMultiChoiceOptionAttribute(string bindingName, params string[] choices)
25+
: base(bindingName, null)
2626
{
2727
Choices = choices.Select(x =>
2828
{

CommunityToolkit.Labs.Core.SourceGenerators/Attributes/ToolkitSampleOptionBaseAttribute.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public abstract class ToolkitSampleOptionBaseAttribute : Attribute
1515
/// <param name="bindingName">The name of the generated property, which you can bind to in XAML.</param>
1616
/// <param name="defaultState">The initial value for the bound property.</param>
1717
/// <param name="title">A title to display on top of this option.</param>
18-
public ToolkitSampleOptionBaseAttribute(string bindingName, object? defaultState, string? title = null)
18+
public ToolkitSampleOptionBaseAttribute(string bindingName, object? defaultState)
1919
{
20-
Title = title;
2120
Name = bindingName;
2221
DefaultState = defaultState;
2322
}
@@ -35,7 +34,7 @@ public ToolkitSampleOptionBaseAttribute(string bindingName, object? defaultState
3534
/// <summary>
3635
/// A title to display on top of the option.
3736
/// </summary>
38-
public string? Title { get; }
37+
public string? Title { get; set; }
3938

4039
/// <summary>
4140
/// The source generator-friendly type name used for casting.

CommunityToolkit.Labs.Core.SourceGenerators/Attributes/ToolkitSampleSliderOptionAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public sealed class ToolkitSampleSliderOptionAttribute : ToolkitSampleOptionBase
2121
/// <param name="bindingName">The name of the generated property, which you can bind to in XAML.</param>
2222
/// <param name="choices">A list of the choices to display to the user. Can be literal values, or labeled values. Use a " : " separator (single colon surrounded by at least 1 whitespace) to separate a label from a value.</param>
2323
/// <param name="title">A title to display on top of this option.</param>
24-
public ToolkitSampleSliderOptionAttribute(string bindingName, double initial = 0, double min = 0, double max = 10, double step = 1, string? title = null)
25-
: base(bindingName, null, title)
24+
public ToolkitSampleSliderOptionAttribute(string bindingName, double initial = 0, double min = 0, double max = 10, double step = 1)
25+
: base(bindingName, null)
2626
{
2727
Initial = initial;
2828
Min = min;

CommunityToolkit.Labs.Core.SourceGenerators/Attributes/ToolkitSampleTextOptionAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public sealed class ToolkitSampleTextOptionAttribute : ToolkitSampleOptionBaseAt
2020
/// <param name="bindingName">The name of the generated property, which you can bind to in XAML.</param>
2121
/// <param name="defaultState">The initial value for the bound property.</param>
2222
/// <param name="title">A title to display on top of this option.</param>
23-
public ToolkitSampleTextOptionAttribute(string bindingName, string placeholderText = null, string? title = null)
24-
: base(bindingName, placeholderText, title)
23+
public ToolkitSampleTextOptionAttribute(string bindingName, string? placeholderText = null)
24+
: base(bindingName, placeholderText)
2525
{
2626
PlaceholderText = placeholderText;
2727
}
@@ -34,5 +34,5 @@ public ToolkitSampleTextOptionAttribute(string bindingName, string placeholderTe
3434
/// <summary>
3535
/// A label to display along the boolean option.
3636
/// </summary>
37-
public string PlaceholderText { get; }
37+
public string? PlaceholderText { get; }
3838
}

CommunityToolkit.Labs.Core.SourceGenerators/Metadata/ToolkitSampleBoolOptionMetadataViewModel.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ namespace CommunityToolkit.Labs.Core.SourceGenerators.Metadata;
1515
/// </remarks>
1616
public class ToolkitSampleBoolOptionMetadataViewModel : IGeneratedToolkitSampleOptionViewModel
1717
{
18-
private string _label;
1918
private string? _title;
2019
private object _value;
2120

2221
/// <summary>
2322
/// Creates a new instance of <see cref="ToolkitSampleBoolOptionAttribute"/>.
2423
/// </summary>
25-
public ToolkitSampleBoolOptionMetadataViewModel(string id, string label, bool defaultState, string? title = null)
24+
public ToolkitSampleBoolOptionMetadataViewModel(string id, bool defaultState, string? title = null)
2625
{
2726
Name = id;
2827
_title = title;
29-
_label = label;
3028
_value = defaultState;
3129
}
3230

@@ -68,19 +66,6 @@ public object? Value
6866
}
6967
}
7068

71-
/// <summary>
72-
/// A label to display along the boolean option.
73-
/// </summary>
74-
public string Label
75-
{
76-
get => _label;
77-
set
78-
{
79-
_label = value;
80-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Label)));
81-
}
82-
}
83-
8469
/// <summary>
8570
/// A title to display on top of the boolean option.
8671
/// </summary>

CommunityToolkit.Labs.Core.SourceGenerators/Metadata/ToolkitSampleSliderOptionMetadataViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public ToolkitSampleSliderOptionMetadataViewModel(string name, double initial =
4444
/// <summary>
4545
/// The initial double value.
4646
/// </summary>
47-
public double Initial
47+
public double? Initial
4848
{
49-
get => (double)_value;
49+
get => (double?)_value;
5050
set
5151
{
5252
_value = value;

CommunityToolkit.Labs.Core.SourceGenerators/ToolkitSampleMetadataGenerator.Sample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private static IEnumerable<string> BuildNewGeneratedSampleOptionMetadataSource(T
291291
}
292292
else if (item is ToolkitSampleBoolOptionAttribute boolAttribute)
293293
{
294-
yield return $@"new {typeof(ToolkitSampleBoolOptionMetadataViewModel).FullName}(id: ""{boolAttribute.Name}"", label: ""{boolAttribute.Label}"", defaultState: {boolAttribute.DefaultState?.ToString().ToLower()}, title: ""{boolAttribute.Title}"")";
294+
yield return $@"new {typeof(ToolkitSampleBoolOptionMetadataViewModel).FullName}(id: ""{boolAttribute.Name}"", defaultState: {boolAttribute.DefaultState?.ToString().ToLower()}, title: ""{boolAttribute.Title}"")";
295295
}
296296
else if (item is ToolkitSampleSliderOptionAttribute sliderAttribute)
297297
{

CommunityToolkit.Labs.Shared/Renderers/GeneratedSampleOptionsRenderer.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
<StackPanel>
2020
<TextBlock Text="{x:Bind Title}"
2121
Visibility="{x:Bind local:GeneratedSampleOptionsRenderer.NullOrWhiteSpaceToVisibility(Title)}" />
22-
<CheckBox Content="{x:Bind Label}"
23-
IsChecked="{x:Bind BoolValue, Mode=TwoWay}" />
22+
<!--<CheckBox Content="{x:Bind Title}"
23+
IsChecked="{x:Bind BoolValue, Mode=TwoWay}" />-->
24+
<ToggleSwitch IsOn="{x:Bind BoolValue, Mode=TwoWay}" />
2425
</StackPanel>
2526
</DataTemplate>
2627
</local:GeneratedSampleOptionTemplateSelector.BoolOptionTemplate>

0 commit comments

Comments
 (0)