Skip to content

Commit 5261585

Browse files
committed
grrrr
1 parent d76e2f1 commit 5261585

File tree

5 files changed

+115
-93
lines changed

5 files changed

+115
-93
lines changed

docs/.vitepress/theme/custom.css

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
:root {
2-
--vp-home-hero-name-color: #fa5c15;
3-
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #fa5c15, rgb(251, 70, 202));
4-
--vp-font-family-mono: ui-monospace, 'SF Mono SC', SFMono-Regular, 'SF Mono', 'Cascadia Code', Menlo, 'JetBrains Mono', Monaco,
5-
Consolas, 'Liberation Mono', 'Courier New', monospace;
6-
--vp-font-family-base: 'Chinese Quotes', 'Inter var', 'Inter', ui-sans-serif,
7-
system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
8-
'Helvetica Neue', Helvetica, Arial, 'Noto Sans', sans-serif,
9-
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
10-
--vp-c-brand-1: #2cbc23;
11-
--vp-c-indigo-2: #fa5c15;
2+
--vp-home-hero-name-color: #fa5c15;
3+
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #fa5c15, rgb(251, 70, 202));
4+
--vp-font-family-mono: 'Noto Mono', 'SF Mono SC', 'SF Mono', 'Cascadia Code', Menlo, 'JetBrains Mono', Monaco,
5+
Consolas, 'Liberation Mono', 'Courier New', ui-monospace, monospace;
6+
--vp-font-family-base: 'Chinese Quotes', 'Inter var', 'Inter', ui-sans-serif,
7+
system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
8+
'Helvetica Neue', Helvetica, Arial, 'Noto Sans', sans-serif,
9+
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
10+
--vp-c-brand-1: #2cbc23;
11+
--vp-c-indigo-2: #fa5c15;
1212
}
1313

1414
.dark {
15-
--vp-code-block-bg: #282c34;
16-
--vp-c-bg: #21252b;
17-
--vp-c-bg-alt: #282c34;
18-
--vp-c-bg-elv: #282c34;
19-
--vp-c-bg-soft: #282c34;
20-
/* inline code color */
21-
--vp-code-color: #2dbc24;
15+
--vp-code-block-bg: #282c34;
16+
--vp-c-bg: #21252b;
17+
--vp-c-bg-alt: #282c34;
18+
--vp-c-bg-elv: #282c34;
19+
--vp-c-bg-soft: #282c34;
20+
/* inline code color */
21+
--vp-code-color: #2dbc24;
2222
}
2323

2424
/* bold for second level sidebar-item */
2525
#VPSidebarNav h3 {
26-
font-weight: bold;
26+
font-weight: bold;
2727
}
2828

2929
.VPImage {
30-
border-radius: 20%;
30+
border-radius: 20%;
3131
}
3232

3333
/* #region impl blur bav-bar */
3434
:root {
35-
--nav-c-bg: rgba(255, 255, 255, 0.5);
35+
--nav-c-bg: rgba(255, 255, 255, 0.5);
3636
}
3737

3838
.dark {
39-
--nav-c-bg: rgba(30, 30, 32, 0.5);
39+
--nav-c-bg: rgba(30, 30, 32, 0.5);
4040
}
4141

4242
.curtain {
43-
display: none !important;
43+
display: none !important;
4444
}
4545

4646
.fill {
47-
background: transparent !important;
47+
background: transparent !important;
4848
}
4949

5050
.content-body {
51-
background: var(--nav-c-bg) !important;
51+
background: var(--nav-c-bg) !important;
5252
}
5353

5454
.content-body::after {
55-
content: "";
56-
position: absolute;
57-
top: 0;
58-
left: 0;
59-
right: 0;
60-
bottom: 0;
61-
backdrop-filter: saturate(180%) blur(5px);
62-
z-index: -1;
55+
content: "";
56+
position: absolute;
57+
top: 0;
58+
left: 0;
59+
right: 0;
60+
bottom: 0;
61+
backdrop-filter: saturate(180%) blur(5px);
62+
z-index: -1;
6363
}
6464

65-
/* #endregion */
65+
/* #endregion */

