Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam committed Dec 3, 2024
2 parents 7283d46 + c353ab5 commit b5fdbd3
Show file tree
Hide file tree
Showing 54 changed files with 3,683 additions and 272 deletions.
37 changes: 31 additions & 6 deletions UniSky/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniSky"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:media="using:Microsoft.UI.Xaml.Media">
xmlns:media="using:Microsoft.UI.Xaml.Media"
xmlns:sheets="using:UniSky.Controls.Sheet">

<Application.Resources>
<controls:XamlControlsResources ControlsResourcesVersion="Version1">
Expand All @@ -14,18 +15,35 @@
<!-- Styles -->
<ResourceDictionary Source="/Templates/NavigationViewStyles.xaml"/>
<ResourceDictionary Source="/Templates/ButtonStyles.xaml"/>
<ResourceDictionary Source="/Templates/TextBoxStyles.xaml"/>
<ResourceDictionary Source="/Templates/MediaTransportControlsStyles.xaml"/>

<!-- Templates -->
<FeedTemplates xmlns="using:UniSky.Templates"/>
</ResourceDictionary.MergedDictionaries>

<!-- Controls -->
<ResourceDictionary Source="/Controls/Sheet/SheetControl.xaml"/>
<ResourceDictionary Source="/Controls/RadialProgressBar/RadialProgressBar.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#FF080808" />
<SolidColorBrush x:Key="SystemControlSeparatorBrush" Color="#FF404040"/>
<Color x:Key="SystemListExtraLowColor">#10FFFFFF</Color>
<Color x:Key="SystemControlSeparatorColor">#FF404040</Color>

<media:RevealBorderBrush x:Key="SystemControlRevealSeparatorBrush"
Color="{ThemeResource SystemControlSeparatorColor}"
FallbackColor="{ThemeResource SystemControlSeparatorColor}"
TargetTheme="Dark"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="SystemControlSeparatorBrush" Color="#FFDEDEDE"/>
<Color x:Key="SystemControlSeparatorColor">#FFDEDEDE</Color>
<Color x:Key="SystemListExtraLowColor">#10000000</Color>

<media:RevealBorderBrush x:Key="SystemControlRevealSeparatorBrush"
Color="{ThemeResource SystemControlSeparatorColor}"
FallbackColor="{ThemeResource SystemControlSeparatorColor}"
TargetTheme="Light"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

Expand All @@ -37,11 +55,18 @@
<x:Int32 x:Key="BlueSkyLogoWidth">64</x:Int32>
<x:Int32 x:Key="BlueSkyLogoHeight">38</x:Int32>-->

<Thickness x:Key="HairlineThickness">0,1,0,0</Thickness>
<Thickness x:Key="HairlineThickness">1</Thickness>
<CornerRadius x:Key="ControlCornerRadius">0,0,0,0</CornerRadius>

<x:Double x:Key="ControlContentThemeFontSize">14</x:Double>
<x:Double x:Key="ContentControlFontSize">14</x:Double>
<x:Double x:Key="ContentControlFontSize">14</x:Double>

<SolidColorBrush x:Key="SystemControlBackgroundListExtraLowBrush"
Color="{ThemeResource SystemListExtraLowColor}"/>

<SolidColorBrush x:Key="SystemControlSeparatorBrush" Color="{ThemeResource SystemControlSeparatorColor}"/>

<Style TargetType="sheets:SheetControl" BasedOn="{StaticResource DefaultSheetControlStyle}"/>
</ResourceDictionary>
</controls:XamlControlsResources.MergedDictionaries>
</controls:XamlControlsResources>
Expand Down
10 changes: 9 additions & 1 deletion UniSky/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using CommunityToolkit.Mvvm.DependencyInjection;
using Humanizer.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using UniSky.Extensions;
using UniSky.Helpers.Localisation;
using UniSky.Services;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
Expand Down Expand Up @@ -55,9 +58,12 @@ private void ConfigureServices()
collection.AddSingleton<INavigationServiceLocator, NavigationServiceLocator>();
collection.AddSingleton<IProtocolService, ProtocolService>();
collection.AddSingleton<ISafeAreaService, SafeAreaService>();
collection.AddSingleton<ISheetService, SheetService>();

