Added Themes + Toggle

This commit is contained in:
Patrick Hellebrand
2021-09-23 15:31:30 +02:00
committed by Felix Hartmann (PEA3-Fe-FI)
parent 4c0413e7d8
commit 5c4b4373d6
5 changed files with 25 additions and 10 deletions

View File

@@ -26,6 +26,8 @@ namespace PolyChat
private ObservableCollection<ChatPartner> Partners;
private ChatPartner selectedPartner = null;
private string username;
private static ElementTheme Theme = ElementTheme.Light;
public MainPage()
{
@@ -35,6 +37,9 @@ namespace PolyChat
// ui variables
ipAddress.Text = IP.GetCodeFromIP(Controller.getIP());
Partners = new ObservableCollection<ChatPartner>();
// theming
RequestedTheme = Theme;
// updated placeholder
updateNoChatsPlaceholder();
updateNoUsernamePlaceholder();
updateNoChatSelected();
@@ -185,7 +190,6 @@ namespace PolyChat
});
}
private void OnDeleteChat(object sender = null, RoutedEventArgs e = null)
{
Controller.CloseChat(selectedPartner.Code);
@@ -214,6 +218,12 @@ namespace PolyChat
if (!Controller.IsConnected(code)) Controller.Connect(code);
}
public void OnToggleTheme(object sender, RoutedEventArgs e)
{
Theme = Theme == ElementTheme.Light ? ElementTheme.Dark : ElementTheme.Light;
RequestedTheme = Theme;
}
private void OnKeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
{
updateSendButtonEnabled();
@@ -230,6 +240,10 @@ namespace PolyChat
return null;
}
// GETTERS
public static ElementTheme GetTheme() => Theme;
// UPDATE FUNCTIONS FOR UI PLACEHOLDERS
private void updateNoChatsPlaceholder()