This file contains 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 partial class MainViewModel : PageViewModel | |
{ | |
private readonly IBlueskyService _blueskyService; | |
public MainViewModel(INavigationService navigationService, IBlueskyService blueskyService) : base(navigationService) | |
{ | |
_blueskyService = blueskyService; | |
} | |
[ObservableProperty] |
This file contains 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
<Grid> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="*" /> | |
<RowDefinition Height="Auto" /> | |
</Grid.RowDefinitions> | |
<ListView SelectionMode="None" ItemsSource="{x:Bind ViewModel.Feed, Mode=OneWay}"> | |
<ListView.ItemTemplate> | |
<DataTemplate x:DataType="vm:FeedItemViewModel"> | |
<StackPanel CornerRadius="8" Margin="8,4,8,4" Padding="8" Spacing="8" Background="{ThemeResource ButtonBackground}"> | |
<TextBlock Text="{x:Bind Text}" TextWrapping="WrapWholeWords" /> |
This file contains 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 Birdsky.Core.Services.Bluesky; | |
using Birdsky.Services.Navigation; | |
using CommunityToolkit.Mvvm.ComponentModel; | |
using CommunityToolkit.Mvvm.Input; | |
using MZikmund.Toolkit.WinUI.Infrastructure; | |
namespace Birdsky.Core.ViewModels; | |
public partial class LoginViewModel : PageViewModel | |
{ |
This file contains 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 void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | |
{ | |
ViewModel!.AppPassword = ((PasswordBox)sender).Password; | |
} |
This file contains 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
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="10"> | |
<TextBox Header="Handle" Text="{Binding Handle, Mode=TwoWay}" Width="300" /> | |
<PasswordBox Header="App Password" Width="300" PasswordChanged="PasswordBox_PasswordChanged" /> | |
<Button Content="Login" Command="{Binding LoginCommand}" Width="300" /> | |
</StackPanel> |
This file contains 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 class CredentialsService : ICredentialsService | |
{ | |
private const string AppName = "MyBlueskyClient"; | |
private readonly PasswordVault _passwordVault; | |
private readonly ApplicationDataContainer _localSettings = ApplicationData.Current.LocalSettings; | |
public CredentialsService() | |
{ | |
if (ApiInformation.IsMethodPresent(typeof(PasswordCredential).FullName, "Retrieve")) |
This file contains 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 class BlueskyService : IBlueskyService | |
{ | |
private readonly ICredentialsService _credentialsService; | |
private ATProtocol _client; | |
private Session? _session; | |
public BlueskyService(ICredentialsService credentialsService) | |
{ | |
_client = new ATProtocolBuilder().EnableAutoRenewSession(true).Build(); | |
_credentialsService = credentialsService; |
This file contains 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
await _blueskyService.PostAsync(Text); |
This file contains 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 record class FeedItemViewModel(string Author, string Text, long Likes, long Reposts, long Replies); | |
var items = timelineData.Feed | |
.Select(f => f.Post) | |
.Where(p => p is not null) | |
.Select(post => new FeedItemViewModel( | |
post!.Author?.DisplayName ?? "", | |
(post.Record as Post)?.Text ?? "", | |
post.LikeCount ?? 0, | |
post.RepostCount ?? 0, |
This file contains 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
var timeline = await client.GetTimelineAsync(); | |
if (timeline?.AsT0 is { Feed: { } } timelineData) | |
{ | |
var posts = timelineData.Feed; | |
// ... | |
} |
NewerOlder