|
1 |
| -using Nickvision.GirExt; |
| 1 | +using Nickvision.GirExt; |
2 | 2 | using NickvisionMoney.GNOME.Controls;
|
3 | 3 | using NickvisionMoney.GNOME.Helpers;
|
4 | 4 | using NickvisionMoney.Shared.Controllers;
|
@@ -49,6 +49,7 @@ public struct MoneyDateTime
|
49 | 49 | private readonly AccountViewController _controller;
|
50 | 50 | private bool _isAccountLoading;
|
51 | 51 | private readonly MainWindow _parentWindow;
|
| 52 | + private readonly Adw.Breakpoint _compactBreakpoint; |
52 | 53 | private readonly Gtk.Adjustment _transactionsScrollAdjustment;
|
53 | 54 | private readonly Gtk.ShortcutController _shortcutController;
|
54 | 55 | private readonly Action<string> _updateSubtitle;
|
@@ -114,7 +115,6 @@ public AccountView(Gtk.Builder builder, AccountViewController controller, MainWi
|
114 | 115 | {
|
115 | 116 | _controller = controller;
|
116 | 117 | _parentWindow = parentWindow;
|
117 |
| - _parentWindow.WidthChanged += OnWindowWidthChanged; |
118 | 118 | _isAccountLoading = false;
|
119 | 119 | _updateSubtitle = updateSubtitle;
|
120 | 120 | _groupRows = new Dictionary<uint, GroupRow>();
|
@@ -147,6 +147,24 @@ public AccountView(Gtk.Builder builder, AccountViewController controller, MainWi
|
147 | 147 | btnFlapToggle.BindProperty("active", _splitView, "show-sidebar", GObject.BindingFlags.Bidirectional | GObject.BindingFlags.SyncCreate);
|
148 | 148 | btnGraphToggle.BindProperty("active", _visualizeGroup, "visible", GObject.BindingFlags.Bidirectional | GObject.BindingFlags.SyncCreate);
|
149 | 149 | btnGraphToggle.BindProperty("active", _visualizeSeparator, "visible", GObject.BindingFlags.Bidirectional | GObject.BindingFlags.SyncCreate);
|
| 150 | + //Compact Breakpoint |
| 151 | + _compactBreakpoint = Adw.Breakpoint.New(Adw.BreakpointCondition.Parse("max-width: 450sp")); |
| 152 | + _compactBreakpoint.AddSetter(_splitView, "collapsed", GObject.Value.From(true)); |
| 153 | + _compactBreakpoint.OnApply += (sender, e) => { |
| 154 | + _transactionsGroup.SetTitle(""); |
| 155 | + foreach (var pair in _transactionRows) |
| 156 | + { |
| 157 | + pair.Value.IsSmall = true; |
| 158 | + } |
| 159 | + }; |
| 160 | + _compactBreakpoint.OnUnapply += (sender, e) => { |
| 161 | + _transactionsGroup.SetTitle(_n("{0} transaction", "{0} transactions", _controller.FilteredTransactionsCount, _controller.FilteredTransactionsCount)); |
| 162 | + foreach (var pair in _transactionRows) |
| 163 | + { |
| 164 | + pair.Value.IsSmall = false; |
| 165 | + } |
| 166 | + }; |
| 167 | + this.AddBreakpoint(_compactBreakpoint); |
150 | 168 | //Search Description Text
|
151 | 169 | _searchDescriptionEntry.OnSearchChanged += (sender, e) => _controller.SearchDescription = _searchDescriptionEntry.GetText();
|
152 | 170 | //Account Income
|
@@ -427,7 +445,6 @@ public async Task StartupAsync()
|
427 | 445 | }
|
428 | 446 | OnToggleGroups();
|
429 | 447 | OnToggleTags();
|
430 |
| - OnWindowWidthChanged(null, new WidthChangedEventArgs(_parentWindow.CompactMode)); |
431 | 448 | if(_controller.TransactionReminders.Count > 0)
|
432 | 449 | {
|
433 | 450 | var remindersDialog = new RemindersDialog(_parentWindow, _controller.AppInfo.ID, _("Upcoming transactions"), _controller.TransactionReminders);
|
@@ -627,7 +644,7 @@ private bool CreateTransactionRow(ModelEventArgs<Transaction> e)
|
627 | 644 | {
|
628 | 645 | var row = new TransactionRow(e.Model, _controller.Groups, _controller.CultureForNumberString, _controller.UseNativeDigits, _controller.TransactionDefaultColor);
|
629 | 646 | row.EditTriggered += EditTransaction;
|
630 |
| - row.IsSmall = _parentWindow.DefaultWidth < 450; |
| 647 | + row.IsSmall = this.GetCurrentBreakpoint() == _compactBreakpoint; |
631 | 648 | row.SetVisible(e.Active);
|
632 | 649 | if (e.Position != null)
|
633 | 650 | {
|
@@ -1316,25 +1333,4 @@ private void OnDateRangeEndMonthChanged()
|
1316 | 1333 | /// Occurs when the date range's end day is changed
|
1317 | 1334 | /// </summary>
|
1318 | 1335 | private void OnDateRangeEndDayChanged() => _controller.FilterEndDate = new DateOnly(int.Parse(_controller.YearsForRangeFilter[(int)_endYearDropDown.GetSelected()]), (int)_endMonthDropDown.GetSelected() + 1, (int)_endDayDropDown.GetSelected() + 1);
|
1319 |
| - |
1320 |
| - /// <summary> |
1321 |
| - /// Occurs when the window's width is changed |
1322 |
| - /// </summary> |
1323 |
| - /// <param name="sender">object?</param> |
1324 |
| - /// <param name="e">WidthChangedEventArgs</param> |
1325 |
| - private void OnWindowWidthChanged(object? sender, WidthChangedEventArgs e) |
1326 |
| - { |
1327 |
| - foreach (var pair in _transactionRows) |
1328 |
| - { |
1329 |
| - pair.Value.IsSmall = e.SmallWidth; |
1330 |
| - } |
1331 |
| - if (e.SmallWidth) |
1332 |
| - { |
1333 |
| - _transactionsGroup.SetTitle(""); |
1334 |
| - } |
1335 |
| - else |
1336 |
| - { |
1337 |
| - _transactionsGroup.SetTitle(_n("{0} transaction", "{0} transactions", _controller.FilteredTransactionsCount, _controller.FilteredTransactionsCount)); |
1338 |
| - } |
1339 |
| - } |
1340 | 1336 | }
|
0 commit comments