Browse Source

Added section to account popup

Krzysztof Krysiński 3 months ago
parent
commit
2dbc8b528f

+ 2 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -1066,5 +1066,6 @@
   "FOUNDERS_BUNDLE": "Founder's Bundle",
   "FOUNDERS_BUNDLE": "Founder's Bundle",
   "FOUNDERS_BUNDLE_SUBTEXT": "Support PixiEditor and boost your productivity!",
   "FOUNDERS_BUNDLE_SUBTEXT": "Support PixiEditor and boost your productivity!",
   "BECOME_A_FOUNDER": "Become a Founder",
   "BECOME_A_FOUNDER": "Become a Founder",
-  "LOGIN": "Login"
+  "LOGIN": "Login",
+  "NOT_FOUNDER_YET": "Not a Founder yet?"
 }
 }

+ 1 - 1
src/PixiEditor/Initialization/ClassicDesktopEntry.cs

@@ -265,7 +265,7 @@ internal class ClassicDesktopEntry
 #if DEBUG
 #if DEBUG
         if (baseUrl.Contains('{') && baseUrl.Contains('}'))
         if (baseUrl.Contains('{') && baseUrl.Contains('}'))
         {
         {
-            string? envUrl = Environment.GetEnvironmentVariable("PIXIEDITOR_API_URL");
+            string? envUrl = Environment.GetEnvironmentVariable("PIXIAUTH_API_URL");
             if (envUrl != null)
             if (envUrl != null)
             {
             {
                 baseUrl = envUrl;
                 baseUrl = envUrl;

+ 12 - 3
src/PixiEditor/ViewModels/SubViewModels/UserViewModel.cs

@@ -92,6 +92,14 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
     public bool NonDefaultIdentityProvider => IdentityProvider is not PixiAuthIdentityProvider;
     public bool NonDefaultIdentityProvider => IdentityProvider is not PixiAuthIdentityProvider;
     public bool AnyUpdateAvailable => OwnedProducts.Any(x => x.UpdateAvailable);
     public bool AnyUpdateAvailable => OwnedProducts.Any(x => x.UpdateAvailable);
 
 
+
+    public static string FoundersBundleLink =>
+#if STEAM
+        "https://store.steampowered.com/app/2435860/PixiEditor__Supporter_Pack/";
+#else
+        "https://pixieditor.net/purchase/";
+#endif
+
     public UserViewModel(ViewModelMain owner) : base(owner)
     public UserViewModel(ViewModelMain owner) : base(owner)
     {
     {
         IdentityProvider = IPlatform.Current.IdentityProvider;
         IdentityProvider = IPlatform.Current.IdentityProvider;
@@ -143,7 +151,8 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
                     .FirstOrDefault(x => x.Metadata.UniqueName == product.Id)?.Metadata.Version;
                     .FirstOrDefault(x => x.Metadata.UniqueName == product.Id)?.Metadata.Version;
             }
             }
 
 
-            OwnedProducts.Add(new OwnedProductViewModel(product, isInstalled, installedVersion, InstallContentCommand, IsInstalled));
+            OwnedProducts.Add(new OwnedProductViewModel(product, isInstalled, installedVersion, InstallContentCommand,
+                IsInstalled));
         }
         }
 
 
         NotifyProperties();
         NotifyProperties();
@@ -316,7 +325,7 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
         }
         }
 
 
         return Owner.ExtensionsSubViewModel.ExtensionLoader.LoadedExtensions
         return Owner.ExtensionsSubViewModel.ExtensionLoader.LoadedExtensions
-                   .FirstOrDefault(x => x.Metadata.UniqueName == productId)?.Metadata.Version != product.LatestVersion;
+            .FirstOrDefault(x => x.Metadata.UniqueName == productId)?.Metadata.Version != product.LatestVersion;
     }
     }
 
 
     private bool IsInstalled(string productId)
     private bool IsInstalled(string productId)
