Skip to content

Commit f3a19f7

Browse files
authored
Merge pull request #619 from irihitech/demo
Simplify Demo
2 parents 14a3384 + 57235c4 commit f3a19f7

File tree

74 files changed

+368
-540
lines changed

Some content is hidden

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

74 files changed

+368
-540
lines changed

demo/Semi.Avalonia.Demo/Constant/ColorTokens.cs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,139 +5,139 @@ namespace Semi.Avalonia.Demo.Constant;
55

66
public static class ColorTokens
77
{
8-
public static IReadOnlyList<Tuple<string, string>> PrimaryTokens { get; } = new List<Tuple<string, string>>
9-
{
8+
public static IReadOnlyList<Tuple<string, string>> PrimaryTokens { get; } =
9+
[
1010
new("SemiColorPrimary", "Primary"),
1111
new("SemiColorPrimaryPointerover", "Primary Pointerover"),
1212
new("SemiColorPrimaryActive", "Primary Active"),
1313
new("SemiColorPrimaryDisabled", "Primary Disabled"),
1414
new("SemiColorPrimaryLight", "Primary Light"),
1515
new("SemiColorPrimaryLightPointerover", "Primary Light Pointerover"),
1616
new("SemiColorPrimaryLightActive", "Primary Light Active"),
17-
};
17+
];
1818

19-
public static IReadOnlyList<Tuple<string, string>> SecondaryTokens { get; } = new List<Tuple<string, string>>
20-
{
19+
public static IReadOnlyList<Tuple<string, string>> SecondaryTokens { get; } =
20+
[
2121
new("SemiColorSecondary", "Secondary"),
2222
new("SemiColorSecondaryPointerover", "Secondary Pointerover"),
2323
new("SemiColorSecondaryActive", "Secondary Active"),
2424
new("SemiColorSecondaryDisabled", "Secondary Disabled"),
2525
new("SemiColorSecondaryLight", "Secondary Light"),
2626
new("SemiColorSecondaryLightPointerover", "Secondary Light Pointerover"),
27-
new("SemiColorSecondaryLightActive", "Secondary Light Active"),
28-
};
27+
new("SemiColorSecondaryLightActive", "Secondary Light Active")
28+
];
2929

30-
public static IReadOnlyList<Tuple<string, string>> TertiaryTokens { get; } = new List<Tuple<string, string>>
31-
{
30+
public static IReadOnlyList<Tuple<string, string>> TertiaryTokens { get; } =
31+
[
3232
new("SemiColorTertiary", "Tertiary"),
3333
new("SemiColorTertiaryPointerover", "Tertiary Pointerover"),
3434
new("SemiColorTertiaryActive", "Tertiary Active"),
3535
new("SemiColorTertiaryLight", "Tertiary Light"),
3636
new("SemiColorTertiaryLightPointerover", "Tertiary Light Pointerover"),
37-
new("SemiColorTertiaryLightActive", "Tertiary Light Active"),
38-
};
37+
new("SemiColorTertiaryLightActive", "Tertiary Light Active")
38+
];
3939

40-
public static IReadOnlyList<Tuple<string, string>> InformationTokens { get; } = new List<Tuple<string, string>>
41-
{
40+
public static IReadOnlyList<Tuple<string, string>> InformationTokens { get; } =
41+
[
4242
new("SemiColorInformation", "Information"),
4343
new("SemiColorInformationPointerover", "Information Pointerover"),
4444
new("SemiColorInformationActive", "Information Active"),
4545
new("SemiColorInformationDisabled", "Information Disabled"),
4646
new("SemiColorInformationLight", "Information Light"),
4747
new("SemiColorInformationLightPointerover", "Information Light Pointerover"),
48-
new("SemiColorInformationLightActive", "Information Light Active"),
49-
};
48+
new("SemiColorInformationLightActive", "Information Light Active")
49+
];
5050

51-
public static IReadOnlyList<Tuple<string, string>> SuccessTokens { get; } = new List<Tuple<string, string>>
52-
{
51+
public static IReadOnlyList<Tuple<string, string>> SuccessTokens { get; } =
52+
[
5353
new("SemiColorSuccess", "Success"),
5454
new("SemiColorSuccessPointerover", "Success Pointerover"),
5555
new("SemiColorSuccessActive", "Success Active"),
5656
new("SemiColorSuccessDisabled", "Success Disabled"),
5757
new("SemiColorSuccessLight", "Success Light"),
5858
new("SemiColorSuccessLightPointerover", "Success Light Pointerover"),
59-
new("SemiColorSuccessLightActive", "Success Light Active"),
60-
};
59+
new("SemiColorSuccessLightActive", "Success Light Active")
60+
];
6161

62-
public static IReadOnlyList<Tuple<string, string>> WarningTokens { get; } = new List<Tuple<string, string>>
63-
{
62+
public static IReadOnlyList<Tuple<string, string>> WarningTokens { get; } =
63+
[
6464
new("SemiColorWarning", "Warning"),
6565
new("SemiColorWarningPointerover", "Warning Pointerover"),
6666
new("SemiColorWarningActive", "Warning Active"),
6767
new("SemiColorWarningLight", "Warning Light"),
6868
new("SemiColorWarningLightPointerover", "Warning Light Pointerover"),
69-
new("SemiColorWarningLightActive", "Warning Light Active"),
70-
};
69+
new("SemiColorWarningLightActive", "Warning Light Active")
70+
];
7171

72-
public static IReadOnlyList<Tuple<string, string>> DangerTokens { get; } = new List<Tuple<string, string>>
73-
{
72+
public static IReadOnlyList<Tuple<string, string>> DangerTokens { get; } =
73+
[
7474
new("SemiColorDanger", "Danger"),
7575
new("SemiColorDangerPointerover", "Danger Pointerover"),
7676
new("SemiColorDangerActive", "Danger Active"),
7777
new("SemiColorDangerLight", "Danger Light"),
7878
new("SemiColorDangerLightPointerover", "Danger Light Pointerover"),
79-
new("SemiColorDangerLightActive", "Danger Light Active"),
80-
};
79+
new("SemiColorDangerLightActive", "Danger Light Active")
80+
];
8181

82-
public static IReadOnlyList<Tuple<string, string>> TextTokens { get; } = new List<Tuple<string, string>>
83-
{
82+
public static IReadOnlyList<Tuple<string, string>> TextTokens { get; } =
83+
[
8484
new("SemiColorText0", "Text 0"),
8585
new("SemiColorText1", "Text 1"),
8686
new("SemiColorText2", "Text 2"),
87-
new("SemiColorText3", "Text 3"),
88-
};
87+
new("SemiColorText3", "Text 3")
88+
];
8989

90-
public static IReadOnlyList<Tuple<string, string>> LinkTokens { get; } = new List<Tuple<string, string>>
91-
{
90+
public static IReadOnlyList<Tuple<string, string>> LinkTokens { get; } =
91+
[
9292
new("SemiColorLink", "Link"),
9393
new("SemiColorLinkPointerover", "Link Pointerover"),
9494
new("SemiColorLinkActive", "Link Active"),
95-
new("SemiColorLinkVisited", "Link Visited"),
96-
};
95+
new("SemiColorLinkVisited", "Link Visited")
96+
];
9797

98-
public static IReadOnlyList<Tuple<string, string>> BackgroundTokens { get; } = new List<Tuple<string, string>>
99-
{
98+
public static IReadOnlyList<Tuple<string, string>> BackgroundTokens { get; } =
99+
[
100100
new("SemiColorBackground0", "Background 0"),
101101
new("SemiColorBackground1", "Background 1"),
102102
new("SemiColorBackground2", "Background 2"),
103103
new("SemiColorBackground3", "Background 3"),
104-
new("SemiColorBackground4", "Background 4"),
105-
};
104+
new("SemiColorBackground4", "Background 4")
105+
];
106106

107-
public static IReadOnlyList<Tuple<string, string>> FillTokens { get; } = new List<Tuple<string, string>>
108-
{
107+
public static IReadOnlyList<Tuple<string, string>> FillTokens { get; } =
108+
[
109109
new("SemiColorFill0", "Fill 0"),
110110
new("SemiColorFill1", "Fill 1"),
111-
new("SemiColorFill2", "Fill 2"),
112-
};
111+
new("SemiColorFill2", "Fill 2")
112+
];
113113

114-
public static IReadOnlyList<Tuple<string, string>> BorderTokens { get; } = new List<Tuple<string, string>>
115-
{
114+
public static IReadOnlyList<Tuple<string, string>> BorderTokens { get; } =
115+
[
116116
new("SemiColorBorder", "Border"),
117-
new("SemiColorFocusBorder", "Focus Border"),
118-
};
117+
new("SemiColorFocusBorder", "Focus Border")
118+
];
119119

120-
public static IReadOnlyList<Tuple<string, string>> DisabledTokens { get; } = new List<Tuple<string, string>>
121-
{
120+
public static IReadOnlyList<Tuple<string, string>> DisabledTokens { get; } =
121+
[
122122
new("SemiColorDisabledText", "Disabled Text"),
123123
new("SemiColorDisabledBorder", "Disabled Border"),
124124
new("SemiColorDisabledBackground", "Disabled Background"),
125-
new("SemiColorDisabledFill", "Disabled Fill"),
126-
};
125+
new("SemiColorDisabledFill", "Disabled Fill")
126+
];
127127

128-
public static IReadOnlyList<Tuple<string, string>> OtherTokens { get; } = new List<Tuple<string, string>>
129-
{
128+
public static IReadOnlyList<Tuple<string, string>> OtherTokens { get; } =
129+
[
130130
new("SemiColorWhite", "White"),
131131
new("SemiColorBlack", "Black"),
132132
new("SemiColorNavBackground", "Navigation Background"),
133133
new("SemiColorOverlayBackground", "Overlay Background"),
134134
new("SemiColorHighlightBackground", "Highlight Background"),
135-
new("SemiColorHighlight", "Highlight Text"),
136-
};
135+
new("SemiColorHighlight", "Highlight Text")
136+
];
137137

138-
public static IReadOnlyList<Tuple<string, string>> ShadowTokens { get; } = new List<Tuple<string, string>>
139-
{
138+
public static IReadOnlyList<Tuple<string, string>> ShadowTokens { get; } =
139+
[
140140
new("SemiColorShadow", "Shadow"),
141-
new("SemiShadowElevated", "Shadow Elevated"),
142-
};
141+
new("SemiShadowElevated", "Shadow Elevated")
142+
];
143143
}