docs/document/Articles/docs/Language Thoughts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ It should offer benefits:
9090
```ts
9191
let foo = 360deg
9292
let bar = 6.28rad // for literal
93-
let baz = Math.PI<rad> // for non literal, or (Math.PI)rad ? What if we need a tuple in future? violates generic property?
93+
let baz = Math.PI<rad> // for non literal, or (Math.PI)rad ? What if we need a tuple in future? this also conflicts with generic property?
9494
let a = 2 * 3deg // evaluates to (2 * 3)deg, unit type as target type always
9595
let b = 1 - 2deg // error: only scalars can be applied, should do (1 - 2)deg instead
9696
let f = (): <rad> => 1rad // bracketed annotation for differ from normal types

docs/document/Avalonia/docs/Beginner/1. Project basics/1. Project Structure.md renamed to docs/document/Avalonia/docs/Beginner/1. Fundamentals/1. How Avalonia Loads.md

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# Project Structure
1+
# How Avalonia Loads
2+
3+
- `Programs.cs`: Entry point of the app, uses a `Avaloni.Application` type to build up the program.
4+
- `App.axaml`: Stores global themes, resources, styles.
5+
- `App.axaml.cs`: Contains a class inherited from `Avalonia.Application` used as loader.
6+
- `MainWindow.axaml.cs`: Contains a class inherited from `Avalonia.Controls.Window`, used as a source for `App`
7+
- `MainWindow.axaml`: The view of `MainWindow`
8+
- `MainWindowViewModel.cs`: Represents the data context of the main window.
29

310
## Entry Point - `Program.cs`
411

@@ -21,76 +28,47 @@ class Program
2128
.StartWithClassicDesktopLifetime(args);
2229

2330
// Avalonia configuration, don't remove; also used by visual designer.
24-
// !!! Register configuration from some dependencies here as extension methods
2531
public static AppBuilder BuildAvaloniaApp()
26-
=> AppBuilder.Configure<App>()
32+
=> AppBuilder.Configure<App>() // `App` is child of `Application`// [!code highlight]
2733
.UsePlatformDetect()
2834
.WithInterFont()
2935
.LogToTrace()
3036
.UseReactiveUI();
3137
}
3238
```
3339

34-
## ViewLocator
35-
36-
The term "locator" in "ViewLocator" refers to the role of the class in **"locating" or finding the appropriate View for a given ViewModel**. In other words, it helps the application determine which View should be used to display the data and operations defined in a ViewModel.
37-
38-
Once the `Match` method has determined the correct View type, this type is passed to the `Build` method, which is responsible for creating an instance of the View.
39-
40-
```cs
41-
using System;
42-
using Avalonia.Controls;
43-
using Avalonia.Controls.Templates;
44-
using AvaloniaApplication.ViewModels;
40+
## `App.axaml`
4541

46-
namespace AvaloniaApplication;
47-
48-
public class ViewLocator : IDataTemplate
49-
{
50-
public Control Build(object data)
51-
{
52-
// Rule for matching View for a ViewModel.
53-
var name = data.GetType().FullName!.Replace("ViewModel", "View");
54-
var type = Type.GetType(name);
55-
// Then create an instance of the View.
56-
if (type is { })
57-
{
58-
return (Control)Activator.CreateInstance(type)!;
59-
}
60-
// Else return a control with warning.
61-
return new TextBlock { Text = "Not Found: " + name };
62-
}
63-
64-
public bool Match(object data)
65-
{
66-
// Matching rules can be more complex...
67-
return data is ViewModelBase;
68-
}
69-
}
70-
```
71-
72-
## App.axaml
73-
74-
:::code-group
42+
`App.axaml` is for configuring styles, themes, data templates and resources **globally**.
7543

