This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your Maui app's login service | |
public async Task<bool> LoginAsync(string username) | |
{ | |
// 1. Request a challenge from the server for this user | |
string challenge = await _apiService.GetLoginChallengeAsync(username); | |
// 2. Load the user's private key from secure storage | |
string privateKeyBase64 = await SecureStorage.GetAsync("user_privateKey"); | |
byte[] privateKeyBytes = Convert.FromBase64String(privateKeyBase64); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your ASP.NET Core API Controller | |
[HttpPost("register")] | |
public async Task<IActionResult> Register([FromBody] UserRegistrationRequest request) | |
{ | |
// In a real app, add validation, check for existing user, etc. | |
var newUser = new User | |
{ | |
Username = request.Username, | |
// Store the user's public key for future verification | |
PublicKey = request.PublicKeyBase64, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void OnRegisterButtonClicked(string username) | |
{ | |
// Create a new key pair using the Ed25519 signature algorithm | |
var algorithm = SignatureAlgorithm.Ed25519; | |
var creationParameters = new KeyCreationParameters | |
{ | |
ExportPolicy = KeyExportPolicies.AllowPlaintextArchiving | |
}; | |
// This is the user's SECRET. Store this securely! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyMauiAiApp/ | |
├── Services/ | |
│ ├── IAIService.cs | |
│ └── OpenAIService.cs | |
├── Utilities/ | |
│ └── JsonToXamlConverter.cs | |
├── Models/ | |
│ └── UISchema.cs | |
├── Views/ | |
│ └── MainPage.xaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void OnGenerateClicked(object sender, EventArgs e) | |
{ | |
try | |
{ | |
// 1. Get the user's prompt | |
string userDescription = PromptEditor.Text; | |
if (string.IsNullOrWhiteSpace(userDescription)) | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ScrollView> | |
<VerticalStackLayout Spacing="20" Padding="20"> | |
<Label Text="AI UI Generator" FontSize="Title" HorizontalOptions="Center" /> | |
<Editor x:Name="PromptEditor" | |
HeightRequest="150" | |
Placeholder="Describe your interface... E.g., 'A login page with a logo, two entries, and a blue button'" /> | |
<Button Text="Generate XAML" Clicked="OnGenerateClicked" /> | |
<Editor x:Name="XamlOutput" | |
HeightRequest="300" | |
IsReadOnly="True" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
using System.Text; | |
public static class JsonToXamlConverter | |
{ | |
public static string Convert(string jsonInput) | |
{ | |
try | |
{ | |
// 1. Deserialize JSON into strongly-typed C# classes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IAIService | |
{ | |
Task<string> GenerateUIJsonAsync(string userPrompt); | |
} | |
public class OpenAIService : IAIService | |
{ | |
private readonly OpenAIClient _client; | |
private const string _model = "gpt-4o"; // or "gpt-3.5-turbo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In MauiProgram.cs or a Service Factory | |
services.AddSingleton<IAIService>(new OpenAIService("your-openai-api-key")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You are an assistant specialized in generating user interface schemas for .NET MAUI in JSON format. | |
The user will describe a screen, and you must generate a valid JSON object that represents it. | |
**Rules:** | |
1. **Respond only with the raw JSON object, no commentary, markdown, or extra text.** | |
2. **JSON Structure:** | |
- Use the schema provided below. | |
- Control types must be valid .NET MAUI types (e.g., 'VerticalStackLayout', 'Button', 'Label'). | |
- All property values must be strings. |