mirror of
https://github.com/Stone-Red-Code/Decho.git
synced 2026-09-07 07:46:11 +02:00
Improve multiline message handling, timestamp formatting, and UI layout
This commit is contained in:
@@ -61,7 +61,7 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
new("message-1", alex, DateTimeOffset.Now.AddMinutes(-30), "This is a message."),
|
new("message-1", alex, DateTimeOffset.Now.AddMinutes(-30), "This is a message."),
|
||||||
new("message-2", sam, DateTimeOffset.Now.AddMinutes(-25), "Another message for the channel."),
|
new("message-2", sam, DateTimeOffset.Now.AddMinutes(-25), "Another message for the channel."),
|
||||||
new("message-3", alex, DateTimeOffset.Now.AddMinutes(-10), "We should test the new layout."),
|
new("message-3", alex, DateTimeOffset.Now.AddMinutes(-10), "We should test the \nnew layout."),
|
||||||
});
|
});
|
||||||
|
|
||||||
var random = new ChannelModel(
|
var random = new ChannelModel(
|
||||||
@@ -69,7 +69,14 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
"random",
|
"random",
|
||||||
new ObservableCollection<MessageModel>
|
new ObservableCollection<MessageModel>
|
||||||
{
|
{
|
||||||
new("message-4", sam, DateTimeOffset.Now.AddMinutes(-5), "Random chat keeps the vibe light."),
|
new("message-4", sam, DateTimeOffset.Now.AddMinutes(-5), @"Random chat keeps the vibe light.
|
||||||
|
rwerwerw
|
||||||
|
rw
|
||||||
|
er
|
||||||
|
wer
|
||||||
|
w
|
||||||
|
r
|
||||||
|
ztr5z56j7u5"),
|
||||||
});
|
});
|
||||||
|
|
||||||
var music = new ChannelModel(
|
var music = new ChannelModel(
|
||||||
@@ -78,13 +85,13 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
new ObservableCollection<MessageModel>());
|
new ObservableCollection<MessageModel>());
|
||||||
|
|
||||||
var server = new ServerModel(
|
var server = new ServerModel(
|
||||||
"server-1",
|
"echo.voidcube.cloud",
|
||||||
"Server",
|
"echo.voidcube.cloud",
|
||||||
new ObservableCollection<ChannelModel> { general, random });
|
new ObservableCollection<ChannelModel> { general, random });
|
||||||
|
|
||||||
var anotherServer = new ServerModel(
|
var anotherServer = new ServerModel(
|
||||||
"server-2",
|
"echo.stone-red.net",
|
||||||
"Another Server",
|
"echo.stone-red.net",
|
||||||
new ObservableCollection<ChannelModel>() { general, music});
|
new ObservableCollection<ChannelModel>() { general, music});
|
||||||
|
|
||||||
return new[] { server, anotherServer };
|
return new[] { server, anotherServer };
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Decho.Models;
|
using Decho.Models;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Decho.ViewModels;
|
namespace Decho.ViewModels;
|
||||||
|
|
||||||
public sealed class MessageViewModel : ViewModelBase
|
public sealed class MessageViewModel : ViewModelBase
|
||||||
@@ -15,5 +17,19 @@ public sealed class MessageViewModel : ViewModelBase
|
|||||||
|
|
||||||
public string Content => Model.Content;
|
public string Content => Model.Content;
|
||||||
|
|
||||||
public string TimeText => Model.SentAt.ToLocalTime().ToString("h:mm tt");
|
public string TimeText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// If today, show time only; otherwise, show date and time.
|
||||||
|
var now = DateTimeOffset.Now;
|
||||||
|
|
||||||
|
if (Model.SentAt.Date == now.Date)
|
||||||
|
{
|
||||||
|
return Model.SentAt.ToLocalTime().ToString("t");
|
||||||
|
}
|
||||||
|
|
||||||
|
return now.ToString("g");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,16 @@
|
|||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto, *" ColumnDefinitions="Auto, *">
|
<Grid RowDefinitions="Auto, *" ColumnDefinitions="Auto, *">
|
||||||
<TextBlock Grid.ColumnSpan="2"
|
<TextBlock FontSize="20"
|
||||||
FontSize="20"
|
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
|
Margin="0 5"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Text="{Binding Title}" />
|
Text="{Binding Title}" />
|
||||||
<views:SidebarView Grid.Row="1"
|
<views:SidebarView Grid.Row="1"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
DataContext="{Binding Sidebar}"
|
DataContext="{Binding Sidebar}"
|
||||||
SelectedChannel="{Binding SelectedChannel, Mode=TwoWay}" />
|
SelectedChannel="{Binding SelectedChannel, Mode=TwoWay}" />
|
||||||
<views:ChatView Grid.Row="1"
|
<views:ChatView Grid.RowSpan="2"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
DataContext="{Binding Chat}" />
|
DataContext="{Binding Chat}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
<Grid ColumnDefinitions="*, Auto, Auto" Margin="5">
|
<Grid ColumnDefinitions="*, Auto, Auto" Margin="5">
|
||||||
<TextBox HorizontalAlignment="Stretch"
|
<TextBox HorizontalAlignment="Stretch"
|
||||||
Margin="0 0 5 0"
|
Margin="0 0 5 0"
|
||||||
Text="{Binding Draft, Mode=TwoWay}" />
|
Text="{Binding Draft, Mode=TwoWay}">
|
||||||
|
<TextBox.KeyBindings>
|
||||||
|
<KeyBinding Command="{Binding SendCommand}" Gesture="Enter" />
|
||||||
|
</TextBox.KeyBindings>
|
||||||
|
</TextBox>
|
||||||
<Button Grid.Column="1"
|
<Button Grid.Column="1"
|
||||||
Height="33"
|
Height="33"
|
||||||
Width="33"
|
Width="33"
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Decho.ViewModels"
|
xmlns:vm="using:Decho.ViewModels"
|
||||||
x:Class="Decho.Views.MessageItemView"
|
x:Class="Decho.Views.MessageItemView"
|
||||||
x:DataType="vm:MessageViewModel">
|
x:DataType="vm:MessageViewModel">
|
||||||
<Grid Margin="5" ColumnDefinitions="Auto, Auto, *" RowDefinitions="Auto, Auto">
|
<Grid Margin="5" ColumnDefinitions="Auto, Auto, *">
|
||||||
<Ellipse Grid.RowSpan="2"
|
<Ellipse Grid.RowSpan="2"
|
||||||
Width="40"
|
VerticalAlignment="Top"
|
||||||
Height="40"
|
Width="40"
|
||||||
Fill="{DynamicResource UiTheme00}"
|
Height="40"
|
||||||
Margin="0 0 5 0" />
|
Fill="{DynamicResource UiTheme00}"
|
||||||
<TextBlock Grid.Column="1"
|
Margin="0 0 8 0" />
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Text="{Binding AuthorName}"
|
<StackPanel Grid.Column="1" VerticalAlignment="Top">
|
||||||
FontWeight="Bold" />
|
<StackPanel Orientation="Horizontal" Margin="0 5 0 0">
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock VerticalAlignment="Top"
|
||||||
Grid.Row="1"
|
Text="{Binding AuthorName}"
|
||||||
Text="{Binding TimeText}"
|
FontWeight="Bold" />
|
||||||
FontSize="10" />
|
<TextBlock VerticalAlignment="Top"
|
||||||
<TextBlock Grid.Column="2"
|
Text="{Binding TimeText}"
|
||||||
Grid.RowSpan="1"
|
FontSize="10"
|
||||||
VerticalAlignment="Center"
|
Margin="5 0 0 0" />
|
||||||
Text="{Binding Content}"
|
</StackPanel>
|
||||||
TextWrapping="Wrap"
|
<TextBlock VerticalAlignment="Top"
|
||||||
Margin="10 5 0 0" />
|
Text="{Binding Content}"
|
||||||
</Grid>
|
TextWrapping="Wrap" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
xmlns:views="using:Decho.Views"
|
xmlns:views="using:Decho.Views"
|
||||||
x:Class="Decho.Views.SidebarView"
|
x:Class="Decho.Views.SidebarView"
|
||||||
x:DataType="vm:SidebarViewModel">
|
x:DataType="vm:SidebarViewModel">
|
||||||
<Panel Background="{DynamicResource UiTheme00}" Width="250">
|
<Border Background="{DynamicResource UiTheme00}" Width="250" CornerRadius="0 6 0 0">
|
||||||
<ScrollViewer Padding="5">
|
<ScrollViewer Padding="5">
|
||||||
<ItemsControl ItemsSource="{Binding Servers}">
|
<ItemsControl ItemsSource="{Binding Servers}">
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate x:DataType="vm:ServerViewModel">
|
<DataTemplate x:DataType="vm:ServerViewModel">
|
||||||
<Expander Padding="0"
|
<Expander Padding="0"
|
||||||
|
Margin="0 0 0 6"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
IsExpanded="{Binding IsExpanded}">
|
IsExpanded="{Binding IsExpanded}">
|
||||||
<Expander.Header>
|
<Expander.Header>
|
||||||
@@ -25,5 +26,5 @@
|
|||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Panel>
|
</Border>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user