7644
```xml
7745
<Application xmlns="https://github.com/avaloniaui"
7846
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
7947
x:Class="AvaloniaApplication.App"
8048
xmlns:local="using:AvaloniaApplication"
81-
RequestedThemeVariant="Default">
49+
RequestedThemeVariant="Default"> <!-- config you theme variant here --> <!-- [!code highlight] -->
8250
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
8351

84-
<Application.DataTemplates>
85-
<local:ViewLocator/>
86-
</Application.DataTemplates>
52+
<Application.DataTemplates> <!-- [!code highlight] -->
53+
<local:ViewLocator/> <!-- [!code highlight] -->
54+
</Application.DataTemplates> <!-- [!code highlight] -->
8755

88-
<Application.Styles>
89-
<FluentTheme />
90-
</Application.Styles>
56+
<Application.Styles> <!-- import styles here --> <!-- [!code highlight] -->
57+
<FluentTheme /> <!-- [!code highlight] -->
58+
</Application.Styles> <!-- [!code highlight] -->
59+
60+
<Application.Resources> <!-- [!code highlight] -->
61+
<SolidColorBrush x:Key="BrightBlueBrush">#7f98c7</SolidColorBrush> <!-- [!code highlight] -->
62+
<SolidColorBrush x:Key="BrightBlueWhenHoverBrush">#98acd0</SolidColorBrush> <!-- [!code highlight] -->
63+
</Application.Resources> <!-- [!code highlight] -->
64+
9165
</Application>
9266
```
9367

68+
The `App.axaml.cs` is the code behind the `App.axaml`.
69+
- Initialize the app
70+
- Loads the `MainWindow`
71+
9472
```cs
9573
using Avalonia;
9674
using Avalonia.Controls.ApplicationLifetimes;
@@ -104,30 +82,25 @@ public partial class App : Application
10482
{
10583
public override void Initialize()
10684
{
107-
AvaloniaXamlLoader.Load(this);
85+
AvaloniaXamlLoader.Load(this); // attach the component from xaml to this `App` // [!code highlight]
10886
}
10987

11088
public override void OnFrameworkInitializationCompleted()
11189
{
11290
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
11391
{
114-
desktop.MainWindow = new MainWindow
92+
desktop.MainWindow = new MainWindow // [!code highlight]
11593
{
116-
DataContext = new MainWindowViewModel(),
94+
DataContext = new MainWindowViewModel(), // [!code highlight]
11795
};
11896
}
119-
12097
base.OnFrameworkInitializationCompleted();
12198
}
12299
}
123100
```
124101

125-
:::
126-
127102
## Main Window
128103

129-
:::code-group
130-
131104
```xml
132105
<Window xmlns="https://github.com/avaloniaui"
133106
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -152,4 +125,41 @@ public partial class App : Application
152125

153126
```
154127

155-
:::
128+
## ViewLocator
129+
130+
The term "locator" in "ViewLocator" refers to the role of the class in **locating or finding the appropriate View for a given ViewModel**.
131+
In other words, it helps the application determine which View should be used to display the data and operations defined in a ViewModel.
132+
133+
Once the `Match` method has determined the correct View type, this type is passed to the `Build` method, which is responsible for creating an instance of the View.
134+
135+
```cs
136+
using System;
137+
using Avalonia.Controls;
138+
using Avalonia.Controls.Templates;
139+
using AvaloniaApplication.ViewModels;
140+
141+
namespace AvaloniaApplication;
142+
143+
public class ViewLocator : IDataTemplate
144+
{
145+
public Control Build(object data)
146+
{
147+
// Rule for matching View for a ViewModel.
148+
var name = data.GetType().FullName!.Replace("ViewModel", "View"); // [!code highlight]
149+
var type = Type.GetType(name); // [!code highlight]
150+
// Then create an instance of the View.
151+
if (type is not null)
152+
{
153+
return (Control)Activator.CreateInstance(type)!;
154+
}
155+
// Else return a control with warning. // [!code highlight]
156+
return new TextBlock { Text = "Not Found: " + name }; // [!code highlight]
157+
}
158+
159+
public bool Match(object data)
160+
{
161+
// Matching rules can be more complex...
162+
return data is ViewModelBase;
163+
}
164+
}
165+
```

docs/document/Avalonia/docs/Beginner/1. Project basics/2. Xml namespace.md renamed to docs/document/Avalonia/docs/Beginner/1. Fundamentals/2. Xml namespace.md

File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
3+
```mmd
4+
graph TD;
5+
A[View] -->|binds to| B[ViewModel]
6+
B -->|notifies| A
7+
B -->|interacts with| C[Model]
8+
C -->|updates| B
9+
A -->|displays data from| C
10+
```
11+
12+
##

0 commit comments

Comments
 (0)