demo/Semi.Avalonia.Demo/Pages/AboutUs.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:iri="https://irihi.tech/shared"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages"
10-
x:DataType="pages:AboutUsViewModel"
9+
xmlns:vm="clr-namespace:Semi.Avalonia.Demo.ViewModels"
10+
x:DataType="vm:AboutUsViewModel"
1111
x:CompileBindings="True"
1212
d:DesignHeight="450"
1313
d:DesignWidth="800"
Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Threading.Tasks;
4-
using System.Windows.Input;
5-
using Avalonia;
61
using Avalonia.Controls;
72
using Avalonia.Interactivity;
8-
using Avalonia.Markup.Xaml;
9-
using Avalonia.Platform.Storage;
10-
using CommunityToolkit.Mvvm.ComponentModel;
11-
using CommunityToolkit.Mvvm.Input;
3+
using Semi.Avalonia.Demo.ViewModels;
124

135
namespace Semi.Avalonia.Demo.Pages;
146

@@ -29,32 +21,4 @@ protected override void OnLoaded(RoutedEventArgs e)
2921
vm.Launcher = launcher;
3022
}
3123
}
32-
}
33-
34-
public partial class AboutUsViewModel: ObservableObject
35-
{
36-
public ICommand NavigateCommand { get; set; }
37-
38-
internal ILauncher? Launcher { get; set; }
39-
40-
public AboutUsViewModel()
41-
{
42-
NavigateCommand = new AsyncRelayCommand<string>(OnNavigateAsync);
43-
}
44-
45-
private static readonly IReadOnlyDictionary<string, string> _keyToUrlMapping = new Dictionary<string, string>()
46-
{
47-
["semi"] = "https://github.com/irihitech/Semi.Avalonia",
48-
["ursa"] = "https://github.com/irihitech/Ursa.Avalonia",
49-
["mantra"] = "https://www.bilibili.com/video/BV15pfKYbEEQ",
50-
};
51-
52-
private async Task OnNavigateAsync(string? arg)
53-
{
54-
if (Launcher is not null && arg is not null && _keyToUrlMapping.TryGetValue(arg.ToLower(), out var uri))
55-
{
56-
await Launcher.LaunchUriAsync(new Uri(uri));
57-
}
58-
59-
}
6024
}