@@ -362,7 +371,7 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
         else
         else
         {
         {
             LastError = arg != null ? new LocalizedString(error, arg) : new LocalizedString(error);
             LastError = arg != null ? new LocalizedString(error, arg) : new LocalizedString(error);
-            if(User is PixiUser { IsWaitingForActivation: true } pixiUser)
+            if (User is PixiUser { IsWaitingForActivation: true } pixiUser)
             {
             {
                 pixiUser.SessionId = null;
                 pixiUser.SessionId = null;
                 pixiUser.SessionToken = null;
                 pixiUser.SessionToken = null;

+ 1 - 6
src/PixiEditor/ViewModels/UserPreferences/OnboardingViewModel.cs

@@ -67,12 +67,7 @@ internal class OnboardingViewModel : PixiObservableObject
 
 
     public RelayCommand<IToolSetHandler> SelectToolsetCommand { get; }
     public RelayCommand<IToolSetHandler> SelectToolsetCommand { get; }
 
 
-    public string FoundersBundleLink =>
-#if STEAM
-        "https://store.steampowered.com/app/2435860/PixiEditor__Supporter_Pack/";
-#else
-        "https://pixieditor.net/purchase/";
-#endif
+    public string FoundersBundleLink => UserViewModel.FoundersBundleLink;
 
 
     Dictionary<string, VecI> DefaultNewFileSizes = new()
     Dictionary<string, VecI> DefaultNewFileSizes = new()
     {
     {

+ 74 - 18
src/PixiEditor/Views/Auth/LoginForm.axaml

@@ -7,6 +7,7 @@
              xmlns:subViewModels="clr-namespace:PixiEditor.ViewModels.SubViewModels"
              xmlns:subViewModels="clr-namespace:PixiEditor.ViewModels.SubViewModels"
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
              xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
              xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
+             xmlns:xaml="clr-namespace:PixiEditor.Models.Commands.XAML"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              x:Class="PixiEditor.Views.Auth.LoginForm">
              x:Class="PixiEditor.Views.Auth.LoginForm">
     <Design.DataContext>
     <Design.DataContext>
@@ -14,6 +15,47 @@
     </Design.DataContext>
     </Design.DataContext>
 
 
     <Panel>
     <Panel>
+        <Panel.Resources>
+            <LinearGradientBrush
+                StartPoint="0%, 84%"
+                EndPoint="100%, 34%"
+                x:Key="FoundersGradientBrush">
+                <GradientStops>
+                    <GradientStop Offset="0" Color="#832ED7" />
+                    <GradientStop Offset="0.24" Color="#9D42F8" />
+                    <GradientStop Offset="0.48" Color="#DCB8FF" />
+                    <GradientStop Offset="0.72" Color="#AB56FF" />
+                    <GradientStop Offset="0.96" Color="#762BC0" />
+                </GradientStops>
+            </LinearGradientBrush>
+            <LinearGradientBrush
+                StartPoint="0%, 84%"
+                EndPoint="100%, 34%"
+                x:Key="FoundersGradientBrushShifted">
+                <GradientStops>
+                    <GradientStop Offset="0" Color="#832ED7" />
+                    <GradientStop Offset="0.25" Color="#DCB8FF" />
+                    <GradientStop Offset="0.75" Color="#DCB8FF" />
+                    <GradientStop Offset="1" Color="#762BC0" />
+                </GradientStops>
+            </LinearGradientBrush>
+        </Panel.Resources>
+        <Panel.Styles>
+            <Style Selector="Button.foundersButton">
+                <Setter Property="BorderBrush" Value="{StaticResource FoundersGradientBrush}" />
+                <Setter Property="Foreground" Value="{StaticResource FoundersGradientBrush}" />
+                <Setter Property="Transitions">
+                    <Transitions>
+                        <BrushTransition Property="BorderBrush" Delay="0" Duration="0:0:0.2" Easing="SineEaseOut" />
+                        <BrushTransition Property="Foreground" Delay="0" Duration="0:0:0.2" Easing="SineEaseOut" />
+                    </Transitions>
+                </Setter>
+            </Style>
+            <Style Selector="Button.foundersButton:pointerover">
+                <Setter Property="BorderBrush" Value="{StaticResource FoundersGradientBrushShifted}" />
+                <Setter Property="Foreground" Value="{StaticResource FoundersGradientBrushShifted}" />
+            </Style>
+        </Panel.Styles>
         <StackPanel IsVisible="{Binding !IsLoggedIn}" VerticalAlignment="Top" Spacing="12">
         <StackPanel IsVisible="{Binding !IsLoggedIn}" VerticalAlignment="Top" Spacing="12">
             <TextBox Text="{Binding CurrentEmail, Mode=TwoWay}" Watermark="{ui:Translate Key=ENTER_EMAIL}" Name="Email"
             <TextBox Text="{Binding CurrentEmail, Mode=TwoWay}" Watermark="{ui:Translate Key=ENTER_EMAIL}" Name="Email"
                      IsVisible="{Binding !IsLoggedIn}" />
                      IsVisible="{Binding !IsLoggedIn}" />
@@ -72,27 +114,41 @@
                 <Run Text="" />
                 <Run Text="" />
                 <Run ui:Translator.LocalizedString="{Binding LastError}" />
                 <Run ui:Translator.LocalizedString="{Binding LastError}" />
             </TextBlock>
             </TextBlock>
+
+            <Separator />
+            <TextBlock HorizontalAlignment="Center" Classes="subtext" ui:Translator.Key="NOT_FOUNDER_YET" />
+            <Button ui:Translator.Key="BECOME_A_FOUNDER" Background="Transparent"
+                    Command="{xaml:Command Name=PixiEditor.Links.OpenHyperlink, UseProvided=True}"
+                    CommandParameter="{Binding FoundersBundleLink}"
+                    HorizontalAlignment="Center"
+                    Classes="foundersButton"
+                    Padding="8, 4" />
         </StackPanel>
         </StackPanel>
-        <StackPanel IsVisible="{Binding IsLoggedIn}" Margin="5" Spacing="12" Orientation="Vertical">
-            <Border ClipToBounds="True" Width="100" Height="100" CornerRadius="100">
-                <HyperlinkButton NavigateUri="{Binding IdentityProvider.EditProfileUrl}"
-                                 ToolTip.Tip="{Binding IdentityProvider.EditProfileUrl}"
-                                 Cursor="Hand">
-                    <Image asyncImageLoader:ImageLoader.Source="{Binding AvatarUrl}" />
-                </HyperlinkButton>
-            </Border>
-            <TextBlock IsVisible="{Binding NonDefaultIdentityProvider}" HorizontalAlignment="Center" Classes="subtext">
-                <Run Text="{ui:Translate Key=ACCOUNT_PROVIDER_INFO}" />
-                <Run Text="{Binding IdentityProvider.ProviderName}" />
-            </TextBlock>
-            <TextBlock HorizontalAlignment="Center" FontSize="{DynamicResource FontSizeNormal}"
-                       ui:Translator.Key="LOGGED_IN_AS">
-                <Run Text="" />
-                <Run Text="{Binding Username}" />
-            </TextBlock>
+        <DockPanel LastChildFill="True" IsVisible="{Binding IsLoggedIn}" Margin="5">
             <Button IsVisible="{Binding IdentityProvider.AllowsLogout}"
             <Button IsVisible="{Binding IdentityProvider.AllowsLogout}"
                     Content="{ui:Translate Key=LOGOUT}"
                     Content="{ui:Translate Key=LOGOUT}"
+                    DockPanel.Dock="Bottom"
                     Command="{Binding LogoutCommand}" />
                     Command="{Binding LogoutCommand}" />
-        </StackPanel>
+
+            <StackPanel VerticalAlignment="Center" Orientation="Vertical" Spacing="12">
+                <Border ClipToBounds="True" Width="100" Height="100" CornerRadius="100">
+                    <HyperlinkButton NavigateUri="{Binding IdentityProvider.EditProfileUrl}"
+                                     ToolTip.Tip="{Binding IdentityProvider.EditProfileUrl}"
+                                     Cursor="Hand">
+                        <Image asyncImageLoader:ImageLoader.Source="{Binding AvatarUrl}" />
+                    </HyperlinkButton>
+                </Border>
+                <TextBlock IsVisible="{Binding NonDefaultIdentityProvider}" HorizontalAlignment="Center"
+                           Classes="subtext">
+                    <Run Text="{ui:Translate Key=ACCOUNT_PROVIDER_INFO}" />
+                    <Run Text="{Binding IdentityProvider.ProviderName}" />
+                </TextBlock>
+                <TextBlock HorizontalAlignment="Center" FontSize="{DynamicResource FontSizeNormal}"
+                           ui:Translator.Key="LOGGED_IN_AS">
+                    <Run Text="" />
+                    <Run Text="{Binding Username}" />
+                </TextBlock>
+            </StackPanel>
+        </DockPanel>
     </Panel>
     </Panel>
 </UserControl>
 </UserControl>

+ 1 - 1
src/PixiEditor/Views/Auth/LoginPopup.axaml

@@ -11,7 +11,7 @@
                          x:Class="PixiEditor.Views.Auth.LoginPopup"
                          x:Class="PixiEditor.Views.Auth.LoginPopup"
                          CanMinimize="True"
                          CanMinimize="True"
                          CanResize="False"
                          CanResize="False"
-                         Width="320" Height="190"
+                         Width="320" Height="280"
                          ui:Translator.Key="ACCOUNT_WINDOW_TITLE">
                          ui:Translator.Key="ACCOUNT_WINDOW_TITLE">
     <Design.DataContext>
     <Design.DataContext>
         <subViewModels:UserViewModel />
         <subViewModels:UserViewModel />

+ 0 - 27
src/PixiEditor/Views/Auth/LoginPopup.axaml.cs

@@ -15,33 +15,6 @@ public partial class LoginPopup : PixiEditorPopup
         InitializeComponent();
         InitializeComponent();
     }
     }
 
 
-    protected override void OnDataContextChanged(EventArgs e)
-    {
-        base.OnDataContextChanged(e);
-        if (DataContext is UserViewModel vm)
-        {
-            vm.PropertyChanged += VmOnPropertyChanged;
-            Height = vm.IsLoggedIn ? 245 : 190;
-        }
-    }
-
-    protected override void OnClosed(EventArgs e)
-    {
-        base.OnClosed(e);
-        if (DataContext is UserViewModel vm)
-        {
-            vm.PropertyChanged -= VmOnPropertyChanged;
-        }
-    }
-
-    private void VmOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
-    {
-        if (e.PropertyName == nameof(UserViewModel.IsLoggedIn))
-        {
-            Height = (DataContext as UserViewModel)?.IsLoggedIn == true ? 245 : 190;
-        }
-    }
-
     protected override async void OnGotFocus(GotFocusEventArgs e)
     protected override async void OnGotFocus(GotFocusEventArgs e)
     {
     {
         if (DataContext is UserViewModel { WaitingForActivation: true } vm)
         if (DataContext is UserViewModel { WaitingForActivation: true } vm)

+ 0 - 1
src/PixiEditor/Views/Dialogs/OnboardingDialog.axaml

@@ -287,7 +287,6 @@
                                 Command="{xaml:Command Name=PixiEditor.Links.OpenHyperlink, UseProvided=True}"
                                 Command="{xaml:Command Name=PixiEditor.Links.OpenHyperlink, UseProvided=True}"
                                 CommandParameter="{Binding FoundersBundleLink}"
                                 CommandParameter="{Binding FoundersBundleLink}"
                                 Classes="foundersButton"
                                 Classes="foundersButton"
-                                FontWeight="700"
                                 Padding="8, 4" />
                                 Padding="8, 4" />
                     </StackPanel>
                     </StackPanel>
                     <Svg VerticalAlignment="Center" Path="/Images/FoundersBundle.svg" Width="532" />
                     <Svg VerticalAlignment="Center" Path="/Images/FoundersBundle.svg" Width="532" />