Skip to content

Commit

Permalink
Merge pull request #302 from nlogozzo/circle
Browse files Browse the repository at this point in the history
Fix things mentioned in GNOME Circle review
  • Loading branch information
nlogozzo authored Feb 10, 2023
2 parents 3bad6ad + 1ecad56 commit 6d33fb5
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 96 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/nlogoz
- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://flathub.org/apps/details/com.uploadedlobster.peek) on Linux.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://flathub.org/apps/details/io.github.seadve.Kooha) on Linux.
- **Explain why this enhancement would be useful** to most Nickvision Denaro users. You may also want to point out the other projects that solved it better and which could serve as inspiration.

### Providing Translations
Expand Down
16 changes: 13 additions & 3 deletions NickvisionMoney.GNOME/Controls/GroupRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class GroupRow : Adw.ActionRow, IGroupRowControl
private CultureInfo _cultureAmount;
private CultureInfo _cultureDate;
private readonly Gtk.CheckButton _chkFilter;
private readonly Gtk.Button _btnAmount;
private readonly Gtk.Label _lblAmount;
private readonly Gtk.Button _btnEdit;
private readonly Gtk.Button _btnDelete;
Expand Down Expand Up @@ -53,12 +54,21 @@ public GroupRow(Group group, CultureInfo cultureAmount, CultureInfo cultureDate,
SetUseMarkup(false);
//Filter Checkbox
_chkFilter = Gtk.CheckButton.New();
_chkFilter.SetValign(Gtk.Align.Center);
_chkFilter.AddCssClass("selection-mode");
_chkFilter.OnToggled += FilterToggled;
AddPrefix(_chkFilter);
//Amount Label
//Amount
_btnAmount = Gtk.Button.New();
_btnAmount.AddCssClass("circular");
_btnAmount.SetHalign(Gtk.Align.End);
_btnAmount.SetValign(Gtk.Align.Center);
_btnAmount.SetMarginEnd(4);
_btnAmount.OnClicked += (sender, e) => Activate();
_lblAmount = Gtk.Label.New(null);
_lblAmount.SetValign(Gtk.Align.Center);
_lblAmount.SetMarginStart(12);
_lblAmount.SetMarginEnd(12);
_btnAmount.SetChild(_lblAmount);
//Edit Button
_btnEdit = Gtk.Button.NewFromIconName("document-edit-symbolic");
_btnEdit.SetValign(Gtk.Align.Center);
Expand All @@ -74,7 +84,7 @@ public GroupRow(Group group, CultureInfo cultureAmount, CultureInfo cultureDate,
_btnDelete.OnClicked += Delete;
//Box
_box = Gtk.Box.New(Gtk.Orientation.Horizontal, 6);
_box.Append(_lblAmount);
_box.Append(_btnAmount);
_box.Append(_btnEdit);
_box.Append(_btnDelete);
AddSuffix(_box);
Expand Down
39 changes: 23 additions & 16 deletions NickvisionMoney.GNOME/Controls/TransactionRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public struct Color
private bool _isSmall;
private readonly Adw.ActionRow _row;
private readonly Gtk.Button _btnId;
private readonly Gtk.Image _iconCompact;
private readonly Gtk.Button _btnAmount;
private readonly Gtk.Label _lblAmount;
private readonly Gtk.Button _btnEdit;
private readonly Gtk.Button _btnDelete;
Expand Down Expand Up @@ -78,18 +80,27 @@ public TransactionRow(Transaction transaction, CultureInfo cultureAmount, Cultur
_row = Adw.ActionRow.New();
_row.SetUseMarkup(false);
_row.SetTitleLines(1);
_row.SetSizeRequest(300, 70);
_row.SetSizeRequest(300, 78);
//Button ID
_btnId = Gtk.Button.New();
_btnId.SetName("btnId");
_btnId.AddCssClass("circular");
_btnId.SetValign(Gtk.Align.Center);
_iconCompact = Gtk.Image.NewFromIconName("big-dot-symbolic");
_iconCompact.SetName("iconCompact");
_row.AddPrefix(_btnId);
//Amount Label
_row.AddPrefix(_iconCompact);
//Amount
_btnAmount = Gtk.Button.New();
_btnAmount.AddCssClass("circular");
_btnAmount.SetHalign(Gtk.Align.End);
_btnAmount.SetValign(Gtk.Align.Center);
_btnAmount.SetMarginEnd(4);
_btnAmount.OnClicked += (sender, e) => _row.Activate();
_lblAmount = Gtk.Label.New(null);
_lblAmount.SetHalign(Gtk.Align.End);
_lblAmount.SetValign(Gtk.Align.Center);
_lblAmount.SetMarginEnd(4);
_lblAmount.SetMarginStart(12);
_lblAmount.SetMarginEnd(12);
_btnAmount.SetChild(_lblAmount);
//Edit Button
_btnEdit = Gtk.Button.NewFromIconName("document-edit-symbolic");
_btnEdit.SetValign(Gtk.Align.Center);
Expand All @@ -105,12 +116,14 @@ public TransactionRow(Transaction transaction, CultureInfo cultureAmount, Cultur
_btnDelete.OnClicked += Delete;
//Buttons Box
_boxButtons = Gtk.Box.New(Gtk.Orientation.Horizontal, 6);
_boxButtons.SetHalign(Gtk.Align.End);
_boxButtons.SetMarginEnd(4);
_boxButtons.Append(_btnEdit);
_boxButtons.Append(_btnDelete);
//Suffix Box
_boxSuffix = Gtk.Box.New(Gtk.Orientation.Horizontal, 2);
_boxSuffix.SetValign(Gtk.Align.Center);
_boxSuffix.Append(_lblAmount);
_boxSuffix.Append(_btnAmount);
_boxSuffix.Append(_boxButtons);
_row.AddSuffix(_boxSuffix);
//Group Settings
Expand All @@ -130,18 +143,16 @@ public bool IsSmall
_isSmall = value;
if (_isSmall)
{
_row.AddCssClass("row-small");
_boxSuffix.SetOrientation(Gtk.Orientation.Vertical);
_boxSuffix.SetMarginTop(4);
_btnId.SetVisible(false);
}
else
{
_row.RemoveCssClass("row-small");
_boxSuffix.SetOrientation(Gtk.Orientation.Horizontal);
_boxSuffix.SetMarginTop(0);
_btnId.SetVisible(true);
}
_btnId.SetVisible(!_isSmall);
_iconCompact.SetVisible(_isSmall);
}
}

Expand All @@ -165,17 +176,13 @@ public void UpdateRow(Transaction transaction, CultureInfo cultureAmount, Cultur
//Row Settings
_row.SetTitle(transaction.Description);
_row.SetSubtitle($"{transaction.Date.ToString("d", _cultureDate)}{(transaction.RepeatInterval != TransactionRepeatInterval.Never ? $"\n{_localizer["TransactionRepeatInterval", "Field"]}: {_localizer["RepeatInterval", transaction.RepeatInterval.ToString()]}" : "")}");
var rowCssProvider = Gtk.CssProvider.New();
var rowCss = @"row {
border-color: " + gdk_rgba_to_string(ref color) + "; }";
gtk_css_provider_load_from_data(rowCssProvider.Handle, rowCss, rowCss.Length);
_row.GetStyleContext().AddProvider(rowCssProvider, GTK_STYLE_PROVIDER_PRIORITY_USER);
//Button Id
_btnId.SetLabel(transaction.Id.ToString());
var btnCssProvider = Gtk.CssProvider.New();
var btnCss = "#btnId { font-size: 14px; color: " + gdk_rgba_to_string(ref color) + "; }";
var btnCss = "#btnId, #iconCompact { font-size: 14px; color: " + gdk_rgba_to_string(ref color) + "; }";
gtk_css_provider_load_from_data(btnCssProvider.Handle, btnCss, btnCss.Length);
_btnId.GetStyleContext().AddProvider(btnCssProvider, GTK_STYLE_PROVIDER_PRIORITY_USER);
_iconCompact.GetStyleContext().AddProvider(btnCssProvider, GTK_STYLE_PROVIDER_PRIORITY_USER);
//Amount Label
_lblAmount.SetLabel($"{(transaction.Type == TransactionType.Income ? "+ " : "- ")}{transaction.Amount.ToString("C", _cultureAmount)}");
_lblAmount.AddCssClass(transaction.Type == TransactionType.Income ? "success" : "error");
Expand Down
15 changes: 8 additions & 7 deletions NickvisionMoney.GNOME/Resources/org.nickvision.money.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@
}


/* Transaction Row */
.row-small {
border-left-width: 4px;
border-left-style: solid;
}


/* Make apply button in TransferDialog's password row to ignore error class */
row.error button.circular {
background-color: @accent_bg_color;
color: @accent_fg_color;
}


/* Transactions header box */
.transactions-header {
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: @borders;
}
Binary file modified NickvisionMoney.GNOME/Screenshots/CompactMode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified NickvisionMoney.GNOME/Screenshots/MainWindow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified NickvisionMoney.GNOME/Screenshots/OpenAccount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified NickvisionMoney.GNOME/Screenshots/OpenAccountDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 57 additions & 10 deletions NickvisionMoney.GNOME/Views/AccountView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ public struct MoneyDateTime
private readonly Gtk.ScrolledWindow _scrollPane;
private readonly Gtk.Box _paneBox;
private readonly Gtk.SearchEntry _txtSearchDescription;
private readonly Gtk.Button _btnTotal;
private readonly Gtk.Label _lblTotal;
private readonly Adw.ActionRow _rowTotal;
private readonly Gtk.Button _btnIncome;
private readonly Gtk.Label _lblIncome;
private readonly Gtk.CheckButton _chkIncome;
private readonly Adw.ActionRow _rowIncome;
private readonly Gtk.Button _btnExpense;
private readonly Gtk.Label _lblExpense;
private readonly Gtk.CheckButton _chkExpense;
private readonly Adw.ActionRow _rowExpense;
Expand Down Expand Up @@ -105,8 +108,10 @@ public struct MoneyDateTime
private readonly Gtk.Box _boxSortButtons;
private readonly Gtk.Box _boxSort;
private readonly Adw.PreferencesGroup _grpTransactions;
private readonly Gtk.Box _boxTransactionsHeader;
private readonly Gtk.FlowBox _flowBox;
private readonly Gtk.ScrolledWindow _scrollTransactions;
private readonly Gtk.Adjustment _scrollTransactionsAdjustment;
private readonly Adw.StatusPage _statusPageNoTransactions;
private readonly Gtk.Box _boxMain;
private readonly Adw.Bin _binSpinner;
Expand Down Expand Up @@ -166,39 +171,59 @@ public AccountView(AccountViewController controller, MainWindow parentWindow, Ad
_txtSearchDescription.OnSearchChanged += (sender, e) => _controller.SearchDescription = _txtSearchDescription.GetText();
_paneBox.Append(_txtSearchDescription);
//Account Total
_btnTotal = Gtk.Button.New();
_btnTotal.AddCssClass("circular");
_btnTotal.SetHalign(Gtk.Align.End);
_btnTotal.SetValign(Gtk.Align.Center);
_lblTotal = Gtk.Label.New("");
_lblTotal.SetValign(Gtk.Align.Center);
_lblTotal.AddCssClass("accent");
_lblTotal.AddCssClass("denaro-total");
_lblTotal.SetMarginStart(12);
_lblTotal.SetMarginEnd(12);
_btnTotal.SetChild(_lblTotal);
_rowTotal = Adw.ActionRow.New();
_rowTotal.SetTitle(_controller.Localizer["Total"]);
_rowTotal.AddSuffix(_lblTotal);
_rowTotal.AddSuffix(_btnTotal);
//Account Income
_btnIncome = Gtk.Button.New();
_btnIncome.AddCssClass("circular");
_btnIncome.SetHalign(Gtk.Align.End);
_btnIncome.SetValign(Gtk.Align.Center);
_lblIncome = Gtk.Label.New("");
_lblIncome.SetValign(Gtk.Align.Center);
_lblIncome.AddCssClass("success");
_lblTotal.AddCssClass("denaro-income");
_lblIncome.AddCssClass("denaro-income");
_lblIncome.SetMarginStart(12);
_lblIncome.SetMarginEnd(12);
_btnIncome.SetChild(_lblIncome);
_chkIncome = Gtk.CheckButton.New();
_chkIncome.SetActive(true);
_chkIncome.AddCssClass("selection-mode");
_chkIncome.SetValign(Gtk.Align.Center);
_chkIncome.OnToggled += (Gtk.CheckButton sender, EventArgs e) => _controller.UpdateFilterValue(-3, _chkIncome.GetActive());
_rowIncome = Adw.ActionRow.New();
_rowIncome.SetTitle(_controller.Localizer["Income"]);
_rowIncome.AddPrefix(_chkIncome);
_rowIncome.AddSuffix(_lblIncome);
_rowIncome.AddSuffix(_btnIncome);
//Account Expense
_btnExpense = Gtk.Button.New();
_btnExpense.AddCssClass("circular");
_btnExpense.SetHalign(Gtk.Align.End);
_btnExpense.SetValign(Gtk.Align.Center);
_lblExpense = Gtk.Label.New("");
_lblExpense.SetValign(Gtk.Align.Center);
_lblExpense.AddCssClass("error");
_lblExpense.AddCssClass("denaro-expense");
_lblExpense.SetMarginStart(12);
_lblExpense.SetMarginEnd(12);
_btnExpense.SetChild(_lblExpense);
_chkExpense = Gtk.CheckButton.New();
_chkExpense.SetActive(true);
_chkExpense.AddCssClass("selection-mode");
_chkExpense.SetValign(Gtk.Align.Center);
_chkExpense.OnToggled += (Gtk.CheckButton sender, EventArgs e) => _controller.UpdateFilterValue(-2, _chkExpense.GetActive());
_rowExpense = Adw.ActionRow.New();
_rowExpense.SetTitle(_controller.Localizer["Expense"]);
_rowExpense.AddPrefix(_chkExpense);
_rowExpense.AddSuffix(_lblExpense);
_rowExpense.AddSuffix(_btnExpense);
//Overview Buttons Box
_boxButtonsOverview = Gtk.Box.New(Gtk.Orientation.Horizontal, 6);
//Button Menu Account Actions
Expand Down Expand Up @@ -430,13 +455,16 @@ public AccountView(AccountViewController controller, MainWindow parentWindow, Ad
_boxSort = Gtk.Box.New(Gtk.Orientation.Horizontal, 6);
_boxSort.Append(_ddSortTransactionBy);
_boxSort.Append(_boxSortButtons);
//Transaction Group
//Transactions Group
_grpTransactions = Adw.PreferencesGroup.New();
_grpTransactions.SetTitle(_controller.Localizer["Transactions"]);
_grpTransactions.SetHeaderSuffix(_boxSort);
_grpTransactions.SetMarginTop(10);
_grpTransactions.SetMarginTop(7);
_grpTransactions.SetMarginStart(10);
_grpTransactions.SetMarginEnd(10);
//Transactions Header Box
_boxTransactionsHeader = Gtk.Box.New(Gtk.Orientation.Horizontal, 0);
_boxTransactionsHeader.Append(_grpTransactions);
//Transactions Flow Box
_flowBox = Gtk.FlowBox.New();
_flowBox.SetHomogeneous(true);
Expand All @@ -455,6 +483,20 @@ public AccountView(AccountViewController controller, MainWindow parentWindow, Ad
_scrollTransactions.SetVexpand(true);
_scrollTransactions.SetChild(_flowBox);
_scrollTransactions.SetVisible(false);
_scrollTransactionsAdjustment = _scrollTransactions.GetVadjustment();
_scrollTransactionsAdjustment.OnNotify += (sender, e) => {
if (e.Pspec.GetName() == "value")
{
if (_scrollTransactionsAdjustment.GetValue() == 0.0)
{
_boxTransactionsHeader.RemoveCssClass("transactions-header");
}
else
{
_boxTransactionsHeader.AddCssClass("transactions-header");
}
}
};
//Page No Transactions
_statusPageNoTransactions = Adw.StatusPage.New();
_statusPageNoTransactions.SetIconName("money-none-symbolic");
Expand All @@ -466,7 +508,7 @@ public AccountView(AccountViewController controller, MainWindow parentWindow, Ad
_boxMain = Gtk.Box.New(Gtk.Orientation.Vertical, 0);
_boxMain.SetHexpand(true);
_boxMain.SetVexpand(true);
_boxMain.Append(_grpTransactions);
_boxMain.Append(_boxTransactionsHeader);
_boxMain.Append(_scrollTransactions);
_boxMain.Append(_statusPageNoTransactions);
//Spinner Box
Expand Down Expand Up @@ -526,6 +568,10 @@ public AccountView(AccountViewController controller, MainWindow parentWindow, Ad
var actAccountSettings = Gio.SimpleAction.New("accountSettings", null);
actAccountSettings.OnActivate += AccountSettings;
actionMap.AddAction(actAccountSettings);
//Toggle Sidebar Action
var actToggleSidebar = Gio.SimpleAction.New("toggleSidebar", null);
actToggleSidebar.OnActivate += (sender, e) => _flap.SetRevealFlap(!_flap.GetRevealFlap());
actionMap.AddAction(actToggleSidebar);
//Shortcut Controller
_shortcutController = Gtk.ShortcutController.New();
_shortcutController.SetScope(Gtk.ShortcutScope.Managed);
Expand All @@ -534,6 +580,7 @@ public AccountView(AccountViewController controller, MainWindow parentWindow, Ad
_shortcutController.AddShortcut(Gtk.Shortcut.New(Gtk.ShortcutTrigger.ParseString("<Ctrl>I"), Gtk.NamedAction.New("account.importFromFile")));
_shortcutController.AddShortcut(Gtk.Shortcut.New(Gtk.ShortcutTrigger.ParseString("<Ctrl>G"), Gtk.NamedAction.New("account.newGroup")));
_shortcutController.AddShortcut(Gtk.Shortcut.New(Gtk.ShortcutTrigger.ParseString("<Ctrl><Shift>N"), Gtk.NamedAction.New("account.newTransaction")));
_shortcutController.AddShortcut(Gtk.Shortcut.New(Gtk.ShortcutTrigger.ParseString("F9"), Gtk.NamedAction.New("account.toggleSidebar")));
_flap.AddController(_shortcutController);
}

Expand Down
Loading

0 comments on commit 6d33fb5

Please sign in to comment.