diff --git a/PolyChat/MainPage.xaml b/PolyChat/MainPage.xaml index 596ea2b..3ec2199 100644 --- a/PolyChat/MainPage.xaml +++ b/PolyChat/MainPage.xaml @@ -6,17 +6,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:models="using:PolyChat.Models" mc:Ignorable="d" - Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" RequestedTheme="Dark"> + Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - + + @@ -37,7 +38,7 @@ - + @@ -55,12 +56,8 @@ - - - - - - + + diff --git a/PolyChat/MainPage.xaml.cs b/PolyChat/MainPage.xaml.cs index 1b6f6e2..d9286c2 100644 --- a/PolyChat/MainPage.xaml.cs +++ b/PolyChat/MainPage.xaml.cs @@ -26,6 +26,8 @@ namespace PolyChat private ObservableCollection 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(); + // theming + RequestedTheme = Theme; + // updated placeholder updateNoChatsPlaceholder(); updateNoUsernamePlaceholder(); updateNoChatSelected(); @@ -181,7 +186,6 @@ namespace PolyChat }); } - private void OnDeleteChat(object sender = null, RoutedEventArgs e = null) { Controller.CloseChat(selectedPartner.Code); @@ -210,6 +214,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(); @@ -226,6 +236,10 @@ namespace PolyChat return null; } + // GETTERS + + public static ElementTheme GetTheme() => Theme; + // UPDATE FUNCTIONS FOR UI PLACEHOLDERS private void updateNoChatsPlaceholder() diff --git a/PolyChat/Views/Dialog.xaml.cs b/PolyChat/Views/Dialog.xaml.cs index 331fb6f..75dd155 100644 --- a/PolyChat/Views/Dialog.xaml.cs +++ b/PolyChat/Views/Dialog.xaml.cs @@ -36,6 +36,7 @@ namespace PolyChat.Views Secondary = secondary.Action; // show MainPage.SafelyOpenDialog(this); + RequestedTheme = MainPage.GetTheme(); } private void setType(string type, string message) diff --git a/PolyChat/Views/EditUsernameDialog.xaml.cs b/PolyChat/Views/EditUsernameDialog.xaml.cs index faec438..8e44c1e 100644 --- a/PolyChat/Views/EditUsernameDialog.xaml.cs +++ b/PolyChat/Views/EditUsernameDialog.xaml.cs @@ -22,6 +22,7 @@ namespace PolyChat.Views if (initialValue == null || initialValue.Length == 0) IsSecondaryButtonEnabled = false; else input.Text = initialValue; validate(); + RequestedTheme = MainPage.GetTheme(); } public string getValue() diff --git a/PolyChat/Views/NewChatDialog.xaml.cs b/PolyChat/Views/NewChatDialog.xaml.cs index 4c888ba..a77d96f 100644 --- a/PolyChat/Views/NewChatDialog.xaml.cs +++ b/PolyChat/Views/NewChatDialog.xaml.cs @@ -20,6 +20,7 @@ namespace PolyChat.Views { this.InitializeComponent(); IsPrimaryButtonEnabled = false; + RequestedTheme = MainPage.GetTheme(); } public string getValue()