diff --git a/KoeBook.Core/Contracts/Services/IStoryCreatorService.cs b/KoeBook.Core/Contracts/Services/IStoryCreatorService.cs new file mode 100644 index 0000000..e032f7e --- /dev/null +++ b/KoeBook.Core/Contracts/Services/IStoryCreatorService.cs @@ -0,0 +1,8 @@ +using KoeBook.Core.Models; + +namespace KoeBook.Core.Contracts.Services; + +public interface IStoryCreaterService +{ + public ValueTask CreateStoryAsync(StoryGenre genre, string intruction, CancellationToken cancellationToken); +} diff --git a/KoeBook.Core/Models/StoryGenre.cs b/KoeBook.Core/Models/StoryGenre.cs new file mode 100644 index 0000000..c6e4513 --- /dev/null +++ b/KoeBook.Core/Models/StoryGenre.cs @@ -0,0 +1,4 @@ +namespace KoeBook.Core.Models; + +public record class StoryGenre(string Genre, string Description); + diff --git a/KoeBook/App.xaml.cs b/KoeBook/App.xaml.cs index bbb16cc..077511c 100644 --- a/KoeBook/App.xaml.cs +++ b/KoeBook/App.xaml.cs @@ -93,6 +93,8 @@ public App() services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); // Configuration services.Configure(context.Configuration.GetSection(nameof(LocalSettingsOptions))); diff --git a/KoeBook/KoeBook.csproj b/KoeBook/KoeBook.csproj index a83ccf0..b7b7f96 100644 --- a/KoeBook/KoeBook.csproj +++ b/KoeBook/KoeBook.csproj @@ -18,6 +18,7 @@ + @@ -28,6 +29,7 @@ + @@ -68,4 +70,12 @@ true + + + + + + + + diff --git a/KoeBook/ViewModels/CreateStoryViewModel.cs b/KoeBook/ViewModels/CreateStoryViewModel.cs new file mode 100644 index 0000000..de9d68f --- /dev/null +++ b/KoeBook/ViewModels/CreateStoryViewModel.cs @@ -0,0 +1,67 @@ +using System.Collections.Immutable; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using KoeBook.Core.Contracts.Services; +using KoeBook.Core.Models; +using KoeBook.Services; + +namespace KoeBook.ViewModels; + +public sealed partial class CreateStoryViewModel : ObservableObject +{ + private readonly IStoryCreaterService _storyCreaterService; + private readonly GenerationTaskRunnerService _generationTaskRunnerService; + + public ImmutableArray Genres { get; } = [ + new("青春小説", "学校生活、友情、恋愛など、若者の成長物語"), + new("ミステリー・サスペンス", "謎解きや犯罪、真相究明などのスリリングな物語"), + new("SF", "未来、科学技術、宇宙などを題材にした物語"), + new("ホラー", "恐怖や怪奇現象を扱った、読者の恐怖心をくすぐる物語"), + new("ロマンス", "恋愛や結婚、人間関係などを扱った、胸キュンな物語"), + new("コメディ", "ユーモアやギャグ、風刺などを交えた、読者を笑わせる物語"), + new("歴史小説", "過去の出来事や人物を題材にした、歴史の背景が感じられる物語"), + new("ノンフィクション・エッセイ", "実際の経験や知識、考えを綴った、リアルな物語"), + new("詩集", "感情や思考、風景などを言葉で表現した、韻文形式の作品集"), + ]; + + [ObservableProperty] + private StoryGenre _selectedGenre; + + [ObservableProperty] + private string _intruction = ""; + + [ObservableProperty] + private string _storyText = """ + # h1 + ## h2 + ### h3 + + 1. aaa + 2. bbb + 3. ccc + + --- + """; + + public CreateStoryViewModel(GenerationTaskRunnerService generationTaskRunnerService) + { + _selectedGenre = Genres[0]; + _generationTaskRunnerService = generationTaskRunnerService; + //_storyCreaterService = storyCreaterService; + _storyCreaterService = null!; + } + + public bool CanCreateStory => !string.IsNullOrWhiteSpace(Intruction); + + [RelayCommand(CanExecute = nameof(CanCreateStory))] + private async Task OnCreateStoryAsync(CancellationToken cancellationToken) + { + StoryText = await _storyCreaterService.CreateStoryAsync(SelectedGenre, Intruction, cancellationToken); + } + + [RelayCommand] + private async void OnStartGenerateTask (CancellationToken cancellationToken) + { + } +} + diff --git a/KoeBook/Views/CreateStoryPage.xaml b/KoeBook/Views/CreateStoryPage.xaml new file mode 100644 index 0000000..17c8e66 --- /dev/null +++ b/KoeBook/Views/CreateStoryPage.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + +