Skip to content

Commit

Permalink
- added chat bubble grouping
Browse files Browse the repository at this point in the history
- added chat bubble dynamic sizing
- updated deprecated dependency on Windows
  • Loading branch information
firestorm40 committed Sep 12, 2024
1 parent 805c781 commit d8dff84
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 18 deletions.
16 changes: 5 additions & 11 deletions Spixi/Platforms/Windows/SAudioPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
using Microsoft.VisualBasic;
using SPIXI.VoIP;
using SPIXI.VoIP;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IXICore.Meta;

namespace Spixi
{
public class SAudioPlayer : IAudioPlayer, IAudioDecoderCallback
{
private WaveOut audioPlayer = null;
private IAudioDecoder audioDecoder = null;
private WaveOut? audioPlayer = null;
private IAudioDecoder? audioDecoder = null;

private bool running = false;

private BufferedWaveProvider provider = null;
private BufferedWaveProvider? provider = null;

int sampleRate = SPIXI.Meta.Config.VoIP_sampleRate;
int bitRate = SPIXI.Meta.Config.VoIP_bitRate;
int channels = SPIXI.Meta.Config.VoIP_channels;

private static SAudioPlayer _singletonInstance;
private static SAudioPlayer? _singletonInstance;
public static SAudioPlayer Instance()
{
if (_singletonInstance == null)
Expand Down
12 changes: 9 additions & 3 deletions Spixi/Resources/Raw/html/css/spixiui-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,10 @@ img.emoji {
background-repeat: repeat;
background-size: 324px 509px;
padding-top: 10px;

display: flex;
flex-direction: column;
align-items: flex-start;
}

.scrollable-div {
Expand Down Expand Up @@ -1853,6 +1857,8 @@ img.emoji {
animation-duration: 0.3s;

word-wrap: break-word;
word-break: break-word;
display: inline-block;
}

.spixi-bubble > div
Expand All @@ -1862,7 +1868,7 @@ img.emoji {
}

.spixi-bubble.myself {
margin-left: 125px;
align-self: flex-end;
margin-right: 12px;
background: #305171;
}
Expand Down Expand Up @@ -2079,7 +2085,7 @@ img.emoji {
padding: 10px;
background-color: #2C3D4A;
color: #EEF2F5;
border-bottom: 1px solid #3A6B87M;
border-bottom: 1px solid #3A6B87;
font-size: 10pt;
vertical-align: middle;
}
Expand All @@ -2091,7 +2097,7 @@ img.emoji {
font-weight: bold;
margin-top: 5px;
vertical-align: middle;
border-bottom: 1px solid #3A6B87M;
border-bottom: 1px solid #3A6B87;
display: table-cell;
}

Expand Down
11 changes: 8 additions & 3 deletions Spixi/Resources/Raw/html/css/spixiui-light.css
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,10 @@ img.emoji {
background-repeat: repeat;
background-size: 324px 509px;
padding-top: 10px;

display: flex;
flex-direction: column;
align-items: flex-start;
}

.scrollable-div {
Expand Down Expand Up @@ -1841,14 +1845,15 @@ img.emoji {
color: black;

margin-left: 56px;
margin-right: 85px;
margin-bottom: 10px;
min-width: 80px;

animation-name: chat_animation;
animation-duration: 0.3s;

word-wrap: break-word;
word-break: break-word;
display: inline-block;
}

.spixi-bubble > div
Expand All @@ -1858,8 +1863,8 @@ img.emoji {
}

.spixi-bubble.myself {
margin-left: 125px;
margin-right: 11px;
align-self: flex-end;
margin-right: 12px;
background: #AAD7F0;
}

Expand Down
51 changes: 51 additions & 0 deletions Spixi/Resources/Raw/html/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,60 @@ function addText(id, address, nick, avatar, text, time, className) {

messagesEl.appendChild(bubbleEl);

adjustLastestBubbles();

scrollToBottom();
}

// TODO: optimize and merge this function with addText
function adjustLastestBubbles() {
var messagesEl = document.getElementById("messages");
var bubbles = messagesEl.querySelectorAll(".spixi-bubble");

if (bubbles.length < 2) {
return;
}

var currentBubble = bubbles[bubbles.length - 1];
var previousBubble = bubbles[bubbles.length - 2];

var isCurrentMyself = currentBubble.classList.contains('myself');
var isPreviousMyself = previousBubble.classList.contains('myself');

if (isCurrentMyself === isPreviousMyself) {
if (!isCurrentMyself) {
var currentNick = currentBubble.querySelector('.nick');
var previousNick = previousBubble.querySelector('.nick');

if (currentNick && previousNick) {
var currentAddress = currentNick.getAttribute('address');
var previousAddress = previousNick.getAttribute('address');

if (currentAddress && previousAddress && currentAddress === previousAddress) {
var currentAvatar = currentBubble.querySelector('.avatar');
if (currentAvatar) {
currentAvatar.remove();
}
currentNick.textContent = '';
previousBubble.style.marginBottom = "2px";
} else {
previousBubble.style.marginBottom = "10px";
}
} else {
var currentAvatar = currentBubble.querySelector('.avatar');
if (currentAvatar) {
currentAvatar.remove();
}
previousBubble.style.marginBottom = "2px";
}
} else {
previousBubble.style.marginBottom = "2px";
}
} else {
previousBubble.style.marginBottom = "10px";
}
}

function addMe(id, address, nick, avatar, text, time, sent, confirmed, read, paid) {
var additionalClasses = "";
if (confirmed == "True") {
Expand Down
2 changes: 1 addition & 1 deletion Spixi/Spixi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.1" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.72" />
<PackageReference Include="Concentus" Version="1.1.7" />
<PackageReference Include="NAudio.Wma" Version="1.0.1" Condition="$(TargetFramework.Contains('-windows'))"></PackageReference>
<PackageReference Include="NAudio" Version="2.2.1" Condition="$(TargetFramework.Contains('-windows'))"></PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OneSignalSDK.DotNet" Version="5.2.1" />
<PackageReference Include="Open.Nat" Version="2.1.0" />
Expand Down

0 comments on commit d8dff84

Please sign in to comment.