diff --git a/controlgallery/AtomUIGallery/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.LanguageGenerator/LanguageResourceConst.g.cs b/controlgallery/AtomUIGallery/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.LanguageGenerator/LanguageResourceConst.g.cs index 1d9dbff20..7f400e1b6 100644 --- a/controlgallery/AtomUIGallery/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.LanguageGenerator/LanguageResourceConst.g.cs +++ b/controlgallery/AtomUIGallery/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.LanguageGenerator/LanguageResourceConst.g.cs @@ -2049,6 +2049,10 @@ namespace AtomUIGallery.Localization PrefixAndSuffixTitle, PrePostTabDescription, PrePostTabTitle, + ScenarioBasic, + ScenarioSearch, + ScenarioState, + ScenarioTextArea, SearchBoxDescription, SearchBoxTitle, SearchBoxWithLoadingDescription, diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/en_US.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/en_US.cs index 09481f9b2..228036f16 100644 --- a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/en_US.cs +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/en_US.cs @@ -6,6 +6,11 @@ namespace AtomUIGallery.ShowCases.LineEdit; [LanguageProvider(LanguageCode.en_US, LineEditShowCase.LanguageId)] internal class en_US : LanguageProvider { + public const string ScenarioBasic = "Basic"; + public const string ScenarioState = "State"; + public const string ScenarioSearch = "Search"; + public const string ScenarioTextArea = "TextArea"; + public const string BasicUsageTitle = "Basic usage"; public const string BasicUsageDescription = "Basic usage example."; public const string InputSizesTitle = "Three sizes of Input"; diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/zh_CN.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/zh_CN.cs index f2518fd5b..246d2fde2 100644 --- a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/zh_CN.cs +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Localization/zh_CN.cs @@ -6,6 +6,11 @@ namespace AtomUIGallery.ShowCases.LineEdit; [LanguageProvider(LanguageCode.zh_CN, LineEditShowCase.LanguageId)] internal class zh_CN : LanguageProvider { + public const string ScenarioBasic = "基础"; + public const string ScenarioState = "状态"; + public const string ScenarioSearch = "搜索"; + public const string ScenarioTextArea = "文本域"; + public const string BasicUsageTitle = "基础用法"; public const string BasicUsageDescription = "基础用法示例。"; public const string InputSizesTitle = "输入框三种尺寸"; diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditBasicShowCase.axaml b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditBasicShowCase.axaml new file mode 100644 index 000000000..0b03e9fc4 --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditBasicShowCase.axaml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditBasicShowCase.axaml.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditBasicShowCase.axaml.cs new file mode 100644 index 000000000..3e5564659 --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditBasicShowCase.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace AtomUIGallery.ShowCases.LineEdit; + +public partial class LineEditBasicShowCase : ReactiveUserControl +{ + public LineEditBasicShowCase() + { + InitializeComponent(); + } +} diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditSearchShowCase.axaml b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditSearchShowCase.axaml new file mode 100644 index 000000000..333b7daab --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditSearchShowCase.axaml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditSearchShowCase.axaml.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditSearchShowCase.axaml.cs new file mode 100644 index 000000000..fa76ef586 --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditSearchShowCase.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace AtomUIGallery.ShowCases.LineEdit; + +public partial class LineEditSearchShowCase : ReactiveUserControl +{ + public LineEditSearchShowCase() + { + InitializeComponent(); + } +} diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml index dd83734b3..dc1a2e11c 100644 --- a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml @@ -3,365 +3,14 @@ x:Class="AtomUIGallery.ShowCases.LineEdit.LineEditShowCase" xmlns:vm="using:AtomUIGallery.ShowCases.LineEdit" xmlns:atom="https://atomui.net" - xmlns:antdicons="https://atomui.net/icons/antdesign" xmlns:gallery="https://atomui.net/oss-controls/gallery" x:DataType="vm:LineEditViewModel"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml.cs index 33fb6d032..87686e0ae 100644 --- a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml.cs +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditShowCase.axaml.cs @@ -1,4 +1,4 @@ -using ReactiveUI; +using Avalonia.Controls; using ReactiveUI.Avalonia; namespace AtomUIGallery.ShowCases.LineEdit; @@ -7,9 +7,64 @@ public partial class LineEditShowCase : ReactiveUserControl { public const string LanguageId = nameof(LineEditShowCase); + private const string BasicScenario = "Basic"; + private const string StateScenario = "State"; + private const string SearchScenario = "Search"; + private const string TextAreaScenario = "TextArea"; + + private readonly Dictionary _scenarioCache = new(StringComparer.Ordinal); + public LineEditShowCase() { - this.WhenActivated(disposables => { }); InitializeComponent(); + ScenarioTabs.SelectionChanged += HandleScenarioSelectionChanged; + EnsureSelectedScenarioContent(); + } + + protected override void OnDataContextChanged(EventArgs e) + { + base.OnDataContextChanged(e); + foreach (var content in _scenarioCache.Values) + { + content.DataContext = DataContext; + } + } + + private void HandleScenarioSelectionChanged(object? sender, SelectionChangedEventArgs args) + { + EnsureSelectedScenarioContent(); + } + + private void EnsureSelectedScenarioContent() + { + if (ScenarioTabs.SelectedItem is not AtomUI.Desktop.Controls.TabItem tabItem || + tabItem.Tag is not string scenario) + { + return; + } + + if (!_scenarioCache.TryGetValue(scenario, out var content)) + { + content = CreateScenarioContent(scenario); + content.DataContext = DataContext; + _scenarioCache.Add(scenario, content); + } + + if (tabItem.Content != content) + { + tabItem.Content = content; + } + } + + private static Control CreateScenarioContent(string scenario) + { + return scenario switch + { + BasicScenario => new LineEditBasicShowCase(), + StateScenario => new LineEditStateShowCase(), + SearchScenario => new LineEditSearchShowCase(), + TextAreaScenario => new LineEditTextAreaShowCase(), + _ => throw new InvalidOperationException($"Unknown LineEdit scenario: {scenario}") + }; } } diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditStateShowCase.axaml b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditStateShowCase.axaml new file mode 100644 index 000000000..1b2829acd --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditStateShowCase.axaml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditStateShowCase.axaml.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditStateShowCase.axaml.cs new file mode 100644 index 000000000..c28db81ac --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditStateShowCase.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace AtomUIGallery.ShowCases.LineEdit; + +public partial class LineEditStateShowCase : ReactiveUserControl +{ + public LineEditStateShowCase() + { + InitializeComponent(); + } +} diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditTextAreaShowCase.axaml b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditTextAreaShowCase.axaml new file mode 100644 index 000000000..5b0ee3ab2 --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditTextAreaShowCase.axaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditTextAreaShowCase.axaml.cs b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditTextAreaShowCase.axaml.cs new file mode 100644 index 000000000..656e2f937 --- /dev/null +++ b/controlgallery/AtomUIGallery/ShowCases/DataEntry/LineEdit/Views/LineEditTextAreaShowCase.axaml.cs @@ -0,0 +1,11 @@ +using ReactiveUI.Avalonia; + +namespace AtomUIGallery.ShowCases.LineEdit; + +public partial class LineEditTextAreaShowCase : ReactiveUserControl +{ + public LineEditTextAreaShowCase() + { + InitializeComponent(); + } +}