demo/Semi.Avalonia.Demo/Pages/AutoCompleteBoxDemo.axaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
xmlns="https://github.com/avaloniaui"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:Semi.Avalonia.Demo.Pages"
76
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:vm="clr-namespace:Semi.Avalonia.Demo.ViewModels"
88
d:DesignHeight="450"
99
d:DesignWidth="800"
1010
x:CompileBindings="False"
11-
x:DataType="local:AutoCompleteBoxDemoViewModel"
11+
x:DataType="vm:AutoCompleteBoxDemoViewModel"
1212
mc:Ignorable="d">
1313
<Design.DataContext>
14-
<local:AutoCompleteBoxDemoViewModel />
14+
<vm:AutoCompleteBoxDemoViewModel />
1515
</Design.DataContext>
1616
<StackPanel HorizontalAlignment="Left" Spacing="20">
1717
<StackPanel.Styles>
@@ -21,7 +21,7 @@
2121
<Binding Path="States" />
2222
</Setter>
2323
<Setter Property="ItemTemplate">
24-
<DataTemplate DataType="local:StateData">
24+
<DataTemplate DataType="vm:StateData">
2525
<TextBlock Text="{Binding Name}" />
2626
</DataTemplate>
2727
</Setter>
Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System.Collections.ObjectModel;
2-
using Avalonia;
31
using Avalonia.Controls;
4-
using Avalonia.Markup.Xaml;
5-
using System.Collections.Generic;
6-
using CommunityToolkit.Mvvm.ComponentModel;
2+
using Semi.Avalonia.Demo.ViewModels;
73

