64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using Microsoft.UI.Xaml.Controls;
|
|
using System;
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
namespace wakka
|
|
{
|
|
/// <summary>
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
/// </summary>
|
|
public sealed partial class FeelsNavigationPage : Page
|
|
{
|
|
public FeelsNavigationPage()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
private void SelectorChanged(SelectorBar sender, SelectorBarSelectionChangedEventArgs args)
|
|
{
|
|
FeelsNavigationFrame.Navigate(typeof(FeelsFeedPage));
|
|
}
|
|
|
|
private async void OnFeelsCreateButton(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
|
{
|
|
var path = Feels.GetTodayFeelPath();
|
|
if (SshConnection.DoesFileExist(path))
|
|
{
|
|
feelsComposeBox.Text = SshConnection.RunCommand($"cat {path}");
|
|
feelsComposeDialog.IsPrimaryButtonEnabled = true;
|
|
}
|
|
else
|
|
{
|
|
feelsComposeBox.Text = string.Empty;
|
|
feelsComposeDialog.IsPrimaryButtonEnabled = false;
|
|
}
|
|
await feelsComposeDialog.ShowAsync();
|
|
}
|
|
|
|
private void OnFeelsSubmitButton(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
|
{
|
|
var message = feelsComposeBox.Text;
|
|
if (!string.IsNullOrEmpty(message))
|
|
{
|
|
Feels.PostFeel(message);
|
|
feelsComposeBox.Text = string.Empty;
|
|
Feels.GetNewFeels();
|
|
}
|
|
}
|
|
|
|
private void OnTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(feelsComposeBox.Text))
|
|
{
|
|
feelsComposeDialog.IsPrimaryButtonEnabled = false;
|
|
}
|
|
else
|
|
{
|
|
feelsComposeDialog.IsPrimaryButtonEnabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|