Ioc.Default.ConfigureServices(collection.BuildServiceProvider());
}

Configurator.Formatters.Register("en", (locale) => new ShortTimespanFormatter("en"));
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
Expand All @@ -66,6 +72,8 @@ private void ConfigureServices()
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Hairline.Initialize();

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (Window.Current.Content is not Frame rootFrame)
Expand Down
42 changes: 0 additions & 42 deletions UniSky/Controls/Compose/ComposeDialog.xaml

This file was deleted.

16 changes: 16 additions & 0 deletions UniSky/Controls/Compose/ComposeDiscardDraftDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ContentDialog
x:Class="UniSky.Controls.Compose.ComposeDiscardDraftDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniSky.Controls.Compose"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Discard draft?"
PrimaryButtonText="Discard"
SecondaryButtonText="Cancel"
SecondaryButtonStyle="{ThemeResource AccentButtonStyle}">

<TextBlock Text="Are you sure you want to discard this draft? This action is irreversible!"
TextWrapping="WrapWholeWords"/>
</ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using UniSky.ViewModels.Compose;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
Expand All @@ -20,26 +17,13 @@

namespace UniSky.Controls.Compose
{
public sealed partial class ComposeDialog : ContentDialog
public sealed partial class ComposeDiscardDraftDialog : ContentDialog
{
public ComposeViewModel ViewModel
{
get { return (ComposeViewModel)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}

public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(ComposeViewModel), typeof(ComposeDialog), new PropertyMetadata(null));

public ComposeDialog()
public ComposeDiscardDraftDialog()
{
this.InitializeComponent();
this.ViewModel = ActivatorUtilities.CreateInstance<ComposeViewModel>(Ioc.Default);
}

public bool Not(bool b, bool a)
=> !a && !b;

private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
}
Expand Down
184 changes: 184 additions & 0 deletions UniSky/Controls/Compose/ComposeSheet.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<sheet:SheetControl
xmlns:sheet="using:UniSky.Controls.Sheet"
x:Class="UniSky.Controls.Compose.ComposeSheet"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniSky.Controls.Compose"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converters="using:UniSky.Converters"
xmlns:extensions="using:UniSky.Extensions" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="320"
Style="{StaticResource DefaultSheetControlStyle}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
PrimaryButtonCommand="{x:Bind ViewModel.PostCommand}"
IsPrimaryButtonEnabled="{x:Bind ViewModel.CanPost, Mode=OneWay}"
SecondaryButtonCommand="{x:Bind ViewModel.HideCommand}">
<sheet:SheetControl.TitleContent>
<TextBlock Text="NEW POST"/>
</sheet:SheetControl.TitleContent>
<sheet:SheetControl.PrimaryButtonContent>
<TextBlock Text="Post" Margin="8,0"/>
</sheet:SheetControl.PrimaryButtonContent>
<sheet:SheetControl.SecondaryButtonContent>
<TextBlock Text="Cancel"/>
</sheet:SheetControl.SecondaryButtonContent>

<Grid x:Name="ContentGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Grid x:Name="ErrorContainer"
x:Load="{x:Bind ViewModel.IsErrored, Mode=OneWay}"
Padding="12,0"
extensions:Hairline.Margin="-1"
extensions:Hairline.BorderThickness="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.Background>
<SolidColorBrush Opacity="0.2" Color="{ThemeResource SystemErrorTextColor}"/>
</Grid.Background>
<Grid.BorderBrush>
<SolidColorBrush Opacity="0.6" Color="{ThemeResource SystemErrorTextColor}"/>
</Grid.BorderBrush>

<Viewbox Width="16"
Height="16"
Margin="0,10,0,0"
VerticalAlignment="Top">
<TextBlock FontFamily="{ThemeResource SymbolThemeFontFamily}">&#xE783;</TextBlock>
</Viewbox>

<TextBlock Text="{Binding Error.Message, FallbackValue='Something went wrong!'}"
TextWrapping="Wrap"
Margin="8"
Grid.Column="1"
MaxLines="2"/>
</Grid>

<ProgressBar Grid.Row="1"
VerticalAlignment="Top"
Background="Transparent"
IsIndeterminate="{x:Bind ViewModel.IsLoading, Mode=OneWay}" />

<ScrollViewer Grid.Row="1"
IsEnabled="{x:Bind converters:Static.Not(ViewModel.IsLoading), Mode=OneWay}"
HorizontalScrollMode="Disabled"
VerticalScrollMode="Enabled"
IsVerticalScrollChainingEnabled="True"
IsVerticalRailEnabled="True"
IsDeferredScrollingEnabled="False"
Padding="12">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="ReplyContainer"
x:Load="{x:Bind ViewModel.HasReply}"
Margin="0,0,0,8"
BorderBrush="{ThemeResource SystemControlSeparatorBrush}"
extensions:Hairline.BorderThickness="0,0,0,1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<muxc:PersonPicture Width="48"
Height="48"
Margin="0,0,8,0"
VerticalAlignment="Top"
ProfilePicture="{x:Bind ViewModel.ReplyTo.Author.AvatarUrl, Mode=OneWay}"/>
<StackPanel Grid.Column="1"
Margin="0,0,0,8">
<TextBlock Foreground="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
VerticalAlignment="Top">
<Run Text="{x:Bind ViewModel.ReplyTo.Author.Name, Mode=OneWay}"
FontWeight="Bold"
Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
<Run Text="{x:Bind ViewModel.ReplyTo.Author.Handle, Mode=OneWay}"/>
</TextBlock>

<TextBlock x:Name="MainContent"
x:Load="{x:Bind converters:Static.NotNullOrWhiteSpace(ViewModel.ReplyTo.Text)}"
Text="{x:Bind ViewModel.ReplyTo.Text}"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis"
MaxLines="4"
Margin="0,0,0,4"
VerticalAlignment="Top"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" MinHeight="150">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Ellipse Width="48"
Height="48"
Margin="0,0,8,0"
VerticalAlignment="Top">
<Ellipse.Fill>
<ImageBrush>
<ImageBrush.ImageSource>
<BitmapImage UriSource="{Binding AvatarUrl}"
DecodePixelWidth="48"
DecodePixelHeight="48"
DecodePixelType="Logical"/>
</ImageBrush.ImageSource>
</ImageBrush>
</Ellipse.Fill>
</Ellipse>
<TextBox x:Name="PrimaryTextBox"
Style="{StaticResource BorderlessTextBoxStyle}"
Grid.Column="1"
Text="{x:Bind ViewModel.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.HorizontalScrollMode="Disabled"
ScrollViewer.IsDeferredScrollingEnabled="False"
VerticalAlignment="Stretch"
PlaceholderText="What's happening?"
MaxLength="300" />
</Grid>
</Grid>
</ScrollViewer>

<Grid x:Name="FooterContainer"
Grid.Row="2"
Background="{ThemeResource SystemControlBackgroundListExtraLowBrush}"
BorderBrush="{ThemeResource SystemControlSeparatorBrush}"
Padding="0,0,0,2"
extensions:Hairline.BorderThickness="0,1,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<StackPanel Margin="2,0,0,0"
VerticalAlignment="Stretch"
Orientation="Horizontal">
<Button Style="{ThemeResource IconButtonStyle}"
Content="&#xEB9F;"
Margin="0,0,2,0"/>
<Button Style="{ThemeResource IconButtonStyle}"
Content="&#xE714;"
Margin="0,0,2,0"/>
<Button Style="{ThemeResource IconButtonStyle}"
Content="&#xE910;"
Margin="0,0,2,0"/>
</StackPanel>

<controls:RadialProgressBar Grid.Column="1"
Margin="8,6"
Minimum="0"
Maximum="{x:Bind ViewModel.MaxCharacters}"
Value="{x:Bind ViewModel.Characters, Mode=OneWay}"
Width="32"
Height="32"/>
</Grid>
</Grid>
</sheet:SheetControl>
Loading

0 comments on commit b5fdbd3

Please sign in to comment.