using Gtk 4.0;
using Adw 1;

Adw.Window _root {
  default-width: 420;
  modal: true;
  resizable: false;
  
  content: Adw.ToolbarView {
    [top]
    Adw.HeaderBar {
      title-widget: Gtk.Label {};
    }

    Gtk.WindowHandle {
      Gtk.Box {
        orientation: vertical;
        spacing: 24;
        margin-start: 24;
        margin-end: 24;

        Gtk.Label {
          label: C_("Title", "Transfer");

          styles ["title-2"]
        }
        
        Gtk.Label {
          label: _("Transferring money will create an expense transaction with the given amount in this account and an income transaction with the given amount in the account to transfer to.");
          wrap: true;
          justify: center;
        }

        Adw.PreferencesGroup {
          Adw.ActionRow _destinationAccountRow {
            title: _("Destination Account");
            subtitle: _("No Account Selected");
            activatable-widget: _selectAccountButton;

            [suffix]
            Gtk.Box {
              orientation: horizontal;
              valign: center;

              Gtk.Button _selectAccountButton {
                icon-name: "document-open-symbolic";
                tooltip-text: _("Select a destination account");
              }

              Gtk.MenuButton _recentAccountsButton {
                icon-name: "document-open-recent-symbolic";
                tooltip-text: _("Recent Accounts");
                popover: Gtk.Popover  _recentAccountsPopover {
                  Adw.PreferencesGroup _recentAccountsGroup {
                    title: _("Recents");
                    width-request: 200;
                    height-request: 55;
                  }
                };
              }

              styles ["linked"]
            }
          }

          Adw.PasswordEntryRow _destinationPasswordRow {
            title: _("Destination Account Password");
            show-apply-button: true;
            visible: false;
          }

          Adw.EntryRow _amountRow {
            title: _("Amount");
            input-purpose: number;
            activates-default: true;

            [suffix]
            Gtk.Label _currencyLabel {
              styles ["dim-label"]
            }
          }

          Adw.PreferencesGroup _conversionRateGroup {
            margin-top: 24;
            title: _("Conversion Needed");
            visible: false;

            Adw.ExpanderRow _rowUseCustomRates {
              title: _("Use Custom Rates");
              subtitle: _("Enter the conversion rates manually");
              enable-expansion: false;
              show-enable-switch: true;
                  
              Adw.EntryRow _sourceCurrencyRow {
                activates-default: true;
              }

              Adw.EntryRow _destinationCurrencyRow {
                activates-default: true;
              }
            }

            Adw.ActionRow {
              title:_("Result");

              [suffix]
              Gtk.Label _conversionResultLabel {}
            }
          }
        }
        
        Gtk.Button _transferButton {
          halign: center;
          valign: center;
          margin-top: 24;
          margin-bottom: 24;
          label: C_("Button", "Transfer");

          styles ["pill", "suggested-action"]
        }
      }
    }
  };
  
  Gtk.ShortcutController {
    Gtk.Shortcut {
      trigger: "Escape";
      action: "action(window.close)";
    }
  }

  default-widget: _transferButton;
}