Skip to content

Commit b9f013e

Browse files
committed
Fix Clock/Search Icon show logic
1 parent 350276d commit b9f013e

File tree

2 files changed

+74
-33
lines changed

2 files changed

+74
-33
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel;
3+
using System.Diagnostics;
34
using System.Linq;
45
using System.Media;
56
using System.Threading.Tasks;
@@ -58,7 +59,6 @@ public partial class MainWindow : IDisposable
5859

5960
// Window Animation
6061
private const double DefaultRightMargin = 66; //* this value from base.xaml
61-
private bool _animating;
6262
private bool _isClockPanelAnimating = false;
6363

6464
// IDisposable
@@ -234,7 +234,7 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
234234

235235
// Detect History.Visibility changes
236236
DependencyPropertyDescriptor
237-
.FromProperty(VisibilityProperty, typeof(StackPanel)) // History는 StackPanel이라고 가정
237+
.FromProperty(VisibilityProperty, typeof(StackPanel))
238238
.AddValueChanged(History, (s, e) => UpdateClockPanelVisibility());
239239
}
240240

@@ -269,7 +269,6 @@ private void OnClosed(object sender, EventArgs e)
269269

270270
private void OnLocationChanged(object sender, EventArgs e)
271271
{
272-
if (_animating) return;
273272

274273
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
275274
{
@@ -592,7 +591,7 @@ private void UpdateNotifyIconText()
592591

593592
private void UpdatePosition(bool force)
594593
{
595-
if (_animating && !force)
594+
if (!force)
596595
{
597596
return;
598597
}
@@ -768,18 +767,20 @@ private void InitProgressbarAnimation()
768767
_viewModel.ProgressBarVisibility = Visibility.Hidden;
769768
}
770769

771-
private void WindowAnimation()
770+
public void WindowAnimation()
772771
{
773-
if (_animating)
774-
return;
775-
776772
_isArrowKeyPressed = true;
777-
_animating = true;
778773
UpdatePosition(false);
779-
780-
ClockPanel.Opacity = 0;
781-
SearchIcon.Opacity = 0;
782-
774+
if(_settings.UseAnimation)
775+
{
776+
ClockPanel.Opacity = 0;
777+
SearchIcon.Opacity = 0;
778+
}
779+
else
780+
{
781+
ClockPanel.Opacity = 1;
782+
SearchIcon.Opacity = 1;
783+
}
783784
var clocksb = new Storyboard();
784785
var iconsb = new Storyboard();
785786
CircleEase easing = new CircleEase { EasingMode = EasingMode.EaseInOut };
@@ -848,16 +849,11 @@ private void WindowAnimation()
848849
clocksb.Children.Add(ClockOpacity);
849850
iconsb.Children.Add(IconMotion);
850851
iconsb.Children.Add(IconOpacity);
851-
852-
clocksb.Completed += (_, _) => _animating = false;
852+
853853
_settings.WindowLeft = Left;
854854
_isArrowKeyPressed = false;
855-
856-
if (QueryTextBox.Text.Length == 0)
857-
{
858-
clocksb.Begin(ClockPanel);
859-
}
860-
855+
856+
clocksb.Begin(ClockPanel);
861857
iconsb.Begin(SearchIcon);
862858
}
863859

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using System.Diagnostics;
45
using System.Globalization;
56
using System.Windows.Input;
67
using System.Linq;
@@ -1437,11 +1438,43 @@ public void Show()
14371438
{
14381439
// 📌 Remove DWM Cloak (Make the window visible normally)
14391440
Win32Helper.DWMSetCloakForWindow(mainWindow, false);
1441+
1442+
//Clock and SearchIcon hide when show situation
1443+
if(Settings.UseAnimation)
1444+
{
1445+
mainWindow.ClockPanel.Opacity = 0;
1446+
mainWindow.SearchIcon.Opacity = 0;
1447+
}
1448+
else
1449+
{
1450+
mainWindow.ClockPanel.Opacity = 1;
1451+
mainWindow.SearchIcon.Opacity = 1;
1452+
}
14401453

1454+
if (mainWindow.QueryTextBox.Text.Length != 0)
1455+
{
1456+
mainWindow.ClockPanel.Visibility = Visibility.Collapsed;
1457+
}
1458+
else
1459+
{
1460+
mainWindow.ClockPanel.Visibility = Visibility.Visible;
1461+
}
1462+
if (PluginIconSource != null)
1463+
{
1464+
mainWindow.SearchIcon.Opacity = 0;
1465+
}
1466+
else
1467+
{
1468+
SearchIconVisibility = Visibility.Visible;
1469+
}
14411470
// 📌 Restore UI elements
1442-
mainWindow.ClockPanel.Visibility = Visibility.Visible;
14431471
//mainWindow.SearchIcon.Visibility = Visibility.Visible;
1444-
SearchIconVisibility = Visibility.Visible;
1472+
if (Settings.UseAnimation)
1473+
{
1474+
Application.Current.Dispatcher.BeginInvoke(() =>
1475+
mainWindow.WindowAnimation());
1476+
Debug.WriteLine("Call Animation");
1477+
}
14451478
}
14461479

14471480
// Update WPF properties
@@ -1474,15 +1507,19 @@ public async void Hide()
14741507
}
14751508

14761509
// 📌 Immediately apply text reset + force UI update
1477-
if (Settings.LastQueryMode == LastQueryMode.Empty)
1510+
/*if (Settings.LastQueryMode == LastQueryMode.Empty)
14781511
{
14791512
ChangeQueryText(string.Empty);
14801513
await Task.Delay(1); // Wait for one frame to ensure UI reflects changes
14811514
Application.Current.Dispatcher.Invoke(Application.Current.MainWindow.UpdateLayout); // Force UI update
1482-
}
1515+
}*/
14831516

14841517
switch (Settings.LastQueryMode)
14851518
{
1519+
case LastQueryMode.Empty:
1520+
ChangeQueryText(string.Empty);
1521+
await Task.Delay(1);
1522+
break;
14861523
case LastQueryMode.Preserved:
14871524
case LastQueryMode.Selected:
14881525
LastQuerySelected = (Settings.LastQueryMode == LastQueryMode.Preserved);
@@ -1504,18 +1541,26 @@ public async void Hide()
15041541
{
15051542
// 📌 Set Opacity of icon and clock to 0 and apply Visibility.Hidden
15061543
Application.Current.Dispatcher.Invoke(() =>
1544+
{
1545+
1546+
}, DispatcherPriority.Render);
1547+
if(Settings.UseAnimation)
15071548
{
15081549
mainWindow.ClockPanel.Opacity = 0;
15091550
mainWindow.SearchIcon.Opacity = 0;
1510-
mainWindow.ClockPanel.Visibility = Visibility.Hidden;
1511-
//mainWindow.SearchIcon.Visibility = Visibility.Hidden;
1512-
SearchIconVisibility = Visibility.Hidden;
1513-
1514-
// Force UI update
1515-
mainWindow.ClockPanel.UpdateLayout();
1516-
mainWindow.SearchIcon.UpdateLayout();
1517-
}, DispatcherPriority.Render);
1551+
}
1552+
else
1553+
{
1554+
mainWindow.ClockPanel.Opacity = 1;
1555+
mainWindow.SearchIcon.Opacity = 1;
1556+
}
1557+
mainWindow.ClockPanel.Visibility = Visibility.Hidden;
1558+
//mainWindow.SearchIcon.Visibility = Visibility.Hidden;
1559+
SearchIconVisibility = Visibility.Hidden;
15181560

1561+
// Force UI update
1562+
mainWindow.ClockPanel.UpdateLayout();
1563+
mainWindow.SearchIcon.UpdateLayout();
15191564
// 📌 Apply DWM Cloak (Completely hide the window)
15201565
Win32Helper.DWMSetCloakForWindow(mainWindow, true);
15211566
}

0 commit comments

Comments
 (0)