84
namespace Semi.Avalonia.Demo.Pages;
95

@@ -14,86 +10,4 @@ public AutoCompleteBoxDemo()
1410
InitializeComponent();
1511
this.DataContext = new AutoCompleteBoxDemoViewModel();
1612
}
17-
}
18-
19-
public class AutoCompleteBoxDemoViewModel: ObservableObject
20-
{
21-
public ObservableCollection<StateData> States { get; set; }
22-
23-
public AutoCompleteBoxDemoViewModel()
24-
{
25-
States = new ObservableCollection<StateData>(GetStates());
26-
27-
}
28-
29-
private static List<StateData> GetStates()
30-
{
31-
return new List<StateData>
32-
{
33-
new StateData("Alabama", "AL", "Montgomery"),
34-
new StateData("Alaska", "AK", "Juneau"),
35-
new StateData("Arizona", "AZ", "Phoenix"),
36-
new StateData("Arkansas", "AR", "Little Rock"),
37-
new StateData("California", "CA", "Sacramento"),
38-
new StateData("Colorado", "CO", "Denver"),
39-
new StateData("Connecticut", "CT", "Hartford"),
40-
new StateData("Delaware", "DE", "Dover"),
41-
new StateData("Florida", "FL", "Tallahassee"),
42-
new StateData("Georgia", "GA", "Atlanta"),
43-
new StateData("Hawaii", "HI", "Honolulu"),
44-
new StateData("Idaho", "ID", "Boise"),
45-
new StateData("Illinois", "IL", "Springfield"),
46-
new StateData("Indiana", "IN", "Indianapolis"),
47-
new StateData("Iowa", "IA", "Des Moines"),
48-
new StateData("Kansas", "KS", "Topeka"),
49-
new StateData("Kentucky", "KY", "Frankfort"),
50-
new StateData("Louisiana", "LA", "Baton Rouge"),
51-
new StateData("Maine", "ME", "Augusta"),
52-
new StateData("Maryland", "MD", "Annapolis"),
53-
new StateData("Massachusetts", "MA", "Boston"),
54-
new StateData("Michigan", "MI", "Lansing"),
55-
new StateData("Minnesota", "MN", "St. Paul"),
56-
new StateData("Mississippi", "MS", "Jackson"),
57-
new StateData("Missouri", "MO", "Jefferson City"),
58-
new StateData("Montana", "MT", "Helena"),
59-
new StateData("Nebraska", "NE", "Lincoln"),
60-
new StateData("Nevada", "NV", "Carson City"),
61-
new StateData("New Hampshire", "NH", "Concord"),
62-
new StateData("New Jersey", "NJ", "Trenton"),
63-
new StateData("New Mexico", "NM", "Santa Fe"),
64-
new StateData("New York", "NY", "Albany"),
65-
new StateData("North Carolina", "NC", "Raleigh"),
66-
new StateData("North Dakota", "ND", "Bismarck"),
67-
new StateData("Ohio", "OH", "Columbus"),
68-
new StateData("Oklahoma", "OK", "Oklahoma City"),
69-
new StateData("Oregon", "OR", "Salem"),
70-
new StateData("Pennsylvania", "PA", "Harrisburg"),
71-
new StateData("Rhode Island", "RI", "Providence"),
72-
new StateData("South Carolina", "SC", "Columbia"),
73-
new StateData("South Dakota", "SD", "Pierre"),
74-
new StateData("Tennessee", "TN", "Nashville"),
75-
new StateData("Texas", "TX", "Austin"),
76-
new StateData("Utah", "UT", "Salt Lake City"),
77-
new StateData("Vermont", "VT", "Montpelier"),
78-
new StateData("Virginia", "VA", "Richmond"),
79-
new StateData("Washington", "WA", "Olympia"),
80-
new StateData("West Virginia", "WV", "Charleston"),
81-
new StateData("Wisconsin", "WI", "Madison"),
82-
new StateData("Wyoming", "WY", "Cheyenne"),
83-
};
84-
}
85-
}
86-
87-
public class StateData
88-
{
89-
public string Name { get; private set; }
90-
public string Abbreviation { get; private set; }
91-
public string Capital { get; private set; }
92-
93-
public StateData(string name, string abbreviation, string capital)
94-
{
95-
Name = name;
96-
Abbreviation = abbreviation;
97-
Capital = capital;
98-
}
9913
}

demo/Semi.Avalonia.Demo/Pages/BorderDemo.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
<TextBlock>Shadow on Pointerover</TextBlock>
1919
</Border>
2020
</StackPanel>
21-
</UserControl>
21+
</UserControl>

0 commit comments

Comments